Skip to content

Commit

Permalink
JS: Run the autoformatter for .qll/.ql files
Browse files Browse the repository at this point in the history
  • Loading branch information
yuske committed Aug 26, 2021
1 parent 681b1a5 commit f1957df
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
41 changes: 18 additions & 23 deletions javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ module DataFlow {
}

/**
* A data flow node representing arguments of the `.apply` function call
* A data flow node representing arguments of the `.apply` function call
* to emulate a separate argument for each parameter of a reflective function call.
*/
private class ApplyArgumentNode extends DataFlow::Node {
Expand All @@ -1171,24 +1171,25 @@ module DataFlow {
int index;

ApplyArgumentNode() {
this = TApplyArgumentNode(
call.asExpr(),
call.getReceiver().getABoundFunctionValue(_).getFunction(),
index) and
this =
TApplyArgumentNode(call.asExpr(),
call.getReceiver().getABoundFunctionValue(_).getFunction(), index) and
arrayArgument = call.getArgument(1)
}

/**
* Gets an explicit call of the `.apply` function call
* that takes an argument represented by this data flow node.
* */
/**
* Gets an explicit call of the `.apply` function call
* that takes an argument represented by this data flow node.
*/
ExplicitMethodCallNode getCall() { result = call }

/** Gets an argument index represented by this data flow node. */
int getIndex() { result = index }

override string toString() { result = arrayArgument.toString() + "[" + index.toString() + "]" }

override string toString() {
result = arrayArgument.toString() + "[" + index.toString() + "]"
}

override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
Expand All @@ -1199,7 +1200,7 @@ module DataFlow {
/**
* A data flow node representing a reflective function call.
*/
private abstract class ReflectiveCallNodeDef extends CallNodeDef {
abstract private class ReflectiveCallNodeDef extends CallNodeDef {
ExplicitMethodCallNode originalCall;

override InvokeExpr getInvokeExpr() { result = originalCall.getInvokeExpr() }
Expand All @@ -1224,17 +1225,13 @@ module DataFlow {
}

override DataFlow::Node getAnArgument() {
result = originalCall.getAnArgument() and
result = originalCall.getAnArgument() and
result != getReceiver()
}

override DataFlow::Node getASpreadArgument() {
result = originalCall.getASpreadArgument()
}
override DataFlow::Node getASpreadArgument() { result = originalCall.getASpreadArgument() }

override int getNumArgument() {
result >= 0 and result = originalCall.getNumArgument() - 1
}
override int getNumArgument() { result >= 0 and result = originalCall.getNumArgument() - 1 }
}

/**
Expand All @@ -1244,17 +1241,15 @@ module DataFlow {
ApplyReflectiveCallNodeDef() { this = TReflectiveCallNode(originalCall.asExpr(), "apply") }

ApplyArgumentNode getApplyArgument(int i) {
result.getCall() = originalCall and
result.getCall() = originalCall and
result.getIndex() = i
}

override DataFlow::Node getArgument(int i) { none() }

override DataFlow::Node getAnArgument() { none() }

override DataFlow::Node getASpreadArgument() {
result = originalCall.getArgument(1)
}
override DataFlow::Node getASpreadArgument() { result = originalCall.getArgument(1) }

override int getNumArgument() { none() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,4 @@ newtype TNode =
TExceptionalInvocationReturnNode(InvokeExpr e) or
TGlobalAccessPathRoot() or
TTemplatePlaceholderTag(Templating::TemplatePlaceholderTag tag) or
TApplyArgumentNode(MethodCallExpr ce, Function func, int i) {
exists(func.getParameter(i))
}
TApplyArgumentNode(MethodCallExpr ce, Function func, int i) { exists(func.getParameter(i)) }
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ private module CachedSteps {
) {
calls(invk, f) and
(
exists(int i | arg = invk.(DataFlow::InvokeNode).getArgument(i) or arg = invk.(DataFlow::Impl::ApplyReflectiveCallNodeDef).getApplyArgument(i) |
exists(int i |
arg = invk.(DataFlow::InvokeNode).getArgument(i) or
arg = invk.(DataFlow::Impl::ApplyReflectiveCallNodeDef).getApplyArgument(i)
|
exists(Parameter p |
f.getParameter(i) = p and
not p.isRestParameter() and
Expand Down
2 changes: 1 addition & 1 deletion javascript/ql/test/library-tests/Arrays/DataFlow.ql
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class ArrayFlowConfig extends DataFlow::Configuration {

from ArrayFlowConfig config, DataFlow::Node src, DataFlow::Node snk, string snk_file
where config.hasFlow(src, snk) and snk_file = snk.getAstNode().getFile().getBaseName()
select snk_file, snk, src
select snk_file, snk, src

0 comments on commit f1957df

Please sign in to comment.