mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #6869 from MathiasVP/fix-prefix/suffix-equality
Java/JS/Python: Replace '.prefix'/'.suffix' with '.matches'
This commit is contained in:
@@ -727,7 +727,7 @@ module NodeJSLib {
|
||||
result = getParameter(1).getARhs()
|
||||
}
|
||||
|
||||
override predicate isSync() { "Sync" = methodName.suffix(methodName.length() - 4) }
|
||||
override predicate isSync() { methodName.matches("%Sync") }
|
||||
|
||||
override DataFlow::Node getOptionsArg() {
|
||||
not result.getALocalSource() instanceof DataFlow::FunctionNode and // looks like callback
|
||||
|
||||
@@ -107,9 +107,7 @@ private class SystemCommandExecutors extends SystemCommandExecution, DataFlow::I
|
||||
*/
|
||||
bindingset[name]
|
||||
private boolean getSync(string name) {
|
||||
if name.suffix(name.length() - 4) = "Sync" or name.suffix(name.length() - 4) = "sync"
|
||||
then result = true
|
||||
else result = false
|
||||
if name.matches("%Sync") or name.matches("%sync") then result = true else result = false
|
||||
}
|
||||
|
||||
private class RemoteCommandExecutor extends SystemCommandExecution, DataFlow::InvokeNode {
|
||||
|
||||
@@ -303,14 +303,11 @@ module PrettyPrintCatCall {
|
||||
bindingset[str]
|
||||
private string createSimplifiedStringConcat(string str) {
|
||||
// Remove an initial ""+ (e.g. in `""+file`)
|
||||
if str.prefix(5) = "\"\" + "
|
||||
if str.matches("\"\" + %")
|
||||
then result = str.suffix(5)
|
||||
else
|
||||
// prettify `${newpath}` to just newpath
|
||||
if
|
||||
str.prefix(3) = "`${" and
|
||||
str.suffix(str.length() - 2) = "}`" and
|
||||
not str.suffix(3).matches("%{%")
|
||||
if str.matches("`${%") and str.matches("%}`") and not str.suffix(3).matches("%{%")
|
||||
then result = str.prefix(str.length() - 2).suffix(3)
|
||||
else result = str
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class AsyncSentinelCall extends DataFlow::CallNode {
|
||||
exists(DataFlow::FunctionNode node | node.getAstNode() = asyncCallee |
|
||||
// manual models
|
||||
exists(string memberName |
|
||||
not "Sync" = memberName.suffix(memberName.length() - 4) and
|
||||
not memberName.matches("%Sync") and
|
||||
this = NodeJSLib::FS::moduleMember(memberName).getACall() and
|
||||
node = this.getCallback([1 .. 2])
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user