Skip to content

Commit e233501

Browse files
committed
Go: mass enable diff-informed data flow
An auto-generated patch that enables diff-informed data flow in the obvious cases. Builds on #18345 and github/codeql-patch#88
1 parent 31770ed commit e233501

30 files changed

+62
-0
lines changed

go/ql/lib/semmle/go/security/CleartextLogging.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ module CleartextLogging {
4646
// Also exclude protobuf field fetches, since they amount to single field reads.
4747
not any(Protobuf::GetMethod gm).taintStep(src, trg)
4848
}
49+
50+
predicate observeDiffInformedIncrementalMode() { any() }
4951
}
5052

5153
/**

go/ql/lib/semmle/go/security/ExternalAPIs.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ private module UntrustedDataToUnknownExternalApiConfig implements DataFlow::Conf
197197
predicate isSource(DataFlow::Node source) { source instanceof ActiveThreatModelSource }
198198

199199
predicate isSink(DataFlow::Node sink) { sink instanceof UnknownExternalApiDataNode }
200+
201+
predicate observeDiffInformedIncrementalMode() { any() }
200202
}
201203

202204
/**

go/ql/lib/semmle/go/security/LogInjection.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module LogInjection {
2121
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
2222

2323
predicate isBarrier(DataFlow::Node sanitizer) { sanitizer instanceof Sanitizer }
24+
25+
predicate observeDiffInformedIncrementalMode() { any() }
2426
}
2527

2628
/** Tracks taint flow for reasoning about log injection vulnerabilities. */

go/ql/lib/semmle/go/security/MissingJwtSignatureCheck.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ module MissingJwtSignatureCheck {
2323
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
2424
any(AdditionalFlowStep s).step(nodeFrom, nodeTo)
2525
}
26+
27+
predicate observeDiffInformedIncrementalMode() { any() }
2628
}
2729

2830
/** Tracks taint flow for reasoning about JWT vulnerabilities. */

go/ql/lib/semmle/go/security/OpenUrlRedirect.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ module OpenUrlRedirect {
5454
or
5555
hostnameSanitizingPrefixEdge(node, _)
5656
}
57+
58+
predicate observeDiffInformedIncrementalMode() { any() }
5759
}
5860

5961
/** Tracks taint flow from unvalidated, untrusted data to URL redirections. */

go/ql/lib/semmle/go/security/SqlInjection.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ module SqlInjection {
2323
}
2424

2525
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
26+
27+
predicate observeDiffInformedIncrementalMode() { any() }
2628
}
2729

2830
/** Tracks taint flow for reasoning about SQL-injection vulnerabilities. */

go/ql/lib/semmle/go/security/StoredCommand.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module StoredCommand {
2626
predicate isSink(DataFlow::Node sink) { sink instanceof CommandInjection::Sink }
2727

2828
predicate isBarrier(DataFlow::Node node) { node instanceof CommandInjection::Sanitizer }
29+
30+
predicate observeDiffInformedIncrementalMode() { any() }
2931
}
3032

3133
/** Tracks taint flow for reasoning about command-injection vulnerabilities. */

go/ql/lib/semmle/go/security/StoredXss.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ module StoredXss {
2222
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
2323

2424
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
25+
26+
predicate observeDiffInformedIncrementalMode() { any() }
2527
}
2628

2729
/** Tracks taint flow for reasoning about XSS. */

go/ql/lib/semmle/go/security/StringBreak.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module StringBreak {
2626
predicate isBarrier(DataFlow::Node node, FlowState state) {
2727
state = node.(Sanitizer).getQuote()
2828
}
29+
30+
predicate observeDiffInformedIncrementalMode() { any() }
2931
}
3032

3133
/**

go/ql/lib/semmle/go/security/TaintedPath.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module TaintedPath {
1717
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
1818

1919
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
20+
21+
predicate observeDiffInformedIncrementalMode() { any() }
2022
}
2123

2224
/** Tracks taint flow for reasoning about path-traversal vulnerabilities. */

go/ql/lib/semmle/go/security/UncontrolledAllocationSize.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module UncontrolledAllocationSize {
2727
node2 = cn.getResult(0)
2828
)
2929
}
30+
31+
predicate observeDiffInformedIncrementalMode() { any() }
3032
}
3133

3234
/** Tracks taint flow for reasoning about uncontrolled allocation size issues. */

go/ql/lib/semmle/go/security/UnsafeUnzipSymlink.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ module UnsafeUnzipSymlink {
4444
predicate isSink(DataFlow::Node sink) { sink instanceof SymlinkSink }
4545

4646
predicate isBarrier(DataFlow::Node node) { node instanceof SymlinkSanitizer }
47+
48+
predicate observeDiffInformedIncrementalMode() { any() }
4749
}
4850

4951
/**

go/ql/lib/semmle/go/security/XPathInjection.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ module XPathInjection {
1919
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
2020

2121
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
22+
23+
predicate observeDiffInformedIncrementalMode() { any() }
2224
}
2325

2426
/**

go/ql/lib/semmle/go/security/ZipSlip.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module ZipSlip {
1717
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
1818

1919
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
20+
21+
predicate observeDiffInformedIncrementalMode() { any() }
2022
}
2123

2224
/** Tracks taint flow for reasoning about zip-slip vulnerabilities. */

go/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ module IncompleteHostNameRegexpConfig implements DataFlow::ConfigSig {
103103
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104104
StringOps::Concatenation::taintStep(node1, node2)
105105
}
106+
107+
predicate observeDiffInformedIncrementalMode() { any() }
106108
}
107109

108110
module Flow = DataFlow::Global<IncompleteHostNameRegexpConfig>;

go/ql/src/Security/CWE-020/MissingRegexpAnchor.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ module Config implements DataFlow::ConfigSig {
7272
predicate isSource(DataFlow::Node source) { isSourceString(source, _) }
7373

7474
predicate isSink(DataFlow::Node sink) { sink instanceof RegexpPattern }
75+
76+
predicate observeDiffInformedIncrementalMode() { any() }
7577
}
7678

7779
module Flow = DataFlow::Global<Config>;

go/ql/src/Security/CWE-020/SuspiciousCharacterInRegexp.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ module SuspiciousCharacterInRegexpConfig implements DataFlow::ConfigSig {
4040
predicate isSource(DataFlow::Node source) { isSourceString(source, _) }
4141

4242
predicate isSink(DataFlow::Node sink) { sink instanceof RegexpPattern }
43+
44+
predicate observeDiffInformedIncrementalMode() { any() }
4345
}
4446

4547
/**

go/ql/src/Security/CWE-209/StackTraceExposure.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ module StackTraceExposureConfig implements DataFlow::ConfigSig {
6262
cgn.dominates(node.getBasicBlock())
6363
)
6464
}
65+
66+
predicate observeDiffInformedIncrementalMode() { any() }
6567
}
6668

6769
/**

go/ql/src/Security/CWE-326/InsufficientKeySize.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ module Config implements DataFlow::ConfigSig {
2525
predicate isBarrier(DataFlow::Node node) {
2626
node = DataFlow::BarrierGuard<comparisonBarrierGuard/3>::getABarrierNode()
2727
}
28+
29+
predicate observeDiffInformedIncrementalMode() { any() }
2830
}
2931

3032
/**

go/ql/src/Security/CWE-352/ConstantOauth2State.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ module ConstantStateFlowConfig implements DataFlow::ConfigSig {
4040
}
4141

4242
predicate isSink(DataFlow::Node sink) { isSinkCall(sink, _) }
43+
44+
predicate observeDiffInformedIncrementalMode() { any() }
4345
}
4446

4547
/**

go/ql/src/Security/CWE-640/EmailInjection.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module EmailInjection {
2020
predicate isSource(DataFlow::Node source) { source instanceof Source }
2121

2222
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
23+
24+
predicate observeDiffInformedIncrementalMode() { any() }
2325
}
2426

2527
/** Tracks taint flow for reasoning about email-injection vulnerabilities. */

