Skip to content
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

How to use CodeQL to scan the sink of code(only sink) #18862

Open
Firebasky opened this issue Feb 26, 2025 · 2 comments
Open

How to use CodeQL to scan the sink of code(only sink) #18862

Firebasky opened this issue Feb 26, 2025 · 2 comments
Labels
question Further information is requested

Comments

@Firebasky
Copy link

I want to know how to use CodeQL to scan the sink in the code and output it as a sarif file.

@Firebasky Firebasky added the question Further information is requested label Feb 26, 2025
@aibaars
Copy link
Contributor

aibaars commented Feb 26, 2025

You can make a query of kind @kind problem that has a select clause with two columns, first the sink and the second a string message (e.g. "a sink").

It should not be too difficult to write such a query from scratch, alternatively, I think you can simply copy an existing @kind path-problem query, change its kind to problem, replace the first 3 columns in the select statement with just the sink and remove the import .....PathGraph line.

@Firebasky
Copy link
Author

You can make a query of kind @kind problem that has a select clause with two columns, first the sink and the second a string message (e.g. "a sink").

It should not be too difficult to write such a query from scratch, alternatively, I think you can simply copy an existing @kind path-problem query, change its kind to problem, replace the first 3 columns in the select statement with just the sink and remove the import .....PathGraph line.

Thank you for your reply. Can you give me a demo? as follows


 import python
 import semmle.python.dataflow.new.DataFlow
 import semmle.python.dataflow.new.TaintTracking
 import semmle.python.ApiGraphs
 import semmle.python.dataflow.new.RemoteFlowSources
 private import semmle.python.Concepts
  
 class SinkCall extends DataFlow::CallCfgNode {
    SinkCall() {
    this = API::moduleImport("js2py").getMember(["eval_js", "eval_js6", "EvalJs"]).getACall()
    }
}

# How to query and ensure that the results support sarif format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants
@aibaars @Firebasky and others