Skip to content

Commit 2957131

Browse files
authored
Merge pull request github#5258 from erik-krogh/nextPerf
Approved by asgerf
2 parents 9ea8f82 + ae051af commit 2957131

File tree

7 files changed

+25
-29
lines changed

7 files changed

+25
-29
lines changed

javascript/ql/src/semmle/javascript/AMD.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class AmdModuleDefinition extends CallExpr {
158158
result = [getAnImplicitExportsValue(), getAnExplicitExportsValue()]
159159
}
160160

161-
pragma[noinline]
161+
pragma[noinline, nomagic]
162162
private AbstractValue getAnImplicitExportsValue() {
163163
// implicit exports: anything that is returned from the factory function
164164
result = getModuleExpr().analyze().getAValue()

javascript/ql/src/semmle/javascript/DOM.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ module DOM {
344344
or
345345
exists(JQuery::MethodCall call | this = call and call.getMethodName() = "get" |
346346
call.getNumArgument() = 1 and
347-
forex(InferredType t | t = call.getArgument(0).analyze().getAType() | t = TTNumber())
347+
unique(InferredType t | t = call.getArgument(0).analyze().getAType()) = TTNumber()
348348
)
349349
or
350350
// A `this` node from a callback given to a `$().each(callback)` call.

javascript/ql/src/semmle/javascript/MembershipCandidates.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,27 +222,27 @@ module MembershipCandidate {
222222
*/
223223
class ObjectPropertyNameMembershipCandidate extends MembershipCandidate::Range,
224224
DataFlow::ValueNode {
225-
DataFlow::ValueNode test;
226-
DataFlow::ValueNode membersNode;
225+
Expr test;
226+
Expr membersNode;
227227

228228
ObjectPropertyNameMembershipCandidate() {
229229
exists(InExpr inExpr |
230230
this = inExpr.getLeftOperand().flow() and
231-
test = inExpr.flow() and
232-
membersNode = inExpr.getRightOperand().flow()
231+
test = inExpr and
232+
membersNode = inExpr.getRightOperand()
233233
)
234234
or
235-
exists(DataFlow::MethodCallNode hasOwn |
236-
this = hasOwn.getArgument(0) and
235+
exists(MethodCallExpr hasOwn |
236+
this = hasOwn.getArgument(0).flow() and
237237
test = hasOwn and
238238
hasOwn.calls(membersNode, "hasOwnProperty")
239239
)
240240
}
241241

242-
override DataFlow::Node getTest() { result = test }
242+
override DataFlow::Node getTest() { result = test.flow() }
243243

244244
override string getAMemberString() {
245-
exists(membersNode.getALocalSource().getAPropertyWrite(result))
245+
exists(membersNode.flow().getALocalSource().getAPropertyWrite(result))
246246
}
247247
}
248248

javascript/ql/src/semmle/javascript/Modules.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ abstract class Module extends TopLevel {
107107
* Symbols defined in another module that are re-exported by
108108
* this module are only sometimes considered.
109109
*/
110+
cached
110111
abstract DataFlow::Node getAnExportedValue(string name);
111112

112113
/**

javascript/ql/src/semmle/javascript/SSA.qll

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,10 @@ class SsaExplicitDefinition extends SsaDefinition, TExplicitDef {
520520
override predicate hasLocationInfo(
521521
string filepath, int startline, int startcolumn, int endline, int endcolumn
522522
) {
523-
getDef().getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
523+
exists(Location loc |
524+
pragma[only_bind_into](loc) = pragma[only_bind_into](getDef()).getLocation() and
525+
loc.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
526+
)
524527
}
525528

526529
/**
@@ -552,7 +555,10 @@ abstract class SsaImplicitDefinition extends SsaDefinition {
552555
) {
553556
endline = startline and
554557
endcolumn = startcolumn and
555-
getBasicBlock().getLocation().hasLocationInfo(filepath, startline, startcolumn, _, _)
558+
exists(Location loc |
559+
pragma[only_bind_into](loc) = pragma[only_bind_into](getBasicBlock()).getLocation() and
560+
loc.hasLocationInfo(filepath, startline, startcolumn, _, _)
561+
)
556562
}
557563
}
558564

@@ -660,14 +666,6 @@ class SsaPhiNode extends SsaPseudoDefinition, TPhi {
660666

661667
override string prettyPrintDef() { result = getSourceVariable() + " = phi(" + ppInputs() + ")" }
662668

663-
override predicate hasLocationInfo(
664-
string filepath, int startline, int startcolumn, int endline, int endcolumn
665-
) {
666-
endline = startline and
667-
endcolumn = startcolumn and
668-
getBasicBlock().getLocation().hasLocationInfo(filepath, startline, startcolumn, _, _)
669-
}
670-
671669
/**
672670
* If all inputs to this phi node are (transitive) refinements of the same variable,
673671
* gets that variable.

javascript/ql/src/semmle/javascript/frameworks/jQuery.qll

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,17 +544,17 @@ module JQuery {
544544
}
545545

546546
/** A source of jQuery objects from the AST-based `JQueryObject` class. */
547-
private DataFlow::Node legacyObjectSource() { result = any(JQueryObjectInternal e).flow() }
547+
private DataFlow::SourceNode legacyObjectSource() {
548+
result = any(JQueryObjectInternal e).flow().getALocalSource()
549+
}
548550

549551
/** Gets a source of jQuery objects. */
550552
private DataFlow::SourceNode objectSource(DataFlow::TypeTracker t) {
551553
t.start() and
552554
result instanceof ObjectSource::Range
553555
or
554-
exists(DataFlow::TypeTracker init |
555-
init.start() and
556-
t = init.smallstep(legacyObjectSource(), result)
557-
)
556+
t.start() and
557+
result = legacyObjectSource()
558558
}
559559

560560
/** Gets a data flow node referring to a jQuery object. */
@@ -590,10 +590,6 @@ module JQuery {
590590
read.getBase().getALocalSource() = [dollar(), objectRef()] and
591591
read.mayHavePropertyName(name)
592592
)
593-
or
594-
// Handle contributed JQuery objects that aren't source nodes (usually parameter uses)
595-
getReceiver() = legacyObjectSource() and
596-
this.(DataFlow::MethodCallNode).getMethodName() = name
597593
}
598594

599595
/**

javascript/ql/src/semmle/javascript/security/dataflow/DOM.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ private class PostMessageEventParameter extends RemoteFlowSource {
229229
* even if the window is opened from a foreign domain.
230230
*/
231231
private class WindowNameAccess extends RemoteFlowSource {
232+
pragma[nomagic, noinline]
232233
WindowNameAccess() {
233234
this = DataFlow::globalObjectRef().getAPropertyRead("name")
234235
or

0 commit comments

Comments
 (0)