-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rust: Value flow and taint flow through formatting strings #18394
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some small comments.
@@ -522,6 +522,7 @@ private ExprCfgNode getALastEvalNode(ExprCfgNode e) { | |||
result = e.(BreakExprCfgNode).getExpr() or | |||
result = e.(BlockExprCfgNode).getTailExpr() or | |||
result = e.(MatchExprCfgNode).getArmExpr(_) or | |||
result = e.(MacroExprCfgNode).getMacroCall().(MacroCallCfgNode).getExpandedNode() or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this rather be
result = e.(MacroExprCfgNode).getMacroCall() or
result = e.(MacroCallCfgNode).getExpandedNode() or
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually yes, but MacroCall
is not an expression and doesn't have a node in the data-flow graph, so it won't work. To do that I think we'd have to change the type of getALastEvalNode
and add a new kind of data-flow node for MacroCall
.
ThaSo just adding a step over the MacroCall
seems simpler and is also what we do for the other kind of nodes that have their expression nested further down.
We could add a method on MacroExprCfgNode
to get the expanded node directly?
@@ -0,0 +1,2 @@ | |||
edges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be removed again.
@@ -0,0 +1,122 @@ | |||
localStep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the corresponding .ql
test missing?
This PR adds:
format_args!
to theformat_args!
expression itself.format!
.The original goal was to get taint through the
format!
macro. But since its definition uses alet
statement, the issue in #18330 prevents that from working. Once that is fixed, the changes here should give flow throughfomat!
.MacroCall
AST nodes are now included in the CFG in post-order. Previously they where skipped over and not included in the CFG, but this caused thegetMacroCall
predicate onMacroExprCfgNode
to never have any results. Including them in the CFG fixes that, and I don't think there's any reason to exclude them.