Skip to content

Commit 011fc20

Browse files
committed
use matches instead of regexpMatch
1 parent 6c2713d commit 011fc20

File tree

11 files changed

+16
-16
lines changed

11 files changed

+16
-16
lines changed

cpp/ql/src/Security/CWE/CWE-313/CleartextSqliteDatabase.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SqliteFunctionCall extends FunctionCall {
2929
}
3030

3131
predicate sqlite_encryption_used() {
32-
any(StringLiteral l).getValue().toLowerCase().regexpMatch("pragma key.*") or
32+
any(StringLiteral l).getValue().toLowerCase().matches("pragma key%") or
3333
any(StringLiteral l).getValue().toLowerCase().matches("%attach%database%key%") or
3434
any(FunctionCall fc).getTarget().getName().matches("sqlite%\\_key\\_%")
3535
}

java/ql/src/experimental/Security/CWE/CWE-598/SensitiveGetQuery.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SensitiveInfoExpr extends Expr {
2020
SensitiveInfoExpr() {
2121
exists(Variable v | this = v.getAnAccess() |
2222
v.getName().regexpMatch(getCommonSensitiveInfoRegex()) and
23-
not v.getName().regexpMatch("token.*") // exclude ^token.* since sensitive tokens are usually in the form of accessToken, authToken, ...
23+
not v.getName().matches("token%") // exclude ^token.* since sensitive tokens are usually in the form of accessToken, authToken, ...
2424
)
2525
}
2626
}

javascript/ql/lib/semmle/javascript/frameworks/AngularJS/AngularJSExpressions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ class NgDataFlowNode extends TNode {
833833
private predicate fileIsImplicitlyAngularJS(HTML::HtmlFile file) {
834834
// The file contains ng-* attributes.
835835
exists(HTML::Attribute attrib |
836-
attrib.getName().regexpMatch("ng-.*") and
836+
attrib.getName().matches("ng-%") and
837837
attrib.getFile() = file
838838
) and
839839
// But does not contain the ng-app root element, implying that file is

javascript/ql/lib/semmle/javascript/frameworks/ClientRequests.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ module ClientRequest {
787787
cmd.getACommandArgument()
788788
.(StringOps::ConcatenationRoot)
789789
.getConstantStringParts()
790-
.regexpMatch("curl .*")
790+
.matches("curl %")
791791
)
792792
}
793793

javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ module NodeJSLib {
554554
}
555555

556556
override DataFlow::Node getADataNode() {
557-
if methodName.regexpMatch(".*Sync")
557+
if methodName.matches("%Sync")
558558
then result = this
559559
else
560560
exists(int i, string paramName | fsDataParam(methodName, i, paramName) |
@@ -720,9 +720,9 @@ module NodeJSLib {
720720
not result = getParameter(0).getARhs() and
721721
// fork/spawn and all sync methos always has options as the last argument
722722
if
723-
methodName.regexpMatch("fork.*") or
724-
methodName.regexpMatch("spawn.*") or
725-
methodName.regexpMatch(".*Sync")
723+
methodName.matches("fork%") or
724+
methodName.matches("spawn%") or
725+
methodName.matches("%Sync")
726726
then result = getLastArgument()
727727
else
728728
// the rest (exec/execFile) has the options argument as their second last.

javascript/ql/lib/semmle/javascript/security/dataflow/XssThroughDomCustomizations.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ module XssThroughDom {
2222
*/
2323
bindingset[result]
2424
string unsafeAttributeName() {
25-
result.regexpMatch("data-.*") or
26-
result.regexpMatch("aria-.*") or
25+
result.matches("data-%") or
26+
result.matches("aria-%") or
2727
result = ["name", "value", "title", "alt"]
2828
}
2929

javascript/ql/src/Expressions/UnknownDirective.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ where
1818
// but exclude attribute top-levels: `<a href="javascript:'some-attribute-string'">`
1919
not d.getParent() instanceof CodeInAttribute and
2020
// exclude babel generated directives like "@babel/helpers - typeof".
21-
not d.getDirectiveText().prefix(14) = "@babel/helpers"
21+
not d.getDirectiveText().matches("@babel/helpers%")
2222
select d, "Unknown directive: '" + truncate(d.getDirectiveText(), 20, " ... (truncated)") + "'."

javascript/ql/test/library-tests/RangeAnalysis/DeadBranch.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ class AssertionComment extends LineComment {
44
boolean isOK;
55

66
AssertionComment() {
7-
isOK = true and getText().trim().regexpMatch("OK.*")
7+
isOK = true and getText().trim().matches("OK%")
88
or
9-
isOK = false and getText().trim().regexpMatch("NOT OK.*")
9+
isOK = false and getText().trim().matches("NOT OK%")
1010
}
1111

1212
ConditionGuardNode getAGuardNode() {

javascript/ql/test/library-tests/StringConcatenation/ClassContainsTwo.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import javascript
22

33
// Select all expressions whose string value contains the word "two"
44
predicate containsTwo(DataFlow::Node node) {
5-
node.getStringValue().regexpMatch(".*two.*")
5+
node.getStringValue().matches("%two%")
66
or
77
containsTwo(node.getAPredecessor())
88
or

javascript/ql/test/library-tests/StringConcatenation/ContainsTwo.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import javascript
22

33
// Select all expressions whose string value contains the word "two"
44
predicate containsTwo(DataFlow::Node node) {
5-
node.getStringValue().regexpMatch(".*two.*")
5+
node.getStringValue().matches("%two%")
66
or
77
containsTwo(node.getAPredecessor())
88
or

0 commit comments

Comments
 (0)