Skip to content

Commit efcadbd

Browse files
committed
Swift: Get the IncompleteHostnameRegex query working for Swift.
1 parent 6deaf4e commit efcadbd

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

swift/ql/lib/codeql/swift/security/IncompleteHostnameRegexShared.qll

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
* that match URLs and hostname patterns.
44
*/
55

6-
private import javascript as JS
7-
private import semmle.javascript.security.regexp.RegExpTreeView::RegExpTreeView as TreeImpl
8-
private import semmle.javascript.Regexp as RegExp
6+
private import swift
7+
private import codeql.swift.dataflow.DataFlow
8+
private import codeql.swift.regex.Regex as Regex
9+
private import codeql.swift.regex.RegexTreeView::RegexTreeView as TreeImpl
910
private import codeql.regex.HostnameRegexp as Shared
1011

11-
/** An implementation of the signature that allows the Hostname analysis to run. */
12+
/**
13+
* An implementation of the signature that allows the Hostname analysis to run.
14+
*/
1215
module Impl implements Shared::HostnameRegexpSig<TreeImpl> {
13-
class DataFlowNode = JS::DataFlow::Node;
16+
class DataFlowNode = DataFlow::Node;
1417

15-
class RegExpPatternSource = RegExp::RegExpPatternSource;
18+
class RegExpPatternSource = Regex::RegexPatternSource;
1619
}
1720

1821
import Shared::Make<TreeImpl, Impl>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* @problem.severity warning
66
* @security-severity 7.8
77
* @precision high
8-
* @id js/incomplete-hostname-regexp
8+
* @id swift/incomplete-hostname-regexp
99
* @tags correctness
1010
* security
1111
* external/cwe/cwe-020
1212
*/
1313

14-
private import semmle.javascript.security.regexp.HostnameRegexp as HostnameRegexp
14+
private import codeql.swift.security.regex.HostnameRegex as HostnameRegex
1515

16-
query predicate problems = HostnameRegexp::incompleteHostnameRegExp/4;
16+
query predicate problems = HostnameRegex::incompleteHostnameRegExp/4;

0 commit comments

Comments
 (0)