Enhance policy conditions view to display properly in case policy condition has 100k characters - #1741
Conversation
…tions Signed-off-by: Meha Bhargava <meha.bhargava2@gmail.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
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:
I'd recommend to change this format to 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. |
|
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>
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