Skip to content

Hooks management command + build & supply-chain hardening - #193

Merged
gnanam1990 merged 5 commits into
mainfrom
fix/toolchain-cve-bump
Jun 14, 2026
Merged

Hooks management command + build & supply-chain hardening#193
gnanam1990 merged 5 commits into
mainfrom
fix/toolchain-cve-bump

Conversation

@gnanam1990

@gnanam1990 gnanam1990 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two things in one PR — a new CLI feature plus build/supply-chain hardening.

1. Hooks management command (feature)

Wires the previously-dormant hooks.ConfigStore (10 unreachable funcs → 0) into the CLI,
so hooks can be managed from the command line, not just listed:

zero hooks add <id> --event <event> --command <cmd> [--name --description --matcher --arg --user --json]
zero hooks remove  <id> [--user --json]
zero hooks enable  <id> [--user --json]
zero hooks disable <id> [--user --json]
  • Writes the project hook config by default (<cwd>/.zero/hooks.json) or the user
    config with --user, reusing the store's existing locking + atomic writes + validation
    (normalizeDefinition).
  • New hooks are enabled; persisted state is managed via enable/disable.
  • JSON output is secret-scrubbed (redaction); mirrors the existing
    zero mcp add/remove/enable/disable command shape.
  • Tests: add→list round-trip, remove, enable/disable, unknown-event rejection, required-flag
    validation, and JSON secret redaction.

2. Build & supply-chain hardening

  • Toolchain bump (P0)go.mod toolchain go1.24.13 → go1.26.4, clearing 9
    govulncheck-reachable stdlib CVEs
    (CI/release build via go-version-file: go.mod, so
    shipped binaries inherited them).
  • govulncheck CI gate — a new security job fails on a reachable vulnerability (hard
    gate); plus an advisory deadcode step.
  • SHA-pinned GitHub Actions — every action pinned to a commit SHA with a version comment
    across all four workflows (previously only setup-go was pinned).

CVEs cleared

Advisory Stdlib pkg Issue Fixed in
GO-2026-4870 crypto/tls TLS 1.3 KeyUpdate → DoS 1.25.9
GO-2026-4918 net/http (http2) infinite loop on bad SETTINGS frame 1.25.10
GO-2026-4947 / 4946 / 5037 crypto/x509 chain / policy / hostname parsing 1.25.9 / 1.25.11
GO-2026-4971 net NUL-byte panic in Dial/LookupPort 1.25.10
GO-2026-5039 net/textproto unescaped inputs in errors 1.25.11
GO-2026-4602 os FileInfo escapes a Root 1.25.8
GO-2026-4601 net/url IPv6 host-literal parsing 1.25.8

Verification

  • go build ./..., go vet ./..., gofmt -l clean; full go test ./... green.
  • govulncheck ./...0 reachable (was 9 under go1.24.13).
  • internal/hooks is now fully reachable (10 → 0 unreachable funcs); total prod-unreachable
    down to 114.
  • All four workflows parse as valid YAML; action SHAs resolve to the current v4/v7.

