Uh oh!
There was an error while loading. Please reload this page.
Rust: Source/sink/barrier MaD trait models apply to implementations - #22445
Conversation
157403e to
3778964CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4305c61 to
42cbd6bCompared94dc40 to
4a7a072CompareThere was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Concrete trait targets can produce duplicate endpoint models, and barrier coverage does not independently exercise all new paths.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll — The inherited endpoint fallback is also applied to concrete <Type as Trait>::method functions.… | |
rust/ql/test/library-tests/dataflow/barrier/main.rs — sanitize3 is not tested independently: s has already passed through the sanitize2 barrier, so… | |
rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll — The new barrierGuardModel inheritance path has no corresponding trait-implementation test, while… |
What changed in this PR
Extends Rust MaD source, sink, and barrier models to trait implementations, aligning them with summary-model inheritance.
Changes:
- Adds exactness-aware endpoint model selection and Rust trait resolution.
- Updates shared and language-specific dataflow adapters.
- Expands Rust cryptography and dataflow tests.
| File | Description |
|---|---|
shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll | Adds exactness-aware endpoint selection. |
rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll | Resolves models through trait implementations. |
rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll | Integrates inherited Rust models. |
rust/ql/lib/codeql/rust/dataflow/FlowSource.qll | Marks explicit sources exact. |
rust/ql/lib/codeql/rust/dataflow/FlowSink.qll | Marks explicit sinks exact. |
rust/ql/lib/codeql/rust/dataflow/FlowBarrier.qll | Marks explicit barriers and guards exact. |
rust/ql/lib/codeql/rust/internal/PathResolution.qll | Adds call-target debugging support. |
rust/ql/test/library-tests/dataflow/models/models.ext.yml | Adds trait source and sink models. |
rust/ql/test/library-tests/dataflow/models/main.rs | Exercises modeled trait implementations. |
rust/ql/test/library-tests/dataflow/models/external_file.rs | Adds external trait implementations. |
rust/ql/test/library-tests/dataflow/models/models.expected | Updates generated model baseline. |
rust/ql/test/library-tests/dataflow/barrier/main.rs | Adds trait barrier cases. |
rust/ql/test/library-tests/dataflow/barrier/external_file.rs | Adds an external barrier trait. |
rust/ql/test/library-tests/dataflow/barrier/inline-flow.ext.yml | Defines trait barrier models. |
rust/ql/test/query-tests/security/CWE-798/test_cipher.rs | Enables newly detected expectations. |
rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected | Updates generated query results. |
rust/ql/test/query-tests/security/CWE-327/WeakSensitiveDataHashing/test.rs | Enables trait-based hashing expectations. |
rust/ql/test/query-tests/security/CWE-327/WeakSensitiveDataHashing/WeakSensitiveDataHashing.expected | Updates generated hashing baseline. |
rust/ql/test/query-tests/security/CWE-327/WeakSensitiveDataHashing/CryptographicOperations.expected | Updates generated operation baseline. |
cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll | Adapts C++ to the shared contract. |
csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll | Removes obsolete endpoint bases. |
go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll | Removes obsolete endpoint bases. |
java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll | Removes obsolete endpoint bases. |
javascript/ql/lib/semmle/javascript/dataflow/internal/FlowSummaryPrivate.qll | Removes obsolete endpoint bases. |
python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll | Removes obsolete endpoint bases. |
ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll | Removes obsolete endpoint bases. |
swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll | Removes obsolete endpoint bases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4a7a072 to
2d69fc3CompareUh oh!
There was an error while loading. Please reload this page.


This PR applies the same inheritance logic to source/sink/barrier MaD models for trait functions as for summary models, that is, a model for
<Foo>::barapplies to any function implementing the trait functionfoo, unless an explicit model exists for that particular implementation.In order to ensure that the same prioritization rules apply as for summary models, this logic is defined in the shared library, but currently only Rust and C++ make use of it.
The updated test output shows that we fix some existing FNs, and DCA shows that we both remove some alerts (presumably because we now have more barriers) and we gain some alerts (presumably because we now have more sources and sinks).