-
Notifications
You must be signed in to change notification settings - Fork 2k
JS: Add AdditionalTypeTrackingStep #1788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
semmle-qlci
merged 1 commit into
github:master
from
asger-semmle:additional-type-tracking-step
Aug 24, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 26 additions & 22 deletions
48
javascript/ql/test/library-tests/TypeTracking/ClassStyle.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,30 @@ | ||
| test_ApiObject | ||
| | tst.js:3:11:3:21 | new myapi() | | ||
| | tst.js:15:10:15:21 | api.chain1() | | ||
| | tst.js:15:10:15:30 | api.cha ... hain2() | | ||
| | tst.js:4:11:4:21 | new myapi() | | ||
| | tst.js:16:10:16:21 | api.chain1() | | ||
| | tst.js:16:10:16:30 | api.cha ... hain2() | | ||
| test_Connection | ||
| | tst.js:6:15:6:18 | conn | | ||
| | tst.js:10:5:10:19 | this.connection | | ||
| | tst.js:15:10:15:49 | api.cha ... ction() | | ||
| | tst.js:18:7:18:21 | getConnection() | | ||
| | tst.js:30:9:30:23 | getConnection() | | ||
| | tst.js:39:7:39:21 | getConnection() | | ||
| | tst.js:47:7:47:21 | getConnection() | | ||
| | tst.js:7:15:7:18 | conn | | ||
| | tst.js:11:5:11:19 | this.connection | | ||
| | tst.js:16:10:16:49 | api.cha ... ction() | | ||
| | tst.js:19:7:19:21 | getConnection() | | ||
| | tst.js:31:9:31:23 | getConnection() | | ||
| | tst.js:40:7:40:21 | getConnection() | | ||
| | tst.js:48:7:48:21 | getConnection() | | ||
| | tst.js:54:37:54:51 | getConnection() | | ||
| | tst.js:57:14:57:48 | config. ... ction') | | ||
| test_DataCallback | ||
| | tst.js:9:11:9:12 | cb | | ||
| | tst.js:20:1:22:1 | functio ... ata);\\n} | | ||
| | tst.js:29:26:29:27 | cb | | ||
| | tst.js:32:17:32:26 | data => {} | | ||
| | tst.js:37:10:37:19 | data => {} | | ||
| | tst.js:39:32:39:45 | getDataCurry() | | ||
| | tst.js:44:19:44:20 | cb | | ||
| | tst.js:47:32:47:60 | identit ... llback) | | ||
| | tst.js:10:11:10:12 | cb | | ||
| | tst.js:21:1:23:1 | functio ... ata);\\n} | | ||
| | tst.js:30:26:30:27 | cb | | ||
| | tst.js:33:17:33:26 | data => {} | | ||
| | tst.js:38:10:38:19 | data => {} | | ||
| | tst.js:40:32:40:45 | getDataCurry() | | ||
| | tst.js:45:19:45:20 | cb | | ||
| | tst.js:48:32:48:60 | identit ... llback) | | ||
| | tst.js:58:16:58:22 | x => {} | | ||
| test_DataValue | ||
| | tst.js:20:18:20:21 | data | | ||
| | tst.js:24:19:24:22 | data | | ||
| | tst.js:32:17:32:20 | data | | ||
| | tst.js:37:10:37:13 | data | | ||
| | tst.js:21:18:21:21 | data | | ||
| | tst.js:25:19:25:22 | data | | ||
| | tst.js:33:17:33:20 | data | | ||
| | tst.js:38:10:38:13 | data | | ||
| | tst.js:58:16:58:16 | x | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import javascript | ||
| import CustomStep | ||
|
|
||
| string chainableMethod() { | ||
| result = "chain1" or | ||
|
|
||
19 changes: 19 additions & 0 deletions
19
javascript/ql/test/library-tests/TypeTracking/CustomStep.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import javascript | ||
| private import DataFlow | ||
|
|
||
| predicate configStep(Node pred, Node succ) { | ||
| exists(CallNode setter, CallNode getter | | ||
| getter = moduleMember("@test/myconfig", "getConfigValue").getACall() and | ||
| setter = moduleMember("@test/myconfig", "setConfigValue").getACall() and | ||
| getter.getArgument(0).getStringValue() = setter.getArgument(0).getStringValue() and | ||
| pred = setter.getArgument(1) and | ||
| succ = getter | ||
| ) | ||
| } | ||
|
|
||
| class CustomStep extends AdditionalTypeTrackingStep, Node { | ||
| override predicate step(Node pred, Node succ) { | ||
| pred = this and | ||
| configStep(pred, succ) | ||
| } | ||
| } |
50 changes: 27 additions & 23 deletions
50
javascript/ql/test/library-tests/TypeTracking/PredicateStyle.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,31 @@ | ||
| apiObject | ||
| | tst.js:3:11:3:21 | new myapi() | | ||
| | tst.js:15:10:15:21 | api.chain1() | | ||
| | tst.js:15:10:15:30 | api.cha ... hain2() | | ||
| | tst.js:4:11:4:21 | new myapi() | | ||
| | tst.js:16:10:16:21 | api.chain1() | | ||
| | tst.js:16:10:16:30 | api.cha ... hain2() | | ||
| connection | ||
| | type tracker with call steps | tst.js:6:15:6:18 | conn | | ||
| | type tracker with call steps | tst.js:10:5:10:19 | this.connection | | ||
| | type tracker with call steps with property connection | tst.js:6:14:6:13 | this | | ||
| | type tracker without call steps | tst.js:15:10:15:49 | api.cha ... ction() | | ||
| | type tracker without call steps | tst.js:18:7:18:21 | getConnection() | | ||
| | type tracker without call steps | tst.js:30:9:30:23 | getConnection() | | ||
| | type tracker without call steps | tst.js:39:7:39:21 | getConnection() | | ||
| | type tracker without call steps | tst.js:47:7:47:21 | getConnection() | | ||
| | type tracker with call steps | tst.js:7:15:7:18 | conn | | ||
| | type tracker with call steps | tst.js:11:5:11:19 | this.connection | | ||
| | type tracker with call steps with property connection | tst.js:7:14:7:13 | this | | ||
| | type tracker without call steps | tst.js:16:10:16:49 | api.cha ... ction() | | ||
| | type tracker without call steps | tst.js:19:7:19:21 | getConnection() | | ||
| | type tracker without call steps | tst.js:31:9:31:23 | getConnection() | | ||
| | type tracker without call steps | tst.js:40:7:40:21 | getConnection() | | ||
| | type tracker without call steps | tst.js:48:7:48:21 | getConnection() | | ||
| | type tracker without call steps | tst.js:54:37:54:51 | getConnection() | | ||
| | type tracker without call steps | tst.js:57:14:57:48 | config. ... ction') | | ||
| dataCallback | ||
| | tst.js:9:11:9:12 | cb | | ||
| | tst.js:20:1:22:1 | functio ... ata);\\n} | | ||
| | tst.js:29:26:29:27 | cb | | ||
| | tst.js:32:17:32:26 | data => {} | | ||
| | tst.js:37:10:37:19 | data => {} | | ||
| | tst.js:39:32:39:45 | getDataCurry() | | ||
| | tst.js:44:19:44:20 | cb | | ||
| | tst.js:47:32:47:60 | identit ... llback) | | ||
| | tst.js:10:11:10:12 | cb | | ||
| | tst.js:21:1:23:1 | functio ... ata);\\n} | | ||
| | tst.js:30:26:30:27 | cb | | ||
| | tst.js:33:17:33:26 | data => {} | | ||
| | tst.js:38:10:38:19 | data => {} | | ||
| | tst.js:40:32:40:45 | getDataCurry() | | ||
| | tst.js:45:19:45:20 | cb | | ||
| | tst.js:48:32:48:60 | identit ... llback) | | ||
| | tst.js:58:16:58:22 | x => {} | | ||
| dataValue | ||
| | tst.js:20:18:20:21 | data | | ||
| | tst.js:24:19:24:22 | data | | ||
| | tst.js:32:17:32:20 | data | | ||
| | tst.js:37:10:37:13 | data | | ||
| | tst.js:21:18:21:21 | data | | ||
| | tst.js:25:19:25:22 | data | | ||
| | tst.js:33:17:33:20 | data | | ||
| | tst.js:38:10:38:13 | data | | ||
| | tst.js:58:16:58:16 | x | |
1 change: 1 addition & 0 deletions
1
javascript/ql/test/library-tests/TypeTracking/PredicateStyle.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import javascript | ||
| import CustomStep | ||
|
|
||
| string chainableMethod() { | ||
| result = "chain1" or | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there is a library function that writes a property that can be read later.
Shouldn't the step type be configurable to support that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, all of our additional step mechanisms have this limitation, and we should totally fix that. I've often wanted to do something about this, but so far I haven't been able to find a robust way to do it right.
Concretely, the API should not restrict future implementation changes too much, and should be applied consistently across all the additional step mechanisms. Adding a step summary as an extra parameter might work here, but if we try the same in data-flow configurations, we will quickly run out of possible ways to overload this predicate, as we already have overloads using flow-labels as extra parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Lets start with this version then, perhaps with a docstring warning about the default choice of flowstep (which all the other additional step mechanism also need).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
TaintFunctionAPI in the C++ library is a fairly nice way of supporting a special, but common, case of this. We're also using it for Go, and I think we should explore having something like it for JavaScript. (Though we'd probably have to attach the models to function calls, not the functions themselves, since we don't have those for most framework functions.)