-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: Prune PathGraph for CsrfUnprotectedRequestType.ql #20083
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
Changes from all commits
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 | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -237,12 +237,35 @@ private predicate sink(CallPathNode sinkMethodCall) { | |||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
private predicate fwdFlow(CallPathNode n) { | ||||||||||||||||||||||||||||||||||||
source(n) | ||||||||||||||||||||||||||||||||||||
or | ||||||||||||||||||||||||||||||||||||
exists(CallPathNode mid | fwdFlow(mid) and CallGraph::edges(mid, n)) | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing documentation for the revFlow predicate. Should explain that it computes backward reachability from sinks within the forward-reachable nodes, implementing the bidirectional pruning strategy.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||
private predicate revFlow(CallPathNode n) { | ||||||||||||||||||||||||||||||||||||
fwdFlow(n) and | ||||||||||||||||||||||||||||||||||||
( | ||||||||||||||||||||||||||||||||||||
sink(n) | ||||||||||||||||||||||||||||||||||||
or | ||||||||||||||||||||||||||||||||||||
exists(CallPathNode mid | revFlow(mid) and CallGraph::edges(n, mid)) | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Holds if `pred` has a successor node `succ` and this edge is in an | ||||||||||||||||||||||||||||||||||||
* `unprotectedStateChange` path. | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The predicate should include documentation about its performance characteristics and the bidirectional pruning strategy, as this is a key optimization that affects query behavior.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||
predicate relevantEdge(CallPathNode pred, CallPathNode succ) { | ||||||||||||||||||||||||||||||||||||
CallGraph::edges(pred, succ) and revFlow(pred) and revFlow(succ) | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Holds if `sourceMethod` is an unprotected request handler that reaches a | ||||||||||||||||||||||||||||||||||||
* `sinkMethodCall` that updates a database. | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
private predicate unprotectedDatabaseUpdate(CallPathNode sourceMethod, CallPathNode sinkMethodCall) = | ||||||||||||||||||||||||||||||||||||
doublyBoundedFastTC(CallGraph::edges/2, source/1, sink/1)(sourceMethod, sinkMethodCall) | ||||||||||||||||||||||||||||||||||||
doublyBoundedFastTC(relevantEdge/2, source/1, sink/1)(sourceMethod, sinkMethodCall) | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Holds if `sourceMethod` is an unprotected request handler that appears to | ||||||||||||||||||||||||||||||||||||
|
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.
Missing documentation for the fwdFlow predicate. Should explain that it computes forward reachability from sources using transitive closure over call graph edges.
Copilot uses AI. Check for mistakes.