feat: centralize report filename construction - #789
Open
trevor-vaughan wants to merge 1 commit into
Open
Conversation
Contributor
✅ CRAP Load Analysis: PASSSummary
Quadrant Distribution
New Functions
|
trevor-vaughan
marked this pull request as ready for review
July 29, 2026 21:12
em-redhat
previously approved these changes
Jul 30, 2026
em-redhat
left a comment
Contributor
There was a problem hiding this comment.
Clean, well-tested fix for multi-target report overwrites (#773). BuildReportFilename is a solid centralization, import cleanup is thorough, and test coverage is strong across all formatters. One non-blocking nit on openspec/config.yaml noted inline.
em-redhat
reviewed
Jul 30, 2026
trevor-vaughan
force-pushed
the
opsx/773-output-overwritten
branch
2 times, most recently
from
August 3, 2026 15:58
4abd374 to
bb97b04
Compare
OSCAL/SARIF/Markdown formatters add targetID to filenames via BuildReportFilename helper, matching EvaluationLog; fixes multi-target scan overwrite. - feat(output): add BuildReportFilename for consistent naming - Sanitize policyID/targetID via FilenameSafe, timestamp via time.Now() - Omit targetID when empty (no double dashes) - refactor(output): migrate formatters to shared helper - Remove inline fmt.Sprintf from evaluator/oscal/sarif/markdown - test(output): add targetID assertions to formatter tests - mockGemaraEvalLog adds Target field, tests verify targetID in output - test(output): add regression test for multi-target collision - TestMultiTargetDistinctFilenames verifies distinct filenames per target - docs: update CHANGELOG and AGENTS.md for #773 Closes: #773 Assisted-By: Claude Opus 4.6 Signed-off-by: Trevor Vaughan <tvaughan@redhat.com>
trevor-vaughan
dismissed stale reviews from hbraswelrh and em-redhat
via
August 4, 2026 15:00
b0abfe0
trevor-vaughan
force-pushed
the
opsx/773-output-overwritten
branch
from
August 4, 2026 15:00
bb97b04 to
b0abfe0
Compare
trevor-vaughan
enabled auto-merge (rebase)
August 4, 2026 15:01
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.
Summary
Multi-target scans under the same policy produced OSCAL, SARIF, and Markdown reports with identical filenames (only
policyID+ timestamp), causing overwrites when targets processed within the same second. The EvaluationLog formatter already includedtargetIDand was unaffected.This PR adds a
BuildReportFilenamehelper ininternal/output/filename.gothat all four formatters now call. Report filenames include the target ID, matching the EvaluationLog pattern.Related Issues
Changes
BuildReportFilename(prefix, policyID, targetID, ext)ininternal/output/filename.goFilenameSafe, timestamps viatime.Now().Format("20060102-150405")fmt.Sprintffrom each formatterfilename_test.gocovers sanitization, empty targetID, compound extensionsTestMultiTargetDistinctFilenamesregression test for OSCAL/SARIF scan output overwritten per-target — only last target's results survive #773Review Hints
internal/output/filename.gowith comprehensive tests infilename_test.goevaluator.go,oscal.go,sarif.go,markdown.go) has a one-line change replacingfmt.SprintfwithBuildReportFilenameTestMultiTargetDistinctFilenamesinoscal_test.goreproduces the original bug (scanning two targets produces two distinct files)openspec/changes/multi-target-report-filenames/(proposal, design, spec, tasks)Testing
make test-unit)make lint)make vet)make crapload-check)TestMultiTargetDistinctFilenames)