Skip to content

[APPX-14752] Remediate Arnica code risk findings for Agent SDK - #468

Open
Matjaz Pirnovar (Mat001) wants to merge 7 commits into
masterfrom
mpirnovar-agent-arnica-appx-14752
Open

Matjaz Pirnovar (Mat001) wants to merge 7 commits into
masterfrom
mpirnovar-agent-arnica-appx-14752

Conversation

@Mat001

Copy link
Copy Markdown
Contributor

Summary

Remediates the Arnica code risk findings for the Agent SDK (optimizely/agent@master). Scoped against govulncheck ground truth — 28 reachable vulnerabilities → 0 — rather than Arnica's list alone (several of whose versions/line numbers were stale, e.g. x/crypto v0.45.0 / x/net v0.47.0 were already recent).

Go dependencies (go.mod / go.sum)

  • Toolchain 1.24.7 → 1.26.11 — the only way to clear the 14 Go-stdlib findings (net/http, crypto/tls, html/template, crypto/x509). Also updates the 8 go-version pins and GIMME_GO_VERSION (which feeds the Docker build) in .github/workflows/agent.yml.
  • otel 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).
  • Removed the stale replace block — its forced "safe" versions were now below the new baselines (and were the source of Arnica's x/crypto v0.45.0 flag).
  • testify is pulled to 1.11.1 by otel and cannot be pinned back without regressing otel/grpc into vulnerable versions.

Code & IaC

  • SAST XSS (pkg/handlers/notification.go): write the already-json.Marshal'd SSE payload via w.Write instead of fmt.Fprintf, removing the flagged format-string-to-ResponseWriter pattern; dropped the now-unused fmt import.
  • HEALTHCHECK: added a wget-based probe (/health on admin :8088) to Dockerfile.alpine, and bumped its base images golang/alpine 3.21 → 3.23 (Go 1.26.11 is not published for alpine3.21). Dockerfile.static is FROM scratch (no shell/HTTP client, no health subcommand), so its omitted HEALTHCHECK is documented inline with the orchestrator-probe alternative.

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 findings — the 5 reputation and 4 MPL-2.0 license findings, all confirmed indirect deps (jwx→lestrrat, prometheus→matttproud, go-kit→VividCortex, viper/go-sdk→hashicorp). MPL-2.0 is compatible for unmodified deps in this Apache-2.0 project.

Test Plan

  • go build ./... ✅
  • go vet ./... — no new warnings (the copylocks/lostcancel warnings in *_test.go are pre-existing on master) ✅
  • gofmt clean on changed files ✅
  • go mod tidy stable (no diff) ✅
  • govulncheck ./... → 0 affected vulnerabilities ✅
  • go test ./... passes except pkg/syncer/pubsub (requires a live Redis — environmental, unrelated to this change; CI runs these with a Redis service) ✅
  • Verified base-image tags exist: golang:1.26.11, golang:1.26.11-alpine3.23, alpine:3.23. (Docker daemon unavailable locally for a full image build — CI will exercise it.)

Jira

https://optimizely-ext.atlassian.net/browse/APPX-14752

🤖 Generated with Claude Code

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>
Comment thread go.mod Resolved
Comment thread go.mod Resolved
Comment thread examples/requirements.txt Resolved
@datadog-optimizely-experimentation

datadog-optimizely-experimentation Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Pipelines

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 5 Pipeline jobs failed

View all 5 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 698c0bf | Docs | View more details | Give us feedback!

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant