feat: support Snyk Code Local Engine on the native code-client-go path - #158
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This comment has been minimized.
This comment has been minimized.
f5f0863 to
10fb8e2
Compare
This comment has been minimized.
This comment has been minimized.
10fb8e2 to
c2ef599
Compare
This comment has been minimized.
This comment has been minimized.
c2ef599 to
a54a99b
Compare
|
@PeterSchafer — you're right, that was the missing piece. Confirmed in the code: Pushed a commit that routes SCLE scans through the legacy/deeproxy scanner the IDE team moved in ( Two things I'd value your read on (also in the description):
|
This comment has been minimized.
This comment has been minimized.
a54a99b to
6befdbd
Compare
|
Addressed review:
Automated-review findings:
Still pending: live run against |
This comment has been minimized.
This comment has been minimized.
6befdbd to
44f5d4c
Compare
This comment has been minimized.
This comment has been minimized.
44f5d4c to
5f73740
Compare
PR Reviewer Guide 🔍
|
| // Reporting goes through the test service, which Snyk Code Local Engine does | ||
| // not implement, so --report is not supported for SCLE. | ||
| if reportMode != noReport && config.GetBool(ConfigurationSlceEnabled) { | ||
| return nil, "", nil, errors.New("--report is not supported with Snyk Code Local Engine") |
There was a problem hiding this comment.
Should we use an explicit Error Catalog error to avoid a generic CLI failure like Peter suggested?
Merge activity
|
#158) ### Description Enables the native (`code-client-go`) Snyk Code path for **Snyk Code Local Engine (SCLE)** orgs, and makes OAuth2 auth work against the local engine — the functional-parity prerequisite for removing the TypeScript `@snyk/code-client` dependency from the CLI ([COIN-2539](https://snyksec.atlassian.net/browse/COIN-2539), [CLI-589](https://snyksec.atlassian.net/browse/CLI-589)). SCLE was disabled on the native path via a `&& !scleEnabled` guard. Three things were missing to support it; this PR addresses all three: 1. **URL mapping** — `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 (new `localCodeEngineURL()` helper). 2. **Auth** — register the local engine URL in `AUTHENTICATION_ADDITIONAL_URLS`. GAF's networking middleware (`middleware/auth_header.go`) only attaches credentials to the configured API host, its `deeproxy` subdomain, or URLs in that allowlist; a customer-hosted SCLE URL matches none, so without this the engine is called **unauthenticated**. Registering it applies the standard auth flow (incl. OAuth2 bearer + refresh) to SCLE requests. 3. **API surface** (per @peter.schafer's review) — SCLE implements the **old deeproxy API**, not the **new test service** that `UploadAndAnalyze` → `RunTest` uses. SCLE scans are now routed through the legacy scanner (`UploadAndAnalyzeLegacy` → `RunLegacyTest`, the deeproxy implementation the IDE team moved into this repo), draining its status channel for progress. Plus: drop the `&& !scleEnabled` guard, and centralize the `internal_sast_settings` / `internal_snyk_scle_enabled` config keys in `code_workflow` (aliased from `pkg/code`). ### Decisions (from review) - **`--report` on SCLE** is **not supported** (reporting goes through the test service). It now **errors early** with a clear message instead of silently using the test-service path. Covered by `Test_defaultAnalyzeFunction_reportNotSupportedWithSCLE`. - **`shardKey`** is passed **empty** — deeproxy uses it only for cache sharding, so it is optional for a CLI scan (the IDE supplies one for editor caching). Documented at the call site. ### Tests `Test_SnykCodeApi`, `Test_registerLocalEngineAuthURL`, updated `useNativeImplementation` + `Test_Code_entrypoint`. The SCLE→legacy-scanner *selection* is not unit-covered (the scanner isn't injectable into `defaultAnalyzeFunction`) — it needs the live/e2e run below. **Still required before broad enablement:** an end-to-end run against the `scle-prod-cluster` org (Code Integrations owns it) with {OAuth2, token} — the unit tests cover URL/auth/routing logic, not a real local-engine handshake. ### Checklist - [x] Tests added and all succeed - [x] Linted - [ ] README.md updated, if user-facing — n/a (internal routing change, no public API change) 🚨After having merged, please update the `snyk-ls` and CLI go.mod to pull in latest client. Refs: [COIN-2539](https://snyksec.atlassian.net/browse/COIN-2539), [CLI-589](https://snyksec.atlassian.net/browse/CLI-589) [COIN-2539]: https://snyksec.atlassian.net/browse/COIN-2539?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [CLI-589]: https://snyksec.atlassian.net/browse/CLI-589?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [COIN-2539]: https://snyksec.atlassian.net/browse/COIN-2539?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
5f73740 to
650ae39
Compare

Description
Enables the native (
code-client-go) Snyk Code path for Snyk Code Local Engine (SCLE) orgs, and makes OAuth2 auth work against the local engine — the functional-parity prerequisite for removing the TypeScript@snyk/code-clientdependency from the CLI (COIN-2539, CLI-589).SCLE was disabled on the native path via a
&& !scleEnabledguard. Three things were missing to support it; this PR addresses all three:SnykCodeApi()now returnslocalCodeEngine.urlfrom the cached SAST settings when SCLE is enabled, instead of the naiveapi→deeproxystring replacement that ignored it (newlocalCodeEngineURL()helper).AUTHENTICATION_ADDITIONAL_URLS. GAF's networking middleware (middleware/auth_header.go) only attaches credentials to the configured API host, itsdeeproxysubdomain, or URLs in that allowlist; a customer-hosted SCLE URL matches none, so without this the engine is called unauthenticated. Registering it applies the standard auth flow (incl. OAuth2 bearer + refresh) to SCLE requests.UploadAndAnalyze→RunTestuses. SCLE scans are now routed through the legacy scanner (UploadAndAnalyzeLegacy→RunLegacyTest, the deeproxy implementation the IDE team moved into this repo), draining its status channel for progress.Plus: drop the
&& !scleEnabledguard, and centralize theinternal_sast_settings/internal_snyk_scle_enabledconfig keys incode_workflow(aliased frompkg/code).Decisions (from review)
--reporton SCLE is not supported (reporting goes through the test service). It now errors early with a clear message instead of silently using the test-service path. Covered byTest_defaultAnalyzeFunction_reportNotSupportedWithSCLE.shardKeyis passed empty — deeproxy uses it only for cache sharding, so it is optional for a CLI scan (the IDE supplies one for editor caching). Documented at the call site.Tests
Test_SnykCodeApi,Test_registerLocalEngineAuthURL, updateduseNativeImplementation+Test_Code_entrypoint. The SCLE→legacy-scanner selection is not unit-covered (the scanner isn't injectable intodefaultAnalyzeFunction) — it needs the live/e2e run below.Still required before broad enablement: an end-to-end run against the
scle-prod-clusterorg (Code Integrations owns it) with {OAuth2, token} — the unit tests cover URL/auth/routing logic, not a real local-engine handshake.Checklist
🚨After having merged, please update the
snyk-lsand CLI go.mod to pull in latest client.Refs: COIN-2539, CLI-589