Compare commits

..

267 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
93898f5ee1 Convert JavaScript CodeInjection test to inline expectations 2026-06-11 21:54:26 +00:00
copilot-swe-agent[bot]
1d5f8e3254 Convert C++ qlref tests to inline expectations 2026-06-11 21:40:42 +00:00
copilot-swe-agent[bot]
d590687904 Convert C# qlref tests to inline expectations 2026-06-11 21:25:03 +00:00
copilot-swe-agent[bot]
27c62aa9b7 Fix ql inline expectation conversion recipe 2026-06-11 20:31:39 +00:00
Owen Mansel-Chan
4d2e16e97b Actions 2026-06-10 22:59:00 +02:00
Owen Mansel-Chan
212e9d07fd Swift 2026-06-10 22:58:52 +02:00
Owen Mansel-Chan
cf1e064131 rust 2026-06-10 22:58:41 +02:00
Owen Mansel-Chan
9ea3e9088c Ruby 2026-06-10 22:57:52 +02:00
Owen Mansel-Chan
8e07690049 Python 2026-06-10 22:57:42 +02:00
Owen Mansel-Chan
d75113de93 JS 2026-06-10 22:57:33 +02:00
Owen Mansel-Chan
11e99a03d5 C# 2026-06-10 22:57:22 +02:00
Owen Mansel-Chan
f54debd65a C++ 2026-06-10 22:57:08 +02:00
copilot-swe-agent[bot]
c732bd6613 Initial plan 2026-06-10 12:31:19 +00:00
Tom Hvitved
f5919875b7 Merge pull request #21941 from hvitved/python/content-approx
Python: Implement `ContentApprox`
2026-06-09 15:46:04 +02:00
Owen Mansel-Chan
8d456df26f Merge pull request #21960 from github/dependabot/go_modules/go/extractor/extractor-dependencies-28a04969f3
Bump golang.org/x/mod from 0.36.0 to 0.37.0 in /go/extractor in the extractor-dependencies group
2026-06-09 05:30:45 +01:00
dependabot[bot]
72fcf27d1a Bump golang.org/x/mod
Bumps the extractor-dependencies group in /go/extractor with 1 update: [golang.org/x/mod](https://github.com/golang/mod).


Updates `golang.org/x/mod` from 0.36.0 to 0.37.0
- [Commits](https://github.com/golang/mod/compare/v0.36.0...v0.37.0)

---
updated-dependencies:
- dependency-name: golang.org/x/mod
  dependency-version: 0.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: extractor-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 03:03:37 +00:00
yoff
0cea01c22f Merge pull request #21926 from github/yoff/python-simplify-decorator-predicates
Python: simplify decorator-detection predicates to pure AST match
2026-06-08 22:04:33 +02:00
Anders Schack-Mulligen
a473565256 Merge pull request #21954 from aschackmull/cfg/consistency-child-idx
Cfg: Add consistency check for relevant child indices.
2026-06-08 14:44:20 +02:00
Anders Schack-Mulligen
c47135a40b Cfg: Add consistency check for relevant child indices. 2026-06-08 13:40:33 +02:00
Owen Mansel-Chan
3cbc8f0262 Merge pull request #21951 from github/workflow/go-version-update
Go: Update to 1.26.4
2026-06-08 11:47:47 +01:00
Tom Hvitved
cc1ea25856 Python: Implement ContentApprox 2026-06-08 08:41:28 +02:00
github-actions[bot]
5a38cbd5d5 Go: Update to 1.26.4 2026-06-08 04:30:10 +00:00
Owen Mansel-Chan
cf6d94cf8a Merge pull request #21324 from github/copilot/automate-go-version-updates-again
Automate Go version updates via scheduled workflow
2026-06-06 03:03:03 +01:00
Owen Mansel-Chan
292fc8b777 Fix detection of failed text replacement
I checked and the comment seems to be correct.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-06 02:52:21 +01:00
Owen Mansel-Chan
a1759d9834 Use --force-with-lease for slightly improved safety
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-06 02:51:36 +01:00
Owen Mansel-Chan
6b74874372 Minor improvement to PR text 2026-06-06 02:32:43 +01:00
copilot-swe-agent[bot]
ef29d22c75 Update Go version workflow to include patch numbers in messages 2026-06-06 01:03:44 +00:00
Owen Mansel-Chan
1f91f915c7 Merge pull request #21888 from owen-mc/py/remove-imprecise-container-steps
Python: Remove imprecise container steps #2
2026-06-04 22:16:24 +01:00
Jon Janego
ba8eebe2b5 Merge pull request #21948 from github/codeql-spark-run-26974832191
Update changelog documentation site for codeql-cli-2.25.6
2026-06-04 14:55:17 -05:00
github-actions[bot]
dc1409e5f4 update codeql documentation 2026-06-04 19:36:45 +00:00
Mario Campos
284f42bb9e Merge pull request #21945 from github/codeql-spark-run-26947645690
Update changelog documentation site for codeql-cli-2.25.6
2026-06-04 13:09:04 -05:00
Henry Mercer
2f3524de74 Merge branch 'rc/3.22' into codeql-spark-run-26947645690 2026-06-04 16:01:11 +01:00
github-actions[bot]
b32573b060 update codeql documentation 2026-06-04 14:57:38 +00:00
Owen Mansel-Chan
cd2398aeea Merge pull request #21936 from github/workflow/coverage/update
Update CSV framework coverage reports
2026-06-04 12:45:21 +01:00
Sotiris Dragonas
d6892eaf0d Merge pull request #21900 from github/bazookamusic/range-analysis-bound-move-to-shared
Bound.qll - Replace utility for range analysis duplicate across java and cs with shared file
2026-06-04 12:45:11 +02:00
BazookaMusic
d2972cb53f Add back alias for module 2026-06-04 11:08:49 +02:00
github-actions[bot]
5576d30780 Add changed framework coverage reports 2026-06-04 01:04:50 +00:00
Owen Mansel-Chan
da999ee440 Address review comments 2026-06-03 21:24:16 +01:00
Tom Hvitved
3da195f50f Merge pull request #21918 from hvitved/rust/expose-resolution
Rust: Add `Impl::getSelf()` and `Impl::getTrait()`
2026-06-03 20:18:05 +02:00
Henry Mercer
93a4b427e3 Merge pull request #21933 from github/post-release-prep/codeql-cli-2.25.6
Post-release preparation for codeql-cli-2.25.6
2026-06-03 16:57:48 +01:00
Tom Hvitved
0430c71318 Merge pull request #21922 from hvitved/rust/static-const-resolution
Rust: Path resolution for `static` items
2026-06-03 17:48:21 +02:00
Owen Mansel-Chan
52f2a5825a Merge pull request #21804 from github/copilot/add-tests-for-models
Java: Update CWE-918 model coverage for Apache HttpClient `execute` sinks
2026-06-03 12:55:56 +01:00
Owen Mansel-Chan
d55ff83568 Merge pull request #21269 from owen-mc/go/improve-tests-for-varargs-flow
Go: improve tests for varargs flow
2026-06-03 12:39:46 +01:00
BazookaMusic
f34275636c No duplicate Ssa and remove release changenot 2026-06-03 11:54:24 +02:00
BazookaMusic
0a801440b9 review comments 2026-06-03 10:48:50 +02:00
Asger F
7edf0100cc Merge pull request #21924 from asgerf/asgerf/yeast-changes
Yeast: some fixes
2026-06-03 10:32:38 +02:00
Owen Mansel-Chan
167c837088 Merge pull request #21914 from owen-mc/shared/cfg/if-init
Shared CFG: allow init stmts for IfStmt
2026-06-02 22:01:02 +01:00
Owen Mansel-Chan
6f2cc43f32 Remove imprecise model for tuple() 2026-06-02 21:59:48 +01:00
Owen Mansel-Chan
5042fdee84 Remove imprecise model for list() 2026-06-02 21:59:46 +01:00
Owen Mansel-Chan
04341c47bd Tweak model for str.join 2026-06-02 21:59:44 +01:00
Tom Hvitved
af45e53e77 Rust: Rename parameter in DB upgrade script 2026-06-02 21:18:53 +02:00
Owen Mansel-Chan
b27d08ee32 Update edges in expected test output 2026-06-02 18:29:56 +01:00
Jeroen Ketema
d11fc3a00e Merge pull request #21932 from jketema/jketema/vue
JS: Add Vue to `file_coverage_languages` and `github_api_languages`
2026-06-02 17:53:25 +02:00
Owen Mansel-Chan
20ce679d61 Accept changed edges in test output
No changes to alerts
2026-06-02 16:15:08 +01:00
Owen Mansel-Chan
f62ebef9e0 Adjust expected test output 2026-06-02 16:15:06 +01:00
Owen Mansel-Chan
c3ef1ddd64 Add MaD models for lxml and xml etree.fromstringlist 2026-06-02 16:15:01 +01:00
Owen Mansel-Chan
dede5bc49b Track flow through tuple() with list with tainted elements 2026-06-02 16:14:59 +01:00
Owen Mansel-Chan
ad97b6dd64 Use access path for str.join model 2026-06-02 16:14:56 +01:00
Jeroen Ketema
9d5dfea5c5 JS: Add Vue to file_coverage_languages and github_api_languages 2026-06-02 16:57:51 +02:00
Tom Hvitved
dc0c7d7ec2 Fix commment typos 2026-06-02 14:41:27 +02:00
Owen Mansel-Chan
aaa3b363e1 Merge pull request #21929 from owen-mc/go/no-ret-functions
Go: Recognize more non-returning logging functions
2026-06-02 10:39:28 +01:00
Sotiris Dragonas
61a5cece56 Merge branch 'main' into bazookamusic/range-analysis-bound-move-to-shared 2026-06-02 10:41:49 +02:00
BazookaMusic
566a92e555 formatting again 2026-06-02 10:41:10 +02:00
Owen Mansel-Chan
9dbe9adb00 Update tests 2026-06-02 09:34:03 +01:00
Owen Mansel-Chan
be9c785cb2 Fix incorrect QLDoc
Co-authored-by: Tom Hvitved <hvitved@github.com>
2026-06-02 09:26:13 +01:00
Tom Hvitved
1fd31d0ddd Rust: Data flow for consts and statics 2026-06-02 09:55:51 +02:00
Tom Hvitved
c4e3720d8a Rust: Run codegen 2026-06-02 09:02:57 +02:00
Tom Hvitved
0547e9c98d Rust: Path resolution for static items 2026-06-02 09:02:56 +02:00
Owen Mansel-Chan
703cea2b65 Model panicking log functions better 2026-06-02 01:32:00 +01:00
Owen Mansel-Chan
e6e8e3d005 Taint doesn't flow through panicking functions 2026-06-02 01:31:44 +01:00
Owen Mansel-Chan
adc9b7714b Accept changed test output 2026-06-02 00:57:06 +01:00
Owen Mansel-Chan
e706c5f444 Improve test for non-returning fns 2026-06-02 00:56:12 +01:00
Owen Mansel-Chan
8a1e6d4f64 Add missing QLDocs 2026-06-02 00:41:48 +01:00
Owen Mansel-Chan
1a747dd8be (Trivial) Fix QLDoc grammar 2026-06-02 00:39:25 +01:00
Owen Mansel-Chan
28bb1a6870 Add change note 2026-06-02 00:16:23 +01:00
Owen Mansel-Chan
45b1253b23 Improve glog and klog tests 2026-06-02 00:16:21 +01:00
Owen Mansel-Chan
c99dab1d71 Improve glog (and klog) modelling 2026-06-02 00:16:19 +01:00
Owen Mansel-Chan
f3e3647209 Improve noretFunctions test 2026-06-02 00:16:17 +01:00
Owen Mansel-Chan
8d099cbe38 Recognize more non-returning logging functions 2026-06-02 00:15:58 +01:00
Tom Hvitved
9618e9b35c Merge pull request #21873 from hvitved/local-name-resolution
Shared: Local name resolution library
2026-06-01 20:51:07 +02:00
BazookaMusic
2a3cff382c more specific comment 2026-06-01 18:20:50 +02:00
BazookaMusic
c610af88d3 fix comment and add overlay[local?] 2026-06-01 18:18:37 +02:00
BazookaMusic
fa63dad1d1 change note 2026-06-01 18:16:51 +02:00
Sotiris Dragonas
019a5c01ad Merge branch 'main' into bazookamusic/range-analysis-bound-move-to-shared 2026-06-01 18:10:02 +02:00
yoff
5fb75ac987 Python: simplify decorator-detection predicates to pure AST match
The internal predicates that identify `@staticmethod`, `@classmethod` and
`@property` decorators previously required the decorator's `NameNode` to
satisfy `isGlobal()` (i.e. no SSA def reaches the decorator's name use).
That filter was correct but unnecessarily indirect: these three names
are builtins, and even when a class body redefines one, the class body
has not started executing at the decorator position, so Python uses the
builtin.

Match the decorator's AST `Name` directly instead, dropping the CFG/SSA
detour. The slight semantic change — `isGlobal()` would have rejected
module-level shadowing of these builtins — is negligible in practice
and explicitly documented in the change note.

`hasContextmanagerDecorator` and `hasOverloadDecorator` keep the
`NameNode.isGlobal()` check because their target names (`contextmanager`,
`overload`) are imported, not builtin, and local shadowing is a real
concern.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-01 14:04:43 +00:00
BazookaMusic
c1c9287535 restore file header 2026-06-01 15:48:26 +02:00
BazookaMusic
d1226b71de formatting 2026-06-01 15:46:52 +02:00
BazookaMusic
71a363545a formatting 2026-06-01 15:24:06 +02:00
Asger F
3f3bed62d3 yeast: type-check for missing required fields
Add FieldCardinality to Schema to track required/multiple per field,
populated from the ast_types.yml suffixes (bare = required single,
? = optional single, + = required multiple, * = optional multiple).

dump_ast_with_type_errors now emits:
  <-- ERROR: missing required field 'name'
for any node in the output AST whose declared schema requires a field
that is absent from the actual node.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-01 14:18:37 +02:00
Asger F
21f216af8c yeast-macros: omit empty fields produced by .. splice
When a {..expr} splice in an output template is empty (e.g. from an
optional capture that did not match), drop the field entirely rather
than emitting an empty named field. This lets a single rule with
optional captures replace what used to be two near-identical rules.

Also re-renders the corpus to drop the now-suppressed empty fields.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-01 14:18:37 +02:00
Asger F
1751d70c62 Fix parsing of corpus tests when --- delimiter is missing 2026-06-01 14:18:37 +02:00
Asger F
ac8eb50c26 Yeast: Allow 'r#type' to escape the 'type' keyword in macro 2026-06-01 14:18:37 +02:00
Asger F
1ecdc3614f Yeast: Fix matching against extras like comments 2026-06-01 14:18:37 +02:00
Asger F
e3b3888bee Yeast: Fix handling of captures with multiple results 2026-06-01 14:18:36 +02:00
Asger F
ef9306d82c Yeast: Allow rules that return an empty sequence 2026-06-01 14:18:36 +02:00
Asger F
56822f8ee1 Tree-sitter-extactor: More helpful panic message 2026-06-01 14:04:49 +02:00
Tom Hvitved
62207f152c Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-01 13:55:22 +02:00
Tom Hvitved
d5f94475b5 Rust: DB upgrade/downgrade scripts 2026-06-01 10:38:10 +02:00
Tom Hvitved
00e95a0757 Rust: Add Impl::getSelf() and Impl::getTrait() 2026-06-01 10:38:09 +02:00
Tom Hvitved
c695c151ea Rust: Rename Impl::getTrait to Impl::getTraitTy 2026-06-01 10:38:07 +02:00
Jeroen Ketema
ab4a575243 Merge pull request #21899 from MathiasVP/use-new-prototype-extensionals
C++: Use the new `prototype`-related extensionals in MaD
2026-06-01 10:24:19 +02:00
Tom Hvitved
d2f474d998 Address review comments 2026-06-01 08:30:01 +02:00
Owen Mansel-Chan
b38440490a Address review comment 2026-05-31 21:47:44 +01:00
Mathias Vorreiter Pedersen
22b08f1ea4 C++: Add a test with a kind of "partial function template" instantiation. 2026-05-31 12:47:31 +02:00
Owen Mansel-Chan
5e5a0437e1 Shared CFG: allow init stmts for IfStmt 2026-05-30 07:35:29 +01:00
Mathias Vorreiter Pedersen
e18448dd59 C++: Add more tests. 2026-05-29 18:22:13 +02:00
Henry Mercer
a16f1c555c Merge pull request #21912 from github/post-release-prep/codeql-cli-2.25.6
Post-release preparation for codeql-cli-2.25.6
2026-05-29 14:43:56 +01:00
Geoffrey White
43c1152634 Merge pull request #21905 from geoffw0/swiftflow2
Swift: Update the new metatype sinks
2026-05-29 14:18:45 +01:00
Tom Hvitved
caae5a8bf1 Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-29 14:24:45 +02:00
github-actions[bot]
cfb18c2477 Post-release preparation for codeql-cli-2.25.6 2026-05-29 12:04:35 +00:00
Owen Mansel-Chan
aee33a0cc9 Add missing code for TAnyTupleOrDictionaryElement 2026-05-29 10:26:24 +01:00
Anders Schack-Mulligen
4c31866910 Merge pull request #21867 from aschackmull/ruby/callable-body
Ruby: Split callable and its body into two AST nodes.
2026-05-29 10:16:19 +02:00
Tom Hvitved
09371339d7 Ruby: Adopt shared local name resolution library 2026-05-29 09:06:14 +02:00
Taus
6165623cbf Merge pull request #21724 from github/tausbn/python-add-self-validating-cfg-tests 2026-05-28 22:07:55 +02:00
Owen Mansel-Chan
df15a719cb Add a ContentSet for any tuple or dictionary element 2026-05-28 16:48:23 +01:00
Michael Nebel
2eac8890d3 Merge pull request #21893 from michaelnebel/cshar/updateroslyn
C#: Update Roslyn and other pinned depenencies.
2026-05-28 13:49:29 +02:00
Mathias Vorreiter Pedersen
2d581504f7 C++: Fix Copilot comments. 2026-05-28 13:34:18 +02:00
Mathias Vorreiter Pedersen
9f211cebd5 C++: Accept test changes. 2026-05-28 13:34:16 +02:00
Mathias Vorreiter Pedersen
8393b40b59 C++: Use the new extensionals to map template functions and classes to their fully templated versions. 2026-05-28 13:34:12 +02:00
Geoffrey White
f8ab76e1ba Swift: Update the new metatype sinks to not rely on name matching '.Type'. 2026-05-28 12:14:10 +01:00
Geoffrey White
34d4e9a8e2 Merge pull request #21898 from geoffw0/swiftflow
Swift: Extend swift/weak-sensitive-data-hashing, swift/weak-password-hashing sinks
2026-05-28 11:52:32 +01:00
Owen Mansel-Chan
812e8e6b34 Add change note 2026-05-28 11:37:54 +01:00
Owen Mansel-Chan
80c6f082d1 Fix TODO in containerStep 2026-05-28 11:34:02 +01:00
Michael Nebel
ed8b9c29cc Merge pull request #21866 from michaelnebel/csharp/refreturnindexerproperty
C#: Property- and Indexer calls for ref return properties and indexers.
2026-05-28 12:31:17 +02:00
Owen Mansel-Chan
d95d99848c Build RequestBuilder more realistically 2026-05-28 11:05:40 +01:00
Owen Mansel-Chan
8937e22735 Add summary models for org.apache.http.client.methods.RequestBuilder
Generated by GPT 5.3-codex, verified by me.
2026-05-28 10:56:37 +01:00
Owen Mansel-Chan
37589dd8a0 Improve how org.apache.http.client.HttpClient is created in test 2026-05-28 10:30:43 +01:00
Owen Mansel-Chan
a159dc1c66 Change variable name in test 2026-05-28 10:28:14 +01:00
Tom Hvitved
7718fe40a0 Ruby: Add more variable tests 2026-05-28 10:50:15 +02:00
Tom Hvitved
aeb82858d7 Rust: Run codegen 2026-05-28 10:50:13 +02:00
Tom Hvitved
c08cf81665 Rust: Adopt shared local name resolution library 2026-05-28 10:50:10 +02:00
Tom Hvitved
e06158629e Rust: More local variable tests 2026-05-28 10:50:05 +02:00
Tom Hvitved
3e09961662 Shared: Add local name binding library 2026-05-28 10:50:03 +02:00
Asger F
17fe3e4e31 Merge pull request #21901 from asgerf/unified-fix-test
Unified: fix test output
2026-05-27 22:19:17 +02:00
Asger F
313500e581 Unified: update test outputs 2026-05-27 21:27:09 +02:00
Asger F
ad56ebd361 Unified: update test output 2026-05-27 21:25:32 +02:00
Asger F
6be9e2315d Merge pull request #21841 from github/tausbn/unified-swift-named-body-fields
Unified: Get rid of all `$children` fields
2026-05-27 21:25:11 +02:00
BazookaMusic
cc12740c0e remove check for files in sync 2026-05-27 17:41:44 +02:00
Geoffrey White
5c2488e304 Swift: Fix typo. 2026-05-27 16:29:48 +01:00
Geoffrey White
4fbea4ef95 Swift: Autoformat. 2026-05-27 16:28:21 +01:00
Taus
35faec3db1 Python: Address review comments
- Get rid of unnecessary parentheses
- Use call syntax in the relevant test
- Get rid of `dead(2)` annotation
2026-05-27 15:27:19 +00:00
BazookaMusic
acb5c0e70f missed changes 2026-05-27 17:23:45 +02:00
BazookaMusic
6042adebae move identical java and cs bound.qll to shared library 2026-05-27 17:23:28 +02:00
Mathias Vorreiter Pedersen
5f54a8691d C++: Small cleanup. This has no effect on semantics. 2026-05-27 17:16:22 +02:00
Taus
41fd59c1c1 Unified: regenerate Ast.qll and dbscheme 2026-05-27 15:02:28 +00:00
Taus
d6e7e38e1c Unified: merge in main
Keeps our version of the conflicting files. They will be regenerated in
the next commit.
2026-05-27 15:01:03 +00:00
Owen Mansel-Chan
ec13e1bcd3 Add wildcard ContentSets to avoid performance problems 2026-05-27 15:28:07 +01:00
Jeroen Ketema
7723324687 Merge pull request #21896 from jketema/jketema/deprecated
C++: Remove deprecated code
2026-05-27 14:11:10 +02:00
Michael Nebel
d4c7b5b6fe C#: Update encoding of SBCS to UTF8 with BOM. 2026-05-27 14:01:34 +02:00
Michael Nebel
6b55f865cd C#: Update integration test expected output. 2026-05-27 13:24:45 +02:00
Jeroen Ketema
42c4d8a98b Merge pull request #21897 from jketema/jketema/missing-friend
C++: Update expected test results after extractor changes
2026-05-27 12:54:00 +02:00
Geoffrey White
f962eac914 Swift: Fill the simple gaps in modelling. 2026-05-27 11:20:00 +01:00
Geoffrey White
c6c3e1474c Swift: Add a few more test cases for simple missing models. 2026-05-27 11:15:28 +01:00
Geoffrey White
94e6ec6511 Swift: Widen the new sinks to cover more cases the MaD sinks are missing. 2026-05-27 10:34:12 +01:00
Geoffrey White
c902c75651 Swift: Add change note. 2026-05-27 10:33:42 +01:00
Geoffrey White
2b4ea18dfe Swift: Add a similar sink for password hashing as well. 2026-05-27 10:33:41 +01:00
Geoffrey White
98b7659cc1 Swift: Add a special case sink for weak sensitive data hashing sinks that are calls through a metatype. 2026-05-27 10:33:39 +01:00
Geoffrey White
d9c0b9ca31 Swift: Additional test cases for CryptoKit. 2026-05-27 10:33:37 +01:00
Geoffrey White
b44bca9ea7 Swift: Add HashFunction protocol and other realism to the CryptoKit test stubs (this is needed for new cases to work as intended). 2026-05-27 10:33:31 +01:00
Jeroen Ketema
e66b1e4beb Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-27 10:58:05 +02:00
Jeroen Ketema
362c48cc6d C++: Add change note 2026-05-27 10:44:44 +02:00
Jeroen Ketema
35364a087a C++: Update expected test results after extractor changes 2026-05-27 10:23:16 +02:00
Anders Schack-Mulligen
780591d42a Ruby: Remove spurious parent-child edges for Ruby::SimpleSymbol.
These treesitter nodes translate to multiple AstNodes, but we only want
those that are Stmts.
2026-05-27 10:06:15 +02:00
Anders Schack-Mulligen
3aa69823af Ruby: Skip BodyStmt in ErbDirective.getAChildStmt. 2026-05-27 10:06:14 +02:00
Asger F
f18cdcfec6 Merge pull request #21848 from asgerf/asgerf/swift-yeast
Unified: Add schema checking and corpus-style tests
2026-05-26 22:00:21 +02:00
Jeroen Ketema
7862922e5c C++: Remove deprecated code 2026-05-26 17:54:51 +02:00
Taus
fbc861e7a4 unified: Clarify grammar comment
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-26 16:19:02 +02:00
Michael Nebel
7f2fb2eb99 C#: Use the generic version of the associated implementation. 2026-05-26 15:59:25 +02:00
Michael Nebel
769b1957a5 C#: Update generated files. 2026-05-26 14:13:02 +02:00
Michael Nebel
26da373bd4 C#: Update Roslyn and other pinned dependencies. 2026-05-26 14:11:36 +02:00
Anders Schack-Mulligen
e07f45fff4 Ruby: Accept test changes. 2026-05-22 13:36:59 +02:00
Anders Schack-Mulligen
3adb7043e8 Ruby: Fix pre-existing bug. 2026-05-22 13:29:45 +02:00
Owen Mansel-Chan
e8779295ee Update test results 2026-05-22 11:43:18 +01:00
Anders Schack-Mulligen
7dcd2d6ab6 Ruby: Adjust CFG to updated AST. 2026-05-22 11:06:15 +02:00
Anders Schack-Mulligen
b6c2915f24 Ruby: Split callable and its body into two AST nodes. 2026-05-22 11:06:14 +02:00
Rasmus Lerchedahl Petersen
fa758d6bf5 python: fix test 2026-05-21 16:59:19 +01:00
Rasmus Lerchedahl Petersen
fa9426c749 Python: extra tests for comprehension 2026-05-21 16:59:18 +01:00
Rasmus Lerchedahl Petersen
0ecca91dea Python: typo 2026-05-21 16:59:16 +01:00
Rasmus Lerchedahl Petersen
f669a4f3bf Python: Make sure all imprecise taint bubbles up 2026-05-21 16:59:14 +01:00
Rasmus Lerchedahl Petersen
3275c814bd Python: reset test expectations 2026-05-21 16:59:11 +01:00
Rasmus Lerchedahl Petersen
9a180036a5 Python: conversion step for format_map
and adjust collection test
2026-05-21 16:59:08 +01:00
Rasmus Lerchedahl Petersen
93e7ab52b7 Python: adjust test expectations
We now find an alert on this line as we hope to
It is not an alert for _full_ SSRF, though, since that configuration cannot handle multiple substitutions.
2026-05-21 16:58:51 +01:00
Rasmus Lerchedahl Petersen
facb3b681d Python: recover taint for % format strings 2026-05-21 16:57:50 +01:00
Rasmus Lerchedahl Petersen
b67694b2ab Python: Remove imprecise container steps
- remove `tupleStoreStep` and `dictStoreStep` from `containerStep`
   These are imprecise compared to the content being precise.
- add implicit reads to recover taint at sinks
- add implicit read steps for decoders
  to supplement the `AdditionalTaintStep`
  that now only covers when the full container is tainted.
2026-05-21 16:57:44 +01:00
Michael Nebel
6825ccc74f C#: Add change-note. 2026-05-19 14:24:08 +02:00
Michael Nebel
c0273ae94f C#: Update other affected tests (including database quality). 2026-05-19 14:24:05 +02:00
Michael Nebel
1c01bb32d9 C#: Update test expected output. 2026-05-19 14:24:03 +02:00
Michael Nebel
c3bb5e8eff C#: Use ref return getters for properties/indexers in write contexts. 2026-05-19 14:24:00 +02:00
Michael Nebel
9d0d4e4912 C#: Add ref return info for accessors. 2026-05-19 14:23:57 +02:00
Michael Nebel
a2ac0ab7d5 C#: Add test case for indexer calls and update test expected for other files. 2026-05-19 14:23:55 +02:00
Michael Nebel
42aaae7cf3 C#: Add test case for property calls and update test expected for other files. 2026-05-19 14:23:52 +02:00
Anders Schack-Mulligen
cb0fc786c7 Ruby: Minor cleanup, Callable is a StmtSequence. 2026-05-18 13:05:14 +02:00
Taus
dd9c066c61 unified: Regenerate files 2026-05-13 14:24:12 +00:00
Taus
f4f85b58ca unified: Remove some pointless fields
All of these fields have contents that are uniquely determined by the
node they appear on, so they convey no information.
2026-05-13 14:22:06 +00:00
Taus
caef72b047 unified: Introduced named property_binding node
This groups together a bunch of related values that would otherwise be
impossible to match up correctly.
2026-05-13 13:54:21 +00:00
Taus
9787a8b072 unified: Group enum entries
Same as in the preceding commit.
2026-05-13 13:51:25 +00:00
Taus
c8f7c3d7f2 unified: Group more paired items
Same as in the preceding commit, these items do not make sense as
separate fields on the parent node, so we materialise (or create new)
intermediate nodes to group them together.
2026-05-13 13:49:30 +00:00
Taus
ea6f3a9568 unified: Encapsulate function parameters
The field representation would have made it difficult to figure out
which parameters correspond to which default values and attributes, so
instead we now encapsulate these in a new `function_parameter` node.
2026-05-13 13:20:58 +00:00
Taus
5d6dc5c3c3 unified: Clean up statements/block mess
Introduces (by making it named) a `block` node, and conversely makes
`statements` anonymous. This enables us to sensibly distinguish between
the "then" and "else" branch of an `if_statement`, which we were not
able to previously.
2026-05-13 13:06:34 +00:00
Asger F
554bdf14b2 Yeast: fix warning about unnecessary mutability 2026-05-13 11:19:51 +02:00
Asger F
b031e5b1f8 Unified: regenerate QL and make tests not crash
The output is not so interesting as the mapping removes most nodes from the current test file.

I added a name_expr.swift test so at least one NameExpr makes it through.
2026-05-13 10:48:43 +02:00
Asger F
7fa6c4e4a3 Unified: Update test output after rebasing on grammar changes
The branch was rebased on the grammar changes, but rewriting the history was too difficult, so I'm just updating the test output here.
2026-05-13 10:35:34 +02:00
Asger F
600a4969c9 Unified: Simplify concatenation of arguments 2026-05-13 10:35:33 +02:00
Asger F
55194dd757 Unified: Support for calls and member access 2026-05-13 10:35:31 +02:00
Asger F
cbe4c81ca6 Unified: add tuple_pattern and sequence_condition; refine if-let/guard mapping
ast_types.yml additions:
- tuple_pattern { element*: pattern } in the pattern supertype.
- sequence_condition { stmt*: stmt, condition: condition } in the
  condition supertype.

swift.rs:
- Map Swift tuple destructuring (e.g. `let (a, b) = pair`) to the new
  tuple_pattern instead of synthesizing an apply_pattern.
- if-let / guard-let: explicitly match the value_binding_pattern
  (the `let` keyword) and bind the source expression as the next
  condition child, so `let` no longer leaks into the output.
2026-05-13 10:35:29 +02:00
Asger F
3b7a53f678 yeast-macros: merge repeated field declarations and support repetition in field patterns
Two changes to parse_query_fields:

- Allow `field: (kind)* @cap` (repetition + optional capture) in field
  position, mirroring how it works for bare children.
- When the same field name is declared multiple times in a query (e.g.
  `condition: (foo) condition: (bar)`), merge them into a single
  ordered list of children rather than emitting duplicate field
  entries (which at runtime restart the iterator for the field and
  cause the second declaration to re-match from the first child).
2026-05-13 10:35:27 +02:00
Asger F
ccc1dd5d3e Unified: Add tuple_pattern 2026-05-13 10:35:26 +02:00
Asger F
a966dff76e Unified: Add more patterns and some fixes to the AST 2026-05-13 10:35:24 +02:00
Asger F
6b58482dfb Yeast: Fix text associated with synthesized nodes 2026-05-13 10:35:22 +02:00
Asger F
2307839050 Yeast: Change how patterns with repetition are parsed 2026-05-13 10:35:21 +02:00
Asger F
92838011dd Unified: Add some more AST nodes and rules 2026-05-13 10:35:19 +02:00
Asger F
5772ee4d9b YEAST: add NodeRef type, YeastDisplay trait, and source text storage
Introduce NodeRef as a typed wrapper around node arena IDs. Captures in
desugaring rules are now bound as NodeRef instead of raw usize, which
prevents accidental misuse and enables source-text-aware rendering.

Add the YeastDisplay trait as an alternative to Display: its
yeast_to_string method receives the Ast, allowing NodeRef to resolve to
the captured node's source text instead of printing a numeric ID.

Store the original source bytes in the Ast so that NodeContent::Range
values (from synthesized literal nodes) can be resolved back to text.

Update yeast-macros to emit NodeRef-typed capture bindings and use
Into::<usize>::into where raw IDs are needed. The #{expr} template
syntax now uses YeastDisplay instead of Display.

The effect is visible in the corpus tests: operator nodes now correctly
render as e.g. operator "+" instead of operator "3".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-13 10:35:17 +02:00
Asger F
72b683d63c Unified: Add Swift corpus tests
Add corpus test cases for Swift covering closures, collections, control
flow, functions, literals, loops, operators, optionals/errors, types,
and variables. Update existing desugar.txt with raw parse sections.

Note: operator nodes currently render their node ID instead of the actual
operator text (e.g. operator "3" instead of operator "+"). This will be
fixed in the next commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-13 10:35:16 +02:00
Asger F
8a2a48d2dd Unified extractor: add AST schema, swift translation rules, and corpus framework
Add ast_types.yml defining the unified output AST schema with supertypes
(expr, stmt, condition, pattern) and named nodes (top_level, binary_expr,
name_expr, etc.).

Rewrite swift translation rules to map from tree-sitter Swift grammar to
the unified AST, using one-shot phase rules.

Update the generator to use the output AST schema for dbscheme/QL
generation, and normalize the extraction table prefix to 'unified'.

Improve the corpus test framework to include raw tree-sitter parse output,
type-error checking against the output schema, and better failure
reporting.

Regenerate Ast.qll, unified.dbscheme, and update BasicTest accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-13 10:35:14 +02:00
Asger F
5d0cb9e805 YEAST: fix one-shot rules for unnamed nodes and self-captures
One-shot desugaring rules now skip unnamed nodes (punctuation, keywords,
etc.) since rules are intended to target named nodes only.

Also prevent infinite recursion when a capture refers to the root node of
the matched tree (e.g. an @_ capture on the pattern root).

Additionally fix the swift.rs add_phase call to match the updated 3-arg
signature introduced by the one-shot phase kind commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-13 10:35:12 +02:00
Asger F
bb9e996cb6 Shared: Do not emit ReservedWord class when there are no unnamed tokens 2026-05-13 10:35:11 +02:00
Asger F
c3a9218dcf Yeast: Add one-shot phase kind 2026-05-13 10:35:09 +02:00
Asger F
a049850c51 Yeast: add type-checking errors in AST dump 2026-05-13 10:35:07 +02:00
Asger F
49f19092fb Yeast: add reachable_node_ids() 2026-05-13 10:35:05 +02:00
Asger F
f668b99d6d Unified: Add support for tree-sitter-style corpus tests
This adds tests consisting of source code and a printout of its rewritten AST.
2026-05-13 10:35:02 +02:00
Taus
bfe5aa8d42 unified: Regenerate files 2026-05-12 16:01:32 +00:00
Taus
52d72836f9 unified: Fix multiline_comment issue
This named node (which is in fact emitted by the scanner as an
`external`) was appearing as a child of `class_body` because of inlining
via `_class_member_separator`. This, in itself, appears to be somewhat
of a hack, to handle cases where a multiline comment signals the end of
a class member.

To fix this, we make the external node _unnamed_, but keep the `extras`
node _named_ (so we can still extract it from the parse tree), and we
add a new rule `multiline_comment` that mediates between the two. That
way, the use inside `_class_member_separator` can use the unnamed
variant, and no node is pushed into $children.
2026-05-12 15:59:18 +00:00
Taus
eb480d1de4 unified: Make parenthesized_type named
I'm not entirely happy about this solution, but it seemed to be the most
straightforward way of avoiding various kinds of token bleeding.
2026-05-12 15:38:29 +00:00
Taus
1ef557c972 Python: Address Copilot's comments 2026-05-12 15:27:14 +00:00
Taus
2eee2e50dc unified: clean up patterns
Mostly by materialising a bunch of (useful) intermediate nodes.
2026-05-12 15:23:26 +00:00
Taus
2010844b1e unified: Add fields to property_declaration
Not entirely sure about the `binding?` field on `pattern`, but it looks
like that might actually be useful.
2026-05-12 15:14:35 +00:00
Taus
406a02fa49 unified: Add fields to switch_entry
Of note: this involved un-inlining where_clause.
2026-05-12 15:09:02 +00:00
Taus
6e5e650b42 unified: Add fields for macro_declaration 2026-05-12 15:03:29 +00:00
Taus
eba9f35673 unified: Get rid of $children* on key_path_expression
Doing this involved materialising a lot of previously anonymous nodes,
and I'm not entirely sure it's the best solution, but the node types
look decent enough.
2026-05-12 15:01:10 +00:00
Taus
e1a0e204b1 unified: Promote enum_type_parameter to named and add fields 2026-05-12 14:55:43 +00:00
Taus
5e14a7574e unified: make compilation_condition named and add fields 2026-05-12 14:55:42 +00:00
Taus
6ff404a6d0 unified: More miscellaneous field additions 2026-05-12 14:50:01 +00:00
Taus
9902beddec unified: add proper fields for availability_condition 2026-05-12 14:47:58 +00:00
Taus
e6eac3784a unified: Consolidate fields in if_let_binding 2026-05-12 14:43:13 +00:00
Taus
5784ef22f6 unified: Unify more fields
Not entirely happy about the mixed nature of the `kind` filed (having
both tokens and the named node `throw_keyword` in there), but that's a
problem for a different time.
2026-05-12 14:40:17 +00:00
Taus
bc96ae6e47 unified: Add lambda and arguments fields 2026-05-12 14:29:23 +00:00
Taus
15d84b3e53 unified: More $children fixes
Some nodes with a single child (arguably redundant to do, but I think
it's nice to have the types be consistent), and also an instance of
ensuring that all branches of a `choice` expose consistent field names.
2026-05-12 14:15:36 +00:00
Taus
0499932ba0 unified: Fix fields in await_expression
This required a change in a different place, due to aliasing.
2026-05-12 14:10:38 +00:00
Taus
732cc7bee0 unified: Add fields to inheritance specifiers and calls 2026-05-12 14:07:58 +00:00
Taus
853a98842d unified: Regenerate files 2026-05-12 14:00:14 +00:00
Taus
d6ef467fba unified: Add more fields
A lot of changes, but for the most part these are just adding named
fields in places where they make sense.

After this, there are still ~20 instances of unnamed children appearing.
2026-05-12 13:59:56 +00:00
Taus
c75d819a92 unified: Add effect field
I ended up also aliasing `_async_keyword` to a named node to make it
more consistent with the other node kinds that can be in this field (as
it would be awkward to have two named types and a token here).

Elsewhere in the node types, we'll still have `async?: "async"`, and I
think that's okay.
2026-05-12 13:46:25 +00:00
Taus
75c07996f3 unified: regenerate files 2026-05-12 12:57:26 +00:00
Taus
9dddd93460 unified: add field declarations for statements and members
Part 1 of N of "getting rid of $children" in node-types.yml

Note: in one of the cases the affected node still has the $children
field present. This is because there's some weirdness about recording
multiline comments as class member separators that I did not want to
figure out how to address right now.
2026-05-12 12:57:26 +00:00
Taus
f5c3b63a4a Python: Add ConsecutiveTimestamps test
This one is potentially a bit iffy -- it checks for a very powerful
property (that implies many of the other queries), but as the test
results show, it can produce false positives when there is in fact no
problem. We may want to get rid of it entirely, if it becomes too noisy.
2026-05-12 12:54:26 +00:00
Taus
c30d6ae3aa Python: Add NeverReachable test
This looks for nodes annotated with `t[never]` in the test that are
reachable in the CFG. This should not happen (it messes with various
queries, e.g. the "mixed returns" query), but the test shows that in a
few particular cases (involving the `match` statement where all cases
contain `return`s), we _do_ have reachable nodes that shouldn't be.
2026-05-12 12:54:26 +00:00
Taus
fc2bc26f36 Python: Add BasicBlockOrdering test
This one demonstrates a bug in the current CFG. In a dictionary
comprehension `{k: v for k, v in d.items()}`, we evaluate the value
before the key, which is incorrect. (A fix for this bug has been
implemented in a separate PR.)
2026-05-12 12:54:25 +00:00
Taus
3a979ac2f8 Python: Add some CFG-validation queries
These use the annotated, self-verifying test files to check various
consistency requirements.

Some of these may be expressing the same thing in different ways, but
it's fairly cheap to keep them around, so I have not attempted to
produce a minimal set of queries for this.
2026-05-12 12:54:25 +00:00
Taus
71cd5be513 Python: Add self-validating CFG tests
These tests consist of various Python constructions (hopefully a
somewhat comprehensive set) with specific timestamp annotations
scattered throughout. When the tests are run using the Python 3
interpreter, these annotations are checked and compared to the "current
timestamp" to see that they are in agreement. This is what makes the
tests "self-validating".

There are a few different kinds of annotations: the basic `t[4]` style
(meaning this is executed at timestamp 4), the `t[dead(4)]` variant
(meaning this _would_ happen at timestamp 4, but it is in a dead
branch), and `t[never]` (meaning this is never executed at all).

In addition to this, there is a query, MissingAnnotations, which checks
whether we have applied these annotations maximally. Many expression
nodes are not actually annotatable, so there is a sizeable list of
excluded nodes for that query.
2026-05-12 12:42:29 +00:00
Owen Mansel-Chan
dc864762c3 Add change note 2026-05-07 10:23:50 +01:00
Owen Mansel-Chan
dd35bc0722 Update test output 2026-05-07 10:17:47 +01:00
copilot-swe-agent[bot]
043ec857ab Replace fluent SSRF changes with Apache HttpClient execute model tests
Agent-Logs-Url: https://github.com/github/codeql/sessions/3db201db-a1b5-4353-a94a-14a8d156dd3b

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-05-06 20:31:34 +00:00
copilot-swe-agent[bot]
f5b17b0b48 Add SSRF tests and stubs for Apache Http fluent Request models
Agent-Logs-Url: https://github.com/github/codeql/sessions/bd4fa112-dbc3-47e8-9cef-9b1b13c7e549

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-05-06 16:08:02 +00:00
copilot-swe-agent[bot]
26dca558c7 Initial plan 2026-05-06 16:02:08 +00:00
Owen Mansel-Chan
a367294c23 Merge branch 'main' into copilot/automate-go-version-updates-again 2026-04-23 14:41:46 +01:00
copilot-swe-agent[bot]
b6004045bd Clean up Go version workflow - remove unnecessary escaping and checks
Co-authored-by: mbg <278086+mbg@users.noreply.github.com>
2026-02-13 11:23:44 +00:00
copilot-swe-agent[bot]
cc7e03b0f5 Add error handling and validation to Go version workflow
Co-authored-by: mbg <278086+mbg@users.noreply.github.com>
2026-02-13 11:22:36 +00:00
copilot-swe-agent[bot]
1cbd423251 Improve portability and fix PR detection in Go version workflow
Co-authored-by: mbg <278086+mbg@users.noreply.github.com>
2026-02-13 11:21:13 +00:00
copilot-swe-agent[bot]
437244fe90 Fix portability issues in Go version update workflow
Co-authored-by: mbg <278086+mbg@users.noreply.github.com>
2026-02-13 11:19:56 +00:00
copilot-swe-agent[bot]
f7cf24d1f9 Add Go version update workflow
Co-authored-by: mbg <278086+mbg@users.noreply.github.com>
2026-02-13 11:17:57 +00:00
copilot-swe-agent[bot]
c3bafacf81 Initial plan 2026-02-13 11:15:15 +00:00
Owen Mansel-Chan
57ce0b3d51 Accept data flow consistency result 2026-02-05 22:28:54 +00:00
Owen Mansel-Chan
408ba2e139 (Misc) Delete spuriously committed binary file 2026-02-04 13:41:14 +00:00
Owen Mansel-Chan
7632bdba88 (Misc) fix variable names 2026-02-04 13:40:52 +00:00
Owen Mansel-Chan
4b830c1864 Test varargs flow with models-as-data 2026-02-04 13:40:33 +00:00
Owen Mansel-Chan
d6c8767647 Test flow out of varargs parameter in function model 2026-02-04 13:40:01 +00:00
Owen Mansel-Chan
ec815397a2 Test flow out of varargs parameter in source function 2026-02-04 13:38:48 +00:00
2378 changed files with 51708 additions and 19276 deletions

208
.github/workflows/go-version-update.yml vendored Normal file
View File

@@ -0,0 +1,208 @@
name: Update Go version
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * 1" # Run weekly on Mondays at 3 AM UTC (1 = Monday)
permissions:
contents: write
pull-requests: write
jobs:
update-go-version:
name: Check and update Go version
if: github.repository == 'github/codeql'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Fetch latest Go version
id: fetch-version
run: |
LATEST_GO_VERSION=$(curl -s https://go.dev/dl/?mode=json | jq -r '.[0].version')
if [ -z "$LATEST_GO_VERSION" ] || [ "$LATEST_GO_VERSION" = "null" ]; then
echo "Error: Failed to fetch latest Go version from go.dev"
exit 1
fi
echo "Latest Go version from go.dev: $LATEST_GO_VERSION"
echo "version=$LATEST_GO_VERSION" >> $GITHUB_OUTPUT
# Extract version numbers (e.g., go1.26.0 -> 1.26.0)
LATEST_VERSION_NUM=$(echo $LATEST_GO_VERSION | sed 's/^go//')
echo "version_num=$LATEST_VERSION_NUM" >> $GITHUB_OUTPUT
# Extract major.minor version (e.g., 1.26.0 -> 1.26)
LATEST_MAJOR_MINOR=$(echo $LATEST_VERSION_NUM | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
echo "major_minor=$LATEST_MAJOR_MINOR" >> $GITHUB_OUTPUT
- name: Check current Go version
id: current-version
run: |
CURRENT_VERSION=$(sed -n 's/.*go_sdk\.download(version = \"\([^\"]*\)\".*/\1/p' MODULE.bazel)
if [ -z "$CURRENT_VERSION" ]; then
echo "Error: Could not extract Go version from MODULE.bazel"
exit 1
fi
echo "Current Go version in MODULE.bazel: $CURRENT_VERSION"
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Extract major.minor version
CURRENT_MAJOR_MINOR=$(echo $CURRENT_VERSION | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
echo "major_minor=$CURRENT_MAJOR_MINOR" >> $GITHUB_OUTPUT
- name: Compare versions
id: compare
run: |
LATEST="${{ steps.fetch-version.outputs.version_num }}"
CURRENT="${{ steps.current-version.outputs.version }}"
echo "Latest: $LATEST"
echo "Current: $CURRENT"
if [ "$LATEST" = "$CURRENT" ]; then
echo "Go version is up to date"
echo "needs_update=false" >> $GITHUB_OUTPUT
else
echo "Go version needs update from $CURRENT to $LATEST"
echo "needs_update=true" >> $GITHUB_OUTPUT
fi
- name: Update Go version in files
if: steps.compare.outputs.needs_update == 'true'
run: |
LATEST_VERSION_NUM="${{ steps.fetch-version.outputs.version_num }}"
LATEST_MAJOR_MINOR="${{ steps.fetch-version.outputs.major_minor }}"
CURRENT_VERSION="${{ steps.current-version.outputs.version }}"
CURRENT_MAJOR_MINOR="${{ steps.current-version.outputs.major_minor }}"
echo "Updating from $CURRENT_VERSION to $LATEST_VERSION_NUM"
# Escape dots in current version strings for use in sed patterns
CURRENT_VERSION_ESCAPED=$(echo "$CURRENT_VERSION" | sed 's/\./\\./g')
CURRENT_MAJOR_MINOR_ESCAPED=$(echo "$CURRENT_MAJOR_MINOR" | sed 's/\./\\./g')
# Update MODULE.bazel
sed -i "s/go_sdk\.download(version = \"$CURRENT_VERSION_ESCAPED\")/go_sdk.download(version = \"$LATEST_VERSION_NUM\")/" MODULE.bazel
if ! grep -q "go_sdk.download(version = \"$LATEST_VERSION_NUM\")" MODULE.bazel; then
echo "Error: Failed to update MODULE.bazel"
exit 1
fi
# Update go/extractor/go.mod
if ! sed -i "s/^go $CURRENT_MAJOR_MINOR_ESCAPED\$/go $LATEST_MAJOR_MINOR/" go/extractor/go.mod; then
echo "Warning: Failed to update go directive in go.mod"
fi
if ! sed -i "s/^toolchain go$CURRENT_VERSION_ESCAPED\$/toolchain go$LATEST_VERSION_NUM/" go/extractor/go.mod; then
echo "Warning: Failed to update toolchain in go.mod"
fi
# Update go/extractor/autobuilder/build-environment.go
if ! sed -i "s/var maxGoVersion = util\.NewSemVer(\"$CURRENT_MAJOR_MINOR_ESCAPED\")/var maxGoVersion = util.NewSemVer(\"$LATEST_MAJOR_MINOR\")/" go/extractor/autobuilder/build-environment.go; then
echo "Warning: Failed to update build-environment.go"
fi
# Update go/actions/test/action.yml
if ! sed -i "s/default: \"~$CURRENT_VERSION_ESCAPED\"/default: \"~$LATEST_VERSION_NUM\"/" go/actions/test/action.yml; then
echo "Warning: Failed to update action.yml"
fi
# Show what changed
git diff
- name: Check for changes
id: check-changes
if: steps.compare.outputs.needs_update == 'true'
run: |
if git diff --quiet; then
echo "No changes detected"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected"
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Check for existing PR
if: steps.check-changes.outputs.has_changes == 'true'
id: check-pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH_NAME="workflow/go-version-update"
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
echo "Existing PR found: #$PR_NUMBER"
echo "pr_exists=true" >> $GITHUB_OUTPUT
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
else
echo "No existing PR found"
echo "pr_exists=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.check-changes.outputs.has_changes == 'true'
run: |
BRANCH_NAME="workflow/go-version-update"
LATEST_VERSION_NUM="${{ steps.fetch-version.outputs.version_num }}"
LATEST_MAJOR_MINOR="${{ steps.fetch-version.outputs.major_minor }}"
# Create or switch to branch
git checkout -B "$BRANCH_NAME"
# Stage and commit changes
git add MODULE.bazel go/extractor/go.mod go/extractor/autobuilder/build-environment.go go/actions/test/action.yml
git commit -m "Go: Update to $LATEST_VERSION_NUM"
# Push changes
git push --force-with-lease origin "$BRANCH_NAME"
- name: Create or update PR
if: steps.check-changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH_NAME="workflow/go-version-update"
LATEST_VERSION_NUM="${{ steps.fetch-version.outputs.version_num }}"
CURRENT_VERSION="${{ steps.current-version.outputs.version }}"
PR_TITLE="Go: Update to $LATEST_VERSION_NUM"
PR_BODY=$(cat <<EOF
This PR updates Go from $CURRENT_VERSION to $LATEST_VERSION_NUM.
Updated files:
- \`MODULE.bazel\` - go_sdk.download version
- \`go/extractor/go.mod\` - go directive and toolchain
- \`go/extractor/autobuilder/build-environment.go\` - maxGoVersion (only if MAJOR.MINOR changes)
- \`go/actions/test/action.yml\` - default go-test-version
This PR was automatically created by the [Go version update workflow](https://github.com/${{ github.repository }}/blob/main/.github/workflows/go-version-update.yml).
EOF
)
if [ "${{ steps.check-pr.outputs.pr_exists }}" = "true" ]; then
echo "Updating existing PR #${{ steps.check-pr.outputs.pr_number }}"
gh pr edit "${{ steps.check-pr.outputs.pr_number }}" --title "$PR_TITLE" --body "$PR_BODY"
else
echo "Creating new PR"
gh pr create \
--title "$PR_TITLE" \
--body "$PR_BODY" \
--base main \
--head "$BRANCH_NAME" \
--label "Go"
fi

View File

@@ -273,7 +273,7 @@ use_repo(
) )
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.26.0") go_sdk.download(version = "1.26.4")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//go/extractor:go.mod") go_deps.from_file(go_mod = "//go/extractor:go.mod")

View File

@@ -2,7 +2,7 @@
### Minor Analysis Improvements ### Minor Analysis Improvements
* The GitHub Actions analysis now recognizes more Bash regex checks that restrict a value to alphanumeric characters, including regexes like `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$` which check for a SHA-1 or SHA-256 hash. This may reduce false positive results where command output is validated with grouped or optional alphanumeric patterns before being used. * The GitHub Actions analysis now recognizes more Bash regex checks that restrict a value to alphanumeric characters, include regexes like `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$` which check for a sha1 or sha256 hash. This may reduce false positive results where command output is validated with grouped or optional alphanumeric patterns before being used.
## 0.4.36 ## 0.4.36

View File

@@ -2,4 +2,4 @@
### Minor Analysis Improvements ### Minor Analysis Improvements
* The GitHub Actions analysis now recognizes more Bash regex checks that restrict a value to alphanumeric characters, including regexes like `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$` which check for a SHA-1 or SHA-256 hash. This may reduce false positive results where command output is validated with grouped or optional alphanumeric patterns before being used. * The GitHub Actions analysis now recognizes more Bash regex checks that restrict a value to alphanumeric characters, include regexes like `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$` which check for a sha1 or sha256 hash. This may reduce false positive results where command output is validated with grouped or optional alphanumeric patterns before being used.

View File

@@ -1,5 +1,5 @@
name: codeql/actions-all name: codeql/actions-all
version: 0.4.37 version: 0.4.38-dev
library: true library: true
warnOnImplicitThis: true warnOnImplicitThis: true
dependencies: dependencies:

View File

@@ -15,7 +15,7 @@
### Bug Fixes ### Bug Fixes
* Adjusted (minor) help file descriptions for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`, `actions/untrusted-checkout/medium`. Clarified wording on a minor point, added one more listed resource and added one more recommendation for things to check. * Adjusted (minor) help file descriptions for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`, `actions/untrusted-checkout/medium`. Clarified wording on in minor point, added one more listed resource and added one more recommendation for things to check.
## 0.6.28 ## 0.6.28

View File

@@ -15,4 +15,4 @@
### Bug Fixes ### Bug Fixes
* Adjusted (minor) help file descriptions for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`, `actions/untrusted-checkout/medium`. Clarified wording on a minor point, added one more listed resource and added one more recommendation for things to check. * Adjusted (minor) help file descriptions for queries: `actions/untrusted-checkout/critical`, `actions/untrusted-checkout/high`, `actions/untrusted-checkout/medium`. Clarified wording on in minor point, added one more listed resource and added one more recommendation for things to check.

View File

@@ -1,5 +1,5 @@
name: codeql/actions-queries name: codeql/actions-queries
version: 0.6.29 version: 0.6.30-dev
library: false library: false
warnOnImplicitThis: true warnOnImplicitThis: true
groups: [actions, queries] groups: [actions, queries]

View File

@@ -11,10 +11,6 @@
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SignAnalysisCommon.qll", "java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SignAnalysisCommon.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisCommon.qll" "csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisCommon.qll"
], ],
"Bound Java/C#": [
"java/ql/lib/semmle/code/java/dataflow/Bound.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/Bound.qll"
],
"ModulusAnalysis Java/C#": [ "ModulusAnalysis Java/C#": [
"java/ql/lib/semmle/code/java/dataflow/ModulusAnalysis.qll", "java/ql/lib/semmle/code/java/dataflow/ModulusAnalysis.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/ModulusAnalysis.qll" "csharp/ql/lib/semmle/code/csharp/dataflow/ModulusAnalysis.qll"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Fix NameQualifier inconsistency
compatibility: full

View File

@@ -30,8 +30,6 @@ class Options extends string {
predicate overrideReturnsNull(Call call) { predicate overrideReturnsNull(Call call) {
// Used in CVS: // Used in CVS:
call.(FunctionCall).getTarget().hasGlobalName("Xstrdup") call.(FunctionCall).getTarget().hasGlobalName("Xstrdup")
or
CustomOptions::overrideReturnsNull(call) // old Options.qll
} }
/** /**
@@ -45,8 +43,6 @@ class Options extends string {
// Used in CVS: // Used in CVS:
call.(FunctionCall).getTarget().hasGlobalName("Xstrdup") and call.(FunctionCall).getTarget().hasGlobalName("Xstrdup") and
nullValue(call.getArgument(0)) nullValue(call.getArgument(0))
or
CustomOptions::returnsNull(call) // old Options.qll
} }
/** /**
@@ -65,8 +61,6 @@ class Options extends string {
f.hasGlobalOrStdName([ f.hasGlobalOrStdName([
"exit", "_exit", "_Exit", "abort", "__assert_fail", "longjmp", "__builtin_unreachable" "exit", "_exit", "_Exit", "abort", "__assert_fail", "longjmp", "__builtin_unreachable"
]) ])
or
CustomOptions::exits(f) // old Options.qll
} }
/** /**
@@ -79,8 +73,7 @@ class Options extends string {
* runtime, the program's behavior is undefined) * runtime, the program's behavior is undefined)
*/ */
predicate exprExits(Expr e) { predicate exprExits(Expr e) {
e.(AssumeExpr).getChild(0).(CompileTimeConstantInt).getIntValue() = 0 or e.(AssumeExpr).getChild(0).(CompileTimeConstantInt).getIntValue() = 0
CustomOptions::exprExits(e) // old Options.qll
} }
/** /**
@@ -88,10 +81,7 @@ class Options extends string {
* *
* By default holds only for `fgets`. * By default holds only for `fgets`.
*/ */
predicate alwaysCheckReturnValue(Function f) { predicate alwaysCheckReturnValue(Function f) { f.hasGlobalOrStdName("fgets") }
f.hasGlobalOrStdName("fgets") or
CustomOptions::alwaysCheckReturnValue(f) // old Options.qll
}
/** /**
* Holds if it is reasonable to ignore the return value of function * Holds if it is reasonable to ignore the return value of function
@@ -107,8 +97,6 @@ class Options extends string {
// common way of sleeping using select: // common way of sleeping using select:
fc.getTarget().hasGlobalName("select") and fc.getTarget().hasGlobalName("select") and
fc.getArgument(0).getValue() = "0" fc.getArgument(0).getValue() = "0"
or
CustomOptions::okToIgnoreReturnValue(fc) // old Options.qll
} }
} }

View File

@@ -98,57 +98,3 @@ class CustomMutexType extends MutexType {
*/ */
override predicate unlockAccess(FunctionCall fc, Expr arg) { none() } override predicate unlockAccess(FunctionCall fc, Expr arg) { none() }
} }
/**
* DEPRECATED: customize `CustomOptions.overrideReturnsNull` instead.
*
* This predicate is required to support backwards compatibility for
* older `Options.qll` files. It should not be removed or modified by
* end users.
*/
predicate overrideReturnsNull(Call call) { none() }
/**
* DEPRECATED: customize `CustomOptions.returnsNull` instead.
*
* This predicate is required to support backwards compatibility for
* older `Options.qll` files. It should not be removed or modified by
* end users.
*/
predicate returnsNull(Call call) { none() }
/**
* DEPRECATED: customize `CustomOptions.exits` instead.
*
* This predicate is required to support backwards compatibility for
* older `Options.qll` files. It should not be removed or modified by
* end users.
*/
predicate exits(Function f) { none() }
/**
* DEPRECATED: customize `CustomOptions.exprExits` instead.
*
* This predicate is required to support backwards compatibility for
* older `Options.qll` files. It should not be removed or modified by
* end users.
*/
predicate exprExits(Expr e) { none() }
/**
* DEPRECATED: customize `CustomOptions.alwaysCheckReturnValue` instead.
*
* This predicate is required to support backwards compatibility for
* older `Options.qll` files. It should not be removed or modified by
* end users.
*/
predicate alwaysCheckReturnValue(Function f) { none() }
/**
* DEPRECATED: customize `CustomOptions.okToIgnoreReturnValue` instead.
*
* This predicate is required to support backwards compatibility for
* older `Options.qll` files. It should not be removed or modified by
* end users.
*/
predicate okToIgnoreReturnValue(FunctionCall fc) { none() }

View File

@@ -0,0 +1,15 @@
---
category: breaking
---
* Removed the deprecated `overrideReturnsNull` predicate from `Options.qll`. Use `CustomOptions.overrideReturnsNull` instead.
* Removed the deprecated `returnsNull` predicate from `Options.qll`. Use `CustomOptions.returnsNull` instead.
* Removed the deprecated `exits` predicate from `Options.qll`. Use `CustomOptions.exits` instead.
* Removed the deprecated `exprExits` predicate from `Options.qll`. Use `CustomOptions.exprExits` instead.
* Removed the deprecated `alwaysCheckReturnValue` predicate from `Options.qll`. Use `CustomOptions.alwaysCheckReturnValue` instead.
* Removed the deprecated `okToIgnoreReturnValue` predicate from `Options.qll`. Use `CustomOptions.okToIgnoreReturnValue` instead.
* Removed the deprecated `semmle.code.cpp.Member`. Import `semmle.code.cpp.Element` and/or `semmle.code.cpp.Type` directly.
* Removed the deprecated `UnknownDefaultLocation` class. Use `UnknownLocation` instead.
* Removed the deprecated `UnknownExprLocation` class. Use `UnknownLocation` instead.
* Removed the deprecated `UnknownStmtLocation` class. Use `UnknownLocation` instead.
* Removed the deprecated `TemplateParameter` class. Use `TypeTemplateParameter` instead.
* Support for class resolution across link targets has been removed for databases which were created with CodeQL versions before 1.23.0.

View File

@@ -32,7 +32,6 @@ import semmle.code.cpp.Class
import semmle.code.cpp.Struct import semmle.code.cpp.Struct
import semmle.code.cpp.Union import semmle.code.cpp.Union
import semmle.code.cpp.Enum import semmle.code.cpp.Enum
import semmle.code.cpp.Member
import semmle.code.cpp.Field import semmle.code.cpp.Field
import semmle.code.cpp.Function import semmle.code.cpp.Function
import semmle.code.cpp.MemberFunction import semmle.code.cpp.MemberFunction

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-all name: codeql/cpp-all
version: 10.2.0 version: 10.2.1-dev
groups: cpp groups: cpp
dbscheme: semmlecode.cpp.dbscheme dbscheme: semmlecode.cpp.dbscheme
extractor: cpp extractor: cpp

View File

@@ -148,28 +148,3 @@ class UnknownLocation extends Location {
this.getFile().getAbsolutePath() = "" and locations_default(this, _, 0, 0, 0, 0) this.getFile().getAbsolutePath() = "" and locations_default(this, _, 0, 0, 0, 0)
} }
} }
/**
* A dummy location which is used when something doesn't have a location in
* the source code but needs to have a `Location` associated with it.
*
* DEPRECATED: use `UnknownLocation`
*/
deprecated class UnknownDefaultLocation extends UnknownLocation { }
/**
* A dummy location which is used when an expression doesn't have a
* location in the source code but needs to have a `Location` associated
* with it.
*
* DEPRECATED: use `UnknownLocation`
*/
deprecated class UnknownExprLocation extends UnknownLocation { }
/**
* A dummy location which is used when a statement doesn't have a location
* in the source code but needs to have a `Location` associated with it.
*
* DEPRECATED: use `UnknownLocation`
*/
deprecated class UnknownStmtLocation extends UnknownLocation { }

View File

@@ -1,6 +0,0 @@
/**
* DEPRECATED: import `semmle.code.cpp.Element` and/or `semmle.code.cpp.Type` directly as required.
*/
import semmle.code.cpp.Element
import semmle.code.cpp.Type

View File

@@ -35,13 +35,6 @@ class NonTypeTemplateParameter extends Literal, TemplateParameterImpl {
override string getAPrimaryQlClass() { result = "NonTypeTemplateParameter" } override string getAPrimaryQlClass() { result = "NonTypeTemplateParameter" }
} }
/**
* A C++ `typename` (or `class`) template parameter.
*
* DEPRECATED: Use `TypeTemplateParameter` instead.
*/
deprecated class TemplateParameter = TypeTemplateParameter;
/** /**
* A C++ `typename` (or `class`) template parameter. * A C++ `typename` (or `class`) template parameter.
* *

View File

@@ -1071,7 +1071,7 @@ class NullPointerType extends BuiltInType {
* const float fa[40]; * const float fa[40];
* ``` * ```
*/ */
class DerivedType extends Type, @derivedtype { class DerivedType extends Type, NameQualifyingElement, @derivedtype {
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
override string getName() { derivedtypes(underlyingElement(this), result, _, _) } override string getName() { derivedtypes(underlyingElement(this), result, _, _) }

View File

@@ -276,6 +276,45 @@ private predicate isClassConstructedFrom(Class c, Class templateClass) {
not c.isConstructedFrom(_) and c = templateClass not c.isConstructedFrom(_) and c = templateClass
} }
/** Gets the fully templated version of `c`. */
private Class getFullyTemplatedClassOld(Class c) {
not c.isFromUninstantiatedTemplate(_) and
isClassConstructedFrom(c, result)
}
private TemplateClass getOriginalClassTemplate(TemplateClass tc) {
result = tc.getOriginalTemplate()
or
not exists(tc.getOriginalTemplate()) and
result = tc
}
/** Gets the fully templated version of `c`. */
private Class getFullyTemplatedClassNew(Class c) {
not c.isFromUninstantiatedTemplate(_) and
exists(Class mid |
c.isConstructedFrom(mid)
or
not c.isConstructedFrom(_) and c = mid
|
result = getOriginalClassTemplate(mid)
or
not mid instanceof TemplateClass and mid = result
)
}
/** Gets the fully templated version of `c`. */
private Class getFullyTemplatedClass(Class c) {
// The `Class::getOriginalTemplate` predicate was introduced in CodeQL
// version 2.25.6 and the upgrade script leaves the
// `class_template_generated_from` extensionals empty if the database
// was generated with an older extractor. So we use the old implementation
// if the `class_template_generated_from` extensional is empty.
if class_template_generated_from(_, _)
then result = getFullyTemplatedClassNew(c)
else result = getFullyTemplatedClassOld(c)
}
/** /**
* Holds if `f` is an instantiation of a function template `templateFunc`, or * Holds if `f` is an instantiation of a function template `templateFunc`, or
* holds with `f = templateFunc` if `f` is not an instantiation of any function * holds with `f = templateFunc` if `f` is not an instantiation of any function
@@ -292,7 +331,7 @@ private predicate isFunctionConstructedFrom(Function f, Function templateFunc) {
} }
/** Gets the fully templated version of `f`. */ /** Gets the fully templated version of `f`. */
Function getFullyTemplatedFunction(Function f) { private Function getFullyTemplatedFunctionOld(Function f) {
not f.isFromUninstantiatedTemplate(_) and not f.isFromUninstantiatedTemplate(_) and
( (
exists(Class c, Class templateClass, int i | exists(Class c, Class templateClass, int i |
@@ -306,13 +345,46 @@ Function getFullyTemplatedFunction(Function f) {
) )
} }
private TemplateFunction getOriginalFunctionTemplate(TemplateFunction tf) {
result = tf.getOriginalTemplate()
or
not exists(tf.getOriginalTemplate()) and
result = tf
}
/** Gets the fully templated version of `f`. */
private Function getFullyTemplatedFunctionNew(Function f) {
not f.isFromUninstantiatedTemplate(_) and
exists(Function mid |
f.isConstructedFrom(mid)
or
not f.isConstructedFrom(_) and f = mid
|
result = getOriginalFunctionTemplate(mid)
or
not mid instanceof TemplateFunction and mid = result
)
}
/** Gets the fully templated version of `f`. */
Function getFullyTemplatedFunction(Function f) {
// The `Function::getOriginalTemplate` predicate was introduced in CodeQL
// version 2.25.6 and the upgrade script leaves the
// `function_template_generated_from` extensionals empty if the database
// was generated with an older extractor. So we use the old implementation
// if the `function_template_generated_from` extensional is empty.
if function_template_generated_from(_, _)
then result = getFullyTemplatedFunctionNew(f)
else result = getFullyTemplatedFunctionOld(f)
}
/** Prefixes `const` to `s` if `t` is const, or returns `s` otherwise. */ /** Prefixes `const` to `s` if `t` is const, or returns `s` otherwise. */
bindingset[s, t] bindingset[s, t]
private string withConst(string s, Type t) { private string withConst(string s, Type t) {
if t.isConst() then result = "const " + s else result = s if t.isConst() then result = "const " + s else result = s
} }
/** Prefixes `volatile` to `s` if `t` is const, or returns `s` otherwise. */ /** Prefixes `volatile` to `s` if `t` is volatile, or returns `s` otherwise. */
bindingset[s, t] bindingset[s, t]
private string withVolatile(string s, Type t) { private string withVolatile(string s, Type t) {
if t.isVolatile() then result = "volatile " + s else result = s if t.isVolatile() then result = "volatile " + s else result = s
@@ -490,7 +562,7 @@ pragma[nomagic]
private string getTypeNameWithoutClassTemplates(Function f, int n, int remaining) { private string getTypeNameWithoutClassTemplates(Function f, int n, int remaining) {
// If there is a declaring type then we start by expanding the function templates // If there is a declaring type then we start by expanding the function templates
exists(Class template | exists(Class template |
isClassConstructedFrom(f.getDeclaringType(), template) and template = getFullyTemplatedClass(f.getDeclaringType()) and
remaining = getNumberOfSupportedClassTemplateArguments(template) and remaining = getNumberOfSupportedClassTemplateArguments(template) and
result = getTypeNameWithoutFunctionTemplates(f, n, 0) result = getTypeNameWithoutFunctionTemplates(f, n, 0)
) )
@@ -502,7 +574,7 @@ private string getTypeNameWithoutClassTemplates(Function f, int n, int remaining
or or
exists(string mid, TypeTemplateParameter tp, Class template | exists(string mid, TypeTemplateParameter tp, Class template |
mid = getTypeNameWithoutClassTemplates(f, n, remaining + 1) and mid = getTypeNameWithoutClassTemplates(f, n, remaining + 1) and
isClassConstructedFrom(f.getDeclaringType(), template) and template = getFullyTemplatedClass(f.getDeclaringType()) and
tp = getSupportedClassTemplateArgument(template, remaining) tp = getSupportedClassTemplateArgument(template, remaining)
| |
result = mid.replaceAll(tp.getName(), "class:" + remaining.toString()) result = mid.replaceAll(tp.getName(), "class:" + remaining.toString())

View File

@@ -1,59 +1,5 @@
import semmle.code.cpp.Type import semmle.code.cpp.Type
/** For upgraded databases without mangled name info. */
pragma[noinline]
private string getTopLevelClassName(@usertype c) {
not mangled_name(_, _, _) and
isClass(c) and
usertypes(c, result, _) and
not namespacembrs(_, c) and // not in a namespace
not member(_, _, c) and // not in some structure
not class_instantiation(c, _) // not a template instantiation
}
/**
* For upgraded databases without mangled name info.
* Holds if `d` is a unique complete class named `name`.
*/
pragma[noinline]
private predicate existsCompleteWithName(string name, @usertype d) {
not mangled_name(_, _, _) and
is_complete(d) and
name = getTopLevelClassName(d) and
onlyOneCompleteClassExistsWithName(name)
}
/** For upgraded databases without mangled name info. */
pragma[noinline]
private predicate onlyOneCompleteClassExistsWithName(string name) {
not mangled_name(_, _, _) and
strictcount(@usertype c | is_complete(c) and getTopLevelClassName(c) = name) = 1
}
/**
* For upgraded databases without mangled name info.
* Holds if `c` is an incomplete class named `name`.
*/
pragma[noinline]
private predicate existsIncompleteWithName(string name, @usertype c) {
not mangled_name(_, _, _) and
not is_complete(c) and
name = getTopLevelClassName(c)
}
/**
* For upgraded databases without mangled name info.
* Holds if `c` is an incomplete class, and there exists a unique complete class `d`
* with the same name.
*/
private predicate oldHasCompleteTwin(@usertype c, @usertype d) {
not mangled_name(_, _, _) and
exists(string name |
existsIncompleteWithName(name, c) and
existsCompleteWithName(name, d)
)
}
pragma[noinline] pragma[noinline]
private @mangledname getClassMangledName(@usertype c) { private @mangledname getClassMangledName(@usertype c) {
isClass(c) and isClass(c) and
@@ -103,10 +49,7 @@ private module Cached {
@usertype resolveClass(@usertype c) { @usertype resolveClass(@usertype c) {
hasCompleteTwin(c, result) hasCompleteTwin(c, result)
or or
oldHasCompleteTwin(c, result)
or
not hasCompleteTwin(c, _) and not hasCompleteTwin(c, _) and
not oldHasCompleteTwin(c, _) and
result = c result = c
} }

View File

@@ -1430,7 +1430,8 @@ specialnamequalifyingelements(
@namequalifyingelement = @namespace @namequalifyingelement = @namespace
| @specialnamequalifyingelement | @specialnamequalifyingelement
| @usertype | @usertype
| @decltype; | @decltype
| @derivedtype;
namequalifiers( namequalifiers(
unique int id: @namequalifier, unique int id: @namequalifier,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Fix NameQualifier inconsistency
compatibility: full

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-queries name: codeql/cpp-queries
version: 1.6.4 version: 1.6.5-dev
groups: groups:
- cpp - cpp
- queries - queries

View File

@@ -1 +1,2 @@
jsf/4.13 Functions/AV Rule 107.ql query: jsf/4.13 Functions/AV Rule 107.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1 +1,2 @@
Best Practices/Hiding/LocalVariableHidesGlobalVariable.ql query: Best Practices/Hiding/LocalVariableHidesGlobalVariable.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -48,7 +48,7 @@ void test1()
void test2() void test2()
{ {
Lock<Mutex> myLock(); // BAD (interpreted as a function declaration, this does nothing) Lock<Mutex> myLock(); // BAD (interpreted as a function declaration, this does nothing) // $ Alert[cpp/function-in-block]
// ... // ...
} }
@@ -62,14 +62,14 @@ void test3()
void test4() void test4()
{ {
Lock<Mutex>(myMutex); // BAD (creates an uninitialized variable called `myMutex`, probably not intended) Lock<Mutex>(myMutex); // BAD (creates an uninitialized variable called `myMutex`, probably not intended) // $ Alert[cpp/local-variable-hides-global-variable]
// ... // ...
} }
void test5() void test5()
{ {
Lock<Mutex> myLock(Mutex); // BAD (interpreted as a function declaration, this does nothing) Lock<Mutex> myLock(Mutex); // BAD (interpreted as a function declaration, this does nothing) // $ Alert[cpp/function-in-block]
// ... // ...
} }

View File

@@ -1 +1 @@
semmle/code/cpp/PrintAST.ql query: semmle/code/cpp/PrintAST.ql

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-020/NoCheckBeforeUnsafePutUser.ql query: experimental/Security/CWE/CWE-020/NoCheckBeforeUnsafePutUser.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-020/LateCheckOfFunctionArgument.ql query: experimental/Security/CWE/CWE-020/LateCheckOfFunctionArgument.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -3,6 +3,6 @@ void workFunction_0(char *s) {
char buf[80], buf1[8]; char buf[80], buf1[8];
if(len<0) return; if(len<0) return;
memset(buf,0,len); //GOOD memset(buf,0,len); //GOOD
memset(buf1,0,len1); //BAD memset(buf1,0,len1); //BAD // $ Alert
if(len1<0) return; if(len1<0) return;
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-078/WordexpTainted.ql query: experimental/Security/CWE/CWE-078/WordexpTainted.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -19,14 +19,14 @@ enum {
int wordexp(const char *restrict s, wordexp_t *restrict p, int flags); int wordexp(const char *restrict s, wordexp_t *restrict p, int flags);
int main(int argc, char** argv) { int main(int argc, char** argv) { // $ Source
char *filePath = argv[2]; char *filePath = argv[2];
{ {
// BAD: the user string is injected directly into `wordexp` which performs command substitution // BAD: the user string is injected directly into `wordexp` which performs command substitution
wordexp_t we; wordexp_t we;
wordexp(filePath, &we, 0); wordexp(filePath, &we, 0); // $ Alert
} }
{ {

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-1041/FindWrapperFunctions.ql query: experimental/Security/CWE/CWE-1041/FindWrapperFunctions.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -20,7 +20,7 @@ void myFclose(FILE * fmy)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
fe = fopen("myFile.txt", "wt"); fe = fopen("myFile.txt", "wt");
fclose(fe); // BAD fclose(fe); // BAD // $ Alert
fe = fopen("myFile.txt", "wt"); fe = fopen("myFile.txt", "wt");
myFclose(fe); // GOOD myFclose(fe); // GOOD
return 0; return 0;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-1126/DeclarationOfVariableWithUnnecessarilyWideScope.ql query: experimental/Security/CWE/CWE-1126/DeclarationOfVariableWithUnnecessarilyWideScope.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -11,7 +11,7 @@ void workFunction_0(char *s) {
while(intIndex > 2) while(intIndex > 2)
{ {
buf[intIndex] = 1; buf[intIndex] = 1;
int intIndex; // BAD int intIndex; // BAD // $ Alert
intIndex--; intIndex--;
} }
intIndex = 10; intIndex = 10;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-1240/CustomCryptographicPrimitive.ql query: experimental/Security/CWE/CWE-1240/CustomCryptographicPrimitive.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -8,7 +8,7 @@ int strlen(const char *string);
// the following function is homebrew crypto written for this test. This is a bad algorithm // the following function is homebrew crypto written for this test. This is a bad algorithm
// on multiple levels and should never be used in cryptography. // on multiple levels and should never be used in cryptography.
void encryptString(char *string, unsigned int key) { void encryptString(char *string, unsigned int key) { // $ Alert
char *ptr = string; char *ptr = string;
int len = strlen(string); int len = strlen(string);
@@ -27,7 +27,7 @@ void encryptString(char *string, unsigned int key) {
// the following function is homebrew crypto written for this test. This is a bad algorithm // the following function is homebrew crypto written for this test. This is a bad algorithm
// on multiple levels and should never be used in cryptography. // on multiple levels and should never be used in cryptography.
void MyEncrypt(const unsigned int *dataIn, unsigned int *dataOut, unsigned int dataSize, unsigned int key[2]) { void MyEncrypt(const unsigned int *dataIn, unsigned int *dataOut, unsigned int dataSize, unsigned int key[2]) { // $ Alert
unsigned int state[2]; unsigned int state[2];
unsigned int t; unsigned int t;
@@ -48,7 +48,7 @@ void MyEncrypt(const unsigned int *dataIn, unsigned int *dataOut, unsigned int d
// the following function resembles an implementation of the AES "mix columns" // the following function resembles an implementation of the AES "mix columns"
// step. It is not accurate, efficient or safe and should never be used in // step. It is not accurate, efficient or safe and should never be used in
// cryptography. // cryptography.
void mix_columns(const uint8_t inputs[4], uint8_t outputs[4]) { void mix_columns(const uint8_t inputs[4], uint8_t outputs[4]) { // $ Alert
// The "mix columns" step takes four bytes as inputs. Each byte represents a // The "mix columns" step takes four bytes as inputs. Each byte represents a
// polynomial with 8 one-bit coefficients, e.g. input bits 00001101 // polynomial with 8 one-bit coefficients, e.g. input bits 00001101
// represent the polynomial x^3 + x^2 + 1. Arithmetic is reduced modulo // represent the polynomial x^3 + x^2 + 1. Arithmetic is reduced modulo
@@ -80,7 +80,7 @@ void mix_columns(const uint8_t inputs[4], uint8_t outputs[4]) {
// the following function resembles initialization of an S-box as may be done // the following function resembles initialization of an S-box as may be done
// in an implementation of DES, AES and other encryption algorithms. It is not // in an implementation of DES, AES and other encryption algorithms. It is not
// accurate, efficient or safe and should never be used in cryptography. // accurate, efficient or safe and should never be used in cryptography.
void init_aes_sbox(unsigned char data[256]) { void init_aes_sbox(unsigned char data[256]) { // $ Alert
// initialize `data` in a loop using lots of ^, ^= and << operations and // initialize `data` in a loop using lots of ^, ^= and << operations and
// a few fixed constants. // a few fixed constants.
unsigned int state = 0x12345678; unsigned int state = 0x12345678;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-125/DangerousWorksWithMultibyteOrWideCharacters.ql query: experimental/Security/CWE/CWE-125/DangerousWorksWithMultibyteOrWideCharacters.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -63,7 +63,7 @@ static void badTest1(const char* ptr)
int ret; int ret;
int len; int len;
len = strlen(ptr); len = strlen(ptr);
for (wchar_t wc; (ret = mbtowc(&wc, ptr, 4)) > 0; len-=ret) { // BAD:we can get unpredictable results for (wchar_t wc; (ret = mbtowc(&wc, ptr, 4)) > 0; len-=ret) { // BAD:we can get unpredictable results // $ Alert
wprintf(L"%lc", wc); wprintf(L"%lc", wc);
ptr += ret; ptr += ret;
} }
@@ -73,7 +73,7 @@ static void badTest2(const char* ptr)
int ret; int ret;
int len; int len;
len = strlen(ptr); len = strlen(ptr);
for (wchar_t wc; (ret = mbtowc(&wc, ptr, sizeof(wchar_t))) > 0; len-=ret) { // BAD:we can get unpredictable results for (wchar_t wc; (ret = mbtowc(&wc, ptr, sizeof(wchar_t))) > 0; len-=ret) { // BAD:we can get unpredictable results // $ Alert
wprintf(L"%lc", wc); wprintf(L"%lc", wc);
ptr += ret; ptr += ret;
} }
@@ -103,7 +103,7 @@ static void badTest3(const char* ptr,int wc_len)
len = wc_len; len = wc_len;
wchar_t *wc = new wchar_t[wc_len]; wchar_t *wc = new wchar_t[wc_len];
while (*ptr && len > 0) { while (*ptr && len > 0) {
ret = mbtowc(wc, ptr, MB_CUR_MAX); // BAD ret = mbtowc(wc, ptr, MB_CUR_MAX); // BAD // $ Alert
if (ret <0) if (ret <0)
break; break;
if (ret == 0 || ret > len) if (ret == 0 || ret > len)
@@ -120,7 +120,7 @@ static void badTest4(const char* ptr,int wc_len)
len = wc_len; len = wc_len;
wchar_t *wc = new wchar_t[wc_len]; wchar_t *wc = new wchar_t[wc_len];
while (*ptr && len > 0) { while (*ptr && len > 0) {
ret = mbtowc(wc, ptr, 16); // BAD ret = mbtowc(wc, ptr, 16); // BAD // $ Alert
if (ret <0) if (ret <0)
break; break;
if (ret == 0 || ret > len) if (ret == 0 || ret > len)
@@ -137,7 +137,7 @@ static void badTest5(const char* ptr,int wc_len)
len = wc_len; len = wc_len;
wchar_t *wc = new wchar_t[wc_len]; wchar_t *wc = new wchar_t[wc_len];
while (*ptr && len > 0) { while (*ptr && len > 0) {
ret = mbtowc(wc, ptr, sizeof(wchar_t)); // BAD ret = mbtowc(wc, ptr, sizeof(wchar_t)); // BAD // $ Alert
if (ret <0) if (ret <0)
break; break;
if (ret == 0 || ret > len) if (ret == 0 || ret > len)
@@ -155,7 +155,7 @@ static void badTest6(const char* ptr,int wc_len)
len = wc_len; len = wc_len;
wchar_t *wc = new wchar_t[wc_len]; wchar_t *wc = new wchar_t[wc_len];
while (*ptr && wc_len > 0) { while (*ptr && wc_len > 0) {
ret = mbtowc(wc, ptr, wc_len); // BAD ret = mbtowc(wc, ptr, wc_len); // BAD // $ Alert
if (ret <0) if (ret <0)
if (checkErrors()) { if (checkErrors()) {
++ptr; ++ptr;
@@ -178,7 +178,7 @@ static void badTest7(const char* ptr,int wc_len)
len = wc_len; len = wc_len;
wchar_t *wc = new wchar_t[wc_len]; wchar_t *wc = new wchar_t[wc_len];
while (*ptr && wc_len > 0) { while (*ptr && wc_len > 0) {
ret = mbtowc(wc, ptr, len); // BAD ret = mbtowc(wc, ptr, len); // BAD // $ Alert
if (ret <0) if (ret <0)
break; break;
if (ret == 0 || ret > len) if (ret == 0 || ret > len)
@@ -194,7 +194,7 @@ static void badTest8(const char* ptr,wchar_t *wc)
int len; int len;
len = strlen(ptr); len = strlen(ptr);
while (*ptr && len > 0) { while (*ptr && len > 0) {
ret = mbtowc(wc, ptr, len); // BAD ret = mbtowc(wc, ptr, len); // BAD // $ Alert
if (ret <0) if (ret <0)
break; break;
if (ret == 0 || ret > len) if (ret == 0 || ret > len)

View File

@@ -25,8 +25,8 @@ void* calloc (size_t num, size_t size);
void* malloc (size_t size); void* malloc (size_t size);
static void badTest1(void *src, int size) { static void badTest1(void *src, int size) {
WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, (LPSTR)src, size, 0, 0); // BAD WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, (LPSTR)src, size, 0, 0); // BAD // $ Alert
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, (LPCWSTR)src, 30); // BAD MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, (LPCWSTR)src, 30); // BAD // $ Alert
} }
void goodTest2(){ void goodTest2(){
wchar_t src[] = L"0123456789ABCDEF"; wchar_t src[] = L"0123456789ABCDEF";
@@ -42,7 +42,7 @@ void goodTest2(){
static void badTest2(){ static void badTest2(){
wchar_t src[] = L"0123456789ABCDEF"; wchar_t src[] = L"0123456789ABCDEF";
char dst[16]; char dst[16];
WideCharToMultiByte(CP_UTF8, 0, src, -1, dst, 16, NULL, NULL); // BAD WideCharToMultiByte(CP_UTF8, 0, src, -1, dst, 16, NULL, NULL); // BAD // $ Alert
printf("%s\n", dst); printf("%s\n", dst);
} }
static void goodTest3(){ static void goodTest3(){
@@ -55,7 +55,7 @@ static void badTest3(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
int size = MultiByteToWideChar(CP_UTF8, 0, src,sizeof(src),NULL,0); int size = MultiByteToWideChar(CP_UTF8, 0, src,sizeof(src),NULL,0);
wchar_t * dst = (wchar_t*)calloc(size + 1, 1); wchar_t * dst = (wchar_t*)calloc(size + 1, 1);
MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, size+1); // BAD MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, size+1); // BAD // $ Alert
} }
static void goodTest4(){ static void goodTest4(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
@@ -67,13 +67,13 @@ static void badTest4(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
int size = MultiByteToWideChar(CP_UTF8, 0, src,sizeof(src),NULL,0); int size = MultiByteToWideChar(CP_UTF8, 0, src,sizeof(src),NULL,0);
wchar_t * dst = (wchar_t*)malloc(size + 1); wchar_t * dst = (wchar_t*)malloc(size + 1);
MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, size+1); // BAD MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, size+1); // BAD // $ Alert
} }
static int goodTest5(void *src){ static int goodTest5(void *src){
return WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, 0, 0, 0, 0); // GOOD return WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, 0, 0, 0, 0); // GOOD
} }
static int badTest5 (void *src) { static int badTest5 (void *src) {
return WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, 0, 3, 0, 0); // BAD return WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)src, -1, 0, 3, 0, 0); // BAD // $ Alert
} }
static void goodTest6(WCHAR *src) static void goodTest6(WCHAR *src)
{ {
@@ -90,6 +90,6 @@ static void goodTest6(WCHAR *src)
static void badTest6(WCHAR *src) static void badTest6(WCHAR *src)
{ {
char dst[5] =""; char dst[5] ="";
WideCharToMultiByte(CP_ACP, 0, src, -1, dst, 260, 0, 0); // BAD WideCharToMultiByte(CP_ACP, 0, src, -1, dst, 260, 0, 0); // BAD // $ Alert
printf("%s\n", dst); printf("%s\n", dst);
} }

View File

@@ -12,11 +12,11 @@ size_t mbsrtowcs(wchar_t *wcstr,const char *mbstr,size_t count, mbstate_t *mbsta
static void badTest1(void *src, int size) { static void badTest1(void *src, int size) {
mbstowcs((wchar_t*)src,(char*)src,size); // BAD mbstowcs((wchar_t*)src,(char*)src,size); // BAD // $ Alert
_locale_t locale; _locale_t locale;
_mbstowcs_l((wchar_t*)src,(char*)src,size,locale); // BAD _mbstowcs_l((wchar_t*)src,(char*)src,size,locale); // BAD // $ Alert
mbstate_t *mbstate; mbstate_t *mbstate;
mbsrtowcs((wchar_t*)src,(char*)src,size,mbstate); // BAD mbsrtowcs((wchar_t*)src,(char*)src,size,mbstate); // BAD // $ Alert
} }
static void goodTest2(){ static void goodTest2(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
@@ -32,7 +32,7 @@ static void goodTest2(){
static void badTest2(){ static void badTest2(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
wchar_t dst[16]; wchar_t dst[16];
mbstowcs(dst, src,16); // BAD mbstowcs(dst, src,16); // BAD // $ Alert
printf("%s\n", dst); printf("%s\n", dst);
} }
static void goodTest3(){ static void goodTest3(){
@@ -45,7 +45,7 @@ static void badTest3(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
int size = mbstowcs(NULL, src,NULL); int size = mbstowcs(NULL, src,NULL);
wchar_t * dst = (wchar_t*)calloc(size + 1, 1); wchar_t * dst = (wchar_t*)calloc(size + 1, 1);
mbstowcs(dst, src,size+1); // BAD mbstowcs(dst, src,size+1); // BAD // $ Alert
} }
static void goodTest4(){ static void goodTest4(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
@@ -57,13 +57,13 @@ static void badTest4(){
char src[] = "0123456789ABCDEF"; char src[] = "0123456789ABCDEF";
int size = mbstowcs(NULL, src,NULL); int size = mbstowcs(NULL, src,NULL);
wchar_t * dst = (wchar_t*)malloc(size + 1); wchar_t * dst = (wchar_t*)malloc(size + 1);
mbstowcs(dst, src,size+1); // BAD mbstowcs(dst, src,size+1); // BAD // $ Alert
} }
static int goodTest5(void *src){ static int goodTest5(void *src){
return mbstowcs(NULL, (char*)src,NULL); // GOOD return mbstowcs(NULL, (char*)src,NULL); // GOOD
} }
static int badTest5 (void *src) { static int badTest5 (void *src) {
return mbstowcs(NULL, (char*)src,3); // BAD return mbstowcs(NULL, (char*)src,3); // BAD // $ Alert
} }
static void goodTest6(void *src){ static void goodTest6(void *src){
wchar_t dst[5]; wchar_t dst[5];
@@ -77,6 +77,6 @@ static void goodTest6(void *src){
} }
static void badTest6(void *src){ static void badTest6(void *src){
wchar_t dst[5]; wchar_t dst[5];
mbstowcs(dst, (char*)src,260); // BAD mbstowcs(dst, (char*)src,260); // BAD // $ Alert
printf("%s\n", dst); printf("%s\n", dst);
} }

View File

@@ -13,7 +13,7 @@ static size_t badTest1(unsigned char *src){
int cb = 0; int cb = 0;
unsigned char dst[50]; unsigned char dst[50];
while( cb < sizeof(dst) ) while( cb < sizeof(dst) )
dst[cb++]=*src++; // BAD dst[cb++]=*src++; // BAD // $ Alert
return _mbclen(dst); return _mbclen(dst);
} }
static void goodTest2(unsigned char *src){ static void goodTest2(unsigned char *src){
@@ -33,7 +33,7 @@ static void badTest2(unsigned char *src){
unsigned char dst[50]; unsigned char dst[50];
while( cb < sizeof(dst) ) while( cb < sizeof(dst) )
{ {
_mbccpy(dst+cb,src); // BAD _mbccpy(dst+cb,src); // BAD // $ Alert
cb+=_mbclen(src); cb+=_mbclen(src);
src=_mbsinc(src); src=_mbsinc(src);
} }
@@ -44,5 +44,5 @@ static void goodTest3(){
} }
static void badTest3(){ static void badTest3(){
wchar_t name[50]; wchar_t name[50];
name[sizeof(name) - 1] = L'\0'; // BAD name[sizeof(name) - 1] = L'\0'; // BAD // $ Alert
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-190/AllocMultiplicationOverflow.ql query: experimental/Security/CWE/CWE-190/AllocMultiplicationOverflow.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -10,31 +10,31 @@ void test()
int y = getAnInt(); int y = getAnInt();
char *buffer1 = (char *)malloc(x + y); // GOOD char *buffer1 = (char *)malloc(x + y); // GOOD
char *buffer2 = (char *)malloc(x * y); // BAD char *buffer2 = (char *)malloc(x * y); // BAD // $ Alert
int *buffer3 = (int *)malloc(x * sizeof(int)); // GOOD int *buffer3 = (int *)malloc(x * sizeof(int)); // GOOD
int *buffer4 = (int *)malloc(x * y * sizeof(int)); // BAD int *buffer4 = (int *)malloc(x * y * sizeof(int)); // BAD // $ Alert
if ((x <= 1000) && (y <= 1000)) if ((x <= 1000) && (y <= 1000))
{ {
char *buffer5 = (char *)malloc(x * y); // GOOD [FALSE POSITIVE] char *buffer5 = (char *)malloc(x * y); // GOOD [FALSE POSITIVE] // $ Alert
} }
size_t size1 = x * y; size_t size1 = x * y; // $ Source
char *buffer5 = (char *)malloc(size1); // BAD char *buffer5 = (char *)malloc(size1); // BAD // $ Alert
size_t size2 = x; size_t size2 = x;
size2 *= y; size2 *= y;
char *buffer6 = (char *)malloc(size2); // BAD [NOT DETECTED] char *buffer6 = (char *)malloc(size2); // BAD [NOT DETECTED]
char *buffer7 = new char[x * 10]; // GOOD char *buffer7 = new char[x * 10]; // GOOD
char *buffer8 = new char[x * y]; // BAD char *buffer8 = new char[x * y]; // BAD // $ Alert
char *buffer9 = new char[x * x]; // BAD char *buffer9 = new char[x * x]; // BAD // $ Alert
} }
// --- custom allocators --- // --- custom allocators ---
void *MyMalloc1(size_t size) { return malloc(size); } // [additional detection here] void *MyMalloc1(size_t size) { return malloc(size); } // [additional detection here] // $ Alert
void *MyMalloc2(size_t size); void *MyMalloc2(size_t size);
void customAllocatorTests() void customAllocatorTests()
@@ -42,6 +42,6 @@ void customAllocatorTests()
int x = getAnInt(); int x = getAnInt();
int y = getAnInt(); int y = getAnInt();
char *buffer1 = (char *)MyMalloc1(x * y); // BAD char *buffer1 = (char *)MyMalloc1(x * y); // BAD // $ Alert Source
char *buffer2 = (char *)MyMalloc2(x * y); // BAD char *buffer2 = (char *)MyMalloc2(x * y); // BAD // $ Alert
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-190/DangerousUseOfTransformationAfterOperation.ql query: experimental/Security/CWE/CWE-190/DangerousUseOfTransformationAfterOperation.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -6,17 +6,17 @@ void functionWork(char aA[10],unsigned int aUI) {
int aI; int aI;
aI = (aUI*8)/10; // GOOD aI = (aUI*8)/10; // GOOD
aI = aUI*8; // BAD aI = aUI*8; // BAD // $ Alert
aP = aA+aI; aP = aA+aI;
aI = (int)aUI*8; // GOOD aI = (int)aUI*8; // GOOD
aL = (unsigned long)(aI*aI); // BAD aL = (unsigned long)(aI*aI); // BAD // $ Alert
aL = ((unsigned long)aI*aI); // GOOD aL = ((unsigned long)aI*aI); // GOOD
testCall((unsigned long)(aI*aI)); // BAD testCall((unsigned long)(aI*aI)); // BAD // $ Alert
testCall(((unsigned long)aI*aI)); // GOOD testCall(((unsigned long)aI*aI)); // GOOD
if((unsigned long)(aI*aI) > aL) // BAD if((unsigned long)(aI*aI) > aL) // BAD // $ Alert
return; return;
if(((unsigned long)aI*aI) > aL) // GOOD if(((unsigned long)aI*aI) > aL) // GOOD
return; return;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-190/IfStatementAdditionOverflow.ql query: experimental/Security/CWE/CWE-190/IfStatementAdditionOverflow.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -15,49 +15,49 @@ void test()
unsigned short b1 = getAnUnsignedShort(); unsigned short b1 = getAnUnsignedShort();
unsigned short c1 = getAnUnsignedShort(); unsigned short c1 = getAnUnsignedShort();
if (a+b>c) a = c-b; // BAD if (a+b>c) a = c-b; // BAD // $ Alert
if (a+b>c) { a = c-b; } // BAD if (a+b>c) { a = c-b; } // BAD // $ Alert
if (b+a>c) a = c-b; // BAD if (b+a>c) a = c-b; // BAD // $ Alert
if (b+a>c) { a = c-b; } // BAD if (b+a>c) { a = c-b; } // BAD // $ Alert
if (c>a+b) a = c-b; // BAD if (c>a+b) a = c-b; // BAD // $ Alert
if (c>a+b) { a = c-b; } // BAD if (c>a+b) { a = c-b; } // BAD // $ Alert
if (c>b+a) a = c-b; // BAD if (c>b+a) a = c-b; // BAD // $ Alert
if (c>b+a) { a = c-b; } // BAD if (c>b+a) { a = c-b; } // BAD // $ Alert
if (a+b>=c) a = c-b; // BAD if (a+b>=c) a = c-b; // BAD // $ Alert
if (a+b>=c) { a = c-b; } // BAD if (a+b>=c) { a = c-b; } // BAD // $ Alert
if (b+a>=c) a = c-b; // BAD if (b+a>=c) a = c-b; // BAD // $ Alert
if (b+a>=c) { a = c-b; } // BAD if (b+a>=c) { a = c-b; } // BAD // $ Alert
if (c>=a+b) a = c-b; // BAD if (c>=a+b) a = c-b; // BAD // $ Alert
if (c>=a+b) { a = c-b; } // BAD if (c>=a+b) { a = c-b; } // BAD // $ Alert
if (c>=b+a) a = c-b; // BAD if (c>=b+a) a = c-b; // BAD // $ Alert
if (c>=b+a) { a = c-b; } // BAD if (c>=b+a) { a = c-b; } // BAD // $ Alert
if (a+b<c) a = c-b; // BAD if (a+b<c) a = c-b; // BAD // $ Alert
if (a+b<c) { a = c-b; } // BAD if (a+b<c) { a = c-b; } // BAD // $ Alert
if (b+a<c) a = c-b; // BAD if (b+a<c) a = c-b; // BAD // $ Alert
if (b+a<c) { a = c-b; } // BAD if (b+a<c) { a = c-b; } // BAD // $ Alert
if (c<a+b) a = c-b; // BAD if (c<a+b) a = c-b; // BAD // $ Alert
if (c<a+b) { a = c-b; } // BAD if (c<a+b) { a = c-b; } // BAD // $ Alert
if (c<b+a) a = c-b; // BAD if (c<b+a) a = c-b; // BAD // $ Alert
if (c<b+a) { a = c-b; } // BAD if (c<b+a) { a = c-b; } // BAD // $ Alert
if (a+b<=c) a = c-b; // BAD if (a+b<=c) a = c-b; // BAD // $ Alert
if (a+b<=c) { a = c-b; } // BAD if (a+b<=c) { a = c-b; } // BAD // $ Alert
if (b+a<=c) a = c-b; // BAD if (b+a<=c) a = c-b; // BAD // $ Alert
if (b+a<=c) { a = c-b; } // BAD if (b+a<=c) { a = c-b; } // BAD // $ Alert
if (c<=a+b) a = c-b; // BAD if (c<=a+b) a = c-b; // BAD // $ Alert
if (c<=a+b) { a = c-b; } // BAD if (c<=a+b) { a = c-b; } // BAD // $ Alert
if (c<=b+a) a = c-b; // BAD if (c<=b+a) a = c-b; // BAD // $ Alert
if (c<=b+a) { a = c-b; } // BAD if (c<=b+a) { a = c-b; } // BAD // $ Alert
if (a+b>d) a = d-b; // BAD if (a+b>d) a = d-b; // BAD // $ Alert
if (a+(double)b>c) a = c-b; // GOOD if (a+(double)b>c) a = c-b; // GOOD
if (a+(-x)>c) a = c-(-y); // GOOD if (a+(-x)>c) a = c-(-y); // GOOD
if (a+b>c) { b++; a = c-b; } // GOOD if (a+b>c) { b++; a = c-b; } // GOOD
if (a+d>c) a = c-d; // GOOD if (a+d>c) a = c-d; // GOOD
if (a1+b1>c1) a1 = c1-b1; // GOOD if (a1+b1>c1) a1 = c1-b1; // GOOD
if (a+b<=c) { /* ... */ } else { a = c-b; } // BAD if (a+b<=c) { /* ... */ } else { a = c-b; } // BAD // $ Alert
if (a+b<=c) { return; } a = c-b; // BAD if (a+b<=c) { return; } a = c-b; // BAD // $ Alert
} }

View File

@@ -1 +1,2 @@
experimental/Likely Bugs/ArrayAccessProductFlow.ql query: experimental/Likely Bugs/ArrayAccessProductFlow.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1,13 +1,13 @@
char *malloc(int size); char *malloc(int size);
void test1(int size) { void test1(int size) {
char *arr = malloc(size); char *arr = malloc(size); // $ Source
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
arr[i] = 0; // GOOD arr[i] = 0; // GOOD
} }
for (int i = 0; i <= size; i++) { for (int i = 0; i <= size; i++) {
arr[i] = i; // BAD arr[i] = i; // BAD // $ Alert
} }
} }
@@ -18,7 +18,7 @@ typedef struct {
array_t mk_array(int size) { array_t mk_array(int size) {
array_t arr; array_t arr;
arr.p = malloc(size); arr.p = malloc(size); // $ Source
arr.size = size; arr.size = size;
return arr; return arr;
@@ -32,7 +32,7 @@ void test2(int size) {
} }
for (int i = 0; i <= arr.size; i++) { for (int i = 0; i <= arr.size; i++) {
arr.p[i] = i; // BAD arr.p[i] = i; // BAD // $ Alert
} }
} }
@@ -42,7 +42,7 @@ void test3_callee(array_t arr) {
} }
for (int i = 0; i <= arr.size; i++) { for (int i = 0; i <= arr.size; i++) {
arr.p[i] = i; // BAD arr.p[i] = i; // BAD // $ Alert
} }
} }
@@ -52,7 +52,7 @@ void test3(int size) {
void test4(int size) { void test4(int size) {
array_t arr; array_t arr;
arr.p = malloc(size); arr.p = malloc(size); // $ Source
arr.size = size; arr.size = size;
for (int i = 0; i < arr.size; i++) { for (int i = 0; i < arr.size; i++) {
@@ -60,13 +60,13 @@ void test4(int size) {
} }
for (int i = 0; i <= arr.size; i++) { for (int i = 0; i <= arr.size; i++) {
arr.p[i] = i; // BAD arr.p[i] = i; // BAD // $ Alert
} }
} }
array_t *mk_array_p(int size) { array_t *mk_array_p(int size) {
array_t *arr = (array_t*) malloc(sizeof(array_t)); array_t *arr = (array_t*) malloc(sizeof(array_t));
arr->p = malloc(size); arr->p = malloc(size); // $ Source
arr->size = size; arr->size = size;
return arr; return arr;
@@ -80,7 +80,7 @@ void test5(int size) {
} }
for (int i = 0; i <= arr->size; i++) { for (int i = 0; i <= arr->size; i++) {
arr->p[i] = i; // BAD arr->p[i] = i; // BAD // $ Alert
} }
} }
@@ -90,7 +90,7 @@ void test6_callee(array_t *arr) {
} }
for (int i = 0; i <= arr->size; i++) { for (int i = 0; i <= arr->size; i++) {
arr->p[i] = i; // BAD arr->p[i] = i; // BAD // $ Alert
} }
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-193/ConstantSizeArrayOffByOne.ql query: experimental/Security/CWE/CWE-193/ConstantSizeArrayOffByOne.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -32,60 +32,60 @@ void testOneArray(OneArray *arr) {
void testBig(BigArray *arr) { void testBig(BigArray *arr) {
arr->buf[MAX_SIZE-1] = 0; // GOOD arr->buf[MAX_SIZE-1] = 0; // GOOD
arr->buf[MAX_SIZE] = 0; // BAD arr->buf[MAX_SIZE] = 0; // BAD // $ Alert
arr->buf[MAX_SIZE+1] = 0; // BAD arr->buf[MAX_SIZE+1] = 0; // BAD // $ Alert
for(int i = 0; i < MAX_SIZE; i++) { for(int i = 0; i < MAX_SIZE; i++) {
arr->buf[i] = 0; // GOOD arr->buf[i] = 0; // GOOD
} }
for(int i = 0; i <= MAX_SIZE; i++) { for(int i = 0; i <= MAX_SIZE; i++) {
arr->buf[i] = 0; // BAD arr->buf[i] = 0; // BAD // $ Alert
} }
} }
void testFields(ArrayAndFields *arr) { void testFields(ArrayAndFields *arr) {
arr->buf[MAX_SIZE-1] = 0; // GOOD arr->buf[MAX_SIZE-1] = 0; // GOOD
arr->buf[MAX_SIZE] = 0; // BAD? arr->buf[MAX_SIZE] = 0; // BAD? // $ Alert
arr->buf[MAX_SIZE+1] = 0; // BAD? arr->buf[MAX_SIZE+1] = 0; // BAD? // $ Alert
for(int i = 0; i < MAX_SIZE; i++) { for(int i = 0; i < MAX_SIZE; i++) {
arr->buf[i] = 0; // GOOD arr->buf[i] = 0; // GOOD
} }
for(int i = 0; i <= MAX_SIZE; i++) { for(int i = 0; i <= MAX_SIZE; i++) {
arr->buf[i] = 0; // BAD? arr->buf[i] = 0; // BAD? // $ Alert
} }
for(int i = 0; i < MAX_SIZE+2; i++) { for(int i = 0; i < MAX_SIZE+2; i++) {
arr->buf[i] = 0; // BAD? arr->buf[i] = 0; // BAD? // $ Alert
} }
// is this different if it's a memcpy? // is this different if it's a memcpy?
} }
void assignThroughPointer(int *p) { void assignThroughPointer(int *p) { // $ Sink
*p = 0; // ??? should the result go at a flow source? *p = 0; // ??? should the result go at a flow source?
} }
void addToPointerAndAssign(int *p) { void addToPointerAndAssign(int *p) {
p[MAX_SIZE-1] = 0; // GOOD p[MAX_SIZE-1] = 0; // GOOD
p[MAX_SIZE] = 0; // BAD p[MAX_SIZE] = 0; // BAD // $ Alert
} }
void testInterproc(BigArray *arr) { void testInterproc(BigArray *arr) {
assignThroughPointer(&arr->buf[MAX_SIZE-1]); // GOOD assignThroughPointer(&arr->buf[MAX_SIZE-1]); // GOOD
assignThroughPointer(&arr->buf[MAX_SIZE]); // BAD assignThroughPointer(&arr->buf[MAX_SIZE]); // BAD // $ Alert
addToPointerAndAssign(arr->buf); addToPointerAndAssign(arr->buf); // $ Source
} }
#define MAX_SIZE_BYTES 4096 #define MAX_SIZE_BYTES 4096
void testCharIndex(BigArray *arr) { void testCharIndex(BigArray *arr) {
char *charBuf = (char*) arr->buf; char *charBuf = (char*) arr->buf; // $ Source
charBuf[MAX_SIZE_BYTES - 1] = 0; // GOOD charBuf[MAX_SIZE_BYTES - 1] = 0; // GOOD
charBuf[MAX_SIZE_BYTES] = 0; // BAD charBuf[MAX_SIZE_BYTES] = 0; // BAD // $ Alert
} }
void testEqRefinement() { void testEqRefinement() {
@@ -125,7 +125,7 @@ void testStackAllocated() {
char *arr[MAX_SIZE]; char *arr[MAX_SIZE];
for(int i = 0; i <= MAX_SIZE; i++) { for(int i = 0; i <= MAX_SIZE; i++) {
arr[i] = 0; // BAD arr[i] = 0; // BAD // $ Alert
} }
} }
@@ -133,18 +133,18 @@ int strncmp(const char*, const char*, int);
char testStrncmp2(char *arr) { char testStrncmp2(char *arr) {
if(strncmp(arr, "<test>", 6) == 0) { if(strncmp(arr, "<test>", 6) == 0) {
arr += 6; arr += 6; // $ Alert
} }
return *arr; // GOOD [FALSE POSITIVE] return *arr; // GOOD [FALSE POSITIVE] // $ Sink
} }
void testStrncmp1() { void testStrncmp1() {
char asdf[5]; char asdf[5];
testStrncmp2(asdf); testStrncmp2(asdf); // $ Source
} }
void countdownBuf1(int **p) { void countdownBuf1(int **p) {
*--(*p) = 1; // GOOD [FALSE POSITIVE] *--(*p) = 1; // GOOD [FALSE POSITIVE] // $ Sink
*--(*p) = 2; // GOOD *--(*p) = 2; // GOOD
*--(*p) = 3; // GOOD *--(*p) = 3; // GOOD
*--(*p) = 4; // GOOD *--(*p) = 4; // GOOD
@@ -153,7 +153,7 @@ void countdownBuf1(int **p) {
void countdownBuf2() { void countdownBuf2() {
int buf[4]; int buf[4];
int *x = buf + 4; int *x = buf + 4; // $ Alert
countdownBuf1(&x); countdownBuf1(&x);
} }
@@ -215,10 +215,10 @@ int countdownLength2() {
void pointer_size_larger_than_array_element_size() { void pointer_size_larger_than_array_element_size() {
unsigned char buffer[100]; // getByteSize() = 100 unsigned char buffer[100]; // getByteSize() = 100
int *ptr = (int *)buffer; // pai.getElementSize() will be sizeof(int) = 4 -> size = 25 int *ptr = (int *)buffer; // pai.getElementSize() will be sizeof(int) = 4 -> size = 25 // $ Source
ptr[24] = 0; // GOOD: writes bytes 96, 97, 98, 99 ptr[24] = 0; // GOOD: writes bytes 96, 97, 98, 99
ptr[25] = 0; // BAD: writes bytes 100, 101, 102, 103 ptr[25] = 0; // BAD: writes bytes 100, 101, 102, 103 // $ Alert
} }
struct vec2 { int x, y; }; struct vec2 { int x, y; };
@@ -226,10 +226,10 @@ struct vec3 { int x, y, z; };
void pointer_size_smaller_than_array_element_size_but_does_not_divide_it() { void pointer_size_smaller_than_array_element_size_but_does_not_divide_it() {
vec3 array[3]; // getByteSize() = 9 * sizeof(int) vec3 array[3]; // getByteSize() = 9 * sizeof(int)
vec2 *ptr = (vec2 *)array; // pai.getElementSize() will be 2 * sizeof(int) -> size = 4 vec2 *ptr = (vec2 *)array; // pai.getElementSize() will be 2 * sizeof(int) -> size = 4 // $ Source
ptr[3] = vec2{}; // GOOD: writes ints 6, 7 ptr[3] = vec2{}; // GOOD: writes ints 6, 7
ptr[4] = vec2{}; // BAD: writes ints 8, 9 ptr[4] = vec2{}; // BAD: writes ints 8, 9 // $ Alert
} }
void pointer_size_larger_than_array_element_size_and_does_not_divide_it() { void pointer_size_larger_than_array_element_size_and_does_not_divide_it() {
@@ -258,7 +258,7 @@ void call_use(unsigned char* p, int n) {
if(n == 3) { if(n == 3) {
unsigned char x = p[0]; unsigned char x = p[0];
unsigned char y = p[1]; unsigned char y = p[1];
unsigned char z = p[2]; // GOOD [FALSE POSITIVE]: `call_use(buffer2, 2)` won't reach this point. unsigned char z = p[2]; // GOOD [FALSE POSITIVE]: `call_use(buffer2, 2)` won't reach this point. // $ Alert
use(x, y, z); use(x, y, z);
} }
} }
@@ -283,7 +283,7 @@ void test_call_use2() {
call_call_use(buffer1,1); call_call_use(buffer1,1);
unsigned char buffer2[2]; unsigned char buffer2[2];
call_call_use(buffer2,2); call_call_use(buffer2,2); // $ Source
unsigned char buffer3[3]; unsigned char buffer3[3];
call_call_use(buffer3,3); call_call_use(buffer3,3);
@@ -296,7 +296,7 @@ int guardingCallee(int *arr, int size) {
int sum; int sum;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
sum += arr[i]; // GOOD [FALSE POSITIVE] - guarded by size sum += arr[i]; // GOOD [FALSE POSITIVE] - guarded by size // $ Alert
} }
return sum; return sum;
} }
@@ -306,7 +306,7 @@ int guardingCaller() {
guardingCallee(arr1, MAX_SIZE); guardingCallee(arr1, MAX_SIZE);
int arr2[10]; int arr2[10];
guardingCallee(arr2, 10); guardingCallee(arr2, 10); // $ Source
} }
// simplified md5 padding // simplified md5 padding
@@ -319,10 +319,10 @@ void correlatedCondition(int num) {
end = temp + 56; end = temp + 56;
} }
else if (num < 64) { else if (num < 64) {
end = temp + 64; // GOOD [FALSE POSITVE] end = temp + 64; // GOOD [FALSE POSITVE] // $ Alert
} }
char *temp2 = temp + num; char *temp2 = temp + num;
while(temp2 != end) { while(temp2 != end) { // $ Sink
*temp2 = 0; *temp2 = 0;
temp2++; temp2++;
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-200/ExposureSensitiveInformationUnauthorizedActor.ql query: experimental/Security/CWE/CWE-200/ExposureSensitiveInformationUnauthorizedActor.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
{ {
//umask(0022); //umask(0022);
FILE *fp; FILE *fp;
fp = fopen("myFile.txt","w"); // BAD fp = fopen("myFile.txt","w"); // BAD // $ Alert
//chmod("myFile.txt",0644); //chmod("myFile.txt",0644);
fprintf(fp,"%s\n","data to file"); fprintf(fp,"%s\n","data to file");
fclose(fp); fclose(fp);

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-200/ExposureSensitiveInformationUnauthorizedActor.ql query: experimental/Security/CWE/CWE-200/ExposureSensitiveInformationUnauthorizedActor.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-200/ExposureSensitiveInformationUnauthorizedActor.ql query: experimental/Security/CWE/CWE-200/ExposureSensitiveInformationUnauthorizedActor.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-243/IncorrectChangingWorkingDirectory.ql query: experimental/Security/CWE/CWE-243/IncorrectChangingWorkingDirectory.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -9,7 +9,7 @@ int chdir(char *path);
void exit(int status); void exit(int status);
int funTest1(){ int funTest1(){
if (chroot("/myFold/myTmp") == -1) { // BAD if (chroot("/myFold/myTmp") == -1) { // BAD // $ Alert
exit(-1); exit(-1);
} }
return 0; return 0;
@@ -26,7 +26,7 @@ int funTest2(){
} }
int funTest3(){ int funTest3(){
chdir("/myFold/myTmp"); // BAD chdir("/myFold/myTmp"); // BAD // $ Alert
return 0; return 0;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-266/IncorrectPrivilegeAssignment.ql query: experimental/Security/CWE/CWE-266/IncorrectPrivilegeAssignment.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -6,7 +6,7 @@ int fclose(FILE *stream);
void funcTest1() void funcTest1()
{ {
umask(0666); // BAD umask(0666); // BAD // $ Alert
FILE *fe; FILE *fe;
fe = fopen("myFile.txt", "wt"); fe = fopen("myFile.txt", "wt");
fclose(fe); fclose(fe);
@@ -27,7 +27,7 @@ void funcTest2(int mode)
FILE *fe; FILE *fe;
fe = fopen("myFile.txt", "wt"); fe = fopen("myFile.txt", "wt");
fclose(fe); fclose(fe);
chmod("myFile.txt",0555-mode); // BAD chmod("myFile.txt",0555-mode); // BAD // $ Alert
} }
void funcTest2g(int mode) void funcTest2g(int mode)

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-285/PamAuthorization.ql query: experimental/Security/CWE/CWE-285/PamAuthorization.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -26,7 +26,7 @@ bool PamAuthBad(const std::string &username_in,
return false; return false;
} }
err = pam_authenticate(pamh, 0); err = pam_authenticate(pamh, 0); // $ Alert
if (err != PAM_SUCCESS) if (err != PAM_SUCCESS)
return err; return err;

View File

@@ -22,8 +22,8 @@ char host[] = "codeql.com";
void bad(void) { void bad(void) {
std::unique_ptr<CURL> curl = std::unique_ptr<CURL>(curl_easy_init()); std::unique_ptr<CURL> curl = std::unique_ptr<CURL>(curl_easy_init());
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 0); // $ Alert
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 0); // $ Alert
curl_easy_setopt(curl.get(), CURLOPT_URL, host); curl_easy_setopt(curl.get(), CURLOPT_URL, host);
curl_easy_perform(curl.get()); curl_easy_perform(curl.get());
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-295/CurlSSL.ql query: experimental/Security/CWE/CWE-295/CurlSSL.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-359/PrivateCleartextWrite.ql query: experimental/Security/CWE/CWE-359/PrivateCleartextWrite.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -54,7 +54,7 @@ void file()
FILE *file; FILE *file;
// BAD: write zipcode to file in cleartext // BAD: write zipcode to file in cleartext
fputs(theZipcode, file); fputs(theZipcode, file); // $ Alert
// GOOD: encrypt first // GOOD: encrypt first
char *encrypted = encrypt(theZipcode); char *encrypted = encrypt(theZipcode);
@@ -71,15 +71,15 @@ int main(int argc, char **argv)
char *buff4; char *buff4;
// BAD: write medical to buffer in cleartext // BAD: write medical to buffer in cleartext
sprintf(buff1, "%s", medical); sprintf(buff1, "%s", medical); // $ Alert Source
// BAD: write medical to buffer in cleartext // BAD: write medical to buffer in cleartext
char *temp = medical; char *temp = medical; // $ Source
sprintf(buff2, "%s", temp); sprintf(buff2, "%s", temp); // $ Alert
// BAD: write medical to buffer in cleartext // BAD: write medical to buffer in cleartext
char *buff5 = func(medical); char *buff5 = func(medical); // $ Source
sprintf(buff3, "%s", buff5); sprintf(buff3, "%s", buff5); // $ Alert
char *buff6 = encrypt(medical); char *buff6 = encrypt(medical);
// GOOD: encrypt first // GOOD: encrypt first
@@ -93,10 +93,10 @@ void stream()
ofstream mystream; ofstream mystream;
// BAD: write zipcode to file in cleartext // BAD: write zipcode to file in cleartext
mystream << "the zipcode is: " << theZipcode; mystream << "the zipcode is: " << theZipcode; // $ Alert Source
// BAD: write zipcode to file in cleartext // BAD: write zipcode to file in cleartext
(mystream << "the zipcode is: ").write(theZipcode, strlen(theZipcode)); (mystream << "the zipcode is: ").write(theZipcode, strlen(theZipcode)); // $ Alert
// GOOD: encrypt first // GOOD: encrypt first
char *encrypted = encrypt(theZipcode); char *encrypted = encrypt(theZipcode);

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-369/DivideByZeroUsingReturnValue.ql query: experimental/Security/CWE/CWE-369/DivideByZeroUsingReturnValue.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -44,13 +44,13 @@ int getSize2(int type) {
int badTestf1(int type, int met) { int badTestf1(int type, int met) {
int is = getSize(type); int is = getSize(type);
if (met == 1) return 123 / is; // BAD if (met == 1) return 123 / is; // BAD // $ Alert
else return 123 / getSize2(type); // BAD else return 123 / getSize2(type); // BAD // $ Alert
} }
int badTestf2(int type) { int badTestf2(int type) {
int is; int is;
is = getSize(type); is = getSize(type);
return 123 / is; // BAD return 123 / is; // BAD // $ Alert
} }
int badTestf3(int type, int met) { int badTestf3(int type, int met) {
@@ -62,23 +62,23 @@ int badTestf3(int type, int met) {
case 2: case 2:
if (0 == is) return 123 / is; // BAD [NOT DETECTED] if (0 == is) return 123 / is; // BAD [NOT DETECTED]
case 3: case 3:
if (!is & 123 / is) // BAD if (!is & 123 / is) // BAD // $ Alert
return 123; return 123;
case 4: case 4:
if (!is | 123 / is) // BAD if (!is | 123 / is) // BAD // $ Alert
return 123; return 123;
case 5: case 5:
if (123 / is || !is) // BAD if (123 / is || !is) // BAD // $ Alert
return 123; return 123;
case 6: case 6:
if (123 / is && !is) // BAD if (123 / is && !is) // BAD // $ Alert
return 123; return 123;
case 7: case 7:
if (!is) return 123 / is; // BAD if (!is) return 123 / is; // BAD // $ Alert
case 8: case 8:
if (is > -1) return 123 / is; // BAD if (is > -1) return 123 / is; // BAD // $ Alert
case 9: case 9:
if (is < 2) return 123 / is; // BAD if (is < 2) return 123 / is; // BAD // $ Alert
} }
if (is != 0) return -1; if (is != 0) return -1;
if (is == 0) type += 1; if (is == 0) type += 1;
@@ -125,20 +125,20 @@ int badTestf4(int type) {
int is = getSize(type); int is = getSize(type);
int d; int d;
d = type * is; d = type * is;
return 123 / d; // BAD return 123 / d; // BAD // $ Alert
} }
int badTestf5(int type) { int badTestf5(int type) {
int is = getSize(type); int is = getSize(type);
int d; int d;
d = is / type; d = is / type;
return 123 / d; // BAD return 123 / d; // BAD // $ Alert
} }
int badTestf6(int type) { int badTestf6(int type) {
int is = getSize(type); int is = getSize(type);
int d; int d;
d = is / type; d = is / type;
return type * 123 / d; // BAD return type * 123 / d; // BAD // $ Alert
} }
int badTestf7(int type, int met) { int badTestf7(int type, int met) {
@@ -150,7 +150,7 @@ int badTestf7(int type, int met) {
return 123 / is; // GOOD return 123 / is; // GOOD
} }
quit: quit:
return 123 / is; // BAD return 123 / is; // BAD // $ Alert
} }
int goodTestf7(int type, int met) { int goodTestf7(int type, int met) {
@@ -169,8 +169,8 @@ int goodTestf7(int type, int met) {
int badTestf8(int type) { int badTestf8(int type) {
int is = getSize(type); int is = getSize(type);
type /= is; // BAD type /= is; // BAD // $ Alert
type %= is; // BAD type %= is; // BAD // $ Alert
return type; return type;
} }
@@ -184,7 +184,7 @@ float getSizeFloat(float type) {
} }
float badTestf9(float type) { float badTestf9(float type) {
float is = getSizeFloat(type); float is = getSizeFloat(type);
return 123 / is; // BAD return 123 / is; // BAD // $ Alert
} }
float goodTestf9(float type) { float goodTestf9(float type) {
float is = getSizeFloat(type); float is = getSizeFloat(type);
@@ -196,18 +196,18 @@ int badTestf10(int type) {
int out = type; int out = type;
int is = getSize(type); int is = getSize(type);
if (is > -2) { if (is > -2) {
out /= 123 / (is + 1); // BAD out /= 123 / (is + 1); // BAD // $ Alert
} }
if (is > 0) { if (is > 0) {
return 123 / (is - 1); // BAD return 123 / (is - 1); // BAD // $ Alert
} }
if (is <= 0) return 0; if (is <= 0) return 0;
return 123 / (is - 1); // BAD return 123 / (is - 1); // BAD // $ Alert
return 0; return 0;
} }
int badTestf11(int type) { int badTestf11(int type) {
int is = getSize(type); int is = getSize(type);
return 123 / (is - 3); // BAD return 123 / (is - 3); // BAD // $ Alert
} }
int goodTestf11(int type) { int goodTestf11(int type) {
@@ -255,12 +255,12 @@ int badMySubDiv(int type, int is) {
void badTestf13(int type) { void badTestf13(int type) {
int is = getSize(type); int is = getSize(type);
badMyDiv(type, is); // BAD badMyDiv(type, is); // BAD // $ Alert
badMyDiv(type, is - 2); // BAD badMyDiv(type, is - 2); // BAD // $ Alert
badMySubDiv(type, is); // BAD badMySubDiv(type, is); // BAD // $ Alert
goodMyDiv(type, is); // GOOD goodMyDiv(type, is); // GOOD
if (is < 5) if (is < 5)
badMySubDiv(type, is); // BAD badMySubDiv(type, is); // BAD // $ Alert
if (is < 0) if (is < 0)
badMySubDiv(type, is); // BAD [NOT DETECTED] badMySubDiv(type, is); // BAD [NOT DETECTED]
if (is > 5) if (is > 5)
@@ -270,9 +270,9 @@ void badTestf13(int type) {
if (is > 0) if (is > 0)
badMyDiv(type, is); // GOOD badMyDiv(type, is); // GOOD
if (is < 5) if (is < 5)
badMyDiv(type, is - 3); // BAD badMyDiv(type, is - 3); // BAD // $ Alert
if (is < 0) if (is < 0)
badMyDiv(type, is + 1); // BAD badMyDiv(type, is + 1); // BAD // $ Alert
if (is > 5) if (is > 5)
badMyDiv(type, is - 3); // GOOD badMyDiv(type, is - 3); // GOOD
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-377/InsecureTemporaryFile.ql query: experimental/Security/CWE/CWE-377/InsecureTemporaryFile.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -13,7 +13,7 @@ int fclose(FILE *stream);
int funcTest1() int funcTest1()
{ {
FILE *fp; FILE *fp;
char *filename = tmpnam(NULL); // BAD char *filename = tmpnam(NULL); // BAD // $ Alert
fp = fopen(filename,"w"); fp = fopen(filename,"w");
fprintf(fp,"%s\n","data to file"); fprintf(fp,"%s\n","data to file");
fclose(fp); fclose(fp);

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-401/MemoryLeakOnFailedCallToRealloc.ql query: experimental/Security/CWE/CWE-401/MemoryLeakOnFailedCallToRealloc.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -31,7 +31,7 @@ unsigned char * badResize_0(unsigned char * buffer,size_t currentSize,size_t new
// BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block // BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block
if (currentSize < newSize) if (currentSize < newSize)
{ {
buffer = (unsigned char *)realloc(buffer, newSize); buffer = (unsigned char *)realloc(buffer, newSize); // $ Alert
} }
return buffer; return buffer;
} }
@@ -60,7 +60,7 @@ unsigned char * badResize_1_0(unsigned char * buffer,size_t currentSize,size_t n
// BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block // BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block
if (currentSize < newSize) if (currentSize < newSize)
{ {
buffer = (unsigned char *)realloc(buffer, newSize); buffer = (unsigned char *)realloc(buffer, newSize); // $ Alert
} }
return buffer; return buffer;
} }
@@ -136,7 +136,7 @@ unsigned char * badResize_1_1(unsigned char * buffer,size_t currentSize,size_t n
// BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block // BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block
if (currentSize < newSize) if (currentSize < newSize)
{ {
buffer = (unsigned char *)realloc(buffer, newSize); buffer = (unsigned char *)realloc(buffer, newSize); // $ Alert
} }
if(!buffer) if(!buffer)
aFakeFailed_1(1, 1); aFakeFailed_1(1, 1);
@@ -183,7 +183,7 @@ unsigned char * badResize_2_0(unsigned char * buffer,size_t currentSize,size_t n
assert(buffer!=0); assert(buffer!=0);
if (currentSize < newSize) if (currentSize < newSize)
{ {
buffer = (unsigned char *)realloc(buffer, newSize); buffer = (unsigned char *)realloc(buffer, newSize); // $ Alert
} }
return buffer; return buffer;
} }
@@ -279,7 +279,7 @@ unsigned char *goodResize_3_1(unsigned char *buffer, size_t currentSize, size_t
unsigned char *tmp = buffer; unsigned char *tmp = buffer;
if (currentSize < newSize) if (currentSize < newSize)
{ {
buffer = (unsigned char *)realloc(buffer, newSize); buffer = (unsigned char *)realloc(buffer, newSize); // $ Alert
if (buffer == NULL) if (buffer == NULL)
{ {
free(tmp); free(tmp);
@@ -296,7 +296,7 @@ unsigned char *goodResize_3_2(unsigned char *buffer, size_t currentSize, size_t
unsigned char *tmp = buffer; unsigned char *tmp = buffer;
if (currentSize < newSize) if (currentSize < newSize)
{ {
tmp = (unsigned char *)realloc(tmp, newSize); tmp = (unsigned char *)realloc(tmp, newSize); // $ Alert
if (tmp != 0) if (tmp != 0)
{ {
buffer = tmp; buffer = tmp;
@@ -325,7 +325,7 @@ unsigned char * badResize_5_2(unsigned char *buffer, size_t currentSize, size_t
// BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block // BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block
if (currentSize < newSize) if (currentSize < newSize)
{ {
buffer = (unsigned char *)realloc(buffer, newSize); buffer = (unsigned char *)realloc(buffer, newSize); // $ Alert
} }
if (cond) if (cond)
{ {
@@ -339,7 +339,7 @@ unsigned char * badResize_5_1(unsigned char *buffer, size_t currentSize, size_t
// BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block // BAD: on unsuccessful call to realloc, we will lose a pointer to a valid memory block
if (currentSize < newSize) if (currentSize < newSize)
{ {
buffer = (unsigned char *)realloc(buffer, newSize); buffer = (unsigned char *)realloc(buffer, newSize); // $ Alert
assert(cond); // irrelevant assert(cond); // irrelevant
} }
return buffer; return buffer;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-409/DecompressionBombs.ql query: experimental/Security/CWE/CWE-409/DecompressionBombs.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -15,12 +15,12 @@ BrotliDecoderResult BrotliDecoderDecompressStream(
void brotli_test(int argc, const char **argv) { void brotli_test(int argc, const char **argv) {
uint8_t output[1024]; uint8_t output[1024];
size_t output_size = sizeof(output); size_t output_size = sizeof(output);
BrotliDecoderDecompress(1024, (uint8_t *) argv[2], &output_size, output); // BAD BrotliDecoderDecompress(1024, (uint8_t *) argv[2], &output_size, output); // BAD // $ Alert
size_t input_size = 1024; size_t input_size = 1024;
const uint8_t *input_p = (const uint8_t*)argv[2]; const uint8_t *input_p = (const uint8_t*)argv[2];
uint8_t *output_p = output; uint8_t *output_p = output;
size_t out_size; size_t out_size;
BrotliDecoderDecompressStream(0, &input_size, &input_p, &output_size, // BAD BrotliDecoderDecompressStream(0, &input_size, &input_p, &output_size, // BAD // $ Alert
&output_p, &out_size); &output_p, &out_size);
} }

View File

@@ -19,7 +19,7 @@ static int read_data(archive *ar) {
size_t size; size_t size;
la_int64_t offset; la_int64_t offset;
int r = archive_read_data_block(ar, &buff, &size, &offset); // BAD int r = archive_read_data_block(ar, &buff, &size, &offset); // BAD // $ Alert
if (r == ARCHIVE_EOF) if (r == ARCHIVE_EOF)
return ARCHIVE_OK; return ARCHIVE_OK;
if (r < ARCHIVE_OK) if (r < ARCHIVE_OK)

View File

@@ -4,7 +4,7 @@ void minizip_test(int argc, const char **argv);
void zlib_test(int argc, const char **argv); void zlib_test(int argc, const char **argv);
void zstd_test(int argc, const char **argv); void zstd_test(int argc, const char **argv);
int main(int argc, const char **argv) { int main(int argc, const char **argv) { // $ Source
brotli_test(argc, argv); brotli_test(argc, argv);
libarchive_test(argc, argv); libarchive_test(argc, argv);
minizip_test(argc, argv); minizip_test(argc, argv);

View File

@@ -14,7 +14,7 @@ void minizip_test(int argc, const char **argv) {
int32_t bytes_read; int32_t bytes_read;
char buf[4096]; char buf[4096];
while(true) { while(true) {
bytes_read = mz_zip_entry_read(zip_handle, (char *) argv[1], sizeof(buf)); // BAD bytes_read = mz_zip_entry_read(zip_handle, (char *) argv[1], sizeof(buf)); // BAD // $ Alert
if (bytes_read <= 0) { if (bytes_read <= 0) {
break; break;
} }
@@ -23,7 +23,7 @@ void minizip_test(int argc, const char **argv) {
void *zip_reader = mz_zip_reader_create(); void *zip_reader = mz_zip_reader_create();
mz_zip_reader_open_file(zip_reader, argv[1]); mz_zip_reader_open_file(zip_reader, argv[1]);
mz_zip_reader_goto_first_entry(zip_reader); mz_zip_reader_goto_first_entry(zip_reader);
mz_zip_reader_entry_save(zip_reader, 0, 0); // BAD mz_zip_reader_entry_save(zip_reader, 0, 0); // BAD // $ Alert
UnzOpen(argv[3]); // BAD UnzOpen(argv[3]); // BAD // $ Alert
} }

View File

@@ -22,7 +22,7 @@ void UnsafeInflate(char *input) {
infstream.next_out = output; // output char array infstream.next_out = output; // output char array
inflateInit(&infstream); inflateInit(&infstream);
inflate(&infstream, 0); // BAD inflate(&infstream, 0); // BAD // $ Alert
} }
@@ -38,7 +38,7 @@ void UnsafeGzread(char *fileName) {
gzFile inFileZ = gzopen(fileName, "rb"); gzFile inFileZ = gzopen(fileName, "rb");
unsigned char unzipBuffer[8192]; unsigned char unzipBuffer[8192];
while (true) { while (true) {
if (gzread(inFileZ, unzipBuffer, 8192) <= 0) { // BAD if (gzread(inFileZ, unzipBuffer, 8192) <= 0) { // BAD // $ Alert
break; break;
} }
} }
@@ -48,7 +48,7 @@ void UnsafeGzfread(char *fileName) {
gzFile inFileZ = gzopen(fileName, "rb"); gzFile inFileZ = gzopen(fileName, "rb");
while (true) { while (true) {
char buffer[1000]; char buffer[1000];
if (!gzfread(buffer, 999, 1, inFileZ)) { // BAD if (!gzfread(buffer, 999, 1, inFileZ)) { // BAD // $ Alert
break; break;
} }
} }
@@ -59,7 +59,7 @@ void UnsafeGzgets(char *fileName) {
char *buffer = new char[4000000000]; char *buffer = new char[4000000000];
char *result; char *result;
while (true) { while (true) {
result = gzgets(inFileZ, buffer, 1000000000); // BAD result = gzgets(inFileZ, buffer, 1000000000); // BAD // $ Alert
if (result == nullptr) { if (result == nullptr) {
break; break;
} }
@@ -74,7 +74,7 @@ void InflateString(char *input) {
uLong source_length = 500; uLong source_length = 500;
uLong destination_length = sizeof(output); uLong destination_length = sizeof(output);
uncompress(output, &destination_length, (Bytef *) input, source_length); // BAD uncompress(output, &destination_length, (Bytef *) input, source_length); // BAD // $ Alert
} }
void zlib_test(int argc, char **argv) { void zlib_test(int argc, char **argv) {

View File

@@ -36,7 +36,7 @@ void zstd_test(int argc, const char **argv) {
ZSTD_inBuffer input = {buffIn, read, 0}; ZSTD_inBuffer input = {buffIn, read, 0};
while (input.pos < input.size) { while (input.pos < input.size) {
ZSTD_outBuffer output = {buffOut, buffOutSize, 0}; ZSTD_outBuffer output = {buffOut, buffOutSize, 0};
size_t const ret = ZSTD_decompressStream(dctx, &output, &input); // BAD size_t const ret = ZSTD_decompressStream(dctx, &output, &input); // BAD // $ Alert
CHECK_ZSTD(ret); CHECK_ZSTD(ret);
} }
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-415/DoubleFree.ql query: experimental/Security/CWE/CWE-415/DoubleFree.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -8,14 +8,14 @@ void workFunction_0(char *s) {
char *buf; char *buf;
buf = (char *) malloc(intSize); buf = (char *) malloc(intSize);
free(buf); // GOOD free(buf); // GOOD
if(buf) free(buf); // BAD if(buf) free(buf); // BAD // $ Alert
} }
void workFunction_1(char *s) { void workFunction_1(char *s) {
int intSize = 10; int intSize = 10;
char *buf; char *buf;
buf = (char *) malloc(intSize); buf = (char *) malloc(intSize);
free(buf); // GOOD free(buf); // GOOD
free(buf); // BAD free(buf); // BAD // $ Alert
} }
void workFunction_2(char *s) { void workFunction_2(char *s) {
int intSize = 10; int intSize = 10;
@@ -54,7 +54,7 @@ void workFunction_5(char *s, int intFlag) {
if(intFlag) { if(intFlag) {
free(buf); // GOOD free(buf); // GOOD
} }
free(buf); // BAD free(buf); // BAD // $ Alert
} }
void workFunction_6(char *s, int intFlag) { void workFunction_6(char *s, int intFlag) {
int intSize = 10; int intSize = 10;
@@ -75,7 +75,7 @@ void workFunction_7(char *s) {
char *buf1; char *buf1;
buf = (char *) malloc(intSize); buf = (char *) malloc(intSize);
buf1 = (char *) realloc(buf,intSize*4); buf1 = (char *) realloc(buf,intSize*4);
free(buf); // BAD free(buf); // BAD // $ Alert
} }
void workFunction_8(char *s) { void workFunction_8(char *s) {
int intSize = 10; int intSize = 10;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-476/DangerousUseOfExceptionBlocks.ql query: experimental/Security/CWE/CWE-476/DangerousUseOfExceptionBlocks.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -68,7 +68,7 @@ void funcWork1b() {
} }
delete [] bufMyData; delete [] bufMyData;
} } // $ Alert
} }
void funcWork1() { void funcWork1() {
@@ -97,7 +97,7 @@ void funcWork1() {
} }
delete [] bufMyData; delete [] bufMyData;
} } // $ Alert
} }
void funcWork2() { void funcWork2() {
@@ -125,7 +125,7 @@ void funcWork2() {
} }
delete [] bufMyData; delete [] bufMyData;
} } // $ Alert
} }
void funcWork3() { void funcWork3() {
int a; int a;
@@ -148,7 +148,7 @@ void funcWork3() {
} }
delete [] bufMyData; delete [] bufMyData;
} } // $ Alert
} }
@@ -180,7 +180,7 @@ void funcWork4b() {
catch (...) catch (...)
{ {
delete valData; // BAD delete valData; // BAD
} } // $ Alert
} }
void funcWork5() { void funcWork5() {
int a; int a;
@@ -218,7 +218,7 @@ void funcWork5b() {
catch (...) catch (...)
{ {
delete valData; // BAD delete valData; // BAD
} } // $ Alert
} }
void funcWork6() { void funcWork6() {
int a; int a;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-561/FindIncorrectlyUsedSwitch.ql query: experimental/Security/CWE/CWE-561/FindIncorrectlyUsedSwitch.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -25,7 +25,7 @@ void testFunction(char c1,int i1)
case 9: case 9:
break; break;
dafault: dafault:
} } // $ Alert
switch(c1){ // BAD switch(c1){ // BAD
c1=c1*2; c1=c1*2;
@@ -35,7 +35,7 @@ void testFunction(char c1,int i1)
break; break;
case 9: case 9:
break; break;
} } // $ Alert
if((c1<6)&&(c1>0)) if((c1<6)&&(c1>0))
switch(c1){ // BAD switch(c1){ // BAD
@@ -47,7 +47,7 @@ void testFunction(char c1,int i1)
break; break;
case 1: case 1:
break; break;
} } // $ Alert
if((c1<6)&&(c1>0)) if((c1<6)&&(c1>0))
switch(c1){ // BAD switch(c1){ // BAD
@@ -55,6 +55,6 @@ void testFunction(char c1,int i1)
break; break;
case 1: case 1:
break; break;
} } // $ Alert
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-670/DangerousUseSSL_shutdown.ql query: experimental/Security/CWE/CWE-670/DangerousUseSSL_shutdown.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -42,7 +42,7 @@ int gootTest2(SSL *ssl)
int badTest1(SSL *ssl) int badTest1(SSL *ssl)
{ {
int ret; int ret;
switch ((ret = SSL_shutdown(ssl))) { switch ((ret = SSL_shutdown(ssl))) { // $ Alert
case 1: case 1:
break; break;
case 0: case 0:
@@ -58,7 +58,7 @@ int badTest1(SSL *ssl)
int badTest2(SSL *ssl) int badTest2(SSL *ssl)
{ {
int ret; int ret;
ret = SSL_shutdown(ssl); ret = SSL_shutdown(ssl); // $ Alert
switch (ret) { switch (ret) {
case 1: case 1:
break; break;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-675/DoubleRelease.ql query: experimental/Security/CWE/CWE-675/DoubleRelease.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -17,7 +17,7 @@ void test2()
FILE *f; FILE *f;
f = fopen("myFile.txt", "wt"); f = fopen("myFile.txt", "wt");
fclose(f); // BAD fclose(f); // BAD // $ Alert
fclose(f); fclose(f);
} }
@@ -28,14 +28,14 @@ void test3()
f = fopen("myFile.txt", "wt"); f = fopen("myFile.txt", "wt");
g = f; g = f;
fclose(f); // BAD fclose(f); // BAD // $ Alert
fclose(g); fclose(g);
} }
int fGtest4_1() int fGtest4_1()
{ {
fe = fopen("myFile.txt", "wt"); fe = fopen("myFile.txt", "wt");
fclose(fe); // BAD fclose(fe); // BAD // $ Alert
return -1; return -1;
} }

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-691/InsufficientControlFlowManagementAfterRefactoringTheCode.ql query: experimental/Security/CWE/CWE-691/InsufficientControlFlowManagementAfterRefactoringTheCode.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-691/InsufficientControlFlowManagementWhenUsingBitOperations.ql query: experimental/Security/CWE/CWE-691/InsufficientControlFlowManagementWhenUsingBitOperations.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -5,25 +5,25 @@ void workFunction_0(char *s) {
int intSize; int intSize;
char buf[80]; char buf[80];
if(intSize>0 && intSize<80 && memset(buf,0,intSize)) return; // GOOD if(intSize>0 && intSize<80 && memset(buf,0,intSize)) return; // GOOD
if(intSize>0 & intSize<80 & memset(buf,0,intSize)) return; // BAD if(intSize>0 & intSize<80 & memset(buf,0,intSize)) return; // BAD // $ Alert[cpp/errors-when-using-bit-operations]
if(intSize>0 && tmpFunction()) return; if(intSize>0 && tmpFunction()) return;
if(intSize<0 & tmpFunction()) return; // BAD if(intSize<0 & tmpFunction()) return; // BAD // $ Alert[cpp/errors-when-using-bit-operations]
} }
void workFunction_1(char *s) { void workFunction_1(char *s) {
int intA,intB; int intA,intB;
if(intA + intB) return; // BAD if(intA + intB) return; // BAD // $ Alert[cpp/errors-after-refactoring]
if(intA + intB>4) return; // GOOD if(intA + intB>4) return; // GOOD
if(intA>0 && (intA + intB)) return; // BAD if(intA>0 && (intA + intB)) return; // BAD // $ Alert[cpp/errors-after-refactoring]
while(intA>0) while(intA>0)
{ {
if(intB - intA<10) break; if(intB - intA<10) break;
intA--; intA--;
}while(intA>0); // BAD }while(intA>0); // BAD // $ Alert[cpp/errors-after-refactoring]
for(intA=100; intA>0; intA--) for(intA=100; intA>0; intA--)
{ {
if(intB - intA<10) break; if(intB - intA<10) break;
}while(intA>0); // BAD }while(intA>0); // BAD // $ Alert[cpp/errors-after-refactoring]
while(intA>0) while(intA>0)
{ {
if(intB - intA<10) break; if(intB - intA<10) break;

View File

@@ -1 +1,2 @@
experimental/Security/CWE/CWE-703/FindIncorrectlyUsedExceptions.ql query: experimental/Security/CWE/CWE-703/FindIncorrectlyUsedExceptions.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -32,13 +32,13 @@ void funcTest2()
void funcTest3() void funcTest3()
{ {
std::runtime_error("msg error"); // BAD std::runtime_error("msg error"); // BAD // $ Alert
throw std::runtime_error("msg error"); // GOOD throw std::runtime_error("msg error"); // GOOD
} }
void TestFunc() void TestFunc()
{ {
funcTest1(); funcTest1(); // $ Alert
DllMain(); DllMain(); // $ Alert
funcTest2(); funcTest2();
} }

Some files were not shown because too many files have changed in this diff Show More