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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

aschackmull
Copy link
Contributor

This should be completely behaviour-preserving, but saves hundreds of MBs of output for some repos. Dca has had trouble processing the output of this query even for cases with zero alerts for several repos.

See also comments here:#19872 (comment)

@CopilotCopilotAI review requested due to automatic review settingsJuly 17, 2025 13:11
@aschackmullaschackmull added the no-change-note-requiredThis PR does not need a change note labelJul 17, 2025
@aschackmullaschackmull requested a review froma team as acode ownerJuly 17, 2025 13:11
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR optimizes the PathGraph for the CSRF unprotected request type query by implementing a bidirectional reachability analysis to prune irrelevant edges. The optimization is intended to be behavior-preserving while significantly reducing output size (saving hundreds of MBs) and improving processing performance for the DCA tool.

Key changes:

  • Introduces bidirectional flow analysis predicates (fwdFlow andrevFlow) to identify relevant edges
  • Replaces directCallGraph::edges usage with a prunedrelevantEdge predicate
  • Updates the transitive closure computation to use the optimized edge predicate

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

FileDescription
CsrfUnprotectedRequestType.qlUpdates query to use pruned edge predicate instead of raw call graph edges
CsrfUnprotectedRequestTypeQuery.qllImplements bidirectional reachability analysis and relevantEdge predicate for path pruning

/**
* Holds if `pred` has a successor node `succ` and this edge is in an
* `unprotectedStateChange` path.
*/
Copy link
Preview

CopilotAIJul 17, 2025

Choose a reason for hiding this comment

The 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
*/
*/
/**
*Holdsif `pred` has a successor node `succ`andthis edge isin an
* `unprotectedStateChange` path.
*
*Performancecharacteristics:
*-Thispredicate relies on `revFlow`, which is a recursive flowpredicate
*thatcombinesforwardandreversegraph traversal.
*-Theuse of `CallGraph::edges` ensures that only valid edgesin the call
*graphareconsidered,reducingunnecessary computations.
*
*Bidirectionalpruning strategy:
*-Thepredicate leverages `revFlow(pred)`and `revFlow(succ)` to prune
*thesearchspacebyensuringthatboththepredecessorand successor
*nodesarepartofvalidreverse flows.
*/

Copilot uses AI. Check for mistakes.

@@ -237,12 +237,35 @@ private predicate sink(CallPathNode sinkMethodCall) {
)
}

Copy link
Preview

CopilotAIJul 17, 2025

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.

Suggested change
/**
*Computesforward reachabilityfrom source nodes using transitive closure
*overcallgraphedges.Holdsif `n` is reachablefrom a source node.
*/

Copilot uses AI. Check for mistakes.

or
exists(CallPathNode mid | fwdFlow(mid) and CallGraph::edges(mid, n))
}

Copy link
Preview

CopilotAIJul 17, 2025

Choose a reason for hiding this comment

The 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
/**
*Computesbackward reachabilityfrom sinks within the forward-reachable nodes.
*Thispredicate implements the bidirectional pruning strategyby combining
*forwardreachability(`fwdFlow`)withbackwardreachabilityfrom sinks.
*/

Copilot uses AI. Check for mistakes.

@aschackmull
Copy link
ContributorAuthor

The "Query result disk size" metric shows a massive reduction as expected.

@owen-mc
Copy link
Contributor

I suppose you could add a change note with the "fix" category, so that if anyone notices a change they can figure out what caused it. Up to you.

@aschackmull
Copy link
ContributorAuthor

I suppose you could add a change note with the "fix" category, so that if anyone notices a change they can figure out what caused it. Up to you.

After result interpretation the sarif is unchanged, so it's not very detectable.

@aschackmullaschackmull merged commitf697511 intogithub:mainJul 18, 2025
19 checks passed
@aschackmullaschackmull deleted the java/prune-csrf-unprotected-request-type branchJuly 18, 2025 11:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@owen-mcowen-mcowen-mc approved these changes

Assignees
No one assigned
Labels
Javano-change-note-requiredThis PR does not need a change note
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@aschackmull@owen-mc

[8]ページ先頭

©2009-2025 Movatter.jp