Skip to content

Commit 2fd1ee6

Browse files
committed
JS: add DataFlow::Node.getIntValue()
1 parent 0fd9d15 commit 2fd1ee6

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

javascript/ql/src/semmle/javascript/dataflow/DataFlow.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ module DataFlow {
108108
b = analyze().getAValue().(AbstractBoolean).getBooleanValue()
109109
}
110110

111+
/** Gets the integer value of this node, if it is an integer constant. */
112+
int getIntValue() { result = asExpr().getIntValue() }
113+
111114
/**
112115
* Holds if this expression may refer to the initial value of parameter `p`.
113116
*/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
| eval.js:2:11:2:12 | 42 | 42 |
2+
| sources.js:4:12:4:13 | 19 | 19 |
3+
| sources.js:5:4:5:5 | 23 | 23 |
4+
| tst.js:3:9:3:10 | 42 | 42 |
5+
| tst.js:51:11:51:12 | 42 | 42 |
6+
| tst.js:65:9:65:10 | 42 | 42 |
7+
| tst.js:69:11:69:12 | 23 | 23 |
8+
| tst.js:93:6:93:7 | 19 | 19 |
9+
| tst.js:94:6:94:7 | 23 | 23 |
10+
| tst.js:95:6:95:6 | 0 | 0 |
11+
| tst.js:103:6:103:7 | 19 | 19 |
12+
| tst.js:103:10:103:11 | 23 | 23 |
13+
| tst.js:103:14:103:14 | 0 | 0 |
14+
| tst.ts:2:18:2:19 | 42 | 42 |
15+
| tst.ts:8:9:8:10 | 23 | 23 |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import javascript
2+
3+
from DataFlow::Node node
4+
select node, node.getIntValue()

0 commit comments

Comments
 (0)