Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15d999a

Browse files
committed
JS: Migrate DeepObjectResourceExhaustion
1 parent 5f42a71 commit 15d999a

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

javascript/ql/lib/semmle/javascript/security/dataflow/DeepObjectResourceExhaustionCustomizations.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@ private import semmle.javascript.security.TaintedObjectCustomizations
1111
* DoS attacks due to inefficient handling of user-controlled objects.
1212
*/
1313
module DeepObjectResourceExhaustion {
14+
import semmle.javascript.security.CommonFlowState
15+
1416
/**
1517
* A data flow source for inefficient handling of user-controlled objects.
1618
*/
1719
abstract class Source extends DataFlow::Node {
18-
/** Gets a flow label to associate with this source. */
19-
DataFlow::FlowLabel getAFlowLabel() { result = TaintedObject::label() }
20+
/** Gets a flow state to associate with this source. */
21+
FlowState getAFlowState() { result.isTaintedObject() }
22+
23+
/** DEPRECATED. Use `getAFlowState()` instead. */
24+
deprecated DataFlow::FlowLabel getAFlowLabel() { result = this.getAFlowState().toFlowLabel() }
2025
}
2126

2227
private class TaintedObjectSourceAsSource extends Source instanceof TaintedObject::Source {
23-
override DataFlow::FlowLabel getAFlowLabel() { result = TaintedObject::label() }
28+
override FlowState getAFlowState() { result.isTaintedObject() }
2429
}
2530

2631
/** An active threat-model source, considered as a flow source. */
2732
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource {
28-
override DataFlow::FlowLabel getAFlowLabel() { result.isTaint() }
33+
override FlowState getAFlowState() { result.isTaint() }
2934
}
3035

3136
/**

javascript/ql/lib/semmle/javascript/security/dataflow/DeepObjectResourceExhaustionQuery.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ import DeepObjectResourceExhaustionCustomizations::DeepObjectResourceExhaustion
1212
* of user-controlled objects.
1313
*/
1414
module DeepObjectResourceExhaustionConfig implements DataFlow::StateConfigSig {
15-
class FlowState = DataFlow::FlowLabel;
15+
import semmle.javascript.security.CommonFlowState
1616

17-
predicate isSource(DataFlow::Node source, DataFlow::FlowLabel label) {
18-
source.(Source).getAFlowLabel() = label
17+
predicate isSource(DataFlow::Node source, FlowState state) {
18+
source.(Source).getAFlowState() = state
1919
}
2020

21-
predicate isSink(DataFlow::Node sink, DataFlow::FlowLabel label) {
22-
sink instanceof Sink and label = TaintedObject::label()
21+
predicate isSink(DataFlow::Node sink, FlowState state) {
22+
sink instanceof Sink and state.isTaintedObject()
2323
}
2424

25-
predicate isBarrier(DataFlow::Node node, DataFlow::FlowLabel label) {
26-
node = TaintedObject::SanitizerGuard::getABarrierNode(label)
25+
predicate isBarrier(DataFlow::Node node, FlowState state) {
26+
node = TaintedObject::SanitizerGuard::getABarrierNode(state)
2727
}
2828

2929
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
3030

3131
predicate isAdditionalFlowStep(
32-
DataFlow::Node src, DataFlow::FlowLabel inlbl, DataFlow::Node trg, DataFlow::FlowLabel outlbl
32+
DataFlow::Node node1, FlowState state1, DataFlow::Node node2, FlowState state2
3333
) {
34-
TaintedObject::step(src, trg, inlbl, outlbl)
34+
TaintedObject::isAdditionalFlowStep(node1, state1, node2, state2)
3535
}
3636
}
3737

0 commit comments

Comments
 (0)