Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2bfb015

Browse files
committed
JS: Add closure string ops
1 parent 999e0c8 commit 2bfb015

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

javascript/ql/src/semmle/javascript/StringOps.qll

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,18 @@ module StringOps {
112112
}
113113

114114
/**
115-
* A call of form `_.startsWith(A, B)` or `ramda.startsWith(A, B)`.
115+
* A call of form `_.startsWith(A, B)` or `ramda.startsWith(A, B)` or `goog.string.startsWith(A, B)`.
116116
*/
117117
private class StartsWith_Library extends Range, DataFlow::CallNode {
118118
StartsWith_Library() {
119119
getNumArgument() = 2 and
120120
exists(DataFlow::SourceNode callee | this = callee.getACall() |
121121
callee = LodashUnderscore::member("startsWith") or
122-
callee = DataFlow::moduleMember("ramda", "startsWith")
122+
callee = DataFlow::moduleMember("ramda", "startsWith") or
123+
exists(string name |
124+
callee = Closure::moduleImport("goog.string." + name) and
125+
(name = "startsWith" or name = "caseInsensitiveStartsWith")
126+
)
123127
)
124128
}
125129

@@ -250,6 +254,9 @@ module StringOps {
250254
exists(string name |
251255
this = LodashUnderscore::member(name).getACall() and
252256
(name = "includes" or name = "include" or name = "contains")
257+
or
258+
this = Closure::moduleImport("goog.string." + name).getACall() and
259+
(name = "contains" or name = "caseInsensitiveContains")
253260
)
254261
}
255262

@@ -416,7 +423,11 @@ module StringOps {
416423
getNumArgument() = 2 and
417424
exists(DataFlow::SourceNode callee | this = callee.getACall() |
418425
callee = LodashUnderscore::member("endsWith") or
419-
callee = DataFlow::moduleMember("ramda", "endsWith")
426+
callee = DataFlow::moduleMember("ramda", "endsWith") or
427+
exists(string name |
428+
callee = Closure::moduleImport("goog.string." + name) and
429+
(name = "endsWith" or name = "caseInsensitiveEndsWith")
430+
)
420431
)
421432
}
422433

0 commit comments

Comments
 (0)