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(#"^(xxx:)|(yyy:)|(zzz:)"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
98
+
_ =tryRegex(#"^(xxx?:)|(yyy:zzz\/)"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
99
+
_ =tryRegex(#"^@media|@page"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
100
+
_ =tryRegex(#"^\s*(xxx?|yyy|zzz):|xxx:yyy"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
101
+
_ =tryRegex(#"^click|mouse|touch"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
102
+
_ =tryRegex(#"^http://good\.com|http://better\.com"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
103
+
_ =tryRegex(#"^https?://good\.com|https?://better\.com"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
104
+
_ =tryRegex(#"^mouse|touch|click|contextmenu|drop|dragover|dragend"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
105
+
_ =tryRegex(#"^xxx:|yyy:"#).ignoresCase().firstMatch(in: input) // $ Alert // BAD (missing anchor)
106
+
_ =tryRegex(#"_xxx|_yyy|_zzz$"#).firstMatch(in: input) // $ Alert // BAD (missing anchor)
107
107
_ =tryRegex(#"em|%$"#).firstMatch(in: input) // 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:"https://verygood.com/?id="+#"https?:\/\/good.com\/([0-9]+)"#).matches(in: url, range: urlRange)[0] // OK
103
103
_ =tryNSRegularExpression(pattern:"http"+(secure ?"s":"")+"://"+"verygood.com/?id="+#"https?:\/\/good.com\/([0-9]+)"#).matches(in: url, range: urlRange)[0] // OK
104
104
_ =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) // OK, the other disjunction doesn't match a hostname [FALSE POSITIVE]
107
+
_ =tryNSRegularExpression(pattern:#"example\.com|whatever"#).matches(in: input, range: inputRange) // $ Alert // OK, the other disjunction doesn't match a hostname [FALSE POSITIVE]
108
108
109
109
// tests for the `isLineAnchoredHostnameRegExp` case
_ =tryRegex(#"^http://example\.com/"#).firstMatch(in: tainted) // GOOD
55
55
_ =tryRegex(#"^http://example.com/"#).firstMatch(in: tainted) // GOOD (only '.' here gives a valid top-level domain)
56
-
_ =tryRegex(#"^http://example.com"#).firstMatch(in: tainted) // BAD (missing anchor)
56
+
_ =tryRegex(#"^http://example.com"#).firstMatch(in: tainted) // $ Alert // BAD (missing anchor)
57
57
_ =tryRegex(#"^http://test\.example\.com/"#).firstMatch(in: tainted) // GOOD
58
58
_ =tryRegex(#"^http://test\.example.com/"#).firstMatch(in: tainted) // GOOD (only '.' here gives a valid top-level domain)
59
-
_ =tryRegex(#"^http://test\.example.com"#).firstMatch(in: tainted) // BAD (missing anchor)
60
-
_ =tryRegex(#"^http://test.example.com/"#).firstMatch(in: tainted) // BAD (incomplete hostname)
59
+
_ =tryRegex(#"^http://test\.example.com"#).firstMatch(in: tainted) // $ Alert // BAD (missing anchor)
60
+
_ =tryRegex(#"^http://test.example.com/"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
61
61
_ =tryRegex(#"^http://test[.]example[.]com/"#).firstMatch(in: tainted) // GOOD (alternative method of escaping)
62
62
63
-
_ =tryRegex(#"^http://test.example.net/"#).firstMatch(in: tainted) // BAD (incomplete hostname)
64
-
_ =tryRegex(#"^http://test.(example-a|example-b).com/"#).firstMatch(in: tainted) // BAD (incomplete hostname)
65
-
_ =tryRegex(#"^http://(.+).example.com/"#).firstMatch(in: tainted) // BAD (incomplete hostname x 2)
63
+
_ =tryRegex(#"^http://test.example.net/"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
64
+
_ =tryRegex(#"^http://test.(example-a|example-b).com/"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
65
+
_ =tryRegex(#"^http://(.+).example.com/"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname x 2)
66
66
_ =tryRegex(#"^http://(\.+)\.example.com/"#).firstMatch(in: tainted) // GOOD
67
-
_ =tryRegex(#"^http://(?:.+)\.test\.example.com/"#).firstMatch(in: tainted) // BAD (incomplete hostname)
68
-
_ =tryRegex(#"^http://test.example.com/(?:.*)"#).firstMatch(in: tainted) // BAD (incomplete hostname)
69
-
_ =tryRegex(#"^(.+\.(?:example-a|example-b)\.com)/"#).firstMatch(in: tainted) // BAD (missing anchor)
70
-
_ =tryRegex(#"^(https?:)?//((service|www).)?example.com(?=$|/)"#).firstMatch(in: tainted) // BAD (incomplete hostname)
71
-
_ =tryRegex(#"^(http|https)://www.example.com/p/f/"#).firstMatch(in: tainted) // BAD (incomplete hostname)
72
-
_ =tryRegex(#"^(http://sub.example.com/)"#).firstMatch(in: tainted) // BAD (incomplete hostname)
73
-
_ =tryRegex(#"^https?://api.example.com/"#).firstMatch(in: tainted) // BAD (incomplete hostname)
67
+
_ =tryRegex(#"^http://(?:.+)\.test\.example.com/"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
68
+
_ =tryRegex(#"^http://test.example.com/(?:.*)"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
69
+
_ =tryRegex(#"^(.+\.(?:example-a|example-b)\.com)/"#).firstMatch(in: tainted) // $ Alert // BAD (missing anchor)
70
+
_ =tryRegex(#"^(https?:)?//((service|www).)?example.com(?=$|/)"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
71
+
_ =tryRegex(#"^(http|https)://www.example.com/p/f/"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
72
+
_ =tryRegex(#"^(http://sub.example.com/)"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
73
+
_ =tryRegex(#"^https?://api.example.com/"#).firstMatch(in: tainted) // $ Alert // 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
-
_ =tryRegex(#"^https://[a-z]*.example.com$"#).firstMatch(in: tainted) // BAD (incomplete hostname)
76
-
_ =tryRegex(#"^(example.dev|example.com)"#).firstMatch(in: tainted) // 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) // BAD (incomplete hostname x3, missing anchor x 1)
75
+
_ =tryRegex(#"^https://[a-z]*.example.com$"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
76
+
_ =tryRegex(#"^(example.dev|example.com)"#).firstMatch(in: tainted) // $ Alert // 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 // 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)
81
-
_ =tryRegex(#"^(foo.example\.com|whatever)$"#).firstMatch(in: tainted) // DUBIOUS (one disjunction doesn't even look like a hostname) [DETECTED incomplete hostname, missing anchor]
81
+
_ =tryRegex(#"^(foo.example\.com|whatever)$"#).firstMatch(in: tainted) // $ Alert // DUBIOUS (one disjunction doesn't even look like a hostname) [DETECTED incomplete hostname, missing anchor]
82
82
83
-
_ =tryRegex(#"^test.example.com$"#).firstMatch(in: tainted) // BAD (incomplete hostname)
84
-
_ =tryRegex(#"test.example.com"#).wholeMatch(in: tainted) // BAD (incomplete hostname, missing anchor)
83
+
_ =tryRegex(#"^test.example.com$"#).firstMatch(in: tainted) // $ Alert // BAD (incomplete hostname)
0 commit comments