Repository navigation
[APPX-14752] [APPX-14753] Remediate Arnica code risk findings for Agent SDK - #468
Conversation
Clears the Arnica SCA/SAST/IaC/license/reputation findings on optimizely/agent@master. Scoped against govulncheck ground truth (28 reachable vulnerabilities -> 0), not just the Arnica version list (several of whose versions/line numbers were stale). Go dependencies (go.mod / go.sum): - Bump Go toolchain 1.24.7 -> 1.26.11 (clears 14 Go-stdlib findings: net/http, crypto/tls, html/template, crypto/x509). Updates the 8 go-version pins and GIMME_GO_VERSION (feeds the Docker build) in CI. - otel stack 1.21.0 -> 1.45.0, grpc 1.59.0 -> 1.83.1, x/net -> 0.60.0, go-chi/chi/v5 -> 5.5.0, plus transitive bumps (protobuf, x/crypto, x/text, x/sys). testify is pulled to 1.11.1 by otel and cannot be pinned back without regressing otel/grpc to vulnerable versions. - Remove the stale replace block; its forced "safe" versions were now below the new baselines (and were the source of the x/crypto v0.45.0 flag). Code & IaC: - SAST XSS (pkg/handlers/notification.go): write the already JSON-encoded SSE payload with w.Write instead of fmt.Fprintf, removing the flagged format-string-to-ResponseWriter pattern; drop the now-unused fmt import. - Add a wget-based HEALTHCHECK to Dockerfile.alpine (admin /health on :8088). Bump its base images golang/alpine 3.21 -> 3.23 since Go 1.26.11 is not published for alpine3.21. Dockerfile.static is FROM scratch with no shell/HTTP client, so its omitted HEALTHCHECK is documented inline. Python (example/test deps only, not the Agent binary): - examples/requirements.txt: bump certifi, requests, urllib3, idna. - tests/acceptance/requirements.txt: bump requests; pytest 7.0.0 -> 8.4.2. Documentation: - docs/dependency-security-notes.md records the accepted (non-remediable) reputation and MPL-2.0 license findings, all confirmed indirect deps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Arnica flags direct advisories regardless of reachability, so it reported grpc@v1.83.1 (1 vuln) and x/net@v0.60.0 (2 vulns) even though govulncheck found them unreachable. Bump grpc 1.83.1 -> 1.83.2 and x/net 0.60.0 -> 0.62.0 (pulling transitive x/crypto/x/sys/x/text/x/sync bumps) to clear the findings. govulncheck remains at 0 affected vulnerabilities. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The tests_acceptance_test job failed at setup-python with "Version 3.9 with arch x64 not found" -- the upgraded ubuntu-latest runner no longer provides Python 3.9 (runner drift, not caused by the dependency bumps; the failure is before pip install). Bump actions/setup-python v3 -> v5 and Python 3.9 -> 3.12 (quoted to avoid float parsing). 3.12 is compatible with the pinned acceptance dependencies. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Go 1.26 toolchain bump broke the lint job: golangci-lint v1.64.2
(pinned in the Makefile) is built with Go 1.24 and refuses to analyze a
module targeting a newer Go ("the Go language version (go1.24) used to
build golangci-lint is lower than the targeted Go version (1.26.11)").
The v1 line never shipped a Go 1.26 build. The code uses no post-1.24
language features, so pin run.go to 1.24 as a bridge until golangci-lint
is upgraded to a v2 release built with Go 1.26+.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ately Reverts the setup-python v3->v5 / 3.9->3.12 change. The acceptance job is broken by pre-existing runner drift (ubuntu-latest dropped Python 3.9) and the old pinned openapi_core 0.17.1 does not work on modern Python, which is independent of these Arnica security changes and would fail on master too. Keeping this PR scoped to the security findings; the acceptance-test modernization is tracked under a separate infra ticket. The tests/acceptance/requirements.txt pytest/requests bumps are retained since they clear the Arnica Python findings (static scan). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The lint job timed out at golangci-lint's default 1m ("Timeout exceeded").
The dependency graph grew (otel v1.45, grpc v1.83) and the Go 1.26
toolchain makes the first uncached analysis slower. Raise run.timeout to
5m. (No lint findings -- it was purely a timeout.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Go 1.26 toolchain bump broke the lint job: golangci-lint v1.64.2 is built with Go 1.24 and cannot analyze a module targeting Go 1.26 (x/net v0.62.0 requires go 1.26, forcing the module's go directive to >=1.26, so lowering it is not an option). The v1 line never shipped a Go 1.26 build. - Makefile: bump golangci-lint v1.64.2 -> v2.15.0 and update the lint invocation for v2 flags (--out-format removed; use --output.tab.path). - .golangci.yml: migrate to the v2 schema (golangci-lint migrate). gosimple and stylecheck are merged into staticcheck in v2; typecheck is dropped; run.timeout is no longer needed (disabled by default in v2); the stale revive.min-confidence setting is removed. Fix the findings v2's stricter staticcheck surfaces in non-test code: - pkg/metrics/metrics.go: strings.Replace(-1) -> strings.ReplaceAll; preallocate convertedArray. - pkg/server/server.go: drop tls.Config.PreferServerCipherSuites (ignored since Go 1.18, SA1019). - pkg/syncer/pubsub.go: convert if/else-if chain to a tagged switch. - pkg/optimizely/optimizelytest/config.go, plugins/userprofileservice/ services/rest_ups.go: preallocate slices. golangci-lint v2.15.0 run (matching the Makefile flags) reports 0 issues; build and affected package tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CI setup failed with "checksum did not verify" because the /master/ install.sh is out of sync with the v2.15.0 release artifacts. Pin the install.sh URL to the v2.15.0 tag (the golangci-lint v2 recommended pattern) so the script and the downloaded binary match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… fetched External builders (e.g. the fullstack-sdk-compatibility-suite) build the agent image passing an older GO_VERSION (1.24.0). The official golang base images set GOTOOLCHAIN=local, so go.mod's `go >= 1.26.0` requirement cannot be satisfied and the build fails with: go: go.mod requires go >= 1.26.0 (running go 1.24.0; GOTOOLCHAIN=local) Set GOTOOLCHAIN=auto in the builder stages so the toolchain declared in go.mod (go1.26.11) is downloaded regardless of the base image's Go version. The agent's own release builds use golang:1.26.11, so this is a no-op there (no download needed) and only adds resilience for older-base builders. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ubuntu-latest no longer provides Python 3.9 (setup-python failed with "Version 3.9 with arch x64 not found"). Move the acceptance job to Python 3.12 via actions/setup-python@v5. Python 3.12 then exposed a second, pre-existing break: openapi_core 0.17.1 pulls the old jsonschema-spec file handler, which crashes at import time on 3.12 (AttributeError: '_io.BufferedReader' object has no attribute 'decode') and errored collection of all 14 test modules. Bump openapi_core 0.17.1 -> 0.18.2 and openapi_spec_validator 0.5.6 -> 0.7.2. 0.18.2 keeps the same API helpers.py uses (Spec.from_file_path, unmarshal_request/response, RequestsOpenAPIRequest/Response, the same exception classes), so no test-code changes are needed. Verified locally on Python 3.12: helpers.py imports and loads the spec, and `pytest --collect-only` collects all 94 acceptance tests with 0 errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
govulncheck flagged GO-2026-6974 (published after the initial fix) in go.opentelemetry.io/otel/sdk and otel/trace v1.45.0, fixed in v1.47.0. Bump the otel stack 1.45.0 -> 1.47.0. govulncheck is back to 0 affected vulnerabilities. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…FSC) The fullstack-sdk-compatibility-suite (a required check) added holdout scenarios on 2026-10-27 (decide_holdouts_exclude_td.feature etc.). The agent pinned go-sdk v2.5.0, which predates holdout / exclude_targeted_ deliveries support (added in go-sdk v2.6.0/v2.7.0), so those scenarios failed. This is independent of the Arnica work but blocks the PR because FSC is a required status check. Bump go-sdk to v2.7.0 so holdout evaluation is handled in the SDK and the agent's decide endpoints satisfy the compatibility suite. Build, unit tests, and govulncheck (0 vulnerabilities) all pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Empty commit to re-run checks against the updated compatibility suite master, which now forwards default decide options to the agent (optimizely/fullstack-sdk-compatibility-suite#710). Expecting the final holdout scenario (ETD INCLUDE_REASONS) to pass -> FSC green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Alex Yong (alexjoeyyong)
left a comment
There was a problem hiding this comment.
Verdict: comment. No blockers. I'd approve once the HEALTHCHECK issue below is fixed or consciously accepted.
CI: all checks pass (lint, docker lint, acceptance, Windows build, coverage, compat suite). Arnica's x/net and grpc findings were auto-resolved; the certifi MPL finding was dismissed with a reason.
Checked myself: I ran govulncheck ./... on the head and got 0 affected vulnerabilities (plus 1 in a required module the code doesn't call). Every new Go module, the Go 1.26.11 toolchain and every new Python pin exists on the Go proxy or PyPI. The .golangci.yml v1 to v2 rewrite maps every linter and exclusion (gosimple and stylecheck fold into staticcheck). busybox wget --spider sends a GET, and healthMW answers GET /health before the allowed-hosts check, so the probe works on a default setup.
Good: govulncheck for reachable-only ground truth; removing the stale replace block; an honest accepted-risk doc.
Should-fix
- The HEALTHCHECK hard-codes
http://127.0.0.1:8088(scripts/dockerfiles/Dockerfile.alpine). It reports unhealthy on any deployment that overrides the admin port (OPTIMIZELY_ADMIN_PORT) or enables TLS (server.keyFile/server.certFile, after which the admin listener serves HTTPS). Docker marks those containers unhealthy and Swarm or compose-based autoheal can restart them; Kubernetes ignores the instruction. That changes behavior for existing image users. Fix: use the shell form so the port comes from the environment:CMD wget -q --spider "http://127.0.0.1:${OPTIMIZELY_ADMIN_PORT:-8088}/health" || exit 1. Mention the TLS case in the comment or docs, or drop the check.
Nits
- The description doesn't match the head. It says otel 1.45.0, grpc 1.83.1, x/net 0.60.0 and testify 1.11.1;
go.modhas 1.47.0, 1.83.2, 0.62.0 and 1.12.1. It also omits the golangci-lint v1 to v2 migration, the Makefile changes, Python 3.9 to 3.12,setup-pythonv3 to v5, and thepytest/openapi_core/openapi_spec_validatorbumps. This PR is the audit record, so list them. go 1.26.0plusENV GOTOOLCHAIN=autoin both Dockerfiles. Acceptable, sincego.modpinstoolchain go1.26.11and the checksum database verifies it, but it makes image builds network-dependent. Please confirm the external builders mentioned in the Dockerfile comment, and any downstream importers, can take Go 1.26.pkg/handlers/notification.go: the "XSS" change alters no behavior (the payload isjson.Marshaloutput) and now does threeWritecalls per event. An Arnica dismissal would have been simpler, and the four-line comment mostly defends the change to the scanner.- No dependency vulnerability scan in CI, so "28 to 0" is only enforced by Arnica. One
govulncheck ./...step inagent.ymlwould stop it quietly regressing. - The Makefile still pipes
install.shintosh. It's now pinned to the v2.15.0 tag instead ofmaster, which is an improvement.go install ...@v2.15.0would avoid the pattern, andstatik@lateston the next line is also unpinned (already was). examples/requirements.txtsays "its Arnica findings are transitive" (org check CODE-1.S1); describe the pin instead.
…mments - Dockerfile.alpine HEALTHCHECK: use shell-form port expansion so the probe follows OPTIMIZELY_ADMIN_PORT (default 8088) instead of hard-coding 8088; document that it probes plain HTTP and should be overridden/dropped when the admin listener runs TLS (server.keyFile / server.certFile). (Alex: should-fix) - agent.yml: add a govulncheck job so the "0 reachable vulnerabilities" result is enforced in CI, not only by Arnica. (Alex: nit) - examples/requirements.txt: reword the sseclient note to describe the pin rather than reference scanner findings. (Alex: nit, CODE-1.S1) - notification.go: trim the SSE write comment to a plain rationale. (Alex: nit) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for the thorough review (and the independent govulncheck/proxy verification) 🙏 Addressed in e045669: Should-fix — HEALTHCHECK port. Fixed exactly as suggested — shell form with Nits:
CI is re-running with these changes (incl. the new govulncheck job). |
The govulncheck job failed loading packages because the generated statik package wasn't built (govulncheck: "no required module provides package .../statik"). Install statik and run `make static` before govulncheck, matching how the other jobs build. Verified locally: 0 affected vulnerabilities. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Alex Yong (alexjoeyyong)
left a comment
There was a problem hiding this comment.
Re-review at 0e4b000. Verdict: approve. The one should-fix from my earlier review is resolved.
CI: all checks pass (fmt, lint, docker lint, govulncheck, acceptance, Windows build, coverage, compat suite).
What changed since my last review
- HEALTHCHECK (was should-fix): fixed. It now uses the shell form,
"http://127.0.0.1:${OPTIMIZELY_ADMIN_PORT:-8088}/health", so it follows a port override. The comment now says it probes plain HTTP and fails when the admin listener runs TLS, so override or drop it in that case. That limitation is stated plainly, and I'm fine with it. - govulncheck in CI: added as its own job, so the "0 reachable" result no longer depends on Arnica alone. It generates the statik package first, which is the same failure I hit running it locally.
- Comment cleanups: the
notification.goandexamples/requirements.txtcomments no longer defend the change to the scanner or cite findings. - My other nits: the Go 1.26 /
GOTOOLCHAIN=autoreply holds up (the compat-suite builder ongolang:1.24.0passes and fetches the pinnedgo1.26.11), and I accept the pinnedinstall.shovergo installfor golangci-lint.
Nit (non-blocking)
- The govulncheck job installs
statik@latestandgovulncheck@latest, unpinned. A new vulnerability-database entry or a govulncheck release can turn this job red on an unrelated PR with no code change. That is partly the point of the job. Pin both and bump them deliberately, or accept the occasional red run. If it becomes a required check, decide that first.
Pin the govulncheck job's tool installs (statik@v0.1.7 matching go.mod, govulncheck@v1.10.0) so a tool release can't flip the job independently of the code; bump them deliberately. The vulnerability database is still fetched live at run time (occasional red on a new advisory is intended). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Pinned in 113c0a3: |
Alex Yong (alexjoeyyong)
left a comment
There was a problem hiding this comment.
Approving at 113c0a3. The last commit pins statik and govulncheck, which was my only remaining nit. CI is green and the earlier should-fix (HEALTHCHECK port) was already resolved.
CVE-2025-71176 (GHSA-6w46-j5rx-g56g, medium): pytest < 9.0.3 has vulnerable tmpdir handling. This is the only Dependabot alert remaining on optimizely/agent after the Go-dependency bumps in #468 cleared the other 86. pytest 9.0.3 requires Python >=3.10; the acceptance CI already runs Python 3.12 (.github/workflows/agent.yml). Verified the pinned acceptance requirements install together cleanly and all 94 acceptance tests collect under pytest 9.0.3. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Remediates the Arnica code risk findings for the Agent SDK (
APPX-14752). Scoped against govulncheck ground truth — 28 reachable vulnerabilities → 0 — not Arnica's list alone (several of whose versions/line numbers were stale).Go toolchain
go.mod:go 1.26.0,toolchain go1.26.11(was1.24.0/go1.24.7). Required to clear the 14 Go-stdlib findings (net/http, crypto/tls, html/template, crypto/x509)..github/workflows/agent.yml):GIMME_GO_VERSIONand allgo-versionpins1.24.0 → 1.26.11.Go dependencies (
go.mod/go.sum)1.21.0 → 1.47.0(sdk/trace/metric/otel + otlptrace exporters + stdouttrace); the 1.47.0 step also cleared the newly-published GO-2026-6974.google.golang.org/grpc 1.59.0 → 1.83.2;golang.org/x/net → 0.62.0;go-chi/chi/v5 5.2.2 → 5.5.0; plus transitive bumps (protobuf, x/crypto 0.58.0, x/text, x/sys, testify 1.9.0 → 1.12.1 — pulled by otel, can't be pinned back without regressing otel/grpc).github.com/optimizely/go-sdk/v2 2.5.0 → 2.7.0for holdout / exclude_targeted_deliveries support (needed for the compat-suite holdout scenarios).replaceblock — its forced "safe" versions were below the new baselines (and were the source of Arnica'sx/crypto v0.45.0flag).Lint tooling (consequence of the Go 1.26 bump)
v1.64.2 → v2.15.0(v1 can't analyze a Go-1.26 module);Makefileinstall pinned to thev2.15.0tag; lint invocation updated for v2 flags (--out-formatremoved →--output.tab.path)..golangci.ymlmigrated to the v2 schema (golangci-lint migrate):gosimple/stylecheckfold intostaticcheck,typecheckdropped, stalerevive.min-confidenceremoved.strings.Replace(-1) → ReplaceAll, drop deprecatedtls.Config.PreferServerCipherSuites(SA1019), if/else→switch, and 3 slice preallocations.Code & IaC
pkg/handlers/notification.go): write the already-JSON-encoded SSE payload viaw.Writeinstead offmt.Fprintf; drop the now-unusedfmtimport.scripts/dockerfiles/Dockerfile.alpine: base imagesgolang/alpine3.21 → 3.23(Go 1.26.11 isn't published for alpine3.21); addHEALTHCHECK(wget/health, port via${OPTIMIZELY_ADMIN_PORT:-8088}; HTTP-only — override under TLS).ENV GOTOOLCHAIN=autoso the pinned toolchain is fetched when an external builder passes an olderGO_VERSION(e.g. the compat suite builds withgolang:1.24.0).Dockerfile.static(FROM scratch): HEALTHCHECK intentionally omitted (no shell/HTTP client, no health subcommand) — documented inline.Python (example/test deps only — not the Agent binary)
examples/requirements.txt:certifi,requests,urllib3,idna→ latest.tests/acceptance/requirements.txt:pytest 7.0.0 → 8.4.2,requests → 2.34.2, andopenapi_core 0.17.1 → 0.18.2/openapi_spec_validator 0.5.6 → 0.7.2(the old pins crash at import on Python 3.12).actions/setup-python v3 → v5, Python3.9 → 3.12(3.9 was dropped fromubuntu-latest).CI / docs
govulncheckjob toagent.ymlso "0 reachable vulnerabilities" is enforced in CI.docs/dependency-security-notes.md: documents the accepted (non-remediable) reputation + MPL-2.0 findings — all confirmed indirect deps. The certifi MPL finding was dismissed in Arnica with a documented reason.Test Plan
go build ./...,go vet,gofmt,go mod tidy(stable) ✅govulncheck ./...→ 0 affected vulnerabilities ✅golangci-lint v2.15.0 run --tests=false ./...→ 0 issues ✅go test ./...passes (pubsub integration tests require a live Redis — run in CI) ✅optimizely/fullstack-sdk-compatibility-suite#710).Jira
https://optimizely-ext.atlassian.net/browse/APPX-14752
🤖 Generated with Claude Code