Commit Graph

88586 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
cebddbdd42 Commit 7: Implement POSIX collating symbol and equivalence class support
Add posixCollatingSymbol([.x.]) and posixEquivalenceClass([=x=]) predicates
to ParseRegExp.qll, enabling correct tokenization of all three POSIX bracket
atom types inside character classes:
  - [:name:]  — already handled, unchanged
  - [.x.]     — new: posixCollatingSymbol predicate
  - [=x=]     — new: posixEquivalenceClass predicate

Refactored:
- charSetDelimiter: use inAnyPosixBracket helper (covers all three types)
- charSet closing: use inAnyPosixBracket helper
- inPosixBracket: updated to cover all three types
- simpleCharacter: updated to exclude all three types
- namedCharacterProperty: includes posixCollatingSymbol and posixEquivalenceClass
- inAnyPosixBracket: new private helper; uses pos in [x..y-1] for QL binding

Before this commit (commit 6):
  [[.a.]] → RegExpCharacterClass([[.a.]) + stray ]   (WRONG)
  [[=a=]] → RegExpCharacterClass([[=a=]) + stray ]   (WRONG)

After this commit:
  [[.a.]] → RegExpCharacterClass containing RegExpNamedCharacterProperty [.a.]
  [[=a=]] → RegExpCharacterClass containing RegExpNamedCharacterProperty [=a=]

Regenerated parse.expected and regexp.expected via codeql test run --learn
(CodeQL 2.26.1); all 2 tests pass.
2026-07-21 10:22:50 +00:00
copilot-swe-agent[bot]
9fd7e949c8 Commit 6: Add POSIX-bracket extension tests (pre-fix, capturing incorrect tokenization)
Add new test cases to test.cpp exercising POSIX bracket expressions inside
character classes as supported by std::regex ECMAScript mode:
- Single POSIX classes: [[:alpha:]], [[:digit:]], [[:space:]], [[:upper:]],
  [[:lower:]], [[:alnum:]], [[:print:]], [[:punct:]]
- Negated outer bracket: [^[:space:]]
- Mixed: regular char + POSIX class [a[:space:]]
- POSIX collating symbol [[.a.]]
- POSIX equivalence class [[=a=]]
- Mixed POSIX + range [[:alpha:]0-9]

The existing r_posix1-r_posix4 cases remain untouched. New cases use distinct
names (r_posix_alpha, r_posix_digit, etc.) to avoid redeclaration.

Generated .expected via codeql test run --learn (CodeQL 2.26.1); all 2 tests
pass. The expected output captures the CURRENT (pre-fix) tokenization — commit 7
will change these rows when correct POSIX nesting is implemented.
2026-07-21 10:17:14 +00:00
copilot-swe-agent[bot]
67ff5896a8 Commit 5: Remove Ruby-only parser features; shift to ECMAScript dialect
- ParseRegExp.qll:
  - specialCharacter: remove \A, \Z, \z, \G (Ruby-only anchors); keep only \b, \B
  - firstPart: remove \A arm; keep only ^ for start-of-string
  - lastPart: remove \Z, \z arms; keep only $ for end-of-string
  - nonCapturingGroupStart: remove < from char set (handled by namedGroupStart
    and lookbehindAssertionStart; was causing mis-tokenization of lookbehind)
  - namedGroupStart: remove Ruby-only single-quote (?'name'...) branch; keep
    only ECMAScript (?<name>...) syntax
- RegexTreeView.qll:
  - RegExpCharacterClassEscape: remove h, H (Ruby hex-digit classes); keep
    d, D, s, S, w, W (ECMAScript set)
  - RegExpAnchor: change to [^, $] only (remove \A, \Z, \z)
  - RegExpDollar: change to $ only (remove \Z, \z)
  - RegExpCaret: change to ^ only (remove \A)
- test.cpp:
  - r_cc3: replace \A[+-]?\d+ with ^[+-]?\d+ (ECMAScript caret)
  - r_meta5 \h\H: removed (Ruby-only hex classes)
  - r_anc1 \Gabc: removed (\G not in ECMAScript)
- Regenerated parse.expected and regexp.expected via codeql test run --learn
  (CodeQL 2.26.1); all 2 tests pass.
2026-07-21 10:15:58 +00:00
copilot-swe-agent[bot]
96c7e2dbc5 Commit 4: Curate corpus for C++ ECMAScript; regenerate .expected
Content-only edits to test.cpp to remove Ruby-only syntax that has no
C++ ECMAScript equivalent:

1. Removed: "a{,8}" — Ruby-only "{,n}" no-lower-bound quantifier
   (ECMAScript requires an explicit lower bound in {n,m})

