Repository navigation
Add reviewSarif to export a review as SARIF 2.1.0 - #48
Closed
psyhedeliq wants to merge 1 commit into
Closed
psyhedeliq wants to merge 1 commit into
psyhedeliq wants to merge 1 commit into
Conversation
Member
|
Codex Closing as out of scope. We’re keeping the SDK focused on the existing API and small, necessary client helpers. |
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.
reviewSarif(outcome, organizationId)turns theReviewOutcomethatwaitForReviewalready returns into the SARIF 2.1.0 document thatproofline findings --sarifwrites.Who this helps
Teams that call the SDK from a Node CI job or deploy script and want Proofline findings in GitHub code scanning or another SARIF consumer. Today only the CLI writes SARIF, so a Node pipeline has to install and spawn the CLI for that one file, or rebuild the projection by hand. The projection has rules that are easy to get wrong: a location counts only when it is a verified file read at the reviewed head, a partial CODE record still supplies findings but makes the run unsuccessful, and a withheld or off-commit CODE record supplies none.
Decisions and trade-offs
src/sarif.rs, so a Node job and a CLI job write the same document for the same review. Add SARIF 2.1.0 export for a retained pull-request review sdk-python#40 proposes the same export for Python.ReviewOutcome, not aReview. The outcome already holds the review, its URL, the status and each assessment's gap reasons, so the export derives no second verdict and cannot disagree withwaitForReview. The cost: a caller holding only agetReviewresult callswaitForReviewfirst, which returns after one read for a finished review.ProoflineErrorwith the typeurn:proofline:sdk:sarif-refusedand returns no document. The cost is the CLI's: a new server-side severity or domain blocks the export until the SDK lists it.executionSuccessfulisfalse. A wait that timed out exports the last review it read withREVIEW_IN_PROGRESS.recordedCodeis split out ofcodeAssessmentinsrc/index.ts, because the export reads a CODE record beside environment assessments, as the CLI does.waitForReviewbehaves as before and its 59 existing tests pass unchanged.driver.nameisProofline, so SDK and CLI uploads land under one tool in code scanning.driver.versionis the SDK version, read from the transport's existingVERSIONconstant, which stays out of the public exports.package.json.tests/fixtures/risk-domains.jsonis the CLI's fixture, copied unchanged, and pins the rule catalog.Verification
Tests, in
tests/sarif.test.mjs: 5 tests ported from the CLI'stests/sarif.rs. Every case is read throughwaitForReviewfrom a local HTTP server, so each export is of an outcome the SDK produced. They cover identity and percent-encoded locations, the ten location statuses, duplicate and related locations, message escaping, fingerprints, gap notifications for seven review statuses, 43 CODE record cases (every category, partial, withheld, off-commit, beside environments), each refusal, and all 40 cases of the sharedreview-outcomes.jsonfixture, none of which exports an incomplete review as a successful run.src/sarif.ts(head filter, escaping, path validation, de-duplication, refusals and others) each fail the suite.pnpm generate && git diff --exit-code,pnpm lint,pnpm typecheck,node check-claims.mjs,pnpm build,pnpm test(64 tests, 0 failures, 59 before) andnpm pack.Checksworkflow passes on this branch in my fork: https://github.com/psyhedeliq/sdk-typescript/actions/runs/43653935587Manual runs:
77b04ca(0.2.10), served 31 review documents from a local HTTP server, and exported each with the built SDK and withproofline findings --review ID --sarif. The two documents are deep-equal in all 31 oncedriver.versionis set equal, the one intended difference. In 6 refusal cases the SDK'sdetailequals the CLI's message and the CLI writes no output.locationFromSarifResult: expected at least one location; the same document without that result was accepted. Since the CLI writes the identical document, that limit applies to both, and the README now states it. I removed the test analyses afterwards.reviewSarifand the exported types.Not verified: a run against the live Proofline API. I have no account, so every review document above is a fixture.