Notes

  • The govulncheck gate may flag a newly published advisory on an unrelated PR — intentional
    (don't ship known-reachable vulns); fix is a toolchain bump. deadcode is advisory.
  • The go directive stays at 1.24.2; only the toolchain directive moves.

Summary by CodeRabbit

  • New Features
    • Extended zero hooks with add, remove, enable, and disable commands, including optional JSON output and --user vs project scope.
  • Chores
    • Updated the project Go toolchain version.
    • Pinned commonly used CI actions to fixed revisions for more consistent runs.
  • CI
    • Added a security/code-health job that runs vulnerability checks (blocking) and dead code analysis (non-blocking).
  • Tests
    • Added CLI coverage for adding, toggling, removing hooks, plus JSON redaction of secret args.

go.mod pinned toolchain go1.24.13, whose bundled standard library has 9
govulncheck-reachable CVEs (crypto/tls KeyUpdate DoS, net/http2 loop, crypto/x509 x3,
net, net/url, os, net/textproto). CI and release build via go-version-file: go.mod, so
shipped binaries inherited them.

Bumping the toolchain directive to go1.26.4 clears all nine — govulncheck ./... now
reports 0 reachable (minimum that clears them is go1.25.11; go1.26.4 matches the team's
local Go). The go directive stays at 1.24.2 (minimum language version). Verified:
go build/vet/gofmt clean, full go test ./... green.
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Go toolchain upgraded from go1.24.13 to go1.26.4. GitHub Actions across CI workflows pinned to commit SHAs for supply-chain security, with a new govulncheck and deadcode security job added. Hooks management CLI extended with add, remove, enable, and disable subcommands that parse and validate arguments, persist hooks to project or user config, and output either JSON (with secret redaction) or human-readable messages.

Changes

Toolchain and CI Infrastructure Updates

Layer / File(s) Summary
Go toolchain version upgrade
go.mod
Toolchain directive updated from go1.24.13 to go1.26.4; all other module metadata remains unchanged.
GitHub Actions pinning and new security job
.github/workflows/pr-auto-review.yml, .github/workflows/release-artifacts.yml, .github/workflows/zero-action-smoke.yml, .github/workflows/ci.yml
actions/checkout, actions/upload-artifact, and actions/github-script pinned to specific commit SHAs across all CI/CD workflows. New security job added to ci.yml that runs govulncheck (blocking) and deadcode (advisory) with GOTOOLCHAIN derived from go.mod.

Hooks Management CLI Feature

Layer / File(s) Summary
Hook event validation helpers
internal/hooks/hooks.go
Exported KnownEvents() and IsValidEvent() helpers enable validation of supported hook event types. parseEvent refactored to use the validation helper.
CLI dispatcher for hooks management subcommands
internal/cli/extensions.go
runHooks dispatcher extended to route add, remove, enable, and disable subcommands to dedicated handler functions. writeHooksHelp updated to document all available hooks commands.
Hooks management implementation with argument parsing and tests
internal/cli/hooks_manage.go, internal/cli/hooks_manage_test.go
hookConfigStore resolves project or user-scoped config paths. runHooksAdd parses event/command/args/metadata with secret redaction in JSON output and persists via store.Upsert. runHooksRemove removes hooks and reports removal status. runHooksToggle toggles enabled state with validation. Argument parsers validate required flags (--event, --command), reject unknown options, and support both --flag value and --flag=value forms. Help text provided for all commands. Comprehensive test suite validates hook persistence to disk, required flag enforcement, event type validation, secret redaction in JSON output, and state transitions including enable/disable toggling and removal flows.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant runHooks
  participant Handler
  participant ConfigStore
  User->>runHooks: zero hooks add/remove/enable/disable
  runHooks->>Handler: dispatch to handler function
  Handler->>ConfigStore: Upsert/Remove/SetEnabled
  ConfigStore->>Handler: result (hook config or removal status)
  Handler->>User: JSON or text output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Possibly related PRs

  • Gitlawb/zero#181: Modifies hook event handling in internal/hooks/hooks.go; this PR's KnownEvents/IsValidEvent helpers directly enable the CLI validation logic.

Suggested reviewers

  • Vasanthdev2004
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Hooks management command + build & supply-chain hardening' accurately captures the two major changes: the new hooks CLI feature and the security/supply-chain improvements (go.mod toolchain bump, govulncheck gating, and GitHub Actions pinning).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/toolchain-cve-bump

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Tests: go test ./...
  • [pass] Build: go run ./cmd/zero-release build
  • [pass] Smoke build: go run ./cmd/zero-release smoke

Scope

Head: a5eda64e587f
Changed files (9): .github/workflows/ci.yml, .github/workflows/pr-auto-review.yml, .github/workflows/release-artifacts.yml, .github/workflows/zero-action-smoke.yml, go.mod, internal/cli/extensions.go, internal/cli/hooks_manage.go, internal/cli/hooks_manage_test.go, internal/hooks/hooks.go

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

- ci.yml: new 'security' job runs govulncheck as a hard gate (fails on a reachable
  vulnerability; passes now that the toolchain is bumped) plus an advisory deadcode step
  that surfaces dormant code without blocking.
- Pin every GitHub Action to a full commit SHA (checkout, upload-artifact, github-script)
  with a version comment, across all four workflows — previously only setup-go was pinned,
  leaving the mutable v4/v7 tags as a supply-chain risk.
@gnanam1990 gnanam1990 changed the title Bump toolchain to go1.26.4 to clear 9 reachable stdlib CVEs Build & supply-chain hardening: toolchain CVE bump, govulncheck gate, SHA-pinned actions Jun 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 101-109: The govulncheck and deadcode commands in the CI workflow
are using `@latest` version specifiers, which creates non-deterministic builds and
supply-chain risks. Replace the `@latest` versions with explicit pinned versions:
use govulncheck@v1.3.0 in the govulncheck step and deadcode@v0.45.0 in the
deadcode step. Consider using a locked tool module (such as tools.go) or
environment variables for reproducibility and centralized version management
across your CI pipeline.
- Around line 23-24: Add `persist-credentials: false` to the `with:` section of
each `actions/checkout` step to prevent credential persistence in local git
config. This change is needed at three locations in .github/workflows/ci.yml:
the smoke job at lines 23-24, the performance job at lines 61-62, and the
security job at lines 88-89. For each `actions/checkout` step, add a new line
`persist-credentials: false` under the `with:` configuration block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d90afdd-6614-4fcc-ad15-55f6920c76c5

📥 Commits

Reviewing files that changed from the base of the PR and between 9d32e31 and a603afb.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • .github/workflows/pr-auto-review.yml
  • .github/workflows/release-artifacts.yml
  • .github/workflows/zero-action-smoke.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/zero-action-smoke.yml

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml Outdated
Wires the previously-dormant hooks.ConfigStore (10 unreachable funcs -> 0) into the CLI:

  zero hooks add <id> --event <event> --command <cmd> [--name --description --matcher --arg --user --json]
  zero hooks remove|enable|disable <id> [--user --json]

Writes the project hook config by default (<cwd>/.zero/hooks.json) or the user config with
--user, reusing the store's locking + atomic writes + validation (normalizeDefinition). New
hooks are enabled; state is managed via enable/disable. JSON output is secret-scrubbed via
redaction. Mirrors the existing 'zero mcp add/remove/enable/disable' shape. Covered by
add/remove/toggle round-trip, validation, unknown-event, and JSON-redaction tests.
@gnanam1990 gnanam1990 changed the title Build & supply-chain hardening: toolchain CVE bump, govulncheck gate, SHA-pinned actions Hooks management command + build & supply-chain hardening Jun 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/cli/hooks_manage_test.go (1)

77-85: ⚡ Quick win

Tighten the unknown-event test to assert usage-path behavior explicitly.

This currently accepts any non-success exit, so a crash-path regression would still pass. Please assert the specific usage-error contract (exit code and/or usage-style stderr message) for invalid --event inputs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/hooks_manage_test.go` around lines 77 - 85, The test
TestRunHooksAddRejectsUnknownEvent currently only verifies that runHooksAdd
returns a non-success exit code when given an invalid event, which would pass
even if the command crashes instead of properly reporting a usage error.
Strengthen this test by explicitly asserting the specific usage-error contract:
check that the exit code matches the expected usage-error exit code (not just
any non-success code) and verify that the stderr output contains a usage-style
error message (such as text indicating invalid event or similar usage guidance)
that confirms this is a proper usage error rather than an unexpected crash or
other failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/cli/hooks_manage.go`:
- Around line 295-300: The validation for `options.def.Event` in the argument
parsing section only checks for non-empty values but does not validate that the
event is one of the allowed/valid event types. Add validation in the same block
where the empty check for `options.def.Event` occurs to verify that the event
string matches one of the allowed event values, and if not, return an
execUsageError indicating an invalid event was provided, similar to the
structure of the existing validation errors for missing options.

---

Nitpick comments:
In `@internal/cli/hooks_manage_test.go`:
- Around line 77-85: The test TestRunHooksAddRejectsUnknownEvent currently only
verifies that runHooksAdd returns a non-success exit code when given an invalid
event, which would pass even if the command crashes instead of properly
reporting a usage error. Strengthen this test by explicitly asserting the
specific usage-error contract: check that the exit code matches the expected
usage-error exit code (not just any non-success code) and verify that the stderr
output contains a usage-style error message (such as text indicating invalid
event or similar usage guidance) that confirms this is a proper usage error
rather than an unexpected crash or other failure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fa006616-a7a0-44a7-9b71-085148d424b3

📥 Commits

Reviewing files that changed from the base of the PR and between a603afb and 4f35aa2.

📒 Files selected for processing (3)
  • internal/cli/extensions.go
  • internal/cli/hooks_manage.go
  • internal/cli/hooks_manage_test.go

Comment thread internal/cli/hooks_manage.go
go run govulncheck@latest selected the toolchain from govulncheck's own go.mod
(downgrading to go1.25.11), which then could not load our go1.26-requiring packages
(fips140only_go1.26.go), failing the security job. Resolve GOTOOLCHAIN from go.mod's
toolchain line so govulncheck and deadcode both run under go1.26.4.
@gnanam1990

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gnanam1990

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit approvable ?

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

REPO="Gitlawb/zero"
PR=193

echo "=== PR State ==="
gh pr view $PR --repo $REPO --json state,reviewDecision,mergeable,statusCheckRollup \
  | jq '{state, reviewDecision, mergeable, checks: [.statusCheckRollup[]? | {name, conclusion, status}]}'

echo ""
echo "=== CodeRabbit Review Comments (open/unresolved) ==="
gh api graphql \
  -F owner="Gitlawb" \
  -F name="zero" \
  -F pr=$PR \
  -f query='
query($owner: String!, $name: String!, $pr: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $pr) {
      reviewThreads(first: 50) {
        nodes {
          isResolved
          isOutdated
          comments(first: 1) {
            nodes {
              author { login }
              body
            }
          }
        }
      }
    }
  }
}' | jq '
  .data.repository.pullRequest.reviewThreads.nodes
  | map(select(.isResolved == false and .isOutdated == false))
  | map({
      author: .comments.nodes[0].author.login,
      body: (.comments.nodes[0].body | .[0:200])
    })'

Length of output: 2902



@gnanam1990: Not yet — here's the current status:

✅ CI checks: All green (Smoke on Ubuntu/macOS/Windows, Security & code health, Performance Smoke, Validate action.yml).

❌ Review decision: CHANGES_REQUESTED — there are 3 unresolved CodeRabbit comments, including 2 marked Major:

  1. 🟠 Major — Issue in .github/workflows/ci.yml (first flagged concern — likely around the govulncheck/toolchain setup)
  2. 🟠 Major — Issue in .github/workflows/ci.yml (second flagged concern — likely around action pinning or job configuration)
  3. 🟡 Minor (Quick win)--event flag in hooks_manage.go is only checked for non-empty; invalid event values aren't rejected during argument parsing (they can fall through unvalidated)

The two Major issues need to be addressed (or explicitly acknowledged as non-issues with an explanation) before I can approve. Once those are resolved, the PR looks solid overall — the supply-chain hardening and hooks CLI feature are well-structured, tests cover the key flows, and all checks pass.

…event

CodeRabbit findings on #193:
- ci.yml: persist-credentials: false on all checkout steps (smoke/performance/security)
  — these jobs run repo code and never push, so don't keep the token in git config.
- ci.yml: pin govulncheck@v1.3.0 and deadcode@v0.46.0 instead of @latest, so the security
  gate is deterministic and not subject to supply-chain drift.
- hooks: add exported IsValidEvent/KnownEvents (single source); parseEvent reuses it, and
  'zero hooks add' now rejects an invalid --event with a usage error at parse time instead
  of falling through to the Upsert app-error crash path.
@gnanam1990

Copy link
Copy Markdown
Collaborator Author

All three addressed in a5eda64:

  1. Majorpersist-credentials: false added to all three actions/checkout steps (smoke/performance/security); those jobs run repo code and never push.
  2. Major — pinned govulncheck@v1.3.0 and deadcode@v0.46.0 (no more @latest drift in the security gate).
  3. Minorzero hooks add now validates --event at parse time via a new single-source hooks.IsValidEvent (reused by parseEvent), returning a usage error instead of the Upsert crash path.

Verified: build/vet/gofmt clean, go test ./... green, and the pinned govulncheck/deadcode run correctly under the go.mod toolchain.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

REPO="Gitlawb/zero"
PR=193

echo "=== Commit a5eda64 details ==="
gh api repos/$REPO/commits/a5eda64 --jq '{sha, message: .commit.message}'

echo ""
echo "=== Files changed in a5eda64 ==="
gh api repos/$REPO/commits/a5eda64 --jq '[.files[]| {filename, additions, deletions, status}]'

Length of output: 1434


🏁 Script executed:

#!/bin/bash
set -euo pipefail

REPO="Gitlawb/zero"
PR=193

echo "=== ci.yml current state (relevant sections) ==="
gh api repos/$REPO/contents/.github/workflows/ci.yml --jq '.content' | base64 -d | grep -n "persist-credentials\|govulncheck\|deadcode\|checkout" | head -60

echo ""
echo "=== hooks_manage.go IsValidEvent / parseEvent ==="
gh api "repos/$REPO/git/trees/a5eda64?recursive=1" --jq '[.tree[] | .path] | map(select(test("hooks")))'

Length of output: 867


🏁 Script executed:

#!/bin/bash
set -euo pipefail

REPO="Gitlawb/zero"
COMMIT="a5eda64e587fe57746775a04649acdf1da10c068"

echo "=== ci.yml at commit ==="
gh api "repos/$REPO/contents/.github/workflows/ci.yml?ref=$COMMIT" --jq '.content' | base64 -d | grep -n "persist-credentials\|govulncheck\|deadcode\|checkout\|latest"