2. Removed: second ".*" for /.*/m — mode flags in C++ are construction-site
   arguments (e.g. std::regex::multiline), not part of the pattern string.
   This mode variant was the exact same pattern string as r_meta1 so it
   added no coverage.

3. Removed: "(?'foo'fo+)" — Ruby single-quote named-group form.
   ECMAScript only supports the angle-bracket form (?<name>...).

Left in place for now (removed with the parser in commit 5):
  \\A, \\z, \\G, \\h, \\H — Ruby-only anchor/escape classes.
  The POSIX-bracket cases are kept through commit 7.

.expected regenerated by:
  codeql test run --learn --search-path=. cpp/ql/test/library-tests/regex/
  (CodeQL CLI 2.26.1)
All 2 tests passed.
2026-07-21 10:12:21 +00:00
copilot-swe-agent[bot]
d7a8f48c1c Commit 3: Add test.cpp corpus wrapped in std::regex stubs; generate .expected
Introduces cpp/ql/test/library-tests/regex/test.cpp with the Ruby regex
corpus mechanically translated to C++ string literals and wrapped in
std::regex construction calls using fully self-contained in-file stubs
(no #include of any external/standard header).

Stub surface:
  std::basic_regex<CharT>  constructor(const char*), constructor(const char*, int),
                           assign(const char*)
  std::regex               typedef for basic_regex<char>
  std::regex_match / regex_search / regex_replace  free functions

1:1 corpus mapping from regexp.rb:
  - All Ruby /regex/ literals translated to C++ "string" literals
    (each backslash doubled: /\d/ -> "\\d")
  - Dropped: /#{A}bc/ (Ruby string interpolation, no string-literal form)
  - Kept: a{,8}, .*m, \A, \z, \G, \h\H, (?'foo'...) — these are removed
    in commits 4 and 5 (keeping them here preserves 1:1 mapping)

Also removes `abstract` from RegExp class in ParseRegExp.qll so that all
StringLiterals are regex candidates (trivial syntactic gate; no dataflow).

.expected generated by:
  codeql test run --learn --search-path=. cpp/ql/test/library-tests/regex/
  (CodeQL CLI 2.26.1, bundled C/C++ extractor)
All 2 tests passed.
2026-07-21 10:11:27 +00:00
copilot-swe-agent[bot]
52b35ef08e Commit 2: Adapt Ruby regex library to compile against C++
Changes from verbatim Ruby baseline (Commit 1) to compilable C++:

ParseRegExp.qll:
- Remove: private import codeql.ruby.AST as Ast
- Remove: private import codeql.Locations
- Add: private import semmle.code.cpp.exprs.Literal
- Change RegExp base: Ast::StringlikeLiteral -> StringLiteral
- Replace getText(): removes getConstantValue() Ruby accessor, uses getValue()
  (C++ StringLiteral.getValue() returns the string content, analogous to
   Ruby's getConstantValue().getString())

RegexTreeView.qll:
- Remove Ruby-specific imports (codeql.ruby.AST, codeql.Locations,
  codeql.regex.nfa.NfaUtils)
- Add: private import semmle.code.cpp.exprs.Literal
- Keep: codeql.util.Numbers (for parseHexInt in RegExpEscape.getUnicode())
- Keep: codeql.regex.RegexTreeView (satisfies RegexTreeViewSig)
- Change getParsedRegExp: Ast::RegExpLiteral -> StringLiteral
- Simplify hasLocationInfo to use re.getLocation() directly with +1 offset
  for opening quote (approximate; fixed in commits 8-9)
- Replace isExcluded: remove hasFreeSpacingFlag(), use none()
- Ruby dialect features preserved unchanged (\\A, \\z, \\G, \\h, etc.);
  dialect shift is commit 5

Test queries:
- parse.ql, regexp.ql: replace codeql.ruby.Regexp with
  semmle.code.cpp.regex.RegexTreeView
- .expected cleared (no test.cpp until commit 3)

Verified: both queries compile successfully with codeql query compile.
2026-07-21 10:08:22 +00:00
copilot-swe-agent[bot]
90a14d82b5 Commit 1: Copy Ruby regex library files verbatim (non-compiling checkpoint)
This is a verbatim copy of the Ruby ParseRegExp.qll and RegExpTreeView.qll,
with only the file-header comments updated to reflect the new path.
The test files (parse.ql, regexp.ql, regexp.rb, *.expected) are also copied
verbatim from the Ruby test suite as a baseline reference.

This commit does NOT compile against C++: it still imports codeql.ruby.AST
and references Ruby AST types (RegExpLiteral, StringlikeLiteral, etc.).
The adaptation to compile against C++ is in the next commit.

Also adds the codeql/regex dependency to cpp/ql/lib/qlpack.yml and the
unreleased change-note at cpp/ql/lib/change-notes/2026-07-21-cpp-regex-tree-view.md.
2026-07-21 10:01:38 +00:00
copilot-swe-agent[bot]
f4dbbcd149 Initial plan 2026-07-21 09:52:49 +00:00
Jeroen Ketema
5690ec71b0 Merge pull request #22111 from jketema/jketema/swift-more-autobuild
Swift: Turn off caching and integrated driver in autobuild
2026-07-20 13:54:46 +02:00
Jeroen Ketema
14450f5bf3 Merge pull request #22211 from jketema/jketema/qldoc
Shared: Add missing QLdoc
2026-07-17 19:13:52 +02:00
Jeroen Ketema
a3eee6204b Shared: Add missing QLdoc 2026-07-17 17:22:11 +02:00
Óscar San José
87835f7f3d Merge pull request #22207 from github/codeql-spark-run-29493713448
Update changelog documentation site for codeql-cli-2.26.1
2026-07-17 12:10:28 +02:00
github-actions[bot]
e9e360ae44 update codeql documentation 2026-07-16 11:18:13 +00:00
Michael Nebel
2eb0158b09 Merge pull request #22193 from michaelnebel/csharp/diableuselessassignment
C#: Remove the query `cs/useless-assignment-to-local` from the `code-quality` suite.
2026-07-16 08:07:29 +02:00
Jeroen Ketema
64df10409a Merge pull request #22191 from jketema/jketema/swift-6.3.3
Swift: Update to Swift 6.3.3
2026-07-15 14:09:47 +02:00
Jeroen Ketema
a701922dbd Swift: Update to Swift 6.3.3 2026-07-15 13:28:15 +02:00
Jeroen Ketema
303f81ee14 Merge pull request #22194 from github/jketema/kotlin-2.4.10
Kotlin: Support Kotlin 2.4.10
2026-07-15 11:46:21 +02:00
Michael Nebel
2c161e6b8f Merge pull request #22180 from michaelnebel/csharp/rawurl
C#: Remove the RawUrl sanitizer.
2026-07-15 11:38:28 +02:00
Jeroen Ketema
574ef4d1ac Kotlin: Support Kotlin 2.4.10 2026-07-15 10:17:58 +02:00
Michael Nebel
cb3f8a8394 C#: Add change-note. 2026-07-15 09:16:01 +02:00
Michael Nebel
2395053ed6 C#: Update integration test expected output. 2026-07-15 09:12:52 +02:00
Michael Nebel
b15c243eca C#: Exclude cs/useless-assignment-to-local from the code-quality suite. 2026-07-15 09:12:49 +02:00
Owen Mansel-Chan
05734dcc38 Merge pull request #22175 from owen-mc/java/fix-path-sanitizer
Java: Fix `File.getName()` path sanitizer
2026-07-14 13:12:56 +01:00
Jeroen Ketema
8b477059fe Merge pull request #22178 from jketema/jketema/go-recv
Go: Track whether a type parameter type was declared as part of a receiver
2026-07-14 10:49:52 +02:00
Jeroen Ketema
09da46d8bd Go: Address review comments 2026-07-14 10:23:43 +02:00
Owen Mansel-Chan
2d0095826b Address review comment 2026-07-13 19:40:31 +01:00
Michael Nebel
42843f155e Merge pull request #22159 from aschackmull/java/join-order-effnonvirt
Java: Improve join order.
2026-07-13 16:45:54 +02:00
Jeroen Ketema
2656b5d87d Merge pull request #22179 from jketema/jketema.new-free
C++: Update the CWE tag of `cpp/new-free-mismatch`
2026-07-13 16:25:58 +02:00
Michael Nebel
ae06b778e5 C#: Add change-note. 2026-07-13 15:29:18 +02:00
Michael Nebel
03e44f548f C#: Update test and expected output. 2026-07-13 15:19:04 +02:00
Michael Nebel
a8885aeebd C#: Remove the HttpRequest.RawUrl barrier model. 2026-07-13 15:18:38 +02:00
Jeroen Ketema
b3c16b48c2 Merge pull request #21516 from github/dependabot/bazel/nlohmann_json-3.12.0.bcr.1
Bump nlohmann_json from 3.11.3 to 3.12.0.bcr.1
2026-07-13 14:25:20 +02:00
Jeroen Ketema
5caa29a465 Merge branch 'main' into dependabot/bazel/nlohmann_json-3.12.0.bcr.1 2026-07-13 13:40:25 +02:00
Jeroen Ketema
e0f0987b81 Go: Make isFromReceiver and actual predicate 2026-07-13 13:24:23 +02:00
Jeroen Ketema
fe0d1af079 Merge pull request #22177 from github/workflow/go-version-update
Go: Update to 1.26.5
2026-07-13 13:21:01 +02:00
Jeroen Ketema
9efcc49af7 C++: Update the CWE tag of cpp/new-free-mismatch 2026-07-13 13:06:15 +02:00
Jeroen Ketema
9c1f5c9be2 Go: Fix dowgrade script formatting 2026-07-13 12:47:17 +02:00
Jeroen Ketema
e17508ca51 Go: Expose new TypeParamType column and use in test 2026-07-13 12:41:47 +02:00
Jeroen Ketema
37454ab5f6 Go: Add upgrade and downgrade scripts 2026-07-13 12:35:29 +02:00
Jeroen Ketema
032636cf34 Go: Track whether a type parameter was defined as part of a receiver 2026-07-13 12:35:27 +02:00
Jeroen Ketema
6017cbc6cb Merge pull request #22176 from jketema/jketema/go-dead
Go: Remove dead extractor code
2026-07-13 12:33:00 +02:00
github-actions[bot]
0584ca09dc Go: Update to 1.26.5 2026-07-13 04:12:46 +00:00
Jeroen Ketema
559f9f3850 Go: Remove dead isAlias 2026-07-13 00:38:58 +02:00
Jeroen Ketema
63ff22abd6 Go: Remove dead ObjectsOverride 2026-07-13 00:08:51 +02:00
Owen Mansel-Chan
a142121038 Merge pull request #22157 from github/dependabot/go_modules/go/extractor/extractor-dependencies-ac3bf41f8e
Bump golang.org/x/tools from 0.47.0 to 0.48.0 in /go/extractor in the extractor-dependencies group
2026-07-11 22:28:05 +01:00
Owen Mansel-Chan
6057b4b6e9 Fix path sanitizer 2026-07-11 07:28:14 +01:00
Owen Mansel-Chan
22fca39735 Merge pull request #22156 from github/workflow/coverage/update
Update CSV framework coverage reports
2026-07-11 01:14:26 +01:00
Owen Mansel-Chan
dee6386459 Merge pull request #22126 from owen-mc/js/convert-qlref-inline-expectations
JS: Convert qlref tests to inline expectations
2026-07-11 00:24:20 +01:00
Owen Mansel-Chan
9fc65df23d Merge pull request #22150 from owen-mc/go/remove-incorrect-sanitizer
Go: Fix incorrect path injection sanitizer `FilePath.Rel`
2026-07-10 15:25:17 +01:00
Anders Schack-Mulligen
33261f441e Java: Improve join order.
Before:
```
[2026-07-10 15:15:58] Evaluated non-recursive predicate ControlFlowGraph::NonReturningCalls::EffectivelyNonVirtualMethod.getAnAccess/0#dispred#efac59ed@090459qt in 4303ms (size: 186002).
Evaluated relational algebra for predicate ControlFlowGraph::NonReturningCalls::EffectivelyNonVirtualMethod.getAnAccess/0#dispred#efac59ed@090459qt with tuple counts:
           790592  ~0%    {2} r1 = JOIN `Expr::MethodCall.getMethod/0#dispred#41989dc9_10#join_rhs` WITH `Member::Method.getSourceDeclaration/0#dispred#93e6cdf8` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
        539755681  ~2%    {2}    | JOIN WITH `Member::SrcMethod.getAPossibleImplementationOfSrcMethod/0#dispred#4f4317e6#bf` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
           186002  ~2%    {2}    | JOIN WITH ControlFlowGraph::NonReturningCalls::EffectivelyNonVirtualMethod#86c19e07 ON FIRST 1 OUTPUT Lhs.0, Lhs.1
                          return r1
```
After:
```
[2026-07-10 15:29:39] Evaluated non-recursive predicate ControlFlowGraph::NonReturningCalls::EffectivelyNonVirtualMethod.getAnAccess/0#dispred#efac59ed@32fb2e61 in 10ms (size: 186002).
Evaluated relational algebra for predicate ControlFlowGraph::NonReturningCalls::EffectivelyNonVirtualMethod.getAnAccess/0#dispred#efac59ed@32fb2e61 with tuple counts:
        122765  ~0%    {2} r1 = SCAN ControlFlowGraph::NonReturningCalls::EffectivelyNonVirtualMethod#86c19e07 OUTPUT In.0, In.0
        122766  ~0%    {2}    | JOIN WITH `Member::SrcMethod.getAPossibleImplementationOfSrcMethod/0#dispred#4f4317e6_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
        126911  ~0%    {2}    | JOIN WITH `Member::Method.getSourceDeclaration/0#dispred#93e6cdf8_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
        186002  ~2%    {2}    | JOIN WITH `Expr::MethodCall.getMethod/0#dispred#41989dc9_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1
                       return r1
```
2026-07-10 15:32:44 +02:00