Skip to content

Commit 4781881

Browse files
committed
Swift: Improve mobile/phone number regexp.
1 parent a0cba8c commit 4781881

File tree

4 files changed

+2
-5
lines changed

4 files changed

+2
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SensitivePrivateInfo extends SensitiveDataType, TPrivateInfo {
4848
// Contact information, such as home addresses
4949
"post.?code|zip.?code|home.?address|" +
5050
// and telephone numbers
51-
"telephone|home.?phone|mobile|fax.?no|fax.?number|" +
51+
"(mob(ile)?|home).?(num|no|tel|phone)|(tel|fax).?(num|no)|telephone|" +
5252
// Geographic location - where the user is (or was)
5353
"latitude|longitude|" +
5454
// Financial data - such as credit card numbers, salary, bank accounts, and debts

swift/ql/test/query-tests/Security/CWE-311/CleartextTransmission.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ nodes
3838
| testSend.swift:61:27:61:27 | str3 | semmle.label | str3 |
3939
| testSend.swift:65:27:65:27 | license_key | semmle.label | license_key |
4040
| testSend.swift:66:27:66:30 | .mobileNumber | semmle.label | .mobileNumber |
41-
| testSend.swift:68:27:68:30 | .mobilePlayer | semmle.label | .mobilePlayer |
4241
| testURL.swift:13:22:13:54 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... |
4342
| testURL.swift:13:54:13:54 | passwd | semmle.label | passwd |
4443
| testURL.swift:16:22:16:55 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... |
@@ -58,7 +57,6 @@ subpaths
5857
| testSend.swift:61:27:61:27 | str3 | testSend.swift:54:17:54:17 | password | testSend.swift:61:27:61:27 | str3 | This operation transmits 'str3', which may contain unencrypted sensitive data from $@. | testSend.swift:54:17:54:17 | password | password |
5958
| testSend.swift:65:27:65:27 | license_key | testSend.swift:65:27:65:27 | license_key | testSend.swift:65:27:65:27 | license_key | This operation transmits 'license_key', which may contain unencrypted sensitive data from $@. | testSend.swift:65:27:65:27 | license_key | license_key |
6059
| testSend.swift:66:27:66:30 | .mobileNumber | testSend.swift:66:27:66:30 | .mobileNumber | testSend.swift:66:27:66:30 | .mobileNumber | This operation transmits '.mobileNumber', which may contain unencrypted sensitive data from $@. | testSend.swift:66:27:66:30 | .mobileNumber | .mobileNumber |
61-
| testSend.swift:68:27:68:30 | .mobilePlayer | testSend.swift:68:27:68:30 | .mobilePlayer | testSend.swift:68:27:68:30 | .mobilePlayer | This operation transmits '.mobilePlayer', which may contain unencrypted sensitive data from $@. | testSend.swift:68:27:68:30 | .mobilePlayer | .mobilePlayer |
6260
| testURL.swift:13:22:13:54 | ... .+(_:_:) ... | testURL.swift:13:54:13:54 | passwd | testURL.swift:13:22:13:54 | ... .+(_:_:) ... | This operation transmits '... .+(_:_:) ...', which may contain unencrypted sensitive data from $@. | testURL.swift:13:54:13:54 | passwd | passwd |
6361
| testURL.swift:16:22:16:55 | ... .+(_:_:) ... | testURL.swift:16:55:16:55 | credit_card_no | testURL.swift:16:22:16:55 | ... .+(_:_:) ... | This operation transmits '... .+(_:_:) ...', which may contain unencrypted sensitive data from $@. | testURL.swift:16:55:16:55 | credit_card_no | credit_card_no |
6462
| testURL.swift:20:22:20:22 | passwd | testURL.swift:20:22:20:22 | passwd | testURL.swift:20:22:20:22 | passwd | This operation transmits 'passwd', which may contain unencrypted sensitive data from $@. | testURL.swift:20:22:20:22 | passwd | passwd |

swift/ql/test/query-tests/Security/CWE-311/SensitiveExprs.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
| testSend.swift:57:27:57:27 | password | label:password, type:credential |
129129
| testSend.swift:65:27:65:27 | license_key | label:license_key, type:credential |
130130
| testSend.swift:66:27:66:30 | .mobileNumber | label:mobileNumber, type:private information |
131-
| testSend.swift:68:27:68:30 | .mobilePlayer | label:mobilePlayer, type:private information |
132131
| testSend.swift:69:27:69:30 | .passwordFeatureEnabled | label:passwordFeatureEnabled, type:credential |
133132
| testURL.swift:13:54:13:54 | passwd | label:passwd, type:credential |
134133
| testURL.swift:16:55:16:55 | credit_card_no | label:credit_card_no, type:private information |

swift/ql/test/query-tests/Security/CWE-311/testSend.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ func test2(password : String, license_key: String, ms: MyStruct, connection : NW
6565
connection.send(content: license_key, completion: .idempotent) // BAD
6666
connection.send(content: ms.mobileNumber, completion: .idempotent) // BAD
6767
connection.send(content: ms.mobileUrl, completion: .idempotent) // GOOD (not sensitive)
68-
connection.send(content: ms.mobilePlayer, completion: .idempotent) // GOOD (not sensitive) [FALSE POSITIVE]
68+
connection.send(content: ms.mobilePlayer, completion: .idempotent) // GOOD (not sensitive)
6969
connection.send(content: ms.passwordFeatureEnabled, completion: .idempotent) // GOOD (not sensitive)
7070
}

0 commit comments

Comments
 (0)