forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomAbstractValueDefinitionsFlow.ql
More file actions
31 lines (23 loc) · 997 Bytes
/
CustomAbstractValueDefinitionsFlow.ql
File metadata and controls
31 lines (23 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import javascript
import semmle.javascript.dataflow.InferredTypes
import semmle.javascript.dataflow.CustomAbstractValueDefinitions
class MyCustomAbstractValueDefinition extends CustomAbstractValueDefinition {
DataFlow::ValueNode node;
MyCustomAbstractValueDefinition() {
DataFlow::valueNode(this) = node and
node instanceof DataFlow::ObjectLiteralNode and
exists(DataFlow::PropWrite pwn |
pwn.writes(node, "custom", any(BooleanLiteral l | l.getValue() = "true").flow())
)
}
override boolean getBooleanValue() { result = true }
override predicate isCoercibleToNumber() { none() }
override PrimitiveAbstractValue toPrimitive() { result = TAbstractOtherString() }
override InferredType getType() { result = TTObject() }
override predicate shouldTrackProperties() { none() }
}
from AnalyzedValueNode n, MyCustomAbstractValueDefinition def, CustomAbstractValueFromDefinition val
where
def.getAbstractValue() = val and
n.getAValue() = val
select n, val