Skip to content

Commit 9f683b8

Browse files
committed
Swift: Remove duplicate results.
1 parent cf7f355 commit 9f683b8

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ module StringLengthConflationConfig implements DataFlow::StateConfigSig {
3131

3232
predicate isBarrier(DataFlow::Node barrier) { barrier instanceof StringLengthConflationBarrier }
3333

34+
predicate isBarrierOut(DataFlow::Node node) {
35+
// make sinks barriers so that we only report the closest instance
36+
isSink(node, _)
37+
}
38+
3439
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
3540
any(StringLengthConflationAdditionalFlowStep s).step(nodeFrom, nodeTo)
3641
}

swift/ql/test/query-tests/Security/CWE-135/StringLengthConflation.expected

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
edges
22
| StringLengthConflation2.swift:35:36:35:38 | .count | StringLengthConflation2.swift:35:36:35:46 | ... .-(_:_:) ... |
33
| StringLengthConflation2.swift:37:34:37:36 | .count | StringLengthConflation2.swift:37:34:37:44 | ... .-(_:_:) ... |
4-
| StringLengthConflation.swift:36:30:36:37 | len | StringLengthConflation.swift:36:93:36:93 | len |
5-
| StringLengthConflation.swift:36:30:36:37 | len | StringLengthConflation.swift:36:93:36:93 | len |
6-
| StringLengthConflation.swift:36:30:36:37 | len | StringLengthConflation.swift:36:93:36:93 | len |
74
| StringLengthConflation.swift:60:47:60:50 | .length | StringLengthConflation.swift:60:47:60:59 | ... ./(_:_:) ... |
85
| StringLengthConflation.swift:66:33:66:36 | .length | StringLengthConflation.swift:66:33:66:45 | ... ./(_:_:) ... |
9-
| StringLengthConflation.swift:72:33:72:35 | .count | StringLengthConflation.swift:36:30:36:37 | len |
106
| StringLengthConflation.swift:96:28:96:31 | .length | StringLengthConflation.swift:96:28:96:40 | ... .-(_:_:) ... |
117
| StringLengthConflation.swift:100:27:100:30 | .length | StringLengthConflation.swift:100:27:100:39 | ... .-(_:_:) ... |
128
| StringLengthConflation.swift:104:25:104:28 | .length | StringLengthConflation.swift:104:25:104:37 | ... .-(_:_:) ... |
@@ -32,9 +28,6 @@ edges
3228
| StringLengthConflation.swift:178:35:178:39 | .length | StringLengthConflation.swift:178:35:178:48 | ... .-(_:_:) ... |
3329
| StringLengthConflation.swift:179:37:179:39 | .count | StringLengthConflation.swift:179:37:179:47 | ... .-(_:_:) ... |
3430
| StringLengthConflation.swift:181:37:181:39 | .count | StringLengthConflation.swift:181:37:181:47 | ... .-(_:_:) ... |
35-
| StringLengthConflation.swift:190:28:190:28 | .count | StringLengthConflation.swift:36:30:36:37 | len |
36-
| StringLengthConflation.swift:191:28:191:33 | .count | StringLengthConflation.swift:36:30:36:37 | len |
37-
| StringLengthConflation.swift:193:28:193:43 | .count | StringLengthConflation.swift:36:30:36:37 | len |
3831
| file://:0:0:0:0 | .length | StringLengthConflation.swift:53:43:53:46 | .length |
3932
| file://:0:0:0:0 | .length | StringLengthConflation.swift:60:47:60:50 | .length |
4033
| file://:0:0:0:0 | .length | StringLengthConflation.swift:66:33:66:36 | .length |
@@ -53,12 +46,6 @@ nodes
5346
| StringLengthConflation2.swift:35:36:35:46 | ... .-(_:_:) ... | semmle.label | ... .-(_:_:) ... |
5447
| StringLengthConflation2.swift:37:34:37:36 | .count | semmle.label | .count |
5548
| StringLengthConflation2.swift:37:34:37:44 | ... .-(_:_:) ... | semmle.label | ... .-(_:_:) ... |
56-
| StringLengthConflation.swift:36:30:36:37 | len | semmle.label | len |
57-
| StringLengthConflation.swift:36:30:36:37 | len | semmle.label | len |
58-
| StringLengthConflation.swift:36:30:36:37 | len | semmle.label | len |
59-
| StringLengthConflation.swift:36:93:36:93 | len | semmle.label | len |
60-
| StringLengthConflation.swift:36:93:36:93 | len | semmle.label | len |
61-
| StringLengthConflation.swift:36:93:36:93 | len | semmle.label | len |
6249
| StringLengthConflation.swift:53:43:53:46 | .length | semmle.label | .length |
6350
| StringLengthConflation.swift:54:43:54:50 | .count | semmle.label | .count |
6451
| StringLengthConflation.swift:55:43:55:51 | .count | semmle.label | .count |
@@ -68,7 +55,6 @@ nodes
6855
| StringLengthConflation.swift:66:33:66:36 | .length | semmle.label | .length |
6956
| StringLengthConflation.swift:66:33:66:45 | ... ./(_:_:) ... | semmle.label | ... ./(_:_:) ... |
7057
| StringLengthConflation.swift:72:33:72:35 | .count | semmle.label | .count |
71-
| StringLengthConflation.swift:72:33:72:35 | .count | semmle.label | .count |
7258
| StringLengthConflation.swift:78:47:78:49 | .count | semmle.label | .count |
7359
| StringLengthConflation.swift:79:47:79:54 | .count | semmle.label | .count |
7460
| StringLengthConflation.swift:81:47:81:64 | .count | semmle.label | .count |
@@ -126,20 +112,13 @@ nodes
126112
| StringLengthConflation.swift:181:37:181:39 | .count | semmle.label | .count |
127113
| StringLengthConflation.swift:181:37:181:47 | ... .-(_:_:) ... | semmle.label | ... .-(_:_:) ... |
128114
| StringLengthConflation.swift:190:28:190:28 | .count | semmle.label | .count |
129-
| StringLengthConflation.swift:190:28:190:28 | .count | semmle.label | .count |
130115
| StringLengthConflation.swift:191:28:191:33 | .count | semmle.label | .count |
131-
| StringLengthConflation.swift:191:28:191:33 | .count | semmle.label | .count |
132-
| StringLengthConflation.swift:193:28:193:43 | .count | semmle.label | .count |
133116
| StringLengthConflation.swift:193:28:193:43 | .count | semmle.label | .count |
134117
| file://:0:0:0:0 | .length | semmle.label | .length |
135118
subpaths
136119
#select
137120
| StringLengthConflation2.swift:35:36:35:46 | ... .-(_:_:) ... | StringLengthConflation2.swift:35:36:35:38 | .count | StringLengthConflation2.swift:35:36:35:46 | ... .-(_:_:) ... | This String length is used in an NSString, but it may not be equivalent. |
138121
| StringLengthConflation2.swift:37:34:37:44 | ... .-(_:_:) ... | StringLengthConflation2.swift:37:34:37:36 | .count | StringLengthConflation2.swift:37:34:37:44 | ... .-(_:_:) ... | This String length is used in an NSString, but it may not be equivalent. |
139-
| StringLengthConflation.swift:36:93:36:93 | len | StringLengthConflation.swift:72:33:72:35 | .count | StringLengthConflation.swift:36:93:36:93 | len | This String length is used in an NSString, but it may not be equivalent. |
140-
| StringLengthConflation.swift:36:93:36:93 | len | StringLengthConflation.swift:190:28:190:28 | .count | StringLengthConflation.swift:36:93:36:93 | len | This String length is used in an NSString, but it may not be equivalent. |
141-
| StringLengthConflation.swift:36:93:36:93 | len | StringLengthConflation.swift:191:28:191:33 | .count | StringLengthConflation.swift:36:93:36:93 | len | This String.UTF8View length is used in an NSString, but it may not be equivalent. |
142-
| StringLengthConflation.swift:36:93:36:93 | len | StringLengthConflation.swift:193:28:193:43 | .count | StringLengthConflation.swift:36:93:36:93 | len | This String.UnicodeScalarView length is used in an NSString, but it may not be equivalent. |
143122
| StringLengthConflation.swift:53:43:53:46 | .length | StringLengthConflation.swift:53:43:53:46 | .length | StringLengthConflation.swift:53:43:53:46 | .length | This NSString length is used in a String, but it may not be equivalent. |
144123
| StringLengthConflation.swift:53:43:53:46 | .length | file://:0:0:0:0 | .length | StringLengthConflation.swift:53:43:53:46 | .length | This NSString length is used in a String, but it may not be equivalent. |
145124
| StringLengthConflation.swift:54:43:54:50 | .count | StringLengthConflation.swift:54:43:54:50 | .count | StringLengthConflation.swift:54:43:54:50 | .count | This String.UTF8View length is used in a String, but it may not be equivalent. |

0 commit comments

Comments
 (0)