Skip to content

Commit cf4b834

Browse files
committed
Address comments
1 parent ce50f35 commit cf4b834

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

javascript/ql/lib/semmle/javascript/Regexp.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,13 +999,13 @@ predicate isInterpretedAsRegExp(DataFlow::Node source) {
999999
}
10001000

10011001
/**
1002-
* Provides regular expression patterns.
1002+
* Provides utility predicates related to regular expressions.
10031003
*/
10041004
module RegExpPatterns {
10051005
/**
10061006
* Gets a pattern that matches common top-level domain names in lower case.
10071007
*/
1008-
string commonTLD() {
1008+
string getACommonTld() {
10091009
// according to ranking by http://google.com/search?q=site:.<<TLD>>
10101010
result = "(?:com|org|edu|gov|uk|net|io)(?![a-z0-9])"
10111011
}

javascript/ql/src/Security/CWE-020/HostnameRegexpShared.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ predicate hasTopLevelDomainEnding(RegExpSequence seq, int i) {
6262
seq.getChild(i)
6363
.(RegExpConstant)
6464
.getValue()
65-
.regexpMatch("(?i)" + RegExpPatterns::commonTLD() + "(:\\d+)?([/?#].*)?") and
65+
.regexpMatch("(?i)" + RegExpPatterns::getACommonTld() + "(:\\d+)?([/?#].*)?") and
6666
isDotLike(seq.getChild(i - 1)) and
6767
not (i = 1 and matchesBeginningOfString(seq))
6868
}

javascript/ql/src/Security/CWE-020/IncompleteUrlSubstringSanitization.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
(
4040
// target contains a domain on a common TLD, and perhaps some other URL components
4141
target
42-
.regexpMatch("(?i)([a-z]*:?//)?\\.?([a-z0-9-]+\\.)+" + RegExpPatterns::commonTLD() +
42+
.regexpMatch("(?i)([a-z]*:?//)?\\.?([a-z0-9-]+\\.)+" + RegExpPatterns::getACommonTld() +
4343
"(:[0-9]+)?/?")
4444
or
4545
// target is a HTTP URL to a domain on any TLD

python/ql/lib/semmle/python/RegexTreeView.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ newtype TRegExpParent =
5050
TRegExpBackRef(Regex re, int start, int end) { re.backreference(start, end) }
5151

5252
/**
53-
* Provides regular expression patterns.
53+
* Provides utility predicates related to regular expressions.
5454
*/
5555
module RegExpPatterns {
5656
/**
5757
* Gets a pattern that matches common top-level domain names in lower case.
5858
*/
59-
string commonTLD() {
59+
string getACommonTld() {
6060
// according to ranking by http://google.com/search?q=site:.<<TLD>>
6161
result = "(?:com|org|edu|gov|uk|net|io)(?![a-z0-9])"
6262
}
@@ -768,7 +768,7 @@ class RegExpGroup extends RegExpTerm, TRegExpGroup {
768768
int getNumber() { result = re.getGroupNumber(start, end) }
769769

770770
/** Holds if this is a capture group. */
771-
predicate isCapture() { not exists(this.getNumber()) }
771+
predicate isCapture() { exists(this.getNumber()) }
772772

773773
/** Holds if this is a named capture group. */
774774
predicate isNamed() { exists(this.getName()) }

python/ql/src/Security/CWE-020/HostnameRegexpShared.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ predicate hasTopLevelDomainEnding(RegExpSequence seq, int i) {
6262
seq.getChild(i)
6363
.(RegExpConstant)
6464
.getValue()
65-
.regexpMatch("(?i)" + RegExpPatterns::commonTLD() + "(:\\d+)?([/?#].*)?") and
65+
.regexpMatch("(?i)" + RegExpPatterns::getACommonTld() + "(:\\d+)?([/?#].*)?") and
6666
isDotLike(seq.getChild(i - 1)) and
6767
not (i = 1 and matchesBeginningOfString(seq))
6868
}

ruby/ql/lib/codeql/ruby/security/performance/RegExpTreeView.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ module RegExpFlags {
6060
}
6161

6262
/**
63-
* Provides regular expression patterns.
63+
* Provides utility predicates related to regular expressions.
6464
*/
6565
module RegExpPatterns {
6666
/**
6767
* Gets a pattern that matches common top-level domain names in lower case.
6868
*/
69-
string commonTLD() {
69+
string getACommonTld() {
7070
// according to ranking by http://google.com/search?q=site:.<<TLD>>
7171
result = "(?:com|org|edu|gov|uk|net|io)(?![a-z0-9])"
7272
}
@@ -640,7 +640,7 @@ class RegExpGroup extends RegExpTerm, TRegExpGroup {
640640
int getNumber() { result = re.getGroupNumber(start, end) }
641641

642642
/** Holds if this is a capture group. */
643-
predicate isCapture() { not exists(this.getNumber()) }
643+
predicate isCapture() { exists(this.getNumber()) }
644644

645645
/** Holds if this is a named capture group. */
646646
predicate isNamed() { exists(this.getName()) }

ruby/ql/src/queries/security/cwe-020/HostnameRegexpShared.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ predicate hasTopLevelDomainEnding(RegExpSequence seq, int i) {
6262
seq.getChild(i)
6363
.(RegExpConstant)
6464
.getValue()
65-
.regexpMatch("(?i)" + RegExpPatterns::commonTLD() + "(:\\d+)?([/?#].*)?") and
65+
.regexpMatch("(?i)" + RegExpPatterns::getACommonTld() + "(:\\d+)?([/?#].*)?") and
6666
isDotLike(seq.getChild(i - 1)) and
6767
not (i = 1 and matchesBeginningOfString(seq))
6868
}

0 commit comments

Comments
 (0)