Skip to content

ci: fix gosec image tag (drop v prefix)#25

Merged
KingPin merged 6 commits into
mainfrom
fix/gosec-image-tag
May 22, 2026
Merged

ci: fix gosec image tag (drop v prefix)#25
KingPin merged 6 commits into
mainfrom
fix/gosec-image-tag

Conversation

@KingPin
Copy link
Copy Markdown
Owner

@KingPin KingPin commented May 22, 2026

Summary

  • securego/gosec tags ≥2.10 are published on Docker Hub without the v prefix
  • The existing pin securego/gosec:v2.22.4 returns manifest unknown → exit 125
  • Verified on workflow_dispatch run 26313540231
  • Fix is the minimal change: drop the v. Tag 2.22.4 exists and matches the originally intended pin

Test plan

  • CI run on this branch reaches and passes the Security scan (gosec) step in docker-image.yml
  • (Indirect) binary-release.yml will pick up the same fix on next tag push

KingPin and others added 5 commits April 6, 2026 13:20
defer r.Body.Close() was registered after the early-return error check,
so a read failure leaked the body. Move defer before io.ReadAll.
LimitReader silently truncated bodies at maxBodySize without any error
or indication to the caller. Use the maxBodySize+1 probe (same approach
as multiplex/sendRequest) to detect truncation and return 413. Also
correct the misleading 'Payload too large' message on genuine I/O
errors, which now returns 400 via writeJSONError.
echoHandler default mode and healthCheck wrote JSON bodies without the
corresponding Content-Type header, inconsistent with every other
JSON-producing handler in the service.
Both counters were registered but never incremented, making them dead
metrics. retriesTotal is now recorded at each retry point labelled by
cause (network_error or server_error). retrySuccess is recorded after a
successful response that required at least one retry, labelled by the
total attempt count.
securego/gosec tags ≥2.10 are published without the 'v' prefix on Docker
Hub, so the existing pin `securego/gosec:v2.22.4` resolves to `manifest
unknown` and fails the gosec step with exit 125. Use `2.22.4`.
Copilot AI review requested due to automatic review settings May 22, 2026 21:59
The -healthcheck CLI flag's Close() return value was unchecked; gosec
G104 flagged it. We immediately os.Exit after this point so the close
error is genuinely irrelevant — explicit `_ =` makes the intent clear
and satisfies the scan.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GitHub Actions workflows to use the correct securego/gosec Docker tag format (dropping the v prefix) so CI security scanning no longer fails with manifest unknown. It also includes additional, unrelated runtime changes in fanout.go (echo/health handlers and retry metrics).

Changes:

  • Update securego/gosec image tag from v2.22.42.22.4 in CI workflows.
  • Adjust echo mode request body reading to properly detect “payload too large” via maxBodySize+1, and standardize JSON responses/content-type.
  • Add Prometheus retry counters for network/server retry events and a “retry success” counter.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
fanout.go Updates echo/health response behavior and adds retry-related Prometheus metrics instrumentation.
.github/workflows/docker-image.yml Fixes securego/gosec Docker tag so the security scan step can run.
.github/workflows/binary-release.yml Applies the same gosec tag fix to release workflow security scanning.

Comment thread fanout.go
Comment on lines 372 to +382
func echoHandler(w http.ResponseWriter, r *http.Request) {
bodyBytes, err := io.ReadAll(io.LimitReader(r.Body, maxBodySize))
defer r.Body.Close()
bodyBytes, err := io.ReadAll(io.LimitReader(r.Body, maxBodySize+1))
if err != nil {
logError("Error reading body: %v", err)
http.Error(w, "Payload too large", http.StatusRequestEntityTooLarge)
writeJSONError(w, "Failed to read request body", http.StatusBadRequest)
return
}
if int64(len(bodyBytes)) > maxBodySize {
logError("Request body size exceeds limit (%d bytes read)", len(bodyBytes))
writeJSONError(w, "Payload too large", http.StatusRequestEntityTooLarge)
Comment thread fanout.go
resp.Body = string(respBody)
resp.Attempts = attempts + 1

if metricsEnabled && attempts > 0 {
@KingPin KingPin merged commit eca6aa0 into main May 22, 2026
1 check passed
@KingPin KingPin deleted the fix/gosec-image-tag branch May 22, 2026 22:05
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.

2 participants