mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
JavaScript: Remove omittable exists variables
This commit is contained in:
@@ -465,10 +465,7 @@ module DOM {
|
||||
*/
|
||||
private DataFlow::SourceNode nonFirstLocationType(DataFlow::TypeTracker t) {
|
||||
// One step inlined in the beginning.
|
||||
exists(DataFlow::TypeTracker t2 |
|
||||
result =
|
||||
any(DataFlow::Node n | n.hasUnderlyingType("Location")).getALocalSource().track(t2, t)
|
||||
)
|
||||
result = any(DataFlow::Node n | n.hasUnderlyingType("Location")).getALocalSource().track(_, t)
|
||||
or
|
||||
exists(DataFlow::TypeTracker t2 | result = nonFirstLocationType(t2).track(t2, t))
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ deprecated private int nextDefAfter(BasicBlock bb, Variable v, int i, VarDef d)
|
||||
* DEPRECATED: Use the `SSA.qll` library instead.
|
||||
*/
|
||||
deprecated predicate localDefinitionOverwrites(LocalVariable v, VarDef earlier, VarDef later) {
|
||||
exists(BasicBlock bb, int i, int next | next = nextDefAfter(bb, v, i, earlier) |
|
||||
exists(BasicBlock bb, int next | next = nextDefAfter(bb, v, _, earlier) |
|
||||
bb.defAt(next, v, later)
|
||||
or
|
||||
exists(BasicBlock succ | succ = bb.getASuccessor() |
|
||||
|
||||
@@ -571,7 +571,7 @@ class ObjectExpr extends @obj_expr, Expr {
|
||||
Property getProperty(int i) { properties(result, this, i, _, _) }
|
||||
|
||||
/** Gets a property in this object literal. */
|
||||
Property getAProperty() { exists(int i | result = this.getProperty(i)) }
|
||||
Property getAProperty() { result = this.getProperty(_) }
|
||||
|
||||
/** Gets the number of properties in this object literal. */
|
||||
int getNumProperty() { result = count(this.getAProperty()) }
|
||||
|
||||
@@ -47,7 +47,7 @@ class Function extends @function, Parameterized, TypeParameterized, StmtContaine
|
||||
}
|
||||
|
||||
/** Gets a parameter of this function. */
|
||||
override Parameter getAParameter() { exists(int idx | result = this.getParameter(idx)) }
|
||||
override Parameter getAParameter() { result = this.getParameter(_) }
|
||||
|
||||
/** Gets the parameter named `name` of this function, if any. */
|
||||
SimpleParameter getParameterByName(string name) {
|
||||
|
||||
@@ -316,7 +316,7 @@ class Require extends CallExpr, Import {
|
||||
override Module resolveImportedPath() {
|
||||
moduleInFile(result, this.load(min(int prio | moduleInFile(_, this.load(prio)))))
|
||||
or
|
||||
not exists(Module mod | moduleInFile(mod, this.load(_))) and
|
||||
not moduleInFile(_, this.load(_)) and
|
||||
result = Import.super.resolveImportedPath()
|
||||
}
|
||||
|
||||
|
||||
@@ -723,7 +723,7 @@ module Routing {
|
||||
isInstalledAt(result, router, node)
|
||||
or
|
||||
result = getMostRecentRouteSetupAt(router, node.getAPredecessor()) and
|
||||
not exists(RouteSetup setup | isInstalledAt(setup, router, node))
|
||||
not isInstalledAt(_, router, node)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -977,8 +977,8 @@ module Routing {
|
||||
* Holds if `pred -> succ` is a data-flow step between access paths on request input objects.
|
||||
*/
|
||||
private predicate middlewareDataFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
|
||||
exists(Node writer, Node reader, int n, string path |
|
||||
potentialAccessPathStep(writer, pred, reader, succ, n, path) and
|
||||
exists(Node writer, Node reader |
|
||||
potentialAccessPathStep(writer, pred, reader, succ, _, _) and
|
||||
pragma[only_bind_out](reader).isGuardedByNode(pragma[only_bind_out](writer))
|
||||
)
|
||||
or
|
||||
|
||||
@@ -1155,9 +1155,9 @@ private predicate parameterPropRead(
|
||||
DataFlow::Node arg, string prop, DataFlow::Node succ, DataFlow::Configuration cfg,
|
||||
PathSummary summary
|
||||
) {
|
||||
exists(Function f, DataFlow::Node read, DataFlow::Node invk, DataFlow::Node parm |
|
||||
exists(Function f, DataFlow::Node read |
|
||||
reachesReturn(f, read, cfg, summary) and
|
||||
parameterPropReadStep(parm, read, prop, cfg, arg, invk, f, succ)
|
||||
parameterPropReadStep(_, read, prop, cfg, arg, _, f, succ)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1764,11 +1764,8 @@ private PathNode getASuccessor(PathNode nd) {
|
||||
result = initialMidNode(nd)
|
||||
or
|
||||
// mid node to mid node
|
||||
exists(
|
||||
Configuration cfg, DataFlow::Node predNd, PathSummary summary, DataFlow::Node succNd,
|
||||
PathSummary newSummary
|
||||
|
|
||||
midNodeStep(nd, predNd, cfg, summary, succNd, newSummary) and
|
||||
exists(Configuration cfg, PathSummary summary, DataFlow::Node succNd, PathSummary newSummary |
|
||||
midNodeStep(nd, _, cfg, summary, succNd, newSummary) and
|
||||
result = MkMidNode(succNd, id(cfg), summary.append(newSummary))
|
||||
)
|
||||
or
|
||||
|
||||
@@ -196,18 +196,14 @@ private module NpmPackagePortal {
|
||||
|
||||
/** Holds if `imp` is an import of package `pkgName`. */
|
||||
predicate imports(DataFlow::SourceNode imp, string pkgName) {
|
||||
exists(NpmPackage pkg |
|
||||
imp = getAModuleImport(pkg, pkgName) and
|
||||
pkgName.regexpMatch("[^./].*")
|
||||
)
|
||||
imp = getAModuleImport(_, pkgName) and
|
||||
pkgName.regexpMatch("[^./].*")
|
||||
}
|
||||
|
||||
/** Holds if `imp` imports `member` from package `pkgName`. */
|
||||
predicate imports(DataFlow::SourceNode imp, string pkgName, string member) {
|
||||
exists(NpmPackage pkg |
|
||||
imp = getAModuleMemberImport(pkg, pkgName, member) and
|
||||
pkgName.regexpMatch("[^./].*")
|
||||
)
|
||||
imp = getAModuleMemberImport(_, pkgName, member) and
|
||||
pkgName.regexpMatch("[^./].*")
|
||||
}
|
||||
|
||||
/** Gets the main module of package `pkgName`. */
|
||||
@@ -404,7 +400,7 @@ private module InstancePortal {
|
||||
* right-hand side of that definition.
|
||||
*/
|
||||
predicate instanceMemberDef(Portal base, string name, DataFlow::Node rhs, boolean escapes) {
|
||||
exists(AbstractInstance i, DataFlow::SourceNode ctor | isInstance(base, ctor, i, escapes) |
|
||||
exists(DataFlow::SourceNode ctor | isInstance(base, ctor, _, escapes) |
|
||||
// ES2015 instance method
|
||||
exists(MemberDefinition mem |
|
||||
mem = ctor.getAstNode().(ClassDefinition).getAMember() and
|
||||
|
||||
@@ -611,9 +611,9 @@ module TaintTracking {
|
||||
)
|
||||
or
|
||||
// String.fromCharCode and String.fromCodePoint
|
||||
exists(int i, DataFlow::MethodCallNode mcn |
|
||||
exists(DataFlow::MethodCallNode mcn |
|
||||
mcn = succ and
|
||||
pred = mcn.getArgument(i) and
|
||||
pred = mcn.getAnArgument() and
|
||||
mcn.getMethodName() = ["fromCharCode", "fromCodePoint"]
|
||||
)
|
||||
or
|
||||
|
||||
@@ -6,7 +6,7 @@ private import VariableTypeInference
|
||||
*/
|
||||
pragma[nomagic]
|
||||
predicate isAnalyzedParameter(Parameter p) {
|
||||
exists(FunctionWithAnalyzedParameters f, int parmIdx | p = f.getParameter(parmIdx) |
|
||||
exists(FunctionWithAnalyzedParameters f | p = f.getAParameter() |
|
||||
// we cannot track flow into rest parameters
|
||||
not p.isRestParameter()
|
||||
)
|
||||
|
||||
@@ -82,9 +82,9 @@ private predicate relevantExport(ES2015Module m, string x) {
|
||||
x = id.getASpecifier().getImportedName()
|
||||
)
|
||||
or
|
||||
exists(ReExportDeclaration rexp, string y |
|
||||
exists(ReExportDeclaration rexp |
|
||||
rexp.getReExportedModule() = m and
|
||||
reExportsAs(rexp, x, y)
|
||||
reExportsAs(rexp, x, _)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -620,9 +620,7 @@ module Http {
|
||||
create.getArgument(0).asExpr() instanceof NullLiteral
|
||||
)
|
||||
) and
|
||||
exists(RouteHandlerCandidate candidate |
|
||||
getAPossiblyDecoratedHandler(candidate).flowsTo(this.getAPropertyWrite().getRhs())
|
||||
)
|
||||
getAPossiblyDecoratedHandler(_).flowsTo(this.getAPropertyWrite().getRhs())
|
||||
}
|
||||
|
||||
override DataFlow::SourceNode getRouteHandler(DataFlow::SourceNode access) {
|
||||
|
||||
@@ -130,17 +130,14 @@ private module HandlebarsTaintSteps {
|
||||
* ```
|
||||
*/
|
||||
private predicate isHandlebarsArgStep(DataFlow::Node pred, DataFlow::Node succ) {
|
||||
exists(
|
||||
string helperName, DataFlow::CallNode templatingCall, DataFlow::CallNode compileCall,
|
||||
DataFlow::FunctionNode func
|
||||
|
|
||||
exists(string helperName, DataFlow::CallNode templatingCall, DataFlow::CallNode compileCall |
|
||||
templatingCall = compiledTemplate(compileCall).getACall() and
|
||||
exists(string templateText, string paramName, int argIdx |
|
||||
compileCall.getArgument(0).mayHaveStringValue(templateText)
|
||||
|
|
||||
pred = templatingCall.getArgument(0).getALocalSource().getAPropertyWrite(paramName).getRhs() and
|
||||
isTemplateHelperCallArg(templateText, helperName, argIdx, paramName) and
|
||||
succ = getRegisteredHelperParam(helperName, func, argIdx)
|
||||
succ = getRegisteredHelperParam(helperName, _, argIdx)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ module PkgCloud {
|
||||
string kind;
|
||||
|
||||
Credentials() {
|
||||
exists(string propertyName, DataFlow::InvokeNode invk, int i |
|
||||
takesConfigurationObject(invk, i) and
|
||||
exists(string propertyName, DataFlow::InvokeNode invk |
|
||||
takesConfigurationObject(invk, _) and
|
||||
this = invk.getOptionArgument(0, propertyName)
|
||||
|
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user