Skip to content

Commit ae15992

Browse files
committed
Swift: Add numeric barrier to the regular expression injection query as well.
1 parent e011951 commit ae15992

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

swift/ql/lib/codeql/swift/security/regex/RegexInjectionExtensions.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,13 @@ private class RegexInjectionSinks extends SinkModelCsv {
5757
]
5858
}
5959
}
60+
61+
/**
62+
* A barrier for regular expression injection vulnerabilities.
63+
*/
64+
private class RegexInjectionDefaultBarrier extends RegexInjectionBarrier {
65+
RegexInjectionDefaultBarrier() {
66+
// any numeric type
67+
this.asExpr().getType().getUnderlyingType().getABaseType*().getName() = "Numeric"
68+
}
69+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: minorAnalysis
33
---
4-
* Adder barriers for numeric type values to the injection-like queries, to reduce false positive results where the user input that can be injected is constrainted to a numerical value. The queries updated by this change are: "Predicate built from user-controlled sources" (`swift/predicate-injection`), "Database query built from user-controlled sources" (`swift/sql-injection`), "Uncontrolled format string" (`swift/uncontrolled-format-string`) and "JavaScript Injection" (`swift/unsafe-js-eval`).
4+
* Adder barriers for numeric type values to the injection-like queries, to reduce false positive results where the user input that can be injected is constrainted to a numerical value. The queries updated by this change are: "Predicate built from user-controlled sources" (`swift/predicate-injection`), "Database query built from user-controlled sources" (`swift/sql-injection`), "Uncontrolled format string" (`swift/uncontrolled-format-string`), "JavaScript Injection" (`swift/unsafe-js-eval`) and "Regular expression injection" (`swift/regex-injection`).

0 commit comments

Comments
 (0)