Skip to content

Commit 52c2e37

Browse files
committed
JS: Update CollectionStep usage in HTTP
1 parent 2759d53 commit 52c2e37

File tree

1 file changed

+14
-16
lines changed
  • javascript/ql/src/semmle/javascript/frameworks

1 file changed

+14
-16
lines changed

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import javascript
66
private import semmle.javascript.DynamicPropertyAccess
77
private import semmle.javascript.dataflow.internal.StepSummary
88
private import semmle.javascript.dataflow.internal.CallGraphs
9+
private import DataFlow::PseudoProperties as PseudoProperties
910

1011
module HTTP {
1112
/**
@@ -689,33 +690,30 @@ module HTTP {
689690
isDecoratedCall(result, candidate)
690691
}
691692

693+
private string mapValueProp() {
694+
result = [PseudoProperties::mapValueAll(), PseudoProperties::mapValueUnknownKey()]
695+
}
696+
692697
/**
693698
* A collection that contains one or more route potential handlers.
694699
*/
695-
private class ContainerCollection extends HTTP::RouteHandlerCandidateContainer::Range {
700+
private class ContainerCollection extends HTTP::RouteHandlerCandidateContainer::Range,
701+
DataFlow::NewNode {
696702
ContainerCollection() {
697703
this = DataFlow::globalVarRef("Map").getAnInstantiation() and // restrict to Map for now
698-
exists(
699-
CollectionFlowStep store, DataFlow::Node storeTo, DataFlow::Node input,
700-
RouteHandlerCandidate candidate
701-
|
702-
this.flowsTo(storeTo) and
703-
store.store(input, storeTo, _) and
704-
candidate.flowsTo(input)
704+
exists(DataFlow::Node use |
705+
DataFlow::SharedTypeTrackingStep::storeStep(use, this, mapValueProp()) and
706+
use.getALocalSource() instanceof RouteHandlerCandidate
705707
)
706708
}
707709

708710
override DataFlow::SourceNode getRouteHandler(DataFlow::SourceNode access) {
709-
result instanceof RouteHandlerCandidate and
710-
exists(
711-
DataFlow::Node input, string key, CollectionFlowStep store, CollectionFlowStep load,
712-
DataFlow::Node storeTo, DataFlow::Node loadFrom
713-
|
714-
this.flowsTo(storeTo) and
715-
store.store(input, storeTo, key) and
711+
exists(DataFlow::Node input, string key, DataFlow::Node loadFrom |
716712
getAPossiblyDecoratedHandler(result).flowsTo(input) and
713+
DataFlow::SharedTypeTrackingStep::storeStep(input, this, key) and
717714
ref(this).flowsTo(loadFrom) and
718-
load.load(loadFrom, access, key)
715+
DataFlow::SharedTypeTrackingStep::loadStep(loadFrom, access,
716+
[key, PseudoProperties::mapValueAll()])
719717
)
720718
}
721719
}

0 commit comments

Comments
 (0)