feat(sarif): add invocation startTimeUtc and endTimeUtc to SARIF output#10799
Open
ltianyi992 wants to merge 1 commit into
Open
feat(sarif): add invocation startTimeUtc and endTimeUtc to SARIF output#10799ltianyi992 wants to merge 1 commit into
ltianyi992 wants to merge 1 commit into
Conversation
Adds a SARIF `invocations` block to every run, populated with: - `startTimeUtc` — when the SarifWriter was initialised (approximates scan start) - `endTimeUtc` — when Write() is called (scan completion) - `executionSuccessful: true` (SARIF output is only produced on success) This lets consumers (dashboards, monitoring tools) check how fresh a SARIF report is without inspecting external metadata. The SARIF 2.1.0 spec defines `invocation.startTimeUtc` and `endTimeUtc` as optional UTC-formatted timestamps; all three fields written here are conformant. Tests: extended TestReportWriter_Sarif to verify that each run contains exactly one invocation with executionSuccessful=true and non-empty timestamps. Fixes aquasecurity#3226
|
james seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
1 similar comment
|
james seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Contributor
|
Hello @ltianyi992 |
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
Adds a SARIF
invocationsblock to every run, containing:startTimeUtcSarifWriterwas initialised (approximates scan start)endTimeUtcWrite()returns (scan completion)executionSuccessfultrue(SARIF is only produced on success)Example output:
Motivation
Closes #3226
Consumers of SARIF output often need to verify scan freshness. Without
invocations, there is no timestamp inside the SARIF file itself. This change lets monitoring tools (dashboards, CI gates, compliance pipelines) check the report age without relying on filesystem metadata or external systems.Changes
pkg/report/sarif.go— addedStartTime time.Timefield toSarifWriter;Write()appends an invocation before adding the run to the report.pkg/report/writer.go— initialisesStartTimetotime.Now()when theSarifWriteris created for--format sarif.pkg/report/sarif_test.go— extended the test loop to assert one invocation exists per run withexecutionSuccessful=trueand non-empty timestamps; invocations are stripped before the remaining struct equality check so no existingwantentries need updating.SARIF conformance
Both
startTimeUtcandendTimeUtcare defined as optional in SARIF 2.1.0 §3.20.6–3.20.7 and use the RFC 3339 format required by the spec.