Skip to content

Simplify CEL script visitor#1907

Merged
nscuro merged 1 commit intomainfrom
simplify-cel-visitor
Mar 20, 2026
Merged

Simplify CEL script visitor#1907
nscuro merged 1 commit intomainfrom
simplify-cel-visitor

Conversation

@nscuro
Copy link
Copy Markdown
Member

@nscuro nscuro commented Mar 20, 2026

Description

Simplifies CEL script visitor.

  • Removes unnecessary Deques and use direct type map lookups instead.
  • Visits struct and list elements.
  • Removes noisy debug logging.

Addressed Issue

N/A

Additional Details

N/A

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have updated the migration changelog accordingly
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

@nscuro nscuro added this to the 5.7.0 milestone Mar 20, 2026
Copilot AI review requested due to automatic review settings March 20, 2026 12:02
Copy link
Copy Markdown
Contributor

Copilot AI 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 simplifies the CEL policy script AST visitor used during script compilation/type-checking analysis, with the goal of making requirements detection more direct and covering additional AST node contents.

Changes:

  • Refactors CelPolicyScriptVisitor to remove stack-based bookkeeping and instead use direct type-map lookups.
  • Extends visitor traversal to include list elements and struct entry values (improving requirements analysis coverage).
  • Updates/extends unit tests to validate requirements analysis for field access inside lists and structs.

Reviewed changes

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

File Description
apiserver/src/main/java/org/dependencytrack/policy/cel/CelPolicyScriptVisitor.java Simplifies AST traversal, improves requirements analysis by visiting list/struct contents, and removes debug-stack logging.
apiserver/src/test/java/org/dependencytrack/policy/cel/CelPolicyScriptHostTest.java Adds tests to ensure requirements analysis detects field accesses within list literals and struct literals.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI 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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Mar 20, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 100.00% (target: 70.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (09213bf) 24806 21111 85.10%
Head commit (6cf6a81) 24786 (-20) 21094 (-17) 85.10% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1907) 14 14 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

* Removes unnecessary Deques and use direct type map lookups instead.
* Visits struct and list elements.
* Removes noisy debug logging.

Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro force-pushed the simplify-cel-visitor branch from b489544 to 6cf6a81 Compare March 20, 2026 12:30
@nscuro nscuro merged commit 709406e into main Mar 20, 2026
10 checks passed
@nscuro nscuro deleted the simplify-cel-visitor branch March 20, 2026 12:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants