Skip to content

CDS Extractor: Fix excessive diagnostic info#376

Open
mihai-herda-SAP wants to merge 3 commits into
advanced-security:mainfrom
mihai-herda-SAP:fix_excessive_debug_info
Open

CDS Extractor: Fix excessive diagnostic info#376
mihai-herda-SAP wants to merge 3 commits into
advanced-security:mainfrom
mihai-herda-SAP:fix_excessive_debug_info

Conversation

@mihai-herda-SAP
Copy link
Copy Markdown

Summary

Two adjustments to how the CDS extractor reports compilation failures, motivated by a project where a failed compilation produced ~1000 per-file diagnostics and took 30–40 minutes to finalize.

Changes

  • One diagnostic per failed compilation, not per source file. CDS compilation is project-level (one task per project, with task.sourceFiles listing every CDS file in the project). The previous code spawned codeql database add-diagnostic once per file, which scales linearly with project size. The new behavior emits a single diagnostic per failed task, attached to the project's package.json when available (or the project directory otherwise), and includes the affected file count in the message body so that information is preserved.

  • Severity downgraded from error to warning. A failed CDS compilation does not fail the overall scan — the JavaScript extractor still runs and other-language analyses proceed normally. warning matches that reality.

When CDS compilation fails for a project, the extractor previously called `codeql database add-diagnostic` once for every source file in the project's failed compilation task. Because compilation is project-level (one task per project, with `task.sourceFiles` listing every CDS file), a project with hundreds of `.cds` files paid hundreds of `execFileSync(codeql, ...)` round trips at the end of a failed run — taking 30–40 minutes for ~1000-file projects.

Emit a single diagnostic per failed task instead, attached to the project's `package.json` when available (or the project directory otherwise), and mention the affected file count in the message body so that information is preserved. The existing `cds/compilation-failure` source-id and "Failure to compile one or more SAP CAP CDS files" source-name already read as project-level, so no schema change is needed.

Tests in `retry.test.ts` are updated for the new call shape and two new cases cover (a) a 250-file project emitting exactly one diagnostic and (b) projects without `package.json` falling back to the project directory.
A failed CDS compilation does not fail the overall scan — the JavaScript extractor still runs over the source root and other-language analyses proceed normally. Surfacing as a warning matches that reality and avoids flagging the run as having errors when no security-relevant findings were missed.
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