[x2cpg] AstGenRunner hardening - #6188
Closed
max-leuthaeuser wants to merge 2 commits into
Closed
Conversation
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
force-pushed
the
max/astgen-runner-hardening
branch
from
August 11, 2026 10:36
75462f0 to
6595209
Compare
Contributor
Author
|
This is still prone to problems and complicated. Will have to do it differently. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AstGenRunner:runAstGenNativereturnsExternalCommandResult(both streams kept separate) instead of a lossyTry[Seq[String]].SkippedFile(fileName, reason)case class replaces bare filename strings.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:
isSuccess/logUnsuccessfulRun; replacedsubstring/indexOfparsing with a safe regexrunAstGenNativenow returns a realExternalCommandResultfrom the in-process JRuby run; added a Report (previously had none).