Skip to content

Commit a0b533b

Browse files
authored
Merge pull request #20529 from geoffw0/convert
Rust: Correct from model to taint
2 parents ba07daa + 1635ef9 commit a0b533b

File tree

6 files changed

+80
-90
lines changed

6 files changed

+80
-90
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extensions:
1212
- ["<alloc::string::String as core::convert::Into>::into", "Argument[self].Element", "ReturnValue.Element", "taint", "manual"]
1313
- ["<alloc::string::String as core::convert::Into>::into", "Argument[self].Reference.Element", "ReturnValue.Element", "taint", "manual"]
1414
# From
15-
- ["<_ as core::convert::From>::from", "Argument[0]", "ReturnValue", "value", "manual"]
15+
- ["<_ as core::convert::From>::from", "Argument[0]", "ReturnValue", "taint", "manual"]
1616
# Iterator
1717
- ["<core::result::Result>::iter", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]
1818
- ["<alloc::vec::Vec as value_trait::array::Array>::iter", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]

rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ module HardcodedCryptographicValue {
6969
/**
7070
* An array initialized from a list of literals, considered as a single flow source. For example:
7171
* ```
72-
* `[0, 0, 0, 0]`
72+
* [0, 0, 0, 0]
73+
* [0; 10]
7374
* ```
7475
*/
7576
private class ArrayListSource extends Source {
76-
ArrayListSource() { this.asExpr().getExpr().(ArrayListExpr).getExpr(_) instanceof LiteralExpr }
77+
ArrayListSource() {
78+
this.asExpr().getExpr().(ArrayListExpr).getExpr(_) instanceof LiteralExpr or
79+
this.asExpr().getExpr().(ArrayRepeatExpr).getRepeatOperand() instanceof LiteralExpr
80+
}
7781
}
7882

7983
/**

rust/ql/test/library-tests/dataflow/strings/inline-taint-flow.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
models
2-
| 1 | Summary: <_ as core::convert::From>::from; Argument[0]; ReturnValue; value |
2+
| 1 | Summary: <_ as core::convert::From>::from; Argument[0]; ReturnValue; taint |
33
| 2 | Summary: <alloc::string::String as core::convert::From>::from; Argument[0].Reference; ReturnValue; value |
44
| 3 | Summary: <alloc::string::String as core::ops::arith::Add>::add; Argument[self]; ReturnValue; value |
55
| 4 | Summary: <alloc::string::String>::as_str; Argument[self]; ReturnValue; value |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn string_add_reference() {
5050
fn string_from() {
5151
let s1 = source_slice(36);
5252
let s2 = String::from(s1);
53-
sink(s2); // $ hasValueFlow=36
53+
sink(s2); // $ hasTaintFlow=36
5454
}
5555

5656
fn string_to_string() {

rust/ql/test/query-tests/security/CWE-022/TaintedPath.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ models
123123
| 6 | Sink: std::fs::read_to_string; Argument[0]; path-injection |
124124
| 7 | Source: std::env::args; ReturnValue.Element; commandargs |
125125
| 8 | Summary: <_ as core::clone::Clone>::clone; Argument[self].Reference; ReturnValue; value |
126-
| 9 | Summary: <_ as core::convert::From>::from; Argument[0]; ReturnValue; value |
126+
| 9 | Summary: <_ as core::convert::From>::from; Argument[0]; ReturnValue; taint |
127127
| 10 | Summary: <_ as core::iter::traits::iterator::Iterator>::nth; Argument[self].Element; ReturnValue.Field[core::option::Option::Some(0)]; value |
128128
| 11 | Summary: <core::option::Option>::unwrap; Argument[self].Field[core::option::Option::Some(0)]; ReturnValue; value |
129129
| 12 | Summary: <core::result::Result>::unwrap; Argument[self].Field[core::result::Result::Ok(0)]; ReturnValue; value |

0 commit comments

Comments
 (0)