Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Show Parent Expression in path-problem query#20903

Unanswered
elManto asked this question inQ&A
Discussion options

Hi all,

I've written a path-problem query for python to track certain data flows I'm interested at that have the input parameters (sys.argv, argparse, etc.) as sources and certain APIs as sinks. Without getting into the details of what's the source and what's the sink (I can share, but probably not needed), the body of the query looks like:

module MyFlow= TaintTracking::Global<MyTaintAnalysis>;import MyFlow::PathGraphfrom MyFlow::PathNodesource, MyFlow::PathNodesinkwhere MyFlow::flowPath(source,sink)selectsink.getNode(),source,sink,"Input arg flowing from "+source.getNode()+" into sink API"

For each node in the PathGraph I would like to obtain the parent expression, if any. For instance, let's consider the following example:

1x=sys.argv[1]2print("no data flow")3y=x+"A"4print(y)

If I look into the Sarif generated with the query above I'll get the line of each node and thestartColumn,endColumn of the variable involved in the Path that is reached by the taint, e.g.,x (line 1),x (line 3),y (line 4). I would like to obtain the parent expression for each node, e.g.,x = sys.argv[1] ,y=x + "A" andprint(y) . Is there a way to do so ? Thank you

You must be logged in to vote

Replies: 1 comment

Comment options

👋@elManto

Could you elaborate on what you want to do with that information? My main point here is whether you intend that for human consumption or to do some further QL or script processing down the line.

If it's just for human consumption when analysing the SARIF result, you could try running yourcodeql database analyze command with the additional--sarif-add-snippets flag. This will addcontextRegion fields with some context (two lines before and after) around the flow nodes. Would that be enough for your use case?

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@elManto@redsun82

[8]ページ先頭

©2009-2025 Movatter.jp