Skip to content

Commit 91ced7e

Browse files
authored
Merge pull request #20109 from github/copilot/fix-20108
Rust: Remove sourceModelDeprecated, summaryModelDeprecated and sinkModelDeprecated
2 parents 63e5c52 + defd4a1 commit 91ced7e

File tree

4 files changed

+11
-141
lines changed

4 files changed

+11
-141
lines changed

.github/copilot-instructions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@ When reviewing code:
22
* do not review changes in files with `.expected` extension (they are automatically ensured to be correct).
33
* in `.ql` and `.qll` files, do not try to review the code itself as you don't understand the programming language
44
well enough to make comments in these languages. You can still check for typos or comment improvements.
5+
6+
When editing `.ql` and `.qll` files:
7+
* All edited `.ql` and `.qll` files should be autoformatted afterwards using the CodeQL CLI.
8+
* To install and use the CodeQL CLI autoformatter:
9+
1. Download and extract CodeQL CLI: `cd /tmp && curl -L -o codeql-linux64.zip https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql-linux64.zip && unzip -q codeql-linux64.zip`
10+
2. Add to PATH: `export PATH="/tmp/codeql:$PATH"`
11+
3. Run autoformatter: `codeql query format [file] --in-place`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Removed deprecated dataflow extensible predicates `sourceModelDeprecated`, `sinkModelDeprecated`, and `summaryModelDeprecated`, along with their associated classes.

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

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,6 @@ private import codeql.rust.dataflow.FlowSource
4949
private import codeql.rust.dataflow.FlowSink
5050
private import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl
5151

52-
/**
53-
* DEPRECATED: Do not use.
54-
*
55-
* Holds if in a call to the function with canonical path `path`, defined in the
56-
* crate `crate`, the value referred to by `output` is a flow source of the given
57-
* `kind`.
58-
*
59-
* `output = "ReturnValue"` simply means the result of the call itself.
60-
*
61-
* For more information on the `kind` parameter, see
62-
* https://github.com/github/codeql/blob/main/docs/codeql/reusables/threat-model-description.rst.
63-
*/
64-
extensible predicate sourceModelDeprecated(
65-
string crate, string path, string output, string kind, string provenance,
66-
QlBuiltins::ExtensionId madId
67-
);
68-
6952
/**
7053
* Holds if in a call to the function with canonical path `path`, the value referred
7154
* to by `output` is a flow source of the given `kind`.
@@ -79,24 +62,6 @@ extensible predicate sourceModel(
7962
string path, string output, string kind, string provenance, QlBuiltins::ExtensionId madId
8063
);
8164

82-
/**
83-
* DEPRECATED: Do not use.
84-
*
85-
* Holds if in a call to the function with canonical path `path`, defined in the
86-
* crate `crate`, the value referred to by `input` is a flow sink of the given
87-
* `kind`.
88-
*
89-
* For example, `input = Argument[0]` means the first argument of the call.
90-
*
91-
* The following kinds are supported:
92-
*
93-
* - `sql-injection`: a flow sink for SQL injection.
94-
*/
95-
extensible predicate sinkModelDeprecated(
96-
string crate, string path, string input, string kind, string provenance,
97-
QlBuiltins::ExtensionId madId
98-
);
99-
10065
/**
10166
* Holds if in a call to the function with canonical path `path`, the value referred
10267
* to by `input` is a flow sink of the given `kind`.
@@ -111,21 +76,6 @@ extensible predicate sinkModel(
11176
string path, string input, string kind, string provenance, QlBuiltins::ExtensionId madId
11277
);
11378

114-
/**
115-
* DEPRECATED: Do not use.
116-
*
117-
* Holds if in a call to the function with canonical path `path`, defined in the
118-
* crate `crate`, the value referred to by `input` can flow to the value referred
119-
* to by `output`.
120-
*
121-
* `kind` should be either `value` or `taint`, for value-preserving or taint-preserving
122-
* steps, respectively.
123-
*/
124-
extensible predicate summaryModelDeprecated(
125-
string crate, string path, string input, string output, string kind, string provenance,
126-
QlBuiltins::ExtensionId madId
127-
);
128-
12979
/**
13080
* Holds if in a call to the function with canonical path `path`, the value referred
13181
* to by `input` can flow to the value referred to by `output`.
@@ -144,67 +94,22 @@ extensible predicate summaryModel(
14494
* This predicate should only be used in tests.
14595
*/
14696
predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
147-
exists(string crate, string path, string output, string kind |
148-
sourceModelDeprecated(crate, path, output, kind, _, madId) and
149-
model = "Source: " + crate + "; " + path + "; " + output + "; " + kind
150-
)
151-
or
15297
exists(string path, string output, string kind |
15398
sourceModel(path, output, kind, _, madId) and
15499
model = "Source: " + path + "; " + output + "; " + kind
155100
)
156101
or
157-
exists(string crate, string path, string input, string kind |
158-
sinkModelDeprecated(crate, path, input, kind, _, madId) and
159-
model = "Sink: " + crate + "; " + path + "; " + input + "; " + kind
160-
)
161-
or
162102
exists(string path, string input, string kind |
163103
sinkModel(path, input, kind, _, madId) and
164104
model = "Sink: " + path + "; " + input + "; " + kind
165105
)
166106
or
167-
exists(string type, string path, string input, string output, string kind |
168-
summaryModelDeprecated(type, path, input, output, kind, _, madId) and
169-
model = "Summary: " + type + "; " + path + "; " + input + "; " + output + "; " + kind
170-
)
171-
or
172107
exists(string path, string input, string output, string kind |
173108
summaryModel(path, input, output, kind, _, madId) and
174109
model = "Summary: " + path + "; " + input + "; " + output + "; " + kind
175110
)
176111
}
177112