echo ""
echo "=== hooks.go at commit ==="
gh api "repos/$REPO/contents/internal/hooks/hooks.go?ref=$COMMIT" --jq '.content' | base64 -d | grep -n "IsValidEvent\|KnownEvents\|parseEvent\|ValidEvent"

echo ""
echo "=== hooks_manage.go at commit (parseEvent / event validation) ==="
gh api "repos/$REPO/contents/internal/cli/hooks_manage.go?ref=$COMMIT" --jq '.content' | base64 -d | grep -n "IsValidEvent\|parseEvent\|event\|Event"

Length of output: 3369



@gnanam1990 All three fixes confirmed in a5eda64:

  1. persist-credentials: false — Present on all three checkout steps (smoke line 25, performance line 65, security line 95). ✅
  2. Pinned tool versionsgovulncheck@v1.3.0 and deadcode@v0.46.0, no @latest anywhere in the security job. ✅
  3. IsValidEvent at parse timehooks.IsValidEvent is exported from hooks.go, called in parseHooksAddArgs before the store is touched, and returns a clear execUsageError listing all valid events. ✅

Everything looks solid. Approving.

[approve]

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/hooks/hooks.go (1)

826-829: ⚡ Quick win

Consider generating the error message from KnownEvents() for maintainability.

The validation now uses IsValidEvent(), but the error message on line 827 still hardcodes the event names. If a new event is added, you'd need to update the const declaration, KnownEvents(), and this error message. Generating the message from KnownEvents() would eliminate that third update point.

♻️ Example refactor
 func parseEvent(raw any, field string) (Event, error) {
 	text, ok := raw.(string)
 	if !ok || strings.TrimSpace(text) == "" {
 		return "", manifestError{fieldPath: field, message: "Expected a hook event."}
 	}
 	event := Event(strings.TrimSpace(text))
 	if !IsValidEvent(event) {
-		return "", manifestError{fieldPath: field, message: "Expected beforeTool, afterTool, sessionStart, sessionEnd, specialistStart, or specialistStop."}
+		known := KnownEvents()
+		names := make([]string, len(known))
+		for i, e := range known {
+			names[i] = string(e)
+		}
+		return "", manifestError{fieldPath: field, message: fmt.Sprintf("Expected %s.", strings.Join(names, ", "))}
 	}
 	return event, nil
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/hooks/hooks.go` around lines 826 - 829, The error message in the
validation block for IsValidEvent() hardcodes the event names, creating a
maintenance burden when new events are added. Instead of manually listing the
event names in the error message, generate the message dynamically from the
KnownEvents() function so that adding a new event only requires updates in the
const declaration and KnownEvents(), not in the error message itself.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/hooks/hooks.go`:
- Around line 826-829: The error message in the validation block for
IsValidEvent() hardcodes the event names, creating a maintenance burden when new
events are added. Instead of manually listing the event names in the error
message, generate the message dynamically from the KnownEvents() function so
that adding a new event only requires updates in the const declaration and
KnownEvents(), not in the error message itself.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c3aafc8c-3288-4ae1-9c8d-5b8b9759e083

📥 Commits

Reviewing files that changed from the base of the PR and between 67b7523 and a5eda64.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • internal/cli/hooks_manage.go
  • internal/hooks/hooks.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/ci.yml
  • internal/cli/hooks_manage.go

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: Approved

No blocking issues found in this rereview.

The hooks management command is scoped and covered, event validation now happens before persistence, workflow checkout credentials are disabled, Actions/tool versions are pinned, and the security job is deterministic with the GOTOOLCHAIN value from go.mod.

Non-blocking nit: CodeRabbit's suggestion to generate the invalid-event error message from KnownEvents() is valid maintenance polish, but I would not block this PR on it.

Validation run locally on PR head a5eda64:

  • gofmt -l internal\\cli internal\\hooks -> clean
  • go test ./internal/cli ./internal/hooks -run Hooks|Hook|KnownEvents|IsValidEvent -count=1 -> pass
  • go test ./... -timeout 300s -> pass
  • go vet ./... -> pass
  • go build ./... -> pass
  • go run ./cmd/zero-release build -> pass, built zero.exe
  • go run ./cmd/zero-release smoke -> pass
  • $env:GOTOOLCHAIN='go1.26.4'; go run golang.org/x/vuln/cmd/govulncheck@v1.3.0 ./... -> no called vulnerabilities found

@gnanam1990
gnanam1990 merged commit b1ab01f into main Jun 14, 2026
8 checks passed
@Vasanthdev2004
Vasanthdev2004 deleted the fix/toolchain-cve-bump branch June 28, 2026 08:27
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