Skip to content

feat: custom-sanitizer discovery via --discover-sanitisers on code test - #159

Draft
NasAmin wants to merge 2 commits into
mainfrom
feat/discover-candidates-model
Draft

feat: custom-sanitizer discovery via --discover-sanitisers on code test#159
NasAmin wants to merge 2 commits into
mainfrom
feat/discover-candidates-model

Conversation

@NasAmin

@NasAmin NasAmin commented Jun 17, 2026

Copy link
Copy Markdown

Summary

Adds snyk code test --discover-sanitisers (ML-1952): upload a bundle, run a discovery test via the existing test-service async pipeline, and surface Appendix-A custom-sanitizer candidates (not vulnerability findings).

Wiring follows the same pattern as --report: flag → helper → UploadAndDiscoveranalysis.RunDiscoverTest.

What changed

  • Candidate model + renderers (internal/analysis/sanitizers/) — PRD Appendix A document; JSON, human, minimal SARIF output.
  • --discover-sanitisers flag — registered in pkg/code/code.go; native workflow branches to discovery path.
  • Analysis orchestrator (internal/analysis/analysis.go) — RunDiscoverTest reuses create → poll → components → fetch (mirrors SARIF analysis).
  • Scanner (scan.go) — UploadAndDiscover (parallel to UploadAndAnalyzeWithOptions).
  • OpenAPI enumscustom_sanitizer_discovery result type, sanitizer_discovery scanner, custom-sanitizer-discovery component document type; WithDiscoverScanConfig() helper.
  • Removed — separate sanitizers.Orchestrator seam and local gRPC hack; discovery transport lives in analysis only.

Dependencies

E2E requires test-service + orchestration + code-gateway to emit the discovery component. Until then, create-test may return 4xx or poll may fail with component-not-found — expected until backend PRs land.

snyk/cli — no code change; picks up the flag via code-client-go version bump.

Test plan

  • go test ./internal/analysis/... ./internal/commands/code_workflow/... ./pkg/code/...
  • snyk code test --discover-sanitisers against org with backend wired
  • Confirm --discover-sanitisers + --report rejected
  • Confirm --json / --sarif output shapes

The native implementation was explicitly disabled for SCLE orgs. Three
things were missing for it to work; this commit addresses all of them.

1. URL: codeClientConfig.SnykCodeApi now returns localCodeEngine.url from
   the cached SAST settings when SCLE is enabled, instead of the naive
   api->deeproxy string replacement that ignored it.
2. Auth: register the local engine URL in AUTHENTICATION_ADDITIONAL_URLS
   so the networking stack attaches credentials (including OAuth2 tokens)
   to the custom SCLE host, which otherwise matches neither the API host
   nor the "deeproxy" subdomain and would be called unauthenticated.
3. API surface: SCLE implements the old deeproxy API, not the new test
   service. Route SCLE scans through the legacy scanner
   (UploadAndAnalyzeLegacy / RunLegacyTest) instead of UploadAndAnalyze,
   which the local engine does not implement.

--report is not supported for SCLE (reporting goes through the test
service); it now errors early instead of silently using the test-service
path. Also drop the '&& !scleEnabled' guard so SCLE flows use the native
path when the native/consistent-ignores feature flags are on, and
centralize the SAST settings / SLCE config keys in the code_workflow
package.

This is the functional-parity prerequisite for removing the TypeScript
@snyk/code-client dependency from the CLI, and closes the OAuth2-on-SCLE
failure tracked in CLI-589.

Refs: COIN-2539, CLI-589
@snyk-io

snyk-io Bot commented Jun 17, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-io

snyk-io Bot commented Jun 17, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@CLAassistant

CLAassistant commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ fsargent
❌ NasAmin
You have signed the CLA already but the status is still pending? Let us recheck it.

@NasAmin NasAmin changed the title feat(sanitizers): custom-sanitizer discovery candidate model, renderers + discover seam feat: custom-sanitizer discovery — model, renderers, seam + --discover-sanitisers flag Jun 17, 2026
@github-actions github-actions Bot added feature and removed feature labels Jun 17, 2026
@NasAmin NasAmin changed the title feat: custom-sanitizer discovery — model, renderers, seam + --discover-sanitisers flag feat: custom-sanitizer discovery via --discover-sanitisers on code test Jun 22, 2026
@github-actions github-actions Bot added feature and removed feature labels Jun 22, 2026
Wire the flag through the native workflow and test-service poll path;
surface Appendix-A candidates as human or JSON output. Reject SCLE and
--report combinations (test-service-only features). Share poll/create
helpers with the standard scan path.
@NasAmin
NasAmin force-pushed the feat/discover-candidates-model branch from c9780b8 to 7b0174d Compare June 22, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants