Skip to content

Commit 766b0bf

Browse files
authored
Merge pull request #20082 from d10c/d10c/diff-informed-phase-3-swift
Swift: Diff-informed queries: phase 3 (non-trivial locations)
2 parents f432cf9 + 4342b2b commit 766b0bf

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

swift/ql/lib/codeql/swift/security/CleartextStorageDatabaseQuery.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ module CleartextStorageDatabaseConfig implements DataFlow::ConfigSig {
4848
node.asExpr().getType().getUnderlyingType() instanceof DictionaryType and
4949
c.getAReadContent().(DataFlow::Content::TupleContent).getIndex() = 1
5050
}
51+
52+
predicate observeDiffInformedIncrementalMode() { any() }
53+
54+
Location getASelectedSinkLocation(DataFlow::Node sink) {
55+
exists(DataFlow::Node cleanSink | result = cleanSink.getLocation() |
56+
cleanSink = sink.(DataFlow::PostUpdateNode).getPreUpdateNode()
57+
or
58+
not sink instanceof DataFlow::PostUpdateNode and
59+
cleanSink = sink
60+
)
61+
}
5162
}
5263

5364
/**

swift/ql/lib/codeql/swift/security/CleartextStoragePreferencesQuery.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ module CleartextStoragePreferencesConfig implements DataFlow::ConfigSig {
3030
// make sources barriers so that we only report the closest instance
3131
isSource(node)
3232
}
33+
34+
predicate observeDiffInformedIncrementalMode() { any() }
35+
36+
Location getASelectedSinkLocation(DataFlow::Node sink) {
37+
exists(DataFlow::Node cleanSink | result = cleanSink.getLocation() |
38+
cleanSink = sink.(DataFlow::PostUpdateNode).getPreUpdateNode()
39+
or
40+
not sink instanceof DataFlow::PostUpdateNode and
41+
cleanSink = sink
42+
)
43+
}
3344
}
3445

3546
/**

swift/ql/lib/codeql/swift/security/InsecureTLSQuery.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ module InsecureTlsConfig implements DataFlow::ConfigSig {
2121
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
2222
any(InsecureTlsExtensionsAdditionalFlowStep s).step(nodeFrom, nodeTo)
2323
}
24+
25+
predicate observeDiffInformedIncrementalMode() {
26+
none() // query selects some Swift nodes (e.g. "[post] self") that have location file://:0:0:0:0, which always fall outside the diff range.
27+
}
2428
}
2529

2630
module InsecureTlsFlow = TaintTracking::Global<InsecureTlsConfig>;

swift/ql/lib/codeql/swift/security/UnsafeWebViewFetchQuery.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig {
2828
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
2929
any(UnsafeWebViewFetchAdditionalFlowStep s).step(nodeFrom, nodeTo)
3030
}
31+
32+
predicate observeDiffInformedIncrementalMode() {
33+
none() // can't override location accurately because of secondary use in select.
34+
}
3135
}
3236

3337
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy