Skip to content

Commit 8000e7c

Browse files
authored
Merge pull request #20074 from d10c/d10c/diff-informed-phase-3-csharp
C#: Diff-informed queries: phase 3 (non-trivial locations)
2 parents ec605b2 + 218fcbb commit 8000e7c

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

csharp/ql/lib/semmle/code/csharp/security/dataflow/ConditionalBypassQuery.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ private module ConditionalBypassConfig implements DataFlow::ConfigSig {
3939
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
4040

4141
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
42+
43+
predicate observeDiffInformedIncrementalMode() { any() }
44+
45+
Location getASelectedSinkLocation(DataFlow::Node sink) {
46+
result = sink.getLocation()
47+
or
48+
// from ConditionalBypass.ql
49+
result = sink.(Sink).getSensitiveMethodCall().getLocation()
50+
}
4251
}
4352

4453
/**

csharp/ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ private module TaintToObjectMethodTrackingConfig implements DataFlow::ConfigSig
5959
predicate isSink(DataFlow::Node sink) { sink instanceof InstanceMethodSink }
6060

6161
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
62+
63+
predicate observeDiffInformedIncrementalMode() {
64+
any() // used in one of the disjuncts in UnsafeDeserializationUntrustedInput.ql
65+
}
6266
}
6367

6468
/**
@@ -77,6 +81,10 @@ private module JsonConvertTrackingConfig implements DataFlow::ConfigSig {
7781
}
7882

7983
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
84+
85+
predicate observeDiffInformedIncrementalMode() {
86+
any() // used in one of the disjuncts in UnsafeDeserializationUntrustedInput.ql
87+
}
8088
}
8189

8290
/**
@@ -133,6 +141,10 @@ private module TypeNameTrackingConfig implements DataFlow::ConfigSig {
133141
)
134142
)
135143
}
144+
145+
predicate observeDiffInformedIncrementalMode() {
146+
none() // Only used as secondary config in UnsafeDeserializationUntrustedInput.ql
147+
}
136148
}
137149

138150
/**
@@ -149,6 +161,10 @@ private module TaintToConstructorOrStaticMethodTrackingConfig implements DataFlo
149161
predicate isSink(DataFlow::Node sink) { sink instanceof ConstructorOrStaticMethodSink }
150162

151163
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
164+
165+
predicate observeDiffInformedIncrementalMode() {
166+
any() // used in one of the disjuncts in UnsafeDeserializationUntrustedInput.ql
167+
}
152168
}
153169

154170
/**
@@ -186,6 +202,10 @@ private module TaintToObjectTypeTrackingConfig implements DataFlow::ConfigSig {
186202
oc.getObjectType() instanceof StrongTypeDeserializer
187203
)
188204
}
205+
206+
predicate observeDiffInformedIncrementalMode() {
207+
none() // only used as secondary config in UnsafeDeserializationUntrustedInput.ql
208+
}
189209
}
190210

191211
/**
@@ -210,6 +230,10 @@ private module WeakTypeCreationToUsageTrackingConfig implements DataFlow::Config
210230
sink.asExpr() = mc.getQualifier()
211231
)
212232
}
233+
234+
predicate observeDiffInformedIncrementalMode() {
235+
none() // only used as secondary config in UnsafeDeserializationUntrustedInput.ql
236+
}
213237
}
214238

215239
/**

csharp/ql/src/Likely Bugs/ThreadUnsafeICryptoTransformLambda.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ module NotThreadSafeCryptoUsageIntoParallelInvokeConfig implements DataFlow::Con
2424
}
2525

2626
predicate isSink(DataFlow::Node sink) { sink instanceof ParallelSink }
27+
28+
predicate observeDiffInformedIncrementalMode() { any() }
2729
}
2830

2931
module NotThreadSafeCryptoUsageIntoParallelInvoke =

csharp/ql/src/Security Features/CWE-798/HardcodedConnectionString.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ module ConnectionStringConfig implements DataFlow::ConfigSig {
3838
}
3939

4040
predicate isBarrier(DataFlow::Node node) { node instanceof StringFormatSanitizer }
41+
42+
predicate observeDiffInformedIncrementalMode() { any() }
43+
44+
Location getASelectedSinkLocation(DataFlow::Node sink) {
45+
any(Call call | call.getAnArgument() = sink.asExpr()).getLocation() = result
46+
}
4147
}
4248

4349
/**

0 commit comments

Comments
 (0)