Swift: Get the IncompleteHostnameRegex query working for Swift.

This commit is contained in:
Geoffrey White
2023-08-16 17:13:51 +01:00
parent 6deaf4e5f8
commit efcadbda69
3 changed files with 12 additions and 16 deletions

View File

@@ -1,7 +0,0 @@
/**
* Provides predicates for reasoning about regular expressions
* that match URLs and hostname patterns.
*/
deprecated import semmle.javascript.security.regexp.HostnameRegexp as Dep
import Dep

View File

@@ -3,16 +3,19 @@
* that match URLs and hostname patterns.
*/
private import javascript as JS
private import semmle.javascript.security.regexp.RegExpTreeView::RegExpTreeView as TreeImpl
private import semmle.javascript.Regexp as RegExp
private import swift
private import codeql.swift.dataflow.DataFlow
private import codeql.swift.regex.Regex as Regex
private import codeql.swift.regex.RegexTreeView::RegexTreeView as TreeImpl
private import codeql.regex.HostnameRegexp as Shared
/** An implementation of the signature that allows the Hostname analysis to run. */
/**
* An implementation of the signature that allows the Hostname analysis to run.
*/
module Impl implements Shared::HostnameRegexpSig<TreeImpl> {
class DataFlowNode = JS::DataFlow::Node;
class DataFlowNode = DataFlow::Node;
class RegExpPatternSource = RegExp::RegExpPatternSource;
class RegExpPatternSource = Regex::RegexPatternSource;
}
import Shared::Make<TreeImpl, Impl>

View File

@@ -5,12 +5,12 @@
* @problem.severity warning
* @security-severity 7.8
* @precision high
* @id js/incomplete-hostname-regexp
* @id swift/incomplete-hostname-regexp
* @tags correctness
* security
* external/cwe/cwe-020
*/
private import semmle.javascript.security.regexp.HostnameRegexp as HostnameRegexp
private import codeql.swift.security.regex.HostnameRegex as HostnameRegex
query predicate problems = HostnameRegexp::incompleteHostnameRegExp/4;
query predicate problems = HostnameRegex::incompleteHostnameRegExp/4;