Skip to content

Commit 415d9e0

Browse files
committed
Swift: Address review comments.
1 parent 242a49e commit 415d9e0

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

swift/ql/src/queries/Security/CWE-020/IncompleteHostnameRegex.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Incomplete regular expression for hostnames
3-
* @description Matching a URL or hostname against a regular expression that contains an unescaped dot as part of the hostname might match more hostnames than expected.
3+
* @description Matching a URL or hostname against a regular expression that contains an unescaped dot as part of the hostname may match more hostnames than expected.
44
* @kind problem
55
* @problem.severity warning
66
* @security-severity 7.8

swift/ql/src/queries/Security/CWE-020/IncompleteHostnameRegexBad.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ func handleUrl(_ urlString: String) {
55
let redirectParam = components?.queryItems?.first(where: { $0.name == "url" })
66

77
// check we trust the host
8-
let regex = #/^(www|beta).example.com//#
8+
let regex = #/^(www|beta).example.com//# // BAD
99
if let match = redirectParam?.value?.firstMatch(of: regex) {
1010
// ... trust the URL ...
1111
}

swift/ql/src/queries/Security/CWE-020/IncompleteHostnameRegexGood.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ func handleUrl(_ urlString: String) {
55
let redirectParam = components?.queryItems?.first(where: { $0.name == "url" })
66

77
// check we trust the host
8-
let regex = #/^(www|beta)\.example\.com//#
8+
let regex = #/^(www|beta)\.example\.com//# // GOOD
99
if let match = redirectParam?.value?.firstMatch(of: regex) {
1010
// ... trust the URL ...
1111
}

0 commit comments

Comments
 (0)