feat: add commit SHA check to skip redundant scans#274
Merged
Conversation
Implements authenticate(), searchScanBySha(), and checkForExistingScan() to look up existing scans by commit SHA before running a new scan.
Implements buildScanSummaryMarkdown, writeScanSummary, and postPrComment for formatting scan results as markdown and posting to GitHub Step Summary or PR comments when a previously completed scan is found by commit SHA.
Add two new action inputs to action.yml and gatherInputs() in src/utilities.js: - commitShaCheck: triggers pre-scan SHA lookup on the StackHawk platform - organizationId: required when commitShaCheck is enabled Rebuild dist/ to include updated utilities.
Bwvolleyball
reviewed
Apr 2, 2026
Contributor
Bwvolleyball
left a comment
There was a problem hiding this comment.
organizationId as a required input
Do we need organizationId as a separate user-provided input? Since the action already has the apiKey and parses applicationId from stackhawk.yml, the org should be derivable — apps can only belong to one organization.
The auth response from /api/v1/auth/login likely contains the org ID, or we can look it up from the app. That would let us drop the organizationId input entirely and reduce setup friction for users.
Bwvolleyball
approved these changes
Apr 2, 2026
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
commitShaCheckinput that looks up existing StackHawk scan results by commit SHA before running a new scanorganizationIdfrom the application lookup (GET /api/v1/app/{appId}) — no extra config neededNew Action Input
commitShaCheckfalseExample Usage
The
configurationFilesis always required — the action parsesapplicationIdfrom it for the SHA lookup. If no existing scan is found, the action falls through to a normal HawkScan run using the same config.New Modules
src/config_parser.js— ParsesapplicationIdfrom stackhawk.ymlsrc/scan_check.js— StackHawk API auth, app lookup for orgId, scan search byGIT_SHAtagsrc/scan_summary.js— Markdown formatting for PR comment and Step SummaryTest plan
npm run allpasses (lint + build + test) — 36 tests across 4 suitescommitShaCheck: false(default) — should behave identically to current actioncommitShaCheck: trueand a commit that has an existing scan — should find scan, post summary, skip CLI runcommitShaCheck: trueand a commit with no existing scan — should fall through to normal scan