Commit Graph

86412 Commits

Author SHA1 Message Date
Taus
3e6e7295c2 Python: Remove some FPs for ContainsNonContainer.ql
First fix handles the case where there's interference from a class-based
decorator on a function. In this case, _technically_ we have an instance
of the decorator class, but in practice this decorator will (hopefully)
forward all accesses to the thing it wraps.

The second fix has to do with methods that are added dynamically using
`setattr`. In this case, we cannot be sure that the relevant methods are
actually missing.
2026-03-16 14:36:29 +00:00
Taus
c6a7aa2c06 Python: Exclude iterators guarded by isinstance checks
A common pattern is to check `isinstance(it, (list, tuple)` before
proceeding with the iteration.
2026-03-16 14:33:59 +00:00
Taus
db8b9905cd Python: Add change note 2026-03-13 16:36:36 +00:00
Taus
1a1f083383 Python: Add DuckTyping::hasUnreliableMro
The relative simplicity of the MRO computation in `DataFlowDispatch` was
causing quite a lot of FPs to appear for the "wrong number/name of
arguments in class instantiation" queries. The easiest fix was to just
exclude cases where we know the MRO computation will be imprecise --
when there are superclasses with multiple inheritance or unknown bases.
2026-03-11 16:59:22 +00:00
Taus
b9ad2b6bd9 Python: Port DocStrings.ql 2026-03-11 16:59:21 +00:00
Taus
db2132a5b5 Python: Port DeprecatedSliceMethod.ql
Only trivial test changes.
2026-03-11 16:59:21 +00:00
Taus
3f16ca7016 Python: Extend DuckTyping module
Adds `overridesMethod` and `isPropertyAccessor`.
2026-03-11 16:59:21 +00:00
Taus
f1dca5d072 Python: Remove missing results
These results are missing because we no longer (unlike the points-to
analysis) track how many elements a given tuple has. This is something
we might want to implement in the future (most likely through an
`int`-indexed type tracker).
2026-03-11 16:59:21 +00:00
Taus
6cbb26e8cb Python: Port WrongNumberArgumentsInClassInstantiation.ql
Included test changes are trivial `toString` changes.
2026-03-11 16:59:21 +00:00
Taus
ccf02e8ead Python: Port WrongNameForArgumentInClassInstantiation.ql 2026-03-11 16:59:21 +00:00
Taus
7ef9119042 Python: Port ShouldBeContextManager.ql
Only trivial test changes.
2026-03-11 16:59:20 +00:00
Taus
ebeff95cdf Python: Port UselessClass.ql
No test changes.
2026-03-11 16:59:20 +00:00
Taus
f953cca6d8 Python: Port HashedButNoHash.ql
This one is a bit more involved. Of note is the fact that it at present
only uses local flow when determining the origin of some value (whereas
the points-to version used global flow). It may be desirable to rewrite
this query to use global data-flow, but this should be done with some
care (as using "all unhashable objects" as the set of sources is
somewhat iffy with respect to performance). For that reason, I'm
sticking to mostly local flow (except for well behaved things like types
and built-ins).
2026-03-11 16:59:20 +00:00
Taus
d06224b066 Python: Port InconsistentMRO.ql
For this one we actually lose a test result. However, this is kind of to
be expected since we no longer have the "precise" MRO that the points-to
analysis computes.

