Skip to content

Enhance policy conditions view to display properly in case policy condition has 100k characters - #1741

Open
mehab wants to merge 2 commits into
DependencyTrack:mainfrom
mehab:feature/large-bundle-policy-condition-viewer
Open

Enhance policy conditions view to display properly in case policy condition has 100k characters#1741
mehab wants to merge 2 commits into
DependencyTrack:mainfrom
mehab:feature/large-bundle-policy-condition-viewer

Conversation

@mehab

@mehab mehab commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses a gap in the view of vulnerability policies from bundles if the policy condition has 100k characters.
I have observed large blank spaces while viewing such large policy with the current implementation.
The condition is effectively one single logical line (thousands of project.name.startsWith(...) || chained together with no newlines).
For a single line that wraps into thousands of visual rows, CodeMirror's per-line height estimation becomes very inaccurate, which produces visible large blank "gap" between the rendered chunk and the remainder. There is a red/uncolored tail seeb at the end (project.name.st) is the JS highlighter/parser hitting its limit on such an enormous single line and stopping tokenization partway. These are both known CodeMirror behaviours with extremely long single lines — not a bug in the stored data.

Addressed Issue

The issue addressed is here: #1738

Additional Details

Checklist

…tions

Signed-off-by: Meha Bhargava <meha.bhargava2@gmail.com>
@owasp-dt-bot

owasp-dt-bot commented Aug 11, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@nscuro

nscuro commented Aug 11, 2026

Copy link
Copy Markdown
Member

I don't think we should try to format CEL without actual AST context (which would require parsing it first).

Why don't we just:

  • disable line-wrapping for conditions with long lines, or
  • switch to a simple <pre> block if we detect excessively long lines?

The condition is effectively one single logical line (thousands of project.name.startsWith(...) || chained together with no newlines).

I'd recommend to change this format to ["prefixA", "prefixB"].exists(pre, project.name.startsWith(pre)), which is cheaper to parse, cheaper to evaluate, and requires a lot fewer characters.

I assume the condition is generated, so another thing you could do is pre-format it during generation to something like:

[
  "prefixA",
  "prefixB"
].exists(
  pre,
  project.name.startsWith(pre)
)

Which would also make it easier to diff changes in your source of truth.

@mehab

mehab commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Hey @nscuro thank you for suggesting the macro :) It will really help. I had originally ended up with a 1.6MB file with so many conditions and I had applied refactoring but only ended up with 864 KB and so many characters. Will apply it in the backend

Signed-off-by: Meha Bhargava <meha.bhargava2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants