Skip to content

Add SAST incremental base-branch support(AST-177680) - #1574

Open
cx-atish-jadhav wants to merge 10 commits into
mainfrom
feature/sast-incremental
Open

cx-atish-jadhav wants to merge 10 commits into
mainfrom
feature/sast-incremental

Conversation

@cx-atish-jadhav

@cx-atish-jadhav cx-atish-jadhav commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR consolidates three related enhancements to the SAST scanning pipeline:

  1. AST-177680 — SAST Incremental Base-Branch Support

    • Add --sast-base-branch flag to explicitly specify baseline branch for incremental scans
    • Validate that --sast-base-branch requires --sast-incremental flag
    • Support flag resubmit inheritance when using --resubmit across scan attempts
  2. AST-177752 — SAST File-Extension Filters

    • Update sast supported file extensions (exclude/include patterns)
    • Support multiple extension filters via comma-separated list
    • Include integration tests with test fixtures for various file types
  3. AST-180086 — Fix Scan Show Incremental Display

    • Enrich cx scan show output with real incremental status from SAST metadata API
    • Graceful degradation: fall back to original response value if metadata fetch fails
    • Add unit tests covering success, fetch-failure, and empty-metadata scenarios

Test Coverage

  • Unit tests for SAST config validation and flag inheritance
  • Integration tests for incremental scan flow with explicit baseline branch
  • File-extension filter integration tests with sample source files
  • Mock improvements for metadata fetch error and empty-result scenarios

Changes Breakdown

Category Changes
Core Feature internal/commands/scan.go, internal/params/flags.go, internal/params/filters.go
Testing internal/commands/scan_test.go, test/integration/scan_test.go, test/integration/filters_test.go
Infrastructure internal/wrappers/scans.go, mock implementations, test data files

Fixes #AST-177680, #AST-177752, #AST-180086

Introduce --sast-base-branch support for incremental SAST scans. Adds flag definition, validation (requires --sast-incremental), wiring into scan creation and resubmit override behavior, and ensures resubmitted config can populate BaseBranch when flag not provided. Updates SastConfig in wrappers, mock scan data, unit and integration tests (including createScanIncrementalWithBaseBranch), and a small govulncheck workflow timeout tweak. Files changed: internal/commands/scan.go, internal/params/flags.go, internal/wrappers/scans.go, internal/wrappers/mock/scans-mock.go, tests in internal/commands/scan_test.go and test/integration/scan_test.go, plus CI workflow.
Pass the SAST metadata wrapper into the scan show command and fetch SAST metadata for the displayed scan. When available, use the metadata to set the scan's incremental status (SastIncremental) before printing. Updated mock wrappers to add FakeMetadataErrorID and FakeMetadataEmptyID behaviors and adjusted the scans mock to return base SastIncremental values for those IDs. Added unit tests to verify enrichment, error-preserving behavior, and empty-metadata handling. Updated an integration incremental-scan test to create an explicit baseline scan, run an incremental scan against it, and assert the Incremental status and project ID consistency. Function signatures for scanShowSubCommand and runGetScanByIDCommand were updated to accept the new wrapper.
@cx-atish-jadhav
cx-atish-jadhav requested a review from a team September 17, 2026 14:21
@cx-atish-jadhav cx-atish-jadhav changed the title AST-177680: Add SAST incremental base-branch support with file-extension filters and scan-show metadata enrichment Add SAST incremental base-branch support(AST-177680) Sep 17, 2026
@cx-atish-jadhav cx-atish-jadhav self-assigned this Sep 17, 2026
cx-atish-jadhav and others added 2 commits September 17, 2026 20:43
…idation

- Fix gofmt formatting in scan_test.go, filters_test.go, and sast-metadata-mock.go
- Add exported symbol comments for FakeMetadataErrorID and FakeMetadataEmptyID
- Initialize actualScanTypes in TestAddSastScan_BaseBranchInheritedFromResubmit to fix nil panic
- Remove excessive comments from integration test file (filters_test.go)
- Add three new filter test functions to CI workflow coverage validation patterns:
  - TestScanWithNewFileExtensions_VerifyIncluded
  - TestScanWithExistingExtensions_VerifyBackwardCompatibility
  - TestScanWithConservativeFiltering_VerifyGenericPatternsExcluded
- Assign filter tests to scan-ops matrix group for coverage collection

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@stepsecurity-app

stepsecurity-app Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Resolved — a later workflow run passed this policy check.

Original alert (resolved)

Security Policy Alert: Secret Policy Violation

This workflow run has been blocked by StepSecurity's secrets policy because it accesses secrets and the workflow file differs from the default branch.

Secret references detected:

  • secrets.CX_BASE_URI at line 213
  • secrets.CX_CLIENT_ID at line 214
  • secrets.CX_CLIENT_SECRET at line 215
  • secrets.CX_BASE_AUTH_URI at line 216
  • secrets.CX_AST_USERNAME at line 217
  • secrets.CX_AST_PASSWORD at line 218
  • secrets.CX_APIKEY at line 219
  • secrets.CX_TENANT at line 220
  • secrets.CX_SCAN_SSH_KEY at line 221
  • secrets.ECHO_LIBRARIES_ACCESS_KEY at line 223
  • secrets.PERSONAL_ACCESS_TOKEN at line 225
  • secrets.PROXY_USER at line 228
  • secrets.PROXY_PASSWORD at line 229
  • secrets.PR_GITLAB_TOKEN at line 234
  • secrets.PR_GITLAB_NAMESPACE at line 235
  • secrets.PR_GITLAB_REPO_NAME at line 236
  • secrets.PR_GITLAB_PROJECT_ID at line 237
  • secrets.PR_GITLAB_IID at line 238
  • secrets.AZURE_ORG at line 239
  • secrets.AZURE_PROJECT at line 240
  • secrets.AZURE_REPOS at line 241
  • secrets.AZURE_TOKEN at line 242
  • secrets.BITBUCKET_WORKSPACE at line 244
  • secrets.BITBUCKET_REPOS at line 245
  • secrets.BITBUCKET_USERNAME at line 246
  • secrets.BITBUCKET_PASSWORD at line 247
  • secrets.GITLAB_TOKEN at line 248
  • secrets.PR_BITBUCKET_TOKEN at line 250
  • secrets.MS_TEAMS_WEBHOOK_URL_INTEGRATION_TESTS at line 429

To approve this workflow, please add the workflows-approved label to this PR.

Note: The label must be added by someone other than the PR author (cx-atish-jadhav) or automation bots to ensure proper security review.

After the label is added, you can re-run the blocked workflow to proceed.

This workflow will be automatically approved once merged into the default branch.

For more information, see StepSecurity's Secret Exfiltration Policy documentation.

cx-rakesh-kadu
cx-rakesh-kadu previously approved these changes Sep 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants