Skip to content

Commit e963c69

Browse files
committed
C#: mass enable diff-informed data flow
1 parent 28f3073 commit e963c69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+298
-0
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/Sql.qll

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ private module DapperCommandDefitionMethodCallSqlConfig implements DataFlow::Con
6868
node.asExpr() = mc.getArgumentForName("command")
6969
)
7070
}
71+
72+
predicate observeDiffInformedIncrementalMode() {
73+
// TODO(diff-informed): Manually verify if config can be diff-informed.
74+
// ql/lib/semmle/code/csharp/frameworks/Sql.qll:54: Flow call outside 'select' clause
75+
none()
76+
}
7177
}
7278

7379
private module DapperCommandDefinitionMethodCallSql =

csharp/ql/lib/semmle/code/csharp/frameworks/system/Xml.qll

+6
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ private module SettingsDataFlowConfig implements DataFlow::ConfigSig {
167167
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof XmlReaderSettingsCreation }
168168

169169
predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof XmlReaderSettingsInstance }
170+
171+
predicate observeDiffInformedIncrementalMode() {
172+
// TODO(diff-informed): Manually verify if config can be diff-informed.
173+
// ql/lib/semmle/code/csharp/frameworks/system/Xml.qll:190: Flow call outside 'select' clause
174+
none()
175+
}
170176
}
171177

172178
private module SettingsDataFlow = DataFlow::Global<SettingsDataFlowConfig>;

csharp/ql/lib/semmle/code/csharp/security/cryptography/EncryptionKeyDataFlowQuery.qll

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ private module SymmetricKeyConfig implements DataFlow::ConfigSig {
7070

7171
/** Holds if the node is a key sanitizer. */
7272
predicate isBarrier(DataFlow::Node sanitizer) { sanitizer instanceof KeySanitizer }
73+
74+
predicate observeDiffInformedIncrementalMode() { any() }
7375
}
7476

7577
/**

csharp/ql/lib/semmle/code/csharp/security/cryptography/HardcodedSymmetricEncryptionKey.qll

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ module HardcodedSymmetricEncryptionKey {
8282
succ.asExpr() = mc
8383
)
8484
}
85+
86+
predicate observeDiffInformedIncrementalMode() { any() }
8587
}
8688

8789
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ private module ClearTextStorageConfig implements DataFlow::ConfigSig {
3232
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3333

3434
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
35+
36+
predicate observeDiffInformedIncrementalMode() { any() }
3537
}
3638

3739
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ private module CodeInjectionConfig implements DataFlow::ConfigSig {
3333
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3434

3535
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
36+
37+
predicate observeDiffInformedIncrementalMode() { any() }
3638
}
3739

3840
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module CommandInjectionConfig implements DataFlow::ConfigSig {
4242
* `node` from the data flow graph.
4343
*/
4444
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
45+
46+
predicate observeDiffInformedIncrementalMode() { any() }
4547
}
4648

4749
/**

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

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ 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() {
44+
// TODO(diff-informed): Manually verify if config can be diff-informed.
45+
// ql/src/Security Features/CWE-807/ConditionalBypass.ql:23: Column 5 selects sink.getSensitiveMethodCall
46+
none()
47+
}
4248
}
4349

4450
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ private module ExposureOfPrivateInformationConfig implements DataFlow::ConfigSig
3232
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3333

3434
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
35+
36+
predicate observeDiffInformedIncrementalMode() { any() }
3537
}
3638

3739
/**

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

+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ private module RemoteSourceToExternalApiConfig implements DataFlow::ConfigSig {
7878
predicate isSource(DataFlow::Node source) { source instanceof ActiveThreatModelSource }
7979

8080
predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }
81+
82+
predicate observeDiffInformedIncrementalMode() {
83+
// TODO(diff-informed): Manually verify if config can be diff-informed.
84+
// ql/lib/semmle/code/csharp/security/dataflow/ExternalAPIsQuery.qll:88: Flow call outside 'select' clause
85+
// ql/lib/semmle/code/csharp/security/dataflow/ExternalAPIsQuery.qll:91: Flow call outside 'select' clause
86+
none()
87+
}
8188
}
8289

8390
/** A module for tracking flow from `ActiveThreatModelSource`s to `ExternalApiDataNode`s. */

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

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ module LdapInjectionConfig implements DataFlow::ConfigSig {
4545
* `node` from the data flow graph.
4646
*/
4747
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
48+
49+
predicate observeDiffInformedIncrementalMode() { any() }
4850
}
4951

5052
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ private module LogForgingConfig implements DataFlow::ConfigSig {
3535
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3636

3737
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
38+
39+
predicate observeDiffInformedIncrementalMode() { any() }
3840
}
3941

4042
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ private module MissingXmlValidationConfig implements DataFlow::ConfigSig {
3939
predicate isSink(DataFlow::Node sink) { exists(sink.(Sink).getReason()) }
4040

4141
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
42+
43+
predicate observeDiffInformedIncrementalMode() { any() }
4244
}
4345

4446
/**

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

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ private module ReDoSConfig implements DataFlow::ConfigSig {
3333
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3434

3535
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
36+
37+
predicate observeDiffInformedIncrementalMode() { any() }
3638
}
3739

3840
/**
@@ -77,6 +79,12 @@ private module ExponentialRegexDataFlowConfig implements DataFlow::ConfigSig {
7779
predicate isSource(DataFlow::Node s) { isExponentialRegex(s.asExpr()) }
7880

7981
predicate isSink(DataFlow::Node s) { s.asExpr() = any(RegexOperation c).getPattern() }
82+
83+
predicate observeDiffInformedIncrementalMode() {
84+
// TODO(diff-informed): Manually verify if config can be diff-informed.
85+
// ql/lib/semmle/code/csharp/security/dataflow/ReDoSQuery.qll:92: Flow call outside 'select' clause
86+
none()
87+
}
8088
}
8189

8290
module ExponentialRegexDataFlow = DataFlow::Global<ExponentialRegexDataFlowConfig>;

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

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ private module RegexInjectionConfig implements DataFlow::ConfigSig {
3333
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3434

3535
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
36+
37+
predicate observeDiffInformedIncrementalMode() { any() }
3638
}
3739

3840
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ private module ResourceInjectionConfig implements DataFlow::ConfigSig {
3232
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3333

3434
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
35+
36+
predicate observeDiffInformedIncrementalMode() { any() }
3537
}
3638

3739
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module SqlInjectionConfig implements DataFlow::ConfigSig {
4343
* `node` from the data flow graph.
4444
*/
4545
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
46+
47+
predicate observeDiffInformedIncrementalMode() { any() }
4648
}
4749

4850
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ private module TaintedPathConfig implements DataFlow::ConfigSig {
3535
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3636

3737
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
38+
39+
predicate observeDiffInformedIncrementalMode() { any() }
3840
}
3941

4042
/**

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

+78
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ 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+
// TODO(diff-informed): Manually verify if config can be diff-informed.
65+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:59: Column 1 does not select a source or sink originating from the flow call on line 33
66+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:60: Column 5 does not select a source or sink originating from the flow call on line 33
67+
none()
68+
}
6269
}
6370

6471
/**
@@ -77,6 +84,13 @@ private module JsonConvertTrackingConfig implements DataFlow::ConfigSig {
7784
}
7885

7986
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
87+
88+
predicate observeDiffInformedIncrementalMode() {
89+
// TODO(diff-informed): Manually verify if config can be diff-informed.
90+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:59: Column 1 does not select a source or sink originating from the flow call on line 55
91+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:60: Column 5 does not select a source or sink originating from the flow call on line 55
92+
none()
93+
}
8094
}
8195

8296
/**
@@ -133,6 +147,13 @@ private module TypeNameTrackingConfig implements DataFlow::ConfigSig {
133147
)
134148
)
135149
}
150+
151+
predicate observeDiffInformedIncrementalMode() {
152+
// TODO(diff-informed): Manually verify if config can be diff-informed.
153+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:59: Column 1 does not select a source or sink originating from the flow call on line 56
154+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:60: Column 5 does not select a source or sink originating from the flow call on line 56
155+
none()
156+
}
136157
}
137158

138159
/**
@@ -149,6 +170,13 @@ private module TaintToConstructorOrStaticMethodTrackingConfig implements DataFlo
149170
predicate isSink(DataFlow::Node sink) { sink instanceof ConstructorOrStaticMethodSink }
150171

151172
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
173+
174+
predicate observeDiffInformedIncrementalMode() {
175+
// TODO(diff-informed): Manually verify if config can be diff-informed.
176+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:59: Column 1 does not select a source or sink originating from the flow call on line 50
177+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:60: Column 5 does not select a source or sink originating from the flow call on line 50
178+
none()
179+
}
152180
}
153181

154182
/**
@@ -186,6 +214,13 @@ private module TaintToObjectTypeTrackingConfig implements DataFlow::ConfigSig {
186214
oc.getObjectType() instanceof StrongTypeDeserializer
187215
)
188216
}
217+
218+
predicate observeDiffInformedIncrementalMode() {
219+
// TODO(diff-informed): Manually verify if config can be diff-informed.
220+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:59: Column 1 does not select a source or sink originating from the flow call on line 43
221+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:60: Column 5 does not select a source or sink originating from the flow call on line 43
222+
none()
223+
}
189224
}
190225

191226
/**
@@ -210,6 +245,13 @@ private module WeakTypeCreationToUsageTrackingConfig implements DataFlow::Config
210245
sink.asExpr() = mc.getQualifier()
211246
)
212247
}
248+
249+
predicate observeDiffInformedIncrementalMode() {
250+
// TODO(diff-informed): Manually verify if config can be diff-informed.
251+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:59: Column 1 does not select a source or sink originating from the flow call on line 37
252+
// ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql:60: Column 5 does not select a source or sink originating from the flow call on line 37
253+
none()
254+
}
213255
}
214256

215257
/**
@@ -342,6 +384,12 @@ private module DataContractJsonSafeConstructorTrackingConfig implements DataFlow
342384
mc.getQualifier() = sink.asExpr()
343385
)
344386
}
387+
388+
predicate observeDiffInformedIncrementalMode() {
389+
// TODO(diff-informed): Manually verify if config can be diff-informed.
390+
// ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll:28: Flow call outside 'select' clause
391+
none()
392+
}
345393
}
346394

347395
private module DataContractJsonSafeConstructorTracking =
@@ -389,6 +437,12 @@ private module JavaScriptSerializerSafeConstructorTrackingConfig implements Data
389437
mc.getQualifier() = sink.asExpr()
390438
)
391439
}
440+
441+
predicate observeDiffInformedIncrementalMode() {
442+
// TODO(diff-informed): Manually verify if config can be diff-informed.
443+
// ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll:29: Flow call outside 'select' clause
444+
none()
445+
}
392446
}
393447

394448
private module JavaScriptSerializerSafeConstructorTracking =
@@ -434,6 +488,12 @@ private module XmlObjectSerializerDerivedConstructorTrackingConfig implements Da
434488
mc.getQualifier() = sink.asExpr()
435489
)
436490
}
491+
492+
predicate observeDiffInformedIncrementalMode() {
493+
// TODO(diff-informed): Manually verify if config can be diff-informed.
494+
// ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll:30: Flow call outside 'select' clause
495+
none()
496+
}
437497
}
438498

439499
private module XmlObjectSerializerDerivedConstructorTracking =
@@ -476,6 +536,12 @@ private module XmlSerializerSafeConstructorTrackingConfig implements DataFlow::C
476536
mc.getQualifier() = sink.asExpr()
477537
)
478538
}
539+
540+
predicate observeDiffInformedIncrementalMode() {
541+
// TODO(diff-informed): Manually verify if config can be diff-informed.
542+
// ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll:31: Flow call outside 'select' clause
543+
none()
544+
}
479545
}
480546

481547
private module XmlSerializerSafeConstructorTracking =
@@ -522,6 +588,12 @@ private module DataContractSerializerSafeConstructorTrackingConfig implements Da
522588
mc.getQualifier() = sink.asExpr()
523589
)
524590
}
591+
592+
predicate observeDiffInformedIncrementalMode() {
593+
// TODO(diff-informed): Manually verify if config can be diff-informed.
594+
// ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll:32: Flow call outside 'select' clause
595+
none()
596+
}
525597
}
526598

527599
private module DataContractSerializerSafeConstructorTracking =
@@ -564,6 +636,12 @@ private module XmlMessageFormatterSafeConstructorTrackingConfig implements DataF
564636
mc.getQualifier() = sink.asExpr()
565637
)
566638
}
639+
640+
predicate observeDiffInformedIncrementalMode() {
641+
// TODO(diff-informed): Manually verify if config can be diff-informed.
642+
// ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll:33: Flow call outside 'select' clause
643+
none()
644+
}
567645
}
568646

569647
private module XmlMessageFormatterSafeConstructorTracking =

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

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ private module UrlRedirectConfig implements DataFlow::ConfigSig {
3737
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3838

3939
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
40+
41+
predicate observeDiffInformedIncrementalMode() { any() }
4042
}
4143

4244
/**

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

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module XpathInjectionConfig implements DataFlow::ConfigSig {
4343
* `node` from the data flow graph.
4444
*/
4545
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
46+
47+
predicate observeDiffInformedIncrementalMode() { any() }
4648
}
4749

4850
/**

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

+6
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ module XssTrackingConfig implements DataFlow::ConfigSig {
158158
* `node` from the data flow graph.
159159
*/
160160
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
161+
162+
predicate observeDiffInformedIncrementalMode() {
163+
// TODO(diff-informed): Manually verify if config can be diff-informed.
164+
// ql/lib/semmle/code/csharp/security/dataflow/XSSQuery.qll:22: Flow call outside 'select' clause
165+
none()
166+
}
161167
}
162168

163169
module XssTracking = TaintTracking::Global<XssTrackingConfig>;

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

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ private module ZipSlipConfig implements DataFlow::ConfigSig {
3030
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3131

3232
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
33+
34+
predicate observeDiffInformedIncrementalMode() { any() }
3335
}
3436

3537
/**

0 commit comments

Comments
 (0)