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: Add AnnotatedExitNodes to the CFG.#19885

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

Merged
aschackmull merged 4 commits intogithub:mainfromaschackmull:java/annotated-exit-cfg
Jul 17, 2025

Conversation

aschackmull
Copy link
Contributor

This adds distinct CFG nodes for normal termination of a callable vs. an exception being raised. This also aligns things with other languages using the shared control flow library.

@CopilotCopilotAI review requested due to automatic review settingsJune 26, 2025 09:48
@aschackmullaschackmull requested a review froma team as acode ownerJune 26, 2025 09:48
@aschackmullaschackmull added the no-change-note-requiredThis PR does not need a change note labelJun 26, 2025
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 enhances the Java CFG by distinguishing normal and exceptional exit nodes and updates the PathSanitizer query to use the new normal-exit node.

  • IntroduceAnnotatedExitNode (withNormalExitNode andExceptionalExitNode) in the CFG.
  • Adjust thesucc function to emit annotated exit nodes before the existingExitNode.
  • RefactorPathSanitizer.qll to useControlFlow::NormalExitNode in its validation logic.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

FileDescription
java/ql/lib/semmle/code/java/security/PathSanitizer.qllSwapped out rawExitNode references forControlFlow::NormalExitNode.
java/ql/lib/semmle/code/java/ControlFlowGraph.qllImportedBoolean, addedAnnotatedExitNode types, and updatedsucc.
Comments suppressed due to low confidence (2)

java/ql/lib/semmle/code/java/ControlFlowGraph.qll:207

  • ThetoString() implementation usesnormal = true (assignment) instead of checking the field value, which mutates the node and may invert its state. Consider using a conditional based onnormal (e.g.normal and result = "Normal Exit" or not normal and result = "Exceptional Exit") without assignments.
      normal = true and result = "Normal Exit"

java/ql/lib/semmle/code/java/ControlFlowGraph.qll:83

  • [nitpick] Importingcodeql.util.Boolean may shadow the primitiveboolean type used in the node definitions. Verify that this import is necessary or remove it to avoid confusion between QL and Java boolean types.
private import codeql.util.Boolean

hvitved
hvitved previously approved these changesJun 26, 2025
Copy link
Contributor

@hvitvedhvitved left a comment

Choose a reason for hiding this comment

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

Did you consider switching post-dominance to use the normal exit node? That is what we do in C#, Ruby, and Rust.

@aschackmull
Copy link
ContributorAuthor

Did you consider switching post-dominance to use the normal exit node? That is what we do in C#, Ruby, and Rust.

Yes, a bit. I agree that's probably more generally useful, but there might be cases where both variants are relevant. OTOH I don't think we have that many uses of post-dominance. First things first, though, I want this change in order to be able to more easily identify guard-wrappers that throw.

@aschackmullaschackmullforce-pushed thejava/annotated-exit-cfg branch from42d1e96 to448cc82CompareJuly 17, 2025 09:21
@aschackmullaschackmull merged commit1485d70 intogithub:mainJul 17, 2025
15 of 16 checks passed
@aschackmullaschackmull deleted the java/annotated-exit-cfg branchJuly 17, 2025 13:02
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

@hvitvedhvitvedhvitved left review comments

Assignees
No one assigned
Labels
JavaKotlinno-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.

3 participants
@aschackmull@hvitved@owen-mc

[8]ページ先頭

©2009-2025 Movatter.jp