Skip to content

[x2cpg] AstGenRunner hardening - #6188

Closed
max-leuthaeuser wants to merge 2 commits into
masterfrom
max/astgen-runner-hardening
Closed

[x2cpg] AstGenRunner hardening#6188
max-leuthaeuser wants to merge 2 commits into
masterfrom
max/astgen-runner-hardening

Conversation

@max-leuthaeuser

@max-leuthaeuser max-leuthaeuser commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

AstGenRunner:

  • New explicit contract: runAstGenNative returns ExternalCommandResult (both streams kept separate) instead of a lossy Try[Seq[String]].
  • New SkippedFile(fileName, reason) case class replaces bare filename strings.
  • New hooks: isSuccess, astGenOutputFiles, postProcessParsedFiles, logUnsuccessfulRun, collectSkippedFiles (defensive, logs uniformly), toRelativeInputPath (handles symlinked tmp dirs), and combine for multi-invocation frontends.
  • execute() is now uniform across all frontends: it always scans the output directory for partial results, even after a failed/thrown run, and always attempts to collect skipped files — six of seven frontends previously discarded everything on failure.

Per-frontend fixes:

  • jssrc2cpg: fixed the dead skipped-file parser (was reading stdout, but skip lines are on stderr) — now correctly detects broken files via safe pattern matching.
  • swiftsrc2cpg: moved the Windows exit-code workaround into isSuccess/logUnsuccessfulRun; replaced substring/indexOf parsing with a safe regex
  • gosrc2cpg: fixed a bug where "Failed to generate AST for X" was mis-parsed as filename "Failed"; wired skipped files into Report.
  • csharpsrc2cpg: fixed a real misattribution bug where compiler errors got attached to the wrong file under interleaved output — now buffers reasons until the terminating line names the file; wired into Report.
  • rubysrc2cpg: same interleaving hardening pattern; runAstGenNative now returns a real ExternalCommandResult from the in-process JRuby run; added a Report (previously had none).
  • abap2cpg / rust2cpg: adapted to the new contract; both gained a Report (abap2cpg had none before) that now records skipped files.

AstGenRunner:
- New explicit contract: runAstGenNative returns ExternalCommandResult (both streams kept separate) instead of a lossy Try[Seq[String]].
- New SkippedFile(fileName, reason) case class replaces bare filename strings.
- New hooks: isSuccess, astGenOutputFiles, postProcessParsedFiles, logUnsuccessfulRun, collectSkippedFiles (defensive, logs uniformly), toRelativeInputPath (handles symlinked tmp dirs), and combine for multi-invocation frontends.
- execute() is now uniform across all frontends: it always scans the output directory for partial results, even after a failed/thrown run, and always attempts to collect skipped files — six of seven frontends previously discarded everything on failure.
- Documented each astgen binary's actual stdout/stderr conventions (verified empirically) directly on the class.

Per-frontend fixes:
- jssrc2cpg: fixed the dead skipped-file parser (was reading stdout, but skip lines are on stderr) — now correctly detects broken files via safe pattern matching.
- swiftsrc2cpg: moved the Windows exit-code quirk into isSuccess/logUnsuccessfulRun; replaced substring/indexOf parsing with a safe regex; deleted the now-dead local ExternalCommand.run.
- gosrc2cpg: fixed a bug where "Failed to generate AST for X" was mis-parsed as filename "Failed"; wired skipped files into Report.
- csharpsrc2cpg: fixed a real misattribution bug (confirmed via test) where compiler errors got attached to the wrong file under interleaved output — now buffers reasons until the terminating line names the file; wired into Report.
- rubysrc2cpg: same interleaving hardening pattern; runAstGenNative now returns a real ExternalCommandResult from the in-process JRuby run; added a Report (previously had none).
- abap2cpg / rust2cpg: adapted to the new contract; both gained a Report (abap2cpg had none before) that now records skipped files.
@max-leuthaeuser
max-leuthaeuser requested a review from ml86 August 11, 2026 10:03
@max-leuthaeuser
max-leuthaeuser force-pushed the max/astgen-runner-hardening branch from 75462f0 to 6595209 Compare August 11, 2026 10:36
@max-leuthaeuser

Copy link
Copy Markdown
Contributor Author

This is still prone to problems and complicated. Will have to do it differently.

@max-leuthaeuser
max-leuthaeuser deleted the max/astgen-runner-hardening branch August 11, 2026 11:12
@max-leuthaeuser
max-leuthaeuser removed the request for review from ml86 August 11, 2026 11:12
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