Skip to content

Commit 0f6e8bf

Browse files
authored
Merge pull request github#18451 from asgerf/jss/cleanup-todos
JS: Clean up some TODO comments
2 parents 1997e0a + 9c4d378 commit 0f6e8bf

File tree

13 files changed

+15
-59
lines changed

13 files changed

+15
-59
lines changed

javascript/ql/lib/semmle/javascript/dataflow/AdditionalTaintSteps.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,7 @@ class LegacyTaintStep extends Unit {
232232
cached
233233
private module Cached {
234234
cached
235-
predicate forceStage() {
236-
// TODO: ensure that this stage is only evaluated if using the old data flow library
237-
Stages::Taint::ref()
238-
}
235+
predicate forceStage() { Stages::Taint::ref() }
239236

240237
/**
241238
* Holds if `pred` → `succ` should be considered a taint-propagating

javascript/ql/lib/semmle/javascript/dataflow/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ private class Node = DataFlow::Node;
2020

2121
class PostUpdateNode = DataFlow::PostUpdateNode;
2222

23-
// TODO: this bypasses refinement nodes, and therefore some sanitisers
2423
class SsaUseNode extends DataFlow::Node, TSsaUseNode {
2524
private ControlFlowNode expr;
2625

@@ -524,7 +523,7 @@ private predicate isArgumentNodeImpl(Node n, DataFlowCall call, ArgumentPosition
524523
// receiver of accessor call
525524
pos.isThis() and n = call.asAccessorCall().getBase()
526525
or
527-
// argument to setter (TODO: this has no post-update node)
526+
// argument to setter
528527
pos.asPositional() = 0 and n = call.asAccessorCall().(DataFlow::PropWrite).getRhs()
529528
or
530529
FlowSummaryImpl::Private::summaryArgumentNode(call.(SummaryCall).getReceiver(),
@@ -640,7 +639,7 @@ predicate nodeIsHidden(Node node) {
640639
node instanceof CaptureNode
641640
or
642641
// Hide function expressions, as capture-flow causes them to appear in unhelpful ways
643-
// TODO: Instead hide PathNodes with a capture content as the head of its access path?
642+
// In the future we could hide PathNodes with a capture content as the head of its access path.
644643
node.asExpr() instanceof Function
645644
or
646645
// Also hide post-update nodes for function expressions
@@ -1402,7 +1401,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
14021401
// shift known array indices
14031402
c.asSingleton().asArrayIndex() = content.asArrayIndex() + restIndex
14041403
or
1405-
content.isUnknownArrayElement() and // TODO: don't read unknown array elements from static array
1404+
content.isUnknownArrayElement() and
14061405
c = ContentSet::arrayElementUnknown()
14071406
)
14081407
or

javascript/ql/lib/semmle/javascript/dataflow/internal/VariableCapture.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
114114

115115
class Callable extends js::StmtContainer {
116116
predicate isConstructor() {
117-
// TODO: clarify exactly what the library wants to know here as the meaning of "constructor" varies between languages.
118117
// JS constructors should not be seen as "constructors" in this context.
119118
none()
120119
}
@@ -254,7 +253,7 @@ js::DataFlow::Node getNodeFromClosureNode(VariableCaptureOutput::ClosureNode nod
254253
TValueNode(node.(VariableCaptureOutput::ParameterNode)
255254
.getParameter()
256255
.asLocalVariable()
257-
.getADeclaration()) // TODO: is this subsumed by the ExprNode case?
256+
.getADeclaration())
258257
or
259258
result = TThisNode(node.(VariableCaptureOutput::ParameterNode).getParameter().asThisContainer())
260259
or

javascript/ql/lib/semmle/javascript/internal/flow_summaries/Arrays.qll

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class CopyWithin extends SummarizedCallable {
140140
input = "Argument[this].WithArrayElement" and
141141
output = "ReturnValue"
142142
or
143-
// TODO: workaround for WithArrayElement not being converted to a taint step
143+
// Explicitly add a taint step since WithArrayElement is not implicitly converted to a taint step
144144
preservesValue = false and
145145
input = "Argument[this]" and
146146
output = "ReturnValue"
@@ -186,7 +186,7 @@ class Filter extends SummarizedCallable {
186186
output = "ReturnValue"
187187
)
188188
or
189-
// TODO: workaround for WithArrayElement not being converted to a taint step
189+
// Explicitly add a taint step since WithArrayElement is not implicitly converted to a taint step
190190
preservesValue = false and
191191
input = "Argument[this]" and
192192
output = "ReturnValue"
@@ -328,10 +328,7 @@ class From1Arg extends SummarizedCallable {
328328
output = "ReturnValue[exception]"
329329
)
330330
or
331-
// TODO: we currently convert ArrayElement read/store steps to taint steps, but this does not
332-
// work for WithArrayElement because it's just an expectsContent node, and there's no way easy
333-
// to omit the expectsContent restriction in taint tracking.
334-
// Work around this for now.
331+
// Explicitly add a taint step since WithArrayElement is not implicitly converted to a taint step
335332
preservesValue = false and
336333
input = "Argument[0]" and
337334
output = "ReturnValue"
@@ -561,7 +558,7 @@ class ArrayCoercionPackage extends FunctionalPackageSummary {
561558
output = "ReturnValue.ArrayElement"
562559
)
563560
or
564-
// TODO: workaround for WithArrayElement not being converted to a taint step
561+
// Explicitly add a taint step since WithArrayElement is not implicitly converted to a taint step
565562
preservesValue = false and
566563
input = "Argument[0]" and
567564
output = "ReturnValue"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ module DomBasedXssConfig implements DataFlow::StateConfigSig {
105105
state1.isTaintedUrlSuffix() and
106106
state2.isTaintedPrefix()
107107
or
108-
// FIXME: this fails to work in the test case at jquery.js:37
109108
exists(DataFlow::FunctionNode callback, DataFlow::Node arg |
110109
any(JQuery::MethodCall c).interpretsArgumentAsHtml(arg) and
111110
callback = arg.getABoundFunctionValue(_) and

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ module PrototypePollutingAssignmentConfig implements DataFlow::StateConfigSig {
6565
state = FlowState::objectPrototype()
6666
}
6767

68-
predicate isBarrierIn(DataFlow::Node node, FlowState state) {
69-
// FIXME: This should only be an in-barrier for the corresponding flow state, but flow-state specific in-barriers are not supported right now.
70-
isSource(node, state)
71-
}
68+
predicate isBarrierIn(DataFlow::Node node, FlowState state) { isSource(node, state) }
7269

7370
predicate isAdditionalFlowStep(
7471
DataFlow::Node node1, FlowState state1, DataFlow::Node node2, FlowState state2
@@ -99,11 +96,6 @@ module PrototypePollutingAssignmentConfig implements DataFlow::StateConfigSig {
9996
state2 = FlowState::objectPrototype()
10097
)
10198
or
102-
// TODO: local field step becomes a jump step, resulting in FPs (closure-lib)
103-
// TODO: localFieldStep is too expensive with dataflow2
104-
// DataFlow::localFieldStep(pred, succ)
105-
none()
106-
or
10799
state1 = FlowState::taint() and
108100
TaintTracking::defaultTaintStep(node1, node2) and
109101
state1 = state2

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ module UnsafeCodeConstruction {
2929
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
3030
// HTML sanitizers are insufficient protection against code injection
3131
node1 = node2.(HtmlSanitizerCall).getInput()
32-
or
33-
none()
34-
// TODO: localFieldStep is too expensive with dataflow2
35-
// DataFlow::localFieldStep(pred, succ)
3632
}
3733

3834
DataFlow::FlowFeature getAFeature() { result instanceof DataFlow::FeatureHasSourceCallContext }

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ module UnsafeHtmlConstructionConfig implements DataFlow::StateConfigSig {
4747
predicate isAdditionalFlowStep(
4848
DataFlow::Node node1, FlowState state1, DataFlow::Node node2, FlowState state2
4949
) {
50-
// TODO: localFieldStep is too expensive with dataflow2
51-
// DataFlow::localFieldStep(pred, succ) and
52-
// inlbl.isTaint() and
53-
// outlbl.isTaint()
54-
none()
55-
or
5650
TaintedObject::isAdditionalFlowStep(node1, state1, node2, state2)
5751
or
5852
// property read from a tainted object is considered tainted

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import UnsafeJQueryPluginCustomizations::UnsafeJQueryPlugin
1111
* A taint-tracking configuration for reasoning about XSS in unsafe jQuery plugins.
1212
*/
1313
module UnsafeJQueryPluginConfig implements DataFlow::ConfigSig {
14-
// TODO: PropertyPresenceSanitizer should not block values in a content.
14+
// Note: This query currently misses some results due to two issues:
15+
// - PropertyPresenceSanitizer blocks values in a content
16+
// - localFieldStep has been omitted for performance reaons
1517
predicate isSource(DataFlow::Node source) { source instanceof Source }
1618

1719
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
@@ -23,11 +25,6 @@ module UnsafeJQueryPluginConfig implements DataFlow::ConfigSig {
2325
}
2426

2527
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node sink) {
26-
// jQuery plugins tend to be implemented as classes that store data in fields initialized by the constructor.
27-
// TODO: localFieldStep is too expensive with dataflow2
28-
// DataFlow::localFieldStep(pred, succ)
29-
none()
30-
or
3128
aliasPropertyPresenceStep(node1, sink)
3229
}
3330

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import UnsafeShellCommandConstructionCustomizations::UnsafeShellCommandConstruct
1414
* A taint-tracking configuration for reasoning about shell command constructed from library input vulnerabilities.
1515
*/
1616
module UnsafeShellCommandConstructionConfig implements DataFlow::ConfigSig {
17-
// TODO: we get a FP in the test case due to SanitizingRegExpTest not being able to generate a barrier edge
18-
// for an edge into a phi node.
1917
predicate isSource(DataFlow::Node source) { source instanceof Source }
2018

2119
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
@@ -26,12 +24,6 @@ module UnsafeShellCommandConstructionConfig implements DataFlow::ConfigSig {
2624
node = TaintTracking::AdHocWhitelistCheckSanitizer::getABarrierNode()
2725
}
2826

29-
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
30-
none()
31-
// TODO: localFieldStep is too expensive with dataflow2
32-
// DataFlow::localFieldStep(pred, succ)
33-
}
34-
3527
DataFlow::FlowFeature getAFeature() { result instanceof DataFlow::FeatureHasSourceCallContext }
3628
}
3729

0 commit comments

Comments
 (0)