You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 48835ab
Browse filesBrowse the repository at this point in the historyBrowse files
Add Actions, Rust, and Swift CodeQL pack support (#245)
* Add Actions, Rust, and Swift pack support
* Include new language packs in workspace
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+23-17Lines changed: 23 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,22 @@ There is lots of useful documentation to help you write queries, ranging from in
6
6
7
7
## Submitting a new query
8
8
9
-
If you have an idea for a query that you would like to share with other CodeQL users, please open a pull request to add it to this repository. New queries start out in a `<language>/ql/src/` directory, to which they can be merged when they meet the following requirements.
9
+
If you have an idea for a query that you would like to share with other CodeQL users, please open a pull request to add it to this repository. New queries start out in a `<language>/src/` directory, to which they can be merged when they meet the following requirements.
10
10
11
11
1.**Directory structure**
12
12
13
-
There are eight language-specific query directories in this repository:
13
+
Query packs are available for the following CodeQL languages:
14
14
15
-
* C/C++: `cpp/ql/src`
16
-
* C#: `csharp/ql/src`
17
-
* Go: `go/ql/src`
18
-
* Java/Kotlin: `java/ql/src`
19
-
* JavaScript: `javascript/ql/src`
20
-
* Python: `python/ql/src`
21
-
* Ruby: `ruby/ql/src`
22
-
* Swift: `swift/ql/src`
15
+
* GitHub Actions: `actions/src`
16
+
* C/C++: `cpp/src`
17
+
* C#: `csharp/src`
18
+
* Go: `go/src`
19
+
* Java/Kotlin: `java/src`
20
+
* JavaScript/TypeScript: `javascript/src`
21
+
* Python: `python/src`
22
+
* Ruby: `ruby/src`
23
+
* Rust: `rust/src`
24
+
* Swift: `swift/src`
23
25
24
26
Each language-specific directory contains further subdirectories that group queries based on their `@tags` or purpose.
25
27
@@ -71,7 +73,7 @@ instead of, or alongside, a query change.
71
73
1.**Pick the right pack: `ext` vs `ext-library-sources`**
72
74
73
75
Every language with data-extension support has a `<language>/ext` pack (`csharp`/`go`/`java`/
74
-
`python`). Two of those languages additionally have a second, narrower pack,
76
+
`python`/`rust`). Two of those languages additionally have a second, narrower pack,
75
77
`<language>/ext-library-sources` (`csharp`/`java` only). They hold different *kinds* of models,
76
78
and picking the right one matters:
77
79
@@ -82,7 +84,8 @@ instead of, or alongside, a query change.
82
84
well-known framework API (e.g. a web framework's `getParameter()`-style methods). This is
83
85
where our own [Spring R2DBC `DatabaseClient` SQL injection sink models][pr-204] live
84
86
(`java/ext/manual/org.springframework.r2dbc.model.yml`) — use it as a concrete reference for
85
-
both the file layout and the row shape.
87
+
both the file layout and the row shape. For example, Rust models for Diesel SQL sinks belong
88
+
in `rust/ext/manual/diesel.model.yml`.
86
89
-**`<language>/ext-library-sources`** (published as
87
90
`githubsecuritylab/codeql-<language>-library-sources`) exists only for `csharp`/`java` and
88
91
holds a narrower category: `sourceModel` rows (almost always `kind: "remote"`) that flag a
@@ -96,7 +99,8 @@ instead of, or alongside, a query change.
96
99
97
100
**Rule of thumb: if you're modeling a dangerous sink, or how taint flows through a library
98
101
method, use `ext`. Only reach for `ext-library-sources` if you're contributing a genuinely new
99
-
remote-data-entry-point (source) model, and only for csharp/java.**
102
+
remote-data-entry-point (source) model, and only for csharp/java. Do not add an empty
103
+
`ext-library-sources` pack for other languages.**
100
104
101
105
2.**Row shape**
102
106
@@ -135,8 +139,9 @@ instead of, or alongside, a query change.
135
139
Add a test under `<language>/test/security/<CWE-id>/<your-library>/`: minimal source stubs that
136
140
reproduce the vulnerable call shape, a `.ql` query that imports the *real* standard query (e.g.
137
141
`SqlInjectionQuery`/`QueryInjectionFlow`, not a reimplementation of it), and a `.expected` file.
138
-
Check that `<language>/test/qlpack.yml` depends on `githubsecuritylab/codeql-<language>-extensions`
139
-
(and `-library-sources` where applicable) — that dependency is what makes `codeql test run`'s
142
+
If the language has an `ext` pack, check that `<language>/test/qlpack.yml` depends on
143
+
`githubsecuritylab/codeql-<language>-extensions` (and `-library-sources` where applicable) —
144
+
that dependency is what makes `codeql test run`'s
140
145
normal dependency resolution load your data extensions automatically, unlike ad-hoc `codeql
141
146
database analyze`/`query run`, which need an explicit `--model-packs` flag. Add the dependency if
142
147
it's missing. Confirm the test actually exercises your model (not just that it compiles) by
@@ -308,7 +313,7 @@ process for each; most of it is manual today.
308
313
[`publish.yml`][publish-workflow] is organized as five jobs: four publish jobs, one per pack type
309
314
(`queries` for `src`, `library` for `lib`, `extensions` for `ext`, `library_sources_extensions` for
310
315
`ext-library-sources`), each matrixed over every language that has that pack type
311
-
(`ext` runs for `csharp`/`go`/`java`/`python`; `ext-library-sources` only runs for `csharp`/`java`, the only languages with that pack) - plus a fifth
316
+
(`src` includes Actions, Rust, and Swift; `lib` is only created where there is shared library code; `ext` runs for `csharp`/`go`/`java`/`python`/`rust`; `ext-library-sources` only runs for `csharp`/`java`, the only languages with that pack) - plus a fifth
312
317
`summary` job that runs after the other four (`if: always()`, so it still runs even if one of them
313
318
fails), aggregates their per-pack results into the publish-summary and CodeQL library/query pack
314
319
version tables, and (on the release-cut `push` trigger only) upserts both tables into the GitHub
@@ -344,7 +349,8 @@ merge. Bumping your pack's own `version:` in a regular PR just *stages* the chan
344
349
To ship a change:
345
350
346
351
-[ ] Make your change in the pack directory you intend to publish: `<language>/src` (queries),
0 commit comments