Honestly, I'm on the fence about even keeping this query at all. It
seems like it might be superfluous in a world with good Python type
checking.
2026-03-11 16:59:20 +00:00
Taus
2f6896395f Python: Port PropertyInOldStyleClass.ql
Only trivial test changes.
2026-03-11 16:59:19 +00:00
Taus
dfdfefd688 Python: Port SuperInOldStyleClass.ql 2026-03-11 16:59:19 +00:00
Taus
bae74a5245 Python: Port SlotsInOldStyleClass.ql
Only trivial test changes.
2026-03-11 16:59:19 +00:00
Taus
0105ec4df5 Python: Add declares/getAttribute API
These could arguably be moved to `Class` itself, but for now I'm
choosing to limit the changes to the `DuckTyping` module (until we
decide on a proper API).
2026-03-11 16:59:19 +00:00
Taus
9adaf671c9 Python: Add DuckTyping::isNewStyle
Approximates the behaviour of `Types::isNewStyle` but without depending
on points-to
2026-03-11 16:59:19 +00:00
Taus
79e4685a6d Python: Port UnusedExceptionObject.ql
Depending on whether other queries depend on this, we may end up moving
the exception utility functions to a more central location.
2026-03-11 16:59:19 +00:00
Taus
53f5da825d Python: Port ShouldUseWithStatement.ql
Only trivial test changes.
2026-03-11 16:59:19 +00:00
Taus
117057c233 Python: Port NonIteratorInForLoop.ql
Same comment as for the preceding commit. We lose one test result due to
the fact that we don't know what to do about `for ... in 1` (because `1`
is an instance of a built-in). I'm going to defer addressing this until
we get some modelling of built-in types.
2026-03-11 16:59:19 +00:00
Taus
bfbfb1523f Python: Port ContainsNonContainer.ql
Uses the new `DuckTyping` module to handle recognising whether a class
is a container or not. Only trivial test changes (one version uses
"class", the other "Class").

Note that the ported query has no understanding of built-in classes. At
some point we'll likely want to replace `hasUnresolvedBase` (which will
hold for any class that extends a built-in) with something that's aware
of the built-in classes.
2026-03-11 16:59:18 +00:00
Taus
4e86c1e03f Python: Introduce DuckTyping module
This module (which for convenience currently resides inside
`DataFlowDispatch`, but this may change later) contains convenience
predicates for bridging the gap between the data-flow layer and the old
points-to analysis.
2026-03-11 16:59:18 +00:00
Taus
e36dbea7b4 Python: Port py/print-during-import
Uses a (perhaps) slightly coarser approximation of what modules are
imported, but it's probably fine.
2026-03-11 16:59:18 +00:00
Taus
33c2be2a2d Python: Use API graphs instead of points-to for simple built-ins
Removes the use of points-to for accessing various built-ins from three
of the queries. In order for this to work I had to extend the lists of
known built-ins slightly.
2026-03-11 16:59:18 +00:00
Ian Lynagh
bbd02b855b Merge pull request #21424 from github/idrissrio/cpp/overlay/discard
C/C++ overlay: update discard mechanism
2026-03-11 13:45:52 +00:00
Idriss Riouak
48a03e2a04 Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-11 14:25:53 +01:00
idrissrio
a92d97744f C/C++ overlay: address review comment 2026-03-11 14:25:52 +01:00
idrissrio
ef6c1a9968 C/C++ overlay: fix failing header_dependency test 2026-03-11 14:25:50 +01:00
idrissrio
72142b51f7 C/C++ overlay: switch to updated discard strategy 2026-03-11 14:25:49 +01:00
Tom Hvitved
c06d4d2647 Merge pull request #21422 from hvitved/rust/type-mention-refactor
Rust: Small refactor in `TypeMention.qll`
2026-03-11 14:01:03 +01:00
Ian Lynagh
68dfa5c83b Merge pull request #21451 from igfoo/igfoo/fix-build
Revert "Bump rules_android from 0.6.4 to 0.7.1"
2026-03-11 12:27:20 +00:00
Ian Lynagh
25a20f74f0 Revert "Bump rules_android from 0.6.4 to 0.7.1"
This reverts commit c7349740f0.

