Skip to content

fix(security): remove no-op identity replacement in errorInspector path helper (#1642) - #1660

Merged
nthmost-orkes merged 5 commits into
mainfrom
fix/error-inspector-identity-replace-1642
Sep 25, 2026
Merged

nthmost-orkes merged 5 commits into
mainfrom
fix/error-inspector-identity-replace-1642

Conversation

@nthmost-orkes

Copy link
Copy Markdown
Contributor

Fixes #1642 (CodeQL alert #23, rule js/identity-replacement, sub-issue of #1010).

What was wrong

jakatraPathToPropertyPath in ui-next/src/pages/definition/errorInspector/state/helpers.ts had:

// Clean up any double brackets that might have been created
.replace(/\]\[/g, "][")

This replaces ][ with ][ — a no-op. CodeQL flags identity replacements because they usually mean an intended transformation isn't happening.

Why removing it is the correct fix

The helper converts a Jakarta bean-validation path (e.g. update.workflowDefs[0].tasks[1].forkTasks[0].<list element>[0]) into a lodash path string that's then fed to lodash/fp/path. After the <list element> / <map value> markers are stripped and .[ is collapsed to [, you can end up with adjacent brackets like [0][0].

That's not a defect to clean up — [0][0] is valid lodash nested-access syntax and is exactly what the downstream _path() call expects. The ][ "cleanup" was guarding against a problem that doesn't exist, and since it replaced the substring with itself it never did anything anyway. Every existing test passes unchanged with the line removed.

So the honest resolution is to delete the dead line and clarify the comment, rather than invent a transformation that would actually break correct output.

Changes

  • Removed the no-op .replace(/\]\[/g, "][") and its misleading comment; noted on the adjacent .[ cleanup that nested brackets are intentionally preserved.
  • Added tests asserting the transformed output for:
    • a <list element> marker sitting directly between brackets (the case the removed line pretended to guard) -> [1].forkTasks[0][0]
    • a <map value> marker between brackets -> [1].decisionCases[switch_case][0]
    • empty and undefined paths -> ""

All jakatraPathToPropertyPath tests pass (7 total). Prettier and eslint clean.

…th helper (Fixes #1642)

The .replace(/\]\[/g, "][") at helpers.ts:194 replaced "][" with itself,
a no-op flagged by CodeQL (js/identity-replacement, alert #23).

It carried the comment "Clean up any double brackets that might have been
created", but adjacent brackets like "[0][1]" are valid lodash nested-access
syntax and are exactly what the downstream lodash/fp/path consumer expects.
The cleanup it implied was never needed, and the line never changed anything --
all existing tests pass with it removed.

Removed the dead replacement and clarified the comment. Added tests covering
markers sitting directly between brackets (the case the line pretended to
guard) plus the empty/undefined path cases.
@nthmost-orkes
nthmost-orkes requested a review from c4lm September 24, 2026 01:30
@nthmost-orkes
nthmost-orkes requested a review from v1r3n September 24, 2026 10:18
@nthmost-orkes
nthmost-orkes merged commit b3b9ad3 into main Sep 25, 2026
14 checks passed
@nthmost-orkes
nthmost-orkes deleted the fix/error-inspector-identity-replace-1642 branch September 25, 2026 00:22
nthmost-orkes added a commit that referenced this pull request Sep 25, 2026
…th helper (Fixes #1642) (#1660)

The .replace(/\]\[/g, "][") at helpers.ts:194 replaced "][" with itself,
a no-op flagged by CodeQL (js/identity-replacement, alert #23).

It carried the comment "Clean up any double brackets that might have been
created", but adjacent brackets like "[0][1]" are valid lodash nested-access
syntax and are exactly what the downstream lodash/fp/path consumer expects.
The cleanup it implied was never needed, and the line never changed anything --
all existing tests pass with it removed.

Removed the dead replacement and clarified the comment. Added tests covering
markers sitting directly between brackets (the case the line pretended to
guard) plus the empty/undefined path cases.

(cherry picked from commit b3b9ad3)
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.

Security: Identity (no-op) string replacement in errorInspector helpers (CodeQL alert #23)

2 participants