Skip to content

CM-77192: Fix IaC detection paths without a leading slash - #108

Open
aaron-butler-cy-int wants to merge 3 commits into
cycodehq:mainfrom
aaron-butler-cy-int:CM-77192-iac-relative-path
Open

aaron-butler-cy-int wants to merge 3 commits into
cycodehq:mainfrom
aaron-butler-cy-int:CM-77192-iac-relative-path

Conversation

@aaron-butler-cy-int

@aaron-butler-cy-int aaron-butler-cy-int commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The results tree failed to load (and stayed empty) when a detection path was not absolute. The tree shows paths relative to the project root with File(filePath).relativeTo(projectRoot), which throws IllegalArgumentException: this and base files have different roots when one path is absolute and the other is not.

Seen in plugin 3.2.0 on IntelliJ IDEA 2026.1.1: an IaC detection for Users/aaron.butler/git/NodeGoat/Dockerfile (no leading slash) against the root /Users/aaron.butler/git/NodeGoat.

  • Root cause (CLI investigation): a backend passthrough. SAST results always had a path without the leading slash, and the plugin already adds it in SastDetectionDetails.getFilepath(). A CLI change moved IaC to the async scan flow (same endpoint as SAST), which passes the backend's path through unmodified, so IaC paths now arrive the same way.
  • IacDetectionDetails.getFilepath() now returns an absolute path (adds the leading slash when the path is not absolute), as SAST does. This also matters beyond the tree: the editor annotators, the result filters and the context menu compare the raw path, so a slash-less IaC path would never match.
  • New toProjectRelativePath that never throws:
    • an absolute path, or a path with the leading slash missing, inside the project is shown relative to it (Dockerfile);
    • a relative path is kept as it is;
    • an absolute path outside the project keeps the upwards walk (../Other/a.js);
    • with no project root, or on different roots (e.g. another drive), the path is shown as it is.
  • TreeView.createDetectionNodes uses it instead of relativeTo.
  • CHANGELOG entry under Unreleased.

The relativeTo call predates the scan scope work (CM-35346, #63). The slash-less path comes from the scan result; it is not yet known whether the CLI 3.25.0 raise changed it. With the IDE working directory at / (a macOS app launch), such a path still resolves to a real file, so it passes the existing "file exists" filter and only the tree crashed.

Jira

CM-77192

Testing

  • Unit tests pass (./gradlew test): new DetectionPathTest covers the IaC path with and without the leading slash, and ProjectRelativePathTest covers the path from the report, relative paths, paths outside the project and a project without a root.
  • Not reproduced against the CLI and not checked in a sandbox IDE yet.

🤖 Generated with Claude Code

@aaron-butler-cy-int aaron-butler-cy-int changed the title CM-77192: Fix results tree failing on detection paths without a leading slash CM-77192: Fix IaC detection paths without a leading slash Nov 26, 2026
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.

1 participant