You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_ =tryRegex(#"^mouse|touch|click|contextmenu|drop|dragover|dragend"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
105
105
_ =tryRegex(#"^xxx:|yyy:"#).ignoresCase().firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
106
106
_ =tryRegex(#"_xxx|_yyy|_zzz$"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
107
-
_ =tryRegex(#"em|%$"#).firstMatch(in: input) // BAD (missing anchor) [NOT DETECTED] - not flagged at the moment due to the anchor not being for letters
107
+
_ =tryRegex(#"em|%$"#).firstMatch(in: input) // $ MISSING: Alert[swift/missing-regexp-anchor] // BAD (missing anchor) [NOT DETECTED] - not flagged at the moment due to the anchor not being for letters
108
108
109
109
// the following are MAYBE OK due to apparent complexity; not flagged
_ =tryNSRegularExpression(pattern:"verygood.com/?id="+#"https?:\/\/good.com\/([0-9]+)"#).matches(in: url, range: urlRange)[0] // OK
105
105
106
106
_ =tryNSRegularExpression(pattern:#"\.com|\.org"#).matches(in: input, range: inputRange) // OK, has no domain name
107
-
_ =tryNSRegularExpression(pattern:#"example\.com|whatever"#).matches(in: input, range: inputRange) // $ Alert[swift/missing-regexp-anchor] // OK, the other disjunction doesn't match a hostname [FALSE POSITIVE]
107
+
_ =tryNSRegularExpression(pattern:#"example\.com|whatever"#).matches(in: input, range: inputRange) // $ SPURIOUS: Alert[swift/missing-regexp-anchor] // OK, the other disjunction doesn't match a hostname [FALSE POSITIVE]
108
108
109
109
// tests for the `isLineAnchoredHostnameRegExp` case
_ =tryNSRegularExpression(pattern:"^good\\.com$").matches(in: attackUrl1, range: attackUrl1Range) // OK
114
-
_ =tryNSRegularExpression(pattern:"^good\\.com$", options:.anchorsMatchLines).matches(in: attackUrl1, range: attackUrl1Range) // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
114
+
_ =tryNSRegularExpression(pattern:"^good\\.com$", options:.anchorsMatchLines).matches(in: attackUrl1, range: attackUrl1Range) // $ MISSING: Alert[swift/missing-regexp-anchor] // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
115
115
_ =tryNSRegularExpression(pattern:"(?i)^good\\.com$").matches(in: attackUrl1, range: attackUrl1Range) // OK
116
-
_ =tryNSRegularExpression(pattern:"(?i)^good\\.com$", options:.anchorsMatchLines).matches(in: attackUrl1, range: attackUrl1Range) // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
116
+
_ =tryNSRegularExpression(pattern:"(?i)^good\\.com$", options:.anchorsMatchLines).matches(in: attackUrl1, range: attackUrl1Range) // $ MISSING: Alert[swift/missing-regexp-anchor] // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
117
117
_ =tryNSRegularExpression(pattern:"^good\\.com$|^another\\.com$").matches(in: attackUrl1, range: attackUrl1Range) // OK
118
-
_ =tryNSRegularExpression(pattern:"^good\\.com$|^another\\.com$", options:.anchorsMatchLines).matches(in: attackUrl1, range: attackUrl1Range) // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
118
+
_ =tryNSRegularExpression(pattern:"^good\\.com$|^another\\.com$", options:.anchorsMatchLines).matches(in: attackUrl1, range: attackUrl1Range) // $ MISSING: Alert[swift/missing-regexp-anchor] // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
_ =tryNSRegularExpression(pattern:"^good\\.com/").matches(in: attackUrl2, range: attackUrl2Range) // OK
123
-
_ =tryNSRegularExpression(pattern:"^good\\.com/", options:.anchorsMatchLines).matches(in: attackUrl2, range: attackUrl2Range) // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
123
+
_ =tryNSRegularExpression(pattern:"^good\\.com/", options:.anchorsMatchLines).matches(in: attackUrl2, range: attackUrl2Range) // $ MISSING: Alert[swift/missing-regexp-anchor] // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
124
124
_ =tryNSRegularExpression(pattern:"(?i)^good\\.com/").matches(in: attackUrl2, range: attackUrl2Range) // OK
125
-
_ =tryNSRegularExpression(pattern:"(?i)^good\\.com/", options:.anchorsMatchLines).matches(in: attackUrl2, range: attackUrl2Range) // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
125
+
_ =tryNSRegularExpression(pattern:"(?i)^good\\.com/", options:.anchorsMatchLines).matches(in: attackUrl2, range: attackUrl2Range) // $ MISSING: Alert[swift/missing-regexp-anchor] // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
126
126
_ =tryNSRegularExpression(pattern:"^good\\.com/|^another\\.com/").matches(in: attackUrl2, range: attackUrl2Range) // OK
127
-
_ =tryNSRegularExpression(pattern:"^good\\.com/|^another\\.com/", options:.anchorsMatchLines).matches(in: attackUrl2, range: attackUrl2Range) // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
127
+
_ =tryNSRegularExpression(pattern:"^good\\.com/|^another\\.com/", options:.anchorsMatchLines).matches(in: attackUrl2, range: attackUrl2Range) // $ MISSING: Alert[swift/missing-regexp-anchor] // BAD [NOT DETECTED]: with the .anchorsMatchLines option this matches the attack URL
_ =tryRegex(#"^https?://api.example.com/"#).firstMatch(in: tainted) // $ Alert[swift/incomplete-hostname-regexp] // BAD (incomplete hostname)
74
74
_ =tryRegex(#"^http[s]?://?sub1\.sub2\.example\.com/f/(.+)"#).firstMatch(in: tainted) // GOOD (it has a capture group after the TLD, so should be ignored)
75
75
_ =tryRegex(#"^https://[a-z]*.example.com$"#).firstMatch(in: tainted) // $ Alert[swift/incomplete-hostname-regexp] // BAD (incomplete hostname)
76
-
_ =tryRegex(#"^(example.dev|example.com)"#).firstMatch(in: tainted) // $ Alert[swift/missing-regexp-anchor] // GOOD (any extended hostname wouldn't be included in the capture group) [FALSE POSITIVE]
77
-
_ =tryRegex(#"^protos?://(localhost|.+.example.net|.+.example-a.com|.+.example-b.com|.+.example.internal)"#).firstMatch(in: tainted) // $ Alert[swift/incomplete-hostname-regexp] Alert[swift/incomplete-hostname-regexp] Alert[swift/incomplete-hostname-regexp] Alert[swift/missing-regexp-anchor] // BAD (incomplete hostname x3, missing anchor x 1)
76
+
_ =tryRegex(#"^(example.dev|example.com)"#).firstMatch(in: tainted) // $ SPURIOUS: Alert[swift/missing-regexp-anchor] // GOOD (any extended hostname wouldn't be included in the capture group) [FALSE POSITIVE]
77
+
_ =tryRegex(#"^protos?://(localhost|.+.example.net|.+.example-a.com|.+.example-b.com|.+.example.internal)"#).firstMatch(in: tainted) // $ Alert[swift/incomplete-hostname-regexp] Alert[swift/missing-regexp-anchor] // BAD (incomplete hostname x3, missing anchor x 1)
78
78
79
79
_ =tryRegex(#"^http://(..|...)\.example\.com/index\.html"#).firstMatch(in: tainted) // GOOD (wildcards are intentional)
80
80
_ =tryRegex(#"^http://.\.example\.com/index\.html"#).firstMatch(in: tainted) // GOOD (the wildcard is intentional)
0 commit comments