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) // BAD (missing anchor)
98
-
_ =tryRegex(#"^(xxx?:)|(yyy:zzz\/)"#).firstMatch(in: input) // BAD (missing anchor)
99
-
_ =tryRegex(#"^@media|@page"#).firstMatch(in: input) // BAD (missing anchor)
100
-
_ =tryRegex(#"^\s*(xxx?|yyy|zzz):|xxx:yyy"#).firstMatch(in: input) // BAD (missing anchor)
101
-
_ =tryRegex(#"^click|mouse|touch"#).firstMatch(in: input) // BAD (missing anchor)
102
-
_ =tryRegex(#"^http://good\.com|http://better\.com"#).firstMatch(in: input) // BAD (missing anchor)
103
-
_ =tryRegex(#"^https?://good\.com|https?://better\.com"#).firstMatch(in: input) // BAD (missing anchor)
104
-
_ =tryRegex(#"^mouse|touch|click|contextmenu|drop|dragover|dragend"#).firstMatch(in: input) // BAD (missing anchor)
105
-
_ =tryRegex(#"^xxx:|yyy:"#).ignoresCase().firstMatch(in: input) // BAD (missing anchor)
106
-
_ =tryRegex(#"_xxx|_yyy|_zzz$"#).firstMatch(in: input) // 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
89
+
_ =tryRegex(#"(\.xxx)|(\.yyy)|(\.zzz)$"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
90
+
_ =tryRegex(#"(^left|right|center)\sbottom$"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
91
+
_ =tryRegex(#"\.xxx|\.yyy|\.zzz$"#).ignoresCase().firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
92
+
_ =tryRegex(#"\.xxx|\.yyy|\.zzz$"#).ignoresCase().firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
93
+
_ =tryRegex(#"\.xxx|\.yyy|zzz$"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
94
+
_ =tryRegex(#"^([A-Z]|xxx[XY]$)"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
_ =tryRegex(#"^mouse|touch|click|contextmenu|drop|dragover|dragend"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
105
+
_ =tryRegex(#"^xxx:|yyy:"#).ignoresCase().firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
106
+
_ =tryRegex(#"_xxx|_yyy|_zzz$"#).firstMatch(in: input) // $ Alert[swift/missing-regexp-anchor] // BAD (missing anchor)
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:"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) // $ 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
0 commit comments