-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: main
Are you sure you want to change the base?
Add 'View DFG' queries #21356
Changes from all commits
9a048c9
dc2c8f3
2017f84
71f4436
aa587c0
61ae276
c236ace
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> { | ||
Check warningCode scanning / CodeQL Dead code Warning
This code is never used, and it's not publicly exported.
|
||
| 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