Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update supported sink and source kinds in the model editor #3511

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Add new supported source and sink kinds in the CodeQL Model Editor [#3511](https://github.com/github/vscode-codeql/pull/3511)

## 1.12.4 - 20 March 2024

- Don't show notification after local query cancellation. [#3489](https://github.com/github/vscode-codeql/pull/3489)
Expand Down
21 changes: 21 additions & 0 deletions extensions/ql-vscode/src/model-editor/languages/csharp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { ModelsAsDataLanguage } from "../models-as-data";
import { staticLanguage } from "../static";

export const csharp: ModelsAsDataLanguage = {
...staticLanguage,
predicates: {
...staticLanguage.predicates,
sink: {
...staticLanguage.predicates.sink,
},
source: {
...staticLanguage.predicates.source,
supportedKinds: [
...staticLanguage.predicates.source.supportedKinds,
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L122-L123
"file-write",
"windows-registry",
],
},
},
};
42 changes: 42 additions & 0 deletions extensions/ql-vscode/src/model-editor/languages/java/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { ModelsAsDataLanguage } from "../models-as-data";
import { staticLanguage } from "../static";

export const java: ModelsAsDataLanguage = {
...staticLanguage,
predicates: {
...staticLanguage.predicates,
sink: {
...staticLanguage.predicates.sink,
supportedKinds: [
...staticLanguage.predicates.sink.supportedKinds,
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L32-L37
"bean-validation",
"fragment-injection",
"groovy-injection",
"hostname-verification",
"information-leak",
"intent-redirection",
"jexl-injection",
"jndi-injection",
"mvel-injection",
"notification",
"ognl-injection",
"pending-intents",
"response-splitting",
"trust-boundary-violation",
"template-injection",
"xpath-injection",
"xslt-injection",
],
},
source: {
...staticLanguage.predicates.source,
supportedKinds: [
...staticLanguage.predicates.source.supportedKinds,
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L120-L121
"android-external-storage-dir",
"contentprovider",
],
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import type {
ModelsAsDataLanguage,
ModelsAsDataLanguagePredicates,
} from "./models-as-data";
import { csharp } from "./csharp";
import { java } from "./java";
import { python } from "./python";
import { ruby } from "./ruby";
import { staticLanguage } from "./static";

const languages: Partial<Record<QueryLanguage, ModelsAsDataLanguage>> = {
[QueryLanguage.CSharp]: staticLanguage,
[QueryLanguage.Java]: staticLanguage,
[QueryLanguage.CSharp]: csharp,
[QueryLanguage.Java]: java,
[QueryLanguage.Python]: python,
[QueryLanguage.Ruby]: ruby,
};
Expand Down
7 changes: 6 additions & 1 deletion extensions/ql-vscode/src/model-editor/languages/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ export const sharedExtensiblePredicates = {
};

export const sharedKinds = {
source: ["local", "remote"],
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L118-L119
source: ["local", "remote", "file", "commandargs", "database", "environment"],
// Bhttps://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L28-L31
sink: [
"code-injection",
"command-injection",
"environment-injection",
"file-content-store",
"html-injection",
"js-injection",
Expand All @@ -20,6 +23,8 @@ export const sharedKinds = {
"sql-injection",
"url-redirection",
],
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L142-L143
summary: ["taint", "value"],
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L155-L156
neutral: ["summary", "source", "sink"],
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function readRowToMethod(row: DataTuple[]): string {
return `${row[0]}.${row[1]}#${row[3]}${row[4]}`;
}

export const staticLanguage: ModelsAsDataLanguage = {
export const staticLanguage = {
createMethodSignature: ({
packageName,
typeName,
Expand Down Expand Up @@ -168,4 +168,4 @@ export const staticLanguage: ModelsAsDataLanguage = {
argumentsList.length > 0 ? argumentsList[0].path : "Argument[this]",
};
},
};
} satisfies ModelsAsDataLanguage;
Loading