Skip to content

Commit cc5179a

Browse files
authored
Merge pull request #18787 from paldepind/rust-core-std-models
Rust: Add generated models for standard libraries including core
2 parents ff36d19 + 26a96d9 commit cc5179a

File tree

19 files changed

+5686
-1092
lines changed

19 files changed

+5686
-1092
lines changed

rust/ql/integration-tests/hello-project/summary.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| Macro calls - resolved | 2 |
1515
| Macro calls - total | 2 |
1616
| Macro calls - unresolved | 0 |
17-
| Taint edges - number of edges | 10 |
17+
| Taint edges - number of edges | 1471 |
1818
| Taint reach - nodes tainted | 0 |
1919
| Taint reach - per million nodes | 0 |
2020
| Taint sinks - cryptographic operations | 0 |

rust/ql/integration-tests/hello-workspace/summary.cargo.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| Macro calls - resolved | 2 |
1515
| Macro calls - total | 2 |
1616
| Macro calls - unresolved | 0 |
17-
| Taint edges - number of edges | 10 |
17+
| Taint edges - number of edges | 1471 |
1818
| Taint reach - nodes tainted | 0 |
1919
| Taint reach - per million nodes | 0 |
2020
| Taint sinks - cryptographic operations | 0 |

rust/ql/integration-tests/hello-workspace/summary.rust-project.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| Macro calls - resolved | 2 |
1515
| Macro calls - total | 2 |
1616
| Macro calls - unresolved | 0 |
17-
| Taint edges - number of edges | 10 |
17+
| Taint edges - number of edges | 1471 |
1818
| Taint reach - nodes tainted | 0 |
1919
| Taint reach - per million nodes | 0 |
2020
| Taint sinks - cryptographic operations | 0 |

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

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ private module Input implements InputSig<Location, RustDataFlow> {
1111
not exists(n.asExpr().getLocation())
1212
}
1313

14+
predicate postWithInFlowExclude(RustDataFlow::Node n) { n instanceof Node::FlowSummaryNode }
15+
1416
predicate missingLocationExclude(RustDataFlow::Node n) { not exists(n.asExpr().getLocation()) }
1517
}
1618

rust/ql/lib/codeql/rust/frameworks/stdlib/Clone.qll

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ final class CloneCallable extends SummarizedCallable::Range {
1515
)
1616
}
1717

18-
final override predicate propagatesFlow(string input, string output, boolean preservesValue) {
19-
input = "Argument[self]" and output = "ReturnValue" and preservesValue = true
18+
final override predicate propagatesFlow(
19+
string input, string output, boolean preservesValue, string model
20+
) {
21+
input = "Argument[self]" and
22+
output = "ReturnValue" and
23+
preservesValue = true and
24+
model = "generated"
2025
}
2126
}

rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml

-16
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ extensions:
55
data:
66
# Fmt
77
- ["lang:alloc", "crate::fmt::format", "Argument[0]", "ReturnValue", "taint", "manual"]
8-
# Hint
9-
- ["lang:core", "crate::hint::must_use", "Argument[0]", "ReturnValue", "value", "manual"]
108
# Iterator
119
- ["lang:core", "<[_]>::iter", "Argument[Self].Element", "ReturnValue.Element", "value", "manual"]
1210
- ["lang:core", "<[_]>::iter_mut", "Argument[Self].Element", "ReturnValue.Element", "value", "manual"]
@@ -21,20 +19,6 @@ extensions:
2119
- ["lang:core", "<crate::slice::iter::Iter as crate::iter::traits::iterator::Iterator>::collect", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]
2220
- ["lang:core", "<crate::slice::iter::Iter as crate::iter::traits::iterator::Iterator>::map", "Argument[self].Element", "Argument[0].Parameter[0]", "value", "manual"]
2321
- ["lang:core", "<crate::slice::iter::Iter as crate::iter::traits::iterator::Iterator>::for_each", "Argument[self].Element", "Argument[0].Parameter[0]", "value", "manual"]
24-
# Option
25-
- ["lang:core", "<crate::option::Option>::expect", "Argument[self].Field[crate::option::Option::Some(0)]", "ReturnValue", "value", "manual"]
26-
# Result
27-
- ["lang:core", "<crate::result::Result>::unwrap", "Argument[self].Field[crate::result::Result::Ok(0)]", "ReturnValue", "value", "manual"]
28-
- ["lang:core", "<crate::result::Result>::unwrap_or", "Argument[self].Field[crate::result::Result::Ok(0)]", "ReturnValue", "value", "manual"]
29-
- ["lang:core", "<crate::result::Result>::unwrap_or", "Argument[0]", "ReturnValue", "value", "manual"]
30-
- ["lang:core", "<crate::result::Result>::unwrap_or_default", "Argument[self].Field[crate::result::Result::Ok(0)]", "ReturnValue", "value", "manual"]
31-
- ["lang:core", "<crate::result::Result>::unwrap_or_else", "Argument[self].Field[crate::result::Result::Ok(0)]", "ReturnValue", "value", "manual"]
32-
- ["lang:core", "<crate::result::Result>::unwrap_or_else", "Argument[0].ReturnValue", "ReturnValue", "value", "manual"]
33-
- ["lang:core", "<crate::result::Result>::unwrap_unchecked", "Argument[self].Field[crate::result::Result::Ok(0)]", "ReturnValue", "value", "manual"]
34-
- ["lang:core", "<crate::result::Result>::unwrap_err", "Argument[self].Field[crate::result::Result::Err(0)]", "ReturnValue", "value", "manual"]
35-
- ["lang:core", "<crate::result::Result>::unwrap_err_unchecked", "Argument[self].Field[crate::result::Result::Err(0)]", "ReturnValue", "value", "manual"]
36-
- ["lang:core", "<crate::result::Result>::expect", "Argument[self].Field[crate::result::Result::Ok(0)]", "ReturnValue", "value", "manual"]
37-
- ["lang:core", "<crate::result::Result>::expect_err", "Argument[self].Field[crate::result::Result::Err(0)]", "ReturnValue", "value", "manual"]
3822
# Str
3923
- ["lang:core", "<str>::parse", "Argument[self]", "ReturnValue.Field[crate::result::Result::Ok(0)]", "taint", "manual"]
4024
# String

rust/ql/lib/ext/generated/option/lang__core.model.yml

-65
This file was deleted.

0 commit comments

Comments
 (0)