Skip to content

Commit 8de8545

Browse files
authored
Merge pull request #3511 from github/koesie10/update-kinds
Update supported sink and source kinds in the model editor
2 parents 21c33b7 + 61fa841 commit 8de8545

File tree

6 files changed

+77
-6
lines changed

6 files changed

+77
-6
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Add new supported source and sink kinds in the CodeQL Model Editor [#3511](https://github.com/github/vscode-codeql/pull/3511)
6+
57
## 1.12.4 - 20 March 2024
68

79
- Don't show notification after local query cancellation. [#3489](https://github.com/github/vscode-codeql/pull/3489)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { ModelsAsDataLanguage } from "../models-as-data";
2+
import { staticLanguage } from "../static";
3+
4+
export const csharp: ModelsAsDataLanguage = {
5+
...staticLanguage,
6+
predicates: {
7+
...staticLanguage.predicates,
8+
sink: {
9+
...staticLanguage.predicates.sink,
10+
},
11+
source: {
12+
...staticLanguage.predicates.source,
13+
supportedKinds: [
14+
...staticLanguage.predicates.source.supportedKinds,
15+
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L122-L123
16+
"file-write",
17+
"windows-registry",
18+
],
19+
},
20+
},
21+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { ModelsAsDataLanguage } from "../models-as-data";
2+
import { staticLanguage } from "../static";
3+
4+
export const java: ModelsAsDataLanguage = {
5+
...staticLanguage,
6+
predicates: {
7+
...staticLanguage.predicates,
8+
sink: {
9+
...staticLanguage.predicates.sink,
10+
supportedKinds: [
11+
...staticLanguage.predicates.sink.supportedKinds,
12+
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L32-L37
13+
"bean-validation",
14+
"fragment-injection",
15+
"groovy-injection",
16+
"hostname-verification",
17+
"information-leak",
18+
"intent-redirection",
19+
"jexl-injection",
20+
"jndi-injection",
21+
"mvel-injection",
22+
"notification",
23+
"ognl-injection",
24+
"pending-intents",
25+
"response-splitting",
26+
"trust-boundary-violation",
27+
"template-injection",
28+
"xpath-injection",
29+
"xslt-injection",
30+
],
31+
},
32+
source: {
33+
...staticLanguage.predicates.source,
34+
supportedKinds: [
35+
...staticLanguage.predicates.source.supportedKinds,
36+
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L120-L121
37+
"android-external-storage-dir",
38+
"contentprovider",
39+
],
40+
},
41+
},
42+
};

extensions/ql-vscode/src/model-editor/languages/languages.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import type {
33
ModelsAsDataLanguage,
44
ModelsAsDataLanguagePredicates,
55
} from "./models-as-data";
6+
import { csharp } from "./csharp";
7+
import { java } from "./java";
68
import { python } from "./python";
79
import { ruby } from "./ruby";
8-
import { staticLanguage } from "./static";
910

1011
const languages: Partial<Record<QueryLanguage, ModelsAsDataLanguage>> = {
11-
[QueryLanguage.CSharp]: staticLanguage,
12-
[QueryLanguage.Java]: staticLanguage,
12+
[QueryLanguage.CSharp]: csharp,
13+
[QueryLanguage.Java]: java,
1314
[QueryLanguage.Python]: python,
1415
[QueryLanguage.Ruby]: ruby,
1516
};

extensions/ql-vscode/src/model-editor/languages/shared.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ export const sharedExtensiblePredicates = {
66
};
77

88
export const sharedKinds = {
9-
source: ["local", "remote"],
9+
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L118-L119
10+
source: ["local", "remote", "file", "commandargs", "database", "environment"],
11+
// Bhttps://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L28-L31
1012
sink: [
1113
"code-injection",
1214
"command-injection",
15+
"environment-injection",
1316
"file-content-store",
1417
"html-injection",
1518
"js-injection",
@@ -20,6 +23,8 @@ export const sharedKinds = {
2023
"sql-injection",
2124
"url-redirection",
2225
],
26+
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L142-L143
2327
summary: ["taint", "value"],
28+
// https://github.com/github/codeql/blob/0c5ea975a4c4dc5c439b908c006e440cb9bdf926/shared/mad/codeql/mad/ModelValidation.qll#L155-L156
2429
neutral: ["summary", "source", "sink"],
2530
};

extensions/ql-vscode/src/model-editor/languages/static/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function readRowToMethod(row: DataTuple[]): string {
1010
return `${row[0]}.${row[1]}#${row[3]}${row[4]}`;
1111
}
1212

13-
export const staticLanguage: ModelsAsDataLanguage = {
13+
export const staticLanguage = {
1414
createMethodSignature: ({
1515
packageName,
1616
typeName,
@@ -168,4 +168,4 @@ export const staticLanguage: ModelsAsDataLanguage = {
168168
argumentsList.length > 0 ? argumentsList[0].path : "Argument[this]",
169169
};
170170
},
171-
};
171+
} satisfies ModelsAsDataLanguage;

0 commit comments

Comments
 (0)