Skip to content

Commit 9529bc5

Browse files
committed
Swift: The regressed test is not realistic, update it to be more like what really happens.
1 parent e266132 commit 9529bc5

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
edges
2+
| StringLengthConflation2.swift:35:36:35:38 | .count : | StringLengthConflation2.swift:35:36:35:46 | ... .-(_:_:) ... |
23
| StringLengthConflation2.swift:37:34:37:36 | .count : | StringLengthConflation2.swift:37:34:37:44 | ... .-(_:_:) ... |
34
| StringLengthConflation.swift:36:30:36:37 | len : | StringLengthConflation.swift:36:93:36:93 | len |
45
| StringLengthConflation.swift:60:47:60:50 | .length : | StringLengthConflation.swift:60:47:60:59 | ... ./(_:_:) ... |
@@ -27,6 +28,8 @@ edges
2728
| file://:0:0:0:0 | .length : | StringLengthConflation.swift:114:23:114:26 | .length : |
2829
| file://:0:0:0:0 | .length : | StringLengthConflation.swift:120:22:120:25 | .length : |
2930
nodes
31+
| StringLengthConflation2.swift:35:36:35:38 | .count : | semmle.label | .count : |
32+
| StringLengthConflation2.swift:35:36:35:46 | ... .-(_:_:) ... | semmle.label | ... .-(_:_:) ... |
3033
| StringLengthConflation2.swift:37:34:37:36 | .count : | semmle.label | .count : |
3134
| StringLengthConflation2.swift:37:34:37:44 | ... .-(_:_:) ... | semmle.label | ... .-(_:_:) ... |
3235
| StringLengthConflation.swift:36:30:36:37 | len : | semmle.label | len : |
@@ -76,6 +79,7 @@ nodes
7679
| file://:0:0:0:0 | .length : | semmle.label | .length : |
7780
subpaths
7881
#select
82+
| 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. |
7983
| 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. |
8084
| 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. |
8185
| 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. |

swift/ql/test/query-tests/Security/CWE-135/StringLengthConflation2.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ class NSObject
1212
{
1313
}
1414

15-
class NSStringBase : NSObject
16-
{
17-
func substring(from: Int) -> String { return "" }
18-
}
19-
20-
class NSString : NSStringBase
15+
class NSString : NSObject
2116
{
2217
init(string: String) { length = string.count }
2318

@@ -26,6 +21,11 @@ class NSString : NSStringBase
2621
private(set) var length: Int
2722
}
2823

24+
extension NSString
25+
{
26+
func substring(from: Int) -> String { return "" }
27+
}
28+
2929
// --- tests ---
3030

3131
func test(s: String) {

0 commit comments

Comments
 (0)