Skip to content

Commit 519f0d2

Browse files
authored
Merge pull request #21023 from paldepind/rust/regenerate-models-1212
Rust: Regenerate models
2 parents 6c4a0bb + 76a1e22 commit 519f0d2

31 files changed

+9791
-5995
lines changed

rust/bulk_generation_targets.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ targets:
1919
- name: serde
2020
- name: tokio
2121
- name: reqwest
22-
- name: rocket
22+
# Disabled due to performance issue
23+
# - name: rocket
2324
- name: actix-web
2425
- name: hyper
2526
- name: clap

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,11 @@ predicate indexAssignment(
306306
not index.getResolvedTarget().fromSource()
307307
}
308308

309-
module RustDataFlow implements InputSig<Location> {
309+
signature module RustDataFlowInputSig {
310+
predicate includeDynamicTargets();
311+
}
312+
313+
module RustDataFlowGen<RustDataFlowInputSig Input> implements InputSig<Location> {
310314
private import Aliases
311315
private import codeql.rust.dataflow.DataFlow
312316
private import Node as Node
@@ -462,7 +466,11 @@ module RustDataFlow implements InputSig<Location> {
462466
/** Gets a viable implementation of the target of the given `Call`. */
463467
DataFlowCallable viableCallable(DataFlowCall call) {
464468
exists(Call c | c = call.asCall() |
465-
result.asCfgScope() = c.getARuntimeTarget()
469+
(
470+
if Input::includeDynamicTargets()
471+
then result.asCfgScope() = c.getARuntimeTarget()
472+
else result.asCfgScope() = c.getStaticTarget()
473+
)
466474
or
467475
result.asSummarizedCallable() = getStaticTargetExt(c)
468476
)
@@ -935,6 +943,12 @@ module RustDataFlow implements InputSig<Location> {
935943
class DataFlowSecondLevelScope = Void;
936944
}
937945

946+
module RustDataFlowInput implements RustDataFlowInputSig {
947+
predicate includeDynamicTargets() { any() }
948+
}
949+
950+
module RustDataFlow = RustDataFlowGen<RustDataFlowInput>;
951+
938952
/** Provides logic related to captured variables. */
939953
module VariableCapture {
940954
private import codeql.rust.internal.CachedStages
@@ -1110,7 +1124,7 @@ private module Cached {
11101124
}
11111125

11121126
cached
1113-
newtype TParameterPosition =
1127+
newtype TParameterPositionImpl =
11141128
TPositionalParameterPosition(int i) {
11151129
i in [0 .. max([any(ParamList l).getNumberOfParams(), any(ArgList l).getNumberOfArgs()]) - 1]
11161130
or
@@ -1121,6 +1135,8 @@ private module Cached {
11211135
TClosureSelfParameterPosition() or
11221136
TSelfParameterPosition()
11231137

1138+
final class TParameterPosition = TParameterPositionImpl;
1139+
11241140
cached
11251141
newtype TReturnKind = TNormalReturnKind()
11261142

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
private import rust
2+
private import codeql.dataflow.DataFlow as DF
23
private import codeql.dataflow.TaintTracking
3-
private import codeql.rust.dataflow.DataFlow
4+
private import codeql.rust.dataflow.DataFlow as RustDataFlow
45
private import codeql.rust.dataflow.FlowSummary
5-
private import DataFlowImpl
6+
private import DataFlowImpl as DataFlowImpl
67
private import Node as Node
78
private import Content
89
private import FlowSummaryImpl as FlowSummaryImpl
@@ -29,7 +30,11 @@ private predicate excludedTaintStepContent(Content c) {
2930
)
3031
}
3132

32-
module RustTaintTracking implements InputSig<Location, RustDataFlow> {
33+
module RustTaintTrackingGen<DataFlowImpl::RustDataFlowInputSig I> implements
34+
InputSig<Location, DataFlowImpl::RustDataFlowGen<I>>
35+
{
36+
private module DataFlow = DataFlowImpl::RustDataFlowGen<I>;
37+
3338
predicate defaultTaintSanitizer(DataFlow::Node node) { none() }
3439

3540
/**
@@ -53,7 +58,7 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
5358
// is tainted and an operation reads from `foo` (e.g., `foo.bar`) then
5459
// taint is propagated.
5560
exists(ContentSet cs |
56-
RustDataFlow::readStep(pred, cs, succ) and
61+
DataFlow::readStep(pred, cs, succ) and
5762
not excludedTaintStepContent(cs.getAReadContent())
5863
)
5964
or
@@ -70,9 +75,11 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
7075
)
7176
or
7277
succ.(Node::PostUpdateNode).getPreUpdateNode().asExpr() =
73-
getPostUpdateReverseStep(pred.(Node::PostUpdateNode).getPreUpdateNode().asExpr(), false)
78+
DataFlowImpl::getPostUpdateReverseStep(pred.(Node::PostUpdateNode)
79+
.getPreUpdateNode()
80+
.asExpr(), false)
7481
or
75-
indexAssignment(any(CompoundAssignmentExpr cae),
82+
DataFlowImpl::indexAssignment(any(CompoundAssignmentExpr cae),
7683
pred.(Node::PostUpdateNode).getPreUpdateNode().asExpr(), _, succ, _)
7784
)
7885
or
@@ -92,7 +99,7 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
9299
c instanceof ReferenceContent
93100
) and
94101
// Optional steps are added through isAdditionalFlowStep but we don't want the implicit reads
95-
not optionalStep(node, _, _)
102+
not DataFlowImpl::optionalStep(node, _, _)
96103
}
97104

98105
/**
@@ -101,3 +108,5 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
101108
*/
102109
predicate speculativeTaintStep(DataFlow::Node src, DataFlow::Node sink) { none() }
103110
}
111+
112+
module RustTaintTracking = RustTaintTrackingGen<DataFlowImpl::RustDataFlowInput>;

rust/ql/lib/codeql/rust/frameworks/reqwest.model.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ extensions:
2929
- ["<reqwest::async_impl::response::Response>::text", "Argument[self]", "ReturnValue.Future.Field[core::result::Result::Ok(0)]", "taint", "manual"]
3030
- ["<reqwest::async_impl::response::Response>::bytes", "Argument[self]", "ReturnValue.Future.Field[core::result::Result::Ok(0)]", "taint", "manual"]
3131
- ["<reqwest::async_impl::response::Response>::chunk", "Argument[self].Reference", "ReturnValue.Future.Field[core::result::Result::Ok(0)].Field[core::option::Option::Some(0)]", "taint", "manual"]
32+
- addsTo:
33+
pack: codeql/rust-all
34+
extensible: excludeFieldTaintStep
35+
data:
36+
- ["reqwest::blocking::response::Response::timeout"]

rust/ql/lib/codeql/rust/frameworks/stdlib/fs.model.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ extensions:
6363
- ["<std::path::Path>::new", "Argument[0].Reference", "ReturnValue.Reference", "value", "manual"]
6464
- ["<std::path::Path>::join", "Argument[self].Reference", "ReturnValue", "taint", "manual"]
6565
- ["<std::path::Path>::join", "Argument[0]", "ReturnValue", "taint", "manual"]
66-
- ["<std::path::Path>::as_os_str", "Argument[self].Reference.Field[std::path::Path::inner]", "ReturnValue.Reference", "value", "manual"]
67-
- ["<std::path::Path>::as_mut_os_str", "Argument[self].Reference.Field[std::path::Path::inner]", "ReturnValue.Reference", "value", "manual"]
6866
- ["<std::path::Path>::canonicalize", "Argument[self].Reference.OptionalStep[normalize-path]", "ReturnValue.Field[core::result::Result::Ok(0)]", "taint", "manual"]
6967
- ["<std::path::Path>::canonicalize", "Argument[self].Reference.OptionalBarrier[normalize-path]", "ReturnValue.Field[core::result::Result::Ok(0)]", "taint", "manual"]
7068
- ["<std::path::Path>::extension", "Argument[self].Reference", "ReturnValue.Field[core::option::Option::Some(0)].Reference", "taint", "manual"]

0 commit comments

Comments
 (0)