178-
private class SummarizedCallableFromModelDeprecated extends SummarizedCallable::Range {
179-
private string crate;
180-
private string path;
181-
182-
SummarizedCallableFromModelDeprecated() {
183-
summaryModelDeprecated(crate, path, _, _, _, _, _) and
184-
exists(CallExprBase call, Resolvable r |
185-
call.getStaticTarget() = this and
186-
r = CallExprBaseImpl::getCallResolvable(call) and
187-
r.getResolvedPath() = path and
188-
r.getResolvedCrateOrigin() = crate
189-
)
190-
}
191-
192-
override predicate propagatesFlow(
193-
string input, string output, boolean preservesValue, string model
194-
) {
195-
exists(string kind, QlBuiltins::ExtensionId madId |
196-
summaryModelDeprecated(crate, path, input, output, kind, _, madId) and
197-
model = "MaD:" + madId.toString()
198-
|
199-
kind = "value" and
200-
preservesValue = true
201-
or
202-
kind = "taint" and
203-
preservesValue = false
204-
)
205-
}
206-
}
207-
208113
private class SummarizedCallableFromModel extends SummarizedCallable::Range {
209114
private string path;
210115

@@ -233,23 +138,6 @@ private class SummarizedCallableFromModel extends SummarizedCallable::Range {
233138
}
234139
}
235140

236-
private class FlowSourceFromModelDeprecated extends FlowSource::Range {
237-
private string crate;
238-
private string path;
239-
240-
FlowSourceFromModelDeprecated() {
241-
sourceModelDeprecated(crate, path, _, _, _, _) and
242-
this.callResolvesTo(crate, path)
243-
}
244-
245-
override predicate isSource(string output, string kind, Provenance provenance, string model) {
246-
exists(QlBuiltins::ExtensionId madId |
247-
sourceModelDeprecated(crate, path, output, kind, provenance, madId) and
248-
model = "MaD:" + madId.toString()
249-
)
250-
}
251-
}
252-
253141
private class FlowSourceFromModel extends FlowSource::Range {
254142
private string path;
255143

@@ -266,23 +154,6 @@ private class FlowSourceFromModel extends FlowSource::Range {
266154
}
267155
}
268156

269-
private class FlowSinkFromModelDeprecated extends FlowSink::Range {
270-
private string crate;
271-
private string path;
272-
273-
FlowSinkFromModelDeprecated() {
274-
sinkModelDeprecated(crate, path, _, _, _, _) and
275-
this.callResolvesTo(crate, path)
276-
}
277-
278-
override predicate isSink(string input, string kind, Provenance provenance, string model) {
279-
exists(QlBuiltins::ExtensionId madId |
280-
sinkModelDeprecated(crate, path, input, kind, provenance, madId) and
281-
model = "MaD:" + madId.toString()
282-
)
283-
}
284-
}
285-
286157
private class FlowSinkFromModel extends FlowSink::Range {
287158
private string path;
288159

rust/ql/lib/codeql/rust/dataflow/internal/empty.model.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
extensions:
22
# Make sure that the extensible model predicates have at least one definition
33
# to avoid errors about undefined extensionals.
4-
- addsTo:
5-
pack: codeql/rust-all
6-
extensible: sourceModelDeprecated
7-
data: []
84
- addsTo:
95
pack: codeql/rust-all
106
extensible: sourceModel
117
data: []
128

13-
- addsTo:
14-
pack: codeql/rust-all
15-
extensible: sinkModelDeprecated
16-
data: []
179
- addsTo:
1810
pack: codeql/rust-all
1911
extensible: sinkModel
2012
data: []
2113

22-
- addsTo:
23-
pack: codeql/rust-all
24-
extensible: summaryModelDeprecated
25-
data: []
2614
- addsTo:
2715
pack: codeql/rust-all
2816
extensible: summaryModel

0 commit comments

Comments
 (0)