-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14405 from erik-krogh/tagCall
JS: recognize tagged template literals as `DataFlow::CallNode`
- Loading branch information
Showing
25 changed files
with
132 additions
and
61 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
javascript/ql/lib/change-notes/2023-10-07-tagged-template-litterals.md
This file contains 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,5 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* Tagged template literals have been added to `DataFlow::CallNode`. This allows the analysis to find flow into functions called with a tagged template literal, | ||
and the arguments to a tagged template literal are part of the API-graph in `ApiGraphs.qll`. |
This file contains 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
This file contains 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
This file contains 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
Empty file.
1 change: 1 addition & 0 deletions
1
javascript/ql/test/ApiGraphs/tagged-template/VerifyAssertions.ql
This file contains 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 @@ | ||
import ApiGraphs.VerifyAssertions |
This file contains 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,9 @@ | ||
const tag = require("tag"); | ||
|
||
tag.string`string1 | ||
${23}` // def=moduleImport("tag").getMember("exports").getMember("string").getParameter(1) | ||
|
||
tag.highlight`string2 | ||
${23} | ||
morestring | ||
${42}` // def=moduleImport("tag").getMember("exports").getMember("highlight").getParameter(2) |
This file contains 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,3 @@ | ||
{ | ||
"name": "tagged-template" | ||
} |
3 changes: 0 additions & 3 deletions
3
javascript/ql/test/library-tests/CallGraphs/FullTest/getACallee.qll
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/getAFunctionValue.qll
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/getAnArgument.qll
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/getArgument.qll
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/getCalleeName.qll
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/getCalleeNode.qll
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/getLastArgument.qll
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/getNumArgument.qll
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
javascript/ql/test/library-tests/CallGraphs/FullTest/isImprecise.qll
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
javascript/ql/test/library-tests/CallGraphs/FullTest/isIncomplete.qll
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
javascript/ql/test/library-tests/CallGraphs/FullTest/isUncertain.qll
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
javascript/ql/test/library-tests/CallGraphs/FullTest/taggedTemplate.js
This file contains 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,5 @@ | ||
function fooTag(strings, par1, par2) { | ||
|
||
} | ||
|
||
fooTag`hello ${arg1} world ${arg2}` |
This file contains 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: 37 additions & 11 deletions
48
javascript/ql/test/library-tests/CallGraphs/FullTest/tests.ql
This file contains 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,11 +1,37 @@ | ||
import isUncertain | ||
import getAFunctionValue | ||
import getArgument | ||
import getNumArgument | ||
import isIncomplete | ||
import getCalleeNode | ||
import getLastArgument | ||
import getAnArgument | ||
import getACallee | ||
import getCalleeName | ||
import isImprecise | ||
import javascript | ||
|
||
query predicate test_isUncertain(DataFlow::InvokeNode invk) { invk.isUncertain() } | ||
|
||
query predicate test_getAFunctionValue(DataFlow::Node node, DataFlow::FunctionNode res) { | ||
res = node.getAFunctionValue() | ||
} | ||
|
||
query predicate test_getArgument(DataFlow::InvokeNode invk, int i, DataFlow::Node res) { | ||
res = invk.getArgument(i) | ||
} | ||
|
||
query predicate test_getNumArgument(DataFlow::InvokeNode invk, int res) { | ||
res = invk.getNumArgument() | ||
} | ||
|
||
query predicate test_isIncomplete(DataFlow::InvokeNode invk) { invk.isIncomplete() } | ||
|
||
query predicate test_getCalleeNode(DataFlow::InvokeNode invk, DataFlow::Node res) { | ||
res = invk.getCalleeNode() | ||
} | ||
|
||
query predicate test_getLastArgument(DataFlow::InvokeNode invk, DataFlow::Node res) { | ||
res = invk.getLastArgument() | ||
} | ||
|
||
query predicate test_getAnArgument(DataFlow::InvokeNode invk, DataFlow::Node res) { | ||
res = invk.getAnArgument() | ||
} | ||
|
||
query predicate test_getACallee(DataFlow::InvokeNode c, Function res) { res = c.getACallee() } | ||
|
||
query predicate test_getCalleeName(DataFlow::InvokeNode invk, string res) { | ||
res = invk.getCalleeName() | ||
} | ||
|
||
query predicate test_isImprecise(DataFlow::InvokeNode invk) { invk.isImprecise() } |
This file contains 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
This file contains 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
This file contains 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