go/ql/src/experimental/CWE-090/LDAPInjection.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ private module LdapInjectionConfig implements DataFlow::ConfigSig {
101101
predicate isSink(DataFlow::Node sink) { sink instanceof LdapSink }
102102

103103
predicate isBarrier(DataFlow::Node node) { node instanceof LdapSanitizer }
104+
105+
predicate observeDiffInformedIncrementalMode() { any() }
104106
}
105107

106108
/**

go/ql/src/experimental/CWE-203/Timing.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ module Config implements DataFlow::ConfigSig {
102102
}
103103

104104
predicate isSink(DataFlow::Node sink) { sink instanceof Sink and not isBadResult(sink) }
105+
106+
predicate observeDiffInformedIncrementalMode() { any() }
105107
}
106108

107109
module Flow = TaintTracking::Global<Config>;

go/ql/src/experimental/CWE-285/PamAuthBypass.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module PamStartToAcctMgmtConfig implements DataFlow::ConfigSig {
4242
predicate isSink(DataFlow::Node sink) {
4343
exists(PamAcctMgmt p | p.getACall().getReceiver() = sink)
4444
}
45+
46+
predicate observeDiffInformedIncrementalMode() { any() }
4547
}
4648

4749
module PamStartToAcctMgmtFlow = TaintTracking::Global<PamStartToAcctMgmtConfig>;
@@ -55,6 +57,8 @@ module PamStartToAuthenticateConfig implements DataFlow::ConfigSig {
5557
predicate isSink(DataFlow::Node sink) {
5658
exists(PamAuthenticate p | p.getACall().getReceiver() = sink)
5759
}
60+
61+
predicate observeDiffInformedIncrementalMode() { any() }
5862
}
5963

6064
module PamStartToAuthenticateFlow = TaintTracking::Global<PamStartToAuthenticateConfig>;

go/ql/src/experimental/CWE-287/ImproperLdapAuthCustomizations.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ module ImproperLdapAuth {
7474
predicate isSink(DataFlow::Node sink) { sink instanceof LdapAuthSink }
7575

7676
predicate isBarrier(DataFlow::Node node) { node instanceof LdapSanitizer }
77+
78+
predicate observeDiffInformedIncrementalMode() { any() }
7779
}
7880

7981
/**

go/ql/src/experimental/CWE-321-V2/HardCodedKeys.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ module JwtParseWithConstantKeyConfig implements DataFlow::ConfigSig {
3333
// second part is the JWT Parsing Functions that get a string or byte as an argument
3434
sink = any(JwtParse jp).getKeyArg()
3535
}
36+
37+
predicate observeDiffInformedIncrementalMode() { any() }
3638
}
3739

3840
module GolangJwtKeyFuncConfig implements DataFlow::ConfigSig {

go/ql/src/experimental/CWE-327/WeakCryptoAlgorithmCustomizations.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ module WeakCryptoAlgorithm {
5454
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
5555

5656
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
57+
58+
predicate observeDiffInformedIncrementalMode() { any() }
5759
}
5860

5961
/**

go/ql/src/experimental/CWE-369/DivideByZero.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ module Config implements DataFlow::ConfigSig {
4545
predicate isSink(DataFlow::Node sink) {
4646
sink = DataFlow::exprNode(any(QuoExpr e).getRightOperand())
4747
}
48+
49+
predicate observeDiffInformedIncrementalMode() { any() }
4850
}
4951

5052
/**

go/ql/src/experimental/CWE-74/DsnInjectionCustomizations.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ private module DsnInjectionConfig implements DataFlow::ConfigSig {
1919
}
2020

2121
predicate isBarrier(DataFlow::Node node) { node instanceof RegexpCheckBarrier }
22+
23+
predicate observeDiffInformedIncrementalMode() { any() }
2224
}
2325

2426
/**

go/ql/src/experimental/frameworks/DecompressionBombs.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module DecompressionBomb {
5656
addStep.isAdditionalFlowStep(fromNode, fromState, toNode, toState)
5757
)
5858
}
59+
60+
predicate observeDiffInformedIncrementalMode() { any() }
5961
}
6062

6163
/** Tracks taint flow for reasoning about decompression bomb vulnerabilities. */

0 commit comments

Comments
 (0)