It was making the build fail
2026-03-11 11:54:18 +00:00
Taus
5a65282241 Merge pull request #21429 from github/tausbn/fix-bad-join-in-method-call-order
Python: Fix bad join in method call order computation
2026-03-10 18:17:35 +01:00
Paolo Tranquilli
79499c240a Merge pull request #21444 from github/dependabot/bazel/googletest-1.17.0.bcr.2
Bump googletest from 1.14.0.bcr.1 to 1.17.0.bcr.2
2026-03-10 16:41:38 +01:00
Paolo Tranquilli
267a46d01b Merge pull request #21445 from github/dependabot/bazel/rules_shell-0.6.1
Bump rules_shell from 0.5.0 to 0.6.1
2026-03-10 16:41:24 +01:00
Ian Lynagh
341059d2d0 Merge pull request #21437 from igfoo/igfoo/onemk
C++: Small simplification
2026-03-10 15:36:38 +00:00
Paolo Tranquilli
3c3c58b0a9 Merge pull request #21443 from github/dependabot/bazel/rules_android-0.7.1
Bump rules_android from 0.6.4 to 0.7.1
2026-03-10 16:06:40 +01:00
Paolo Tranquilli
9bf1072a01 Merge pull request #21447 from github/revert-21414-redsun82/rerun-slash-command
Revert "Add `/rerun` slash command for failed internal checks"
2026-03-10 15:55:45 +01:00
Paolo Tranquilli
a5f23ade8c Revert "Add /rerun slash command for failed internal checks" 2026-03-10 14:43:59 +01:00
Paolo Tranquilli
017b6f2e44 Merge pull request #21414 from github/redsun82/rerun-slash-command
Add `/rerun` slash command for failed internal checks
2026-03-10 14:01:03 +01:00
Anders Schack-Mulligen
6a6bb5ebf9 Merge pull request #21441 from aschackmull/cfg/switch-sharing
Cfg: Share more code for switch statements.
2026-03-10 13:50:21 +01:00
dependabot[bot]
b631138b63 Bump rules_shell from 0.5.0 to 0.6.1
Bumps [rules_shell](https://github.com/bazelbuild/rules_shell) from 0.5.0 to 0.6.1.
- [Release notes](https://github.com/bazelbuild/rules_shell/releases)
- [Commits](https://github.com/bazelbuild/rules_shell/compare/v0.5.0...v0.6.1)

---
updated-dependencies:
- dependency-name: rules_shell
  dependency-version: 0.6.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 11:21:40 +00:00
dependabot[bot]
093d36ebe6 Bump googletest from 1.14.0.bcr.1 to 1.17.0.bcr.2
Bumps [googletest](https://github.com/google/googletest) from 1.14.0.bcr.1 to 1.17.0.bcr.2.
- [Release notes](https://github.com/google/googletest/releases)
- [Commits](https://github.com/google/googletest/commits)

---
updated-dependencies:
- dependency-name: googletest
  dependency-version: 1.17.0.bcr.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 11:21:37 +00:00
dependabot[bot]
c7349740f0 Bump rules_android from 0.6.4 to 0.7.1
Bumps [rules_android](https://github.com/bazelbuild/rules_android) from 0.6.4 to 0.7.1.
- [Release notes](https://github.com/bazelbuild/rules_android/releases)
- [Commits](https://github.com/bazelbuild/rules_android/compare/v0.6.4...v0.7.1)

---
updated-dependencies:
- dependency-name: rules_android
  dependency-version: 0.7.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 11:21:34 +00:00
Anders Schack-Mulligen
efa797a21d Update shared/controlflow/codeql/controlflow/ControlFlowGraph.qll
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-10 11:22:15 +01:00
Anders Schack-Mulligen
77d4f5a2dc Cfg: Update fallsThrough default. 2026-03-10 11:10:24 +01:00
Anders Schack-Mulligen
edf88b34da Cfg: Move Case.getBodyElement to shared code. 2026-03-10 11:02:58 +01:00
Owen Mansel-Chan
0215ea3ee3 Merge pull request #21426 from owen-mc/cpp/validate-constructor-summary-models
C++: Add model validation for constructor summary models
2026-03-10 09:42:24 +00:00