-
Notifications
You must be signed in to change notification settings - Fork 2k
Add 'View DFG' queries #21356
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
Add 'View DFG' queries #21356
Changes from 7 commits
9a048c9
dc2c8f3
2017f84
71f4436
aa587c0
61ae276
c236ace
2698b44
09fb85d
0521eb4
0050ed6
dfe4486
d2ffb00
e6c5266
9b2161b
84aaafd
24c1a61
cfd00a6
59e8c3b
04426ae
6d1f5c8
b6a4b1b
2311d2a
7dcd0a4
38d67c6
2fce632
9efa4d9
9c9c157
b8d8611
35b4b75
3b17084
0839f43
f846daf
ddb116e
ca433e0
cb16d0b
6748a1f
7f1d04b
49c2e09
cab1081
1cb3b62
0f3bd28
2b4afa3
46d76f4
f4b9021
dd6da08
8bf9f23
05490b9
29b0616
06a077b
d4ed4f5
c584895
782c05f
5bd670c
7aea5b6
d108ce8
474535b
c7f4787
d76b786
972b637
24e134a
876fe05
b9e8e5a
2d6dec9
47c77ef
16de6a7
d43969a
e6fe4bf
6341535
3e83a53
0200e12
01a9b61
d7c8b9a
b4ec560
fb21533
5b3737e
23ac9fc
f4cacc3
36848cf
1ee2534
8925535
03e4dfd
b01efe1
b6614c0
7b83da4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /** | ||
| * @name Print DFG | ||
| * @description Produces a representation of a file's Data Flow Graph. | ||
| * This query is used by the VS Code extension. | ||
| * @id cs/print-dfg | ||
| * @kind graph | ||
| * @tags ide-contextual-queries/print-dfg | ||
| */ | ||
|
|
||
| import csharp | ||
| private import semmle.code.csharp.dataflow.internal.DataFlowImplSpecific as DF | ||
| private import semmle.code.csharp.dataflow.internal.TaintTrackingImplSpecific as TT | ||
| private import codeql.dataflow.PrintDfg | ||
| private import MakePrintDfg<Location, DF::CsharpDataFlow, TT::CsharpTaintTracking> | ||
|
|
||
| external string selectedSourceFile(); | ||
|
|
||
| private predicate selectedSourceFileAlias = selectedSourceFile/0; | ||
|
|
||
| external int selectedSourceLine(); | ||
|
|
||
| private predicate selectedSourceLineAlias = selectedSourceLine/0; | ||
|
|
||
| external int selectedSourceColumn(); | ||
|
|
||
| private predicate selectedSourceColumnAlias = selectedSourceColumn/0; | ||
|
|
||
| module ViewDfgQueryInput implements ViewGraphQueryInputSig<File> { | ||
| predicate selectedSourceFile = selectedSourceFileAlias/0; | ||
|
|
||
| predicate selectedSourceLine = selectedSourceLineAlias/0; | ||
|
|
||
| predicate selectedSourceColumn = selectedSourceColumnAlias/0; | ||
|
|
||
| predicate callableSpan( | ||
| DF::CsharpDataFlow::DataFlowCallable callable, File file, int startLine, int startColumn, | ||
| int endLine, int endColumn | ||
| ) { | ||
| exists(Callable c | | ||
| c = callable.asCallable(_) and | ||
| file = c.getFile() and | ||
| callable.getLocation().getStartLine() = startLine and | ||
| callable.getLocation().getStartColumn() = startColumn and | ||
| exists(Location loc | | ||
| loc.getEndLine() = endLine and | ||
| loc.getEndColumn() = endColumn and | ||
| loc = c.getBody().getLocation() | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| import ViewGraphQuery<File, ViewDfgQueryInput> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * @name Print DFG | ||
| * @description Produces a representation of a file's Data Flow Graph. | ||
| * This query is used by the VS Code extension. | ||
| * @id java/print-cfg | ||
| * @kind graph | ||
| * @tags ide-contextual-queries/print-dfg | ||
| */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.internal.DataFlowImplSpecific as DF | ||
| private import semmle.code.java.dataflow.internal.TaintTrackingImplSpecific as TT | ||
| private import codeql.dataflow.PrintDfg | ||
| private import MakePrintDfg<Location, DF::JavaDataFlow, TT::JavaTaintTracking> | ||
|
|
||
| external string selectedSourceFile(); | ||
|
|
||
| private predicate selectedSourceFileAlias = selectedSourceFile/0; | ||
|
|
||
| external int selectedSourceLine(); | ||
|
|
||
| private predicate selectedSourceLineAlias = selectedSourceLine/0; | ||
|
|
||
| external int selectedSourceColumn(); | ||
|
|
||
| private predicate selectedSourceColumnAlias = selectedSourceColumn/0; | ||
|
|
||
| module ViewDfgQueryInput implements ViewGraphQueryInputSig<File> { | ||
| predicate selectedSourceFile = selectedSourceFileAlias/0; | ||
|
|
||
| predicate selectedSourceLine = selectedSourceLineAlias/0; | ||
|
|
||
| predicate selectedSourceColumn = selectedSourceColumnAlias/0; | ||
|
|
||
| predicate callableSpan( | ||
| DF::JavaDataFlow::DataFlowCallable callable, File file, int startLine, int startColumn, | ||
| int endLine, int endColumn | ||
| ) { | ||
| file = callable.asCallable().getFile() and | ||
| callable.getLocation().getStartLine() = startLine and | ||
| callable.getLocation().getStartColumn() = startColumn and | ||
| exists(Location loc | | ||
| loc.getEndLine() = endLine and | ||
| loc.getEndColumn() = endColumn and | ||
| loc = callable.asCallable().getBody().getLocation() | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| import ViewGraphQuery<File, ViewDfgQueryInput> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /** | ||
| * @name Print DFG | ||
| * @description Produces a representation of a file's Data Flow Graph. | ||
| * This query is used by the VS Code extension. | ||
| * @id js/print-dfg | ||
| * @kind graph | ||
| * @tags ide-contextual-queries/print-dfg | ||
| */ | ||
|
|
||
| private import javascript | ||
| private import semmle.javascript.dataflow.internal.sharedlib.DataFlowArg | ||
| private import codeql.dataflow.PrintDfg | ||
| import MakePrintDfg<Location, JSDataFlow, JSTaintFlow> | ||
|
|
||
| external string selectedSourceFile(); | ||
|
|
||
| private predicate selectedSourceFileAlias = selectedSourceFile/0; | ||
Check warningCode scanning / CodeQL Dead code Warning
This code is never used, and it's not publicly exported.
|
||
|
|
||
| external int selectedSourceLine(); | ||
Check warningCode scanning / CodeQL Dead code Warning
This code is never used, and it's not publicly exported.
|
||
|
|
||
| private predicate selectedSourceLineAlias = selectedSourceLine/0; | ||
Check warningCode scanning / CodeQL Dead code Warning
This code is never used, and it's not publicly exported.
|
||
|
|
||
| external int selectedSourceColumn(); | ||
Check warningCode scanning / CodeQL Dead code Warning
This code is never used, and it's not publicly exported.
|
||
|
|
||
| private predicate selectedSourceColumnAlias = selectedSourceColumn/0; | ||
Check warningCode scanning / CodeQL Dead code Warning
This code is never used, and it's not publicly exported.
|
||
|
|
||
| module ViewCfgQueryInput implements ViewGraphQueryInputSig<File> { | ||
|
||
| predicate selectedSourceFile = selectedSourceFileAlias/0; | ||
|
|
||
| predicate selectedSourceLine = selectedSourceLineAlias/0; | ||
|
|
||
| predicate selectedSourceColumn = selectedSourceColumnAlias/0; | ||
|
|
||
| /** | ||
| * Holds if `callable` spans column `startColumn` of line `startLine` to | ||
| * column `endColumn` of line `endLine` in `file`. | ||
| */ | ||
| predicate callableSpan( | ||
| JSDataFlow::DataFlowCallable callable, File file, int startLine, int startColumn, int endLine, | ||
| int endColumn | ||
| ) { | ||
| callable | ||
| .getLocation() | ||
| .hasLocationInfo(file.getAbsolutePath(), startLine, startColumn, endLine, endColumn) | ||
| } | ||
| } | ||
|
|
||
| import ViewGraphQuery<File, ViewGraphInput> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * @name Print DFG | ||
| * @description Produces a representation of a file's Data Flow Graph. | ||
| * This query is used by the VS Code extension. | ||
| * @id rb/print-dfg | ||
| * @kind graph | ||
| * @tags ide-contextual-queries/print-dfg | ||
| */ | ||
|
|
||
| private import codeql.Locations | ||
| private import codeql.ruby.dataflow.internal.DataFlowImplSpecific as DF | ||
| private import codeql.ruby.dataflow.internal.TaintTrackingImplSpecific as TT | ||
| private import codeql.dataflow.PrintDfg | ||
| private import MakePrintDfg<Location, DF::RubyDataFlow, TT::RubyTaintTracking> | ||
|
|
||
| external string selectedSourceFile(); | ||
|
|
||
| private predicate selectedSourceFileAlias = selectedSourceFile/0; | ||
|
|
||
| external int selectedSourceLine(); | ||
|
|
||
| private predicate selectedSourceLineAlias = selectedSourceLine/0; | ||
|
|
||
| external int selectedSourceColumn(); | ||
|
|
||
| private predicate selectedSourceColumnAlias = selectedSourceColumn/0; | ||
|
|
||
| module ViewDfgQueryInput implements ViewGraphQueryInputSig<File> { | ||
| predicate selectedSourceFile = selectedSourceFileAlias/0; | ||
|
|
||
| predicate selectedSourceLine = selectedSourceLineAlias/0; | ||
|
|
||
| predicate selectedSourceColumn = selectedSourceColumnAlias/0; | ||
|
|
||
| predicate callableSpan( | ||
| DF::RubyDataFlow::DataFlowCallable callable, File file, int startLine, int startColumn, | ||
| int endLine, int endColumn | ||
| ) { | ||
| file = callable.asCfgScope().getFile() and | ||
| callable.getLocation().hasLocationInfo(_, startLine, startColumn, endLine, endColumn) | ||
| } | ||
| } | ||
|
|
||
| import ViewGraphQuery<File, ViewDfgQueryInput> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * @name Print DFG | ||
| * @description Produces a representation of a file's Data Flow Graph. | ||
| * This query is used by the VS Code extension. | ||
| * @id rust/print-dfg | ||
| * @kind graph | ||
| * @tags ide-contextual-queries/print-dfg | ||
| */ | ||
|
|
||
| private import rust | ||
| private import codeql.rust.dataflow.internal.DataFlowImpl as DF | ||
| private import codeql.rust.dataflow.internal.TaintTrackingImpl as TT | ||
| private import codeql.dataflow.PrintDfg | ||
| private import MakePrintDfg<Location, DF::RustDataFlow, TT::RustTaintTracking> | ||
|
|
||
| external string selectedSourceFile(); | ||
|
|
||
| private predicate selectedSourceFileAlias = selectedSourceFile/0; | ||
|
|
||
| external int selectedSourceLine(); | ||
|
|
||
| private predicate selectedSourceLineAlias = selectedSourceLine/0; | ||
|
|
||
| external int selectedSourceColumn(); | ||
|
|
||
| private predicate selectedSourceColumnAlias = selectedSourceColumn/0; | ||
|
|
||
| private module ViewDfgQueryInput implements ViewGraphQueryInputSig<File> { | ||
| predicate selectedSourceFile = selectedSourceFileAlias/0; | ||
|
|
||
| predicate selectedSourceLine = selectedSourceLineAlias/0; | ||
|
|
||
| predicate selectedSourceColumn = selectedSourceColumnAlias/0; | ||
|
|
||
| predicate callableSpan( | ||
| DF::RustDataFlow::DataFlowCallable callable, File file, int startLine, int startColumn, | ||
| int endLine, int endColumn | ||
| ) { | ||
| file = callable.asCfgScope().getFile() and | ||
| callable.getLocation().hasLocationInfo(_, startLine, startColumn, endLine, endColumn) | ||
| } | ||
| } | ||
|
|
||
| import ViewGraphQuery<File, ViewDfgQueryInput> |
Check warning
Code scanning / CodeQL
Dead code Warning