Skip to content

Commit 9de5f5c

Browse files
committed
Rust: Clean up and change note.
1 parent d400713 commit 9de5f5c

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added support for neutral models (`extensible: neutralModel`) to control where generated source, sink and flow summary models apply.

rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ extensible predicate summaryModel(
9090
);
9191

9292
/**
93-
* Holds if a neutral model of kind `kind` exists for the function with canonical path `path`. The
94-
* only effect of a neutral model is to prevent generated and inherited models of the corresponding
95-
* `kind` (`source`, `sink` or `summary`) from being applied.
93+
* Holds if a neutral model exists for the function with canonical path `path`. The only
94+
* effect of a neutral model is to prevent generated and inherited models of the corresponding
95+
* `kind` (`source`, `sink` or `summary`) from being applied to that function.
9696
*/
9797
extensible predicate neutralModel(
9898
string path, string kind, string provenance, QlBuiltins::ExtensionId madId
@@ -148,18 +148,16 @@ private predicate summaryModelRelevant(
148148
summaryModel(f, input, output, kind, provenance, isInherited, madId) and
149149
// Only apply generated or inherited models to functions in library code and
150150
// when no strictly better model (or neutral model) exists
151-
(
152-
if provenance.isGenerated() or isInherited = true
153-
then
154-
not f.fromSource() and
155-
not exists(Provenance other | summaryModel(f, _, _, _, other, false, _) |
156-
provenance.isGenerated() and other.isManual()
157-
or
158-
provenance = other and isInherited = true
159-
) and
160-
not neutralModel(f.getCanonicalPath(), "summary", _, _)
161-
else any()
162-
)
151+
if provenance.isGenerated() or isInherited = true
152+
then
153+
not f.fromSource() and
154+
not exists(Provenance other | summaryModel(f, _, _, _, other, false, _) |
155+
provenance.isGenerated() and other.isManual()
156+
or
157+
provenance = other and isInherited = true
158+
) and
159+
not neutralModel(f.getCanonicalPath(), "summary", _, _)
160+
else any()
163161
}
164162

165163
private class SummarizedCallableFromModel extends SummarizedCallable::Range {

rust/ql/test/library-tests/dataflow/models/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ pub fn neutral_manual_sink(i: i64) {}
430430

431431
fn test_neutrals() {
432432
// neutral models should cause corresponding generated models to be ignored.
433-
// Thus, the `neutral_generated_*` source/sink, which have both a
434-
// generated and a neutral model, should not have flow.
433+
// Thus, the `neutral_generated_source` and `neutral_generated_sink`, which
434+
// have both a generated and a neutral model, should not have flow.
435435

436436
sink(generated_source(1)); // $ hasValueFlow=1
437437
sink(neutral_generated_source(2));

0 commit comments

Comments
 (0)