[sergo] Sergo Report: env-override-bypass-audit + init-stub-scan — 2026-05-16 #32547
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Sergo - Serena Go Expert. A newer discussion is available at Discussion #32753. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Executive Summary
Run 11 paired a continuation of the helper-underadoption thread (Runs 5/7/8/9/10) with a fresh init() function audit. Two distinct findings emerged: (1) the
GH_AW_WORKFLOWS_DIRenv-var override is silently bypassed at 5 productionfilepath.Join(*, ".github", "workflows")sites — a shape mismatch bypass that is structurally different from the literal duplication bypass tracked in Run 9; (2) 3 of 11init()functions inpkg/workfloware stubs that only log and do no real work, with the script-registration ones even admitting in their own comments that the work was removed. Two issues filed (#32545 high-severity, #32546 cleanup). Run 8 #aw_sg8a2 (DefaultHTTPClientTimeout) re-confirmed still unfixed 10+ days later but not re-filed.Overall assessment: codebase health is high. The defer-in-loop scan found nothing,
context.TODO()usage remains at zero, type assertions remain safe acrosspkg/. The persistent finding-type across last 4 runs is helper-underadoption, now manifesting in two distinct shapes.🛠️ Serena Tools Update
Tools Snapshot
Tool Capabilities Used Today
activate_project— workspace activation (7.3s, normal)find_symbol/find_referencing_symbolsnot needed for this audit; the work is enumeration + classification, where Grep is fasterfilepath.Joinshapes,time.Afterplacements)📊 Strategy Selection
Cached Reuse Component (50%)
Previous Strategy Adapted: helper-underadoption audit (recurring theme Runs 5/7/8/9/10, all 8–9/10)
.github/workflowsstring, scanned for thefilepath.Join(*, ".github", "workflows")shape — a different bypass mode of the same helperNew Exploration Component (50%)
Novel Approach: init() function audit + bonus
time.After/ defer-in-loop scans^func init\(\); manual classification of each init() body by side-effect typepkg/non-test Go filesCombined Strategy Rationale
The cached component proves the helper-underadoption pattern has nuance (not just literal/helper, but also literal-shape/helper-shape). The new component opens a fresh axis (declaration-site rather than usage-site analysis) for next run. The two complement each other: enumeration-style audits (init() inventory, time.After inventory) catch declaration anti-patterns that usage audits miss.
🔍 Analysis Execution
Codebase Context
pkg/cli,pkg/workflow,pkg/parser,pkg/linters,pkg/constantsFindings Summary
📋 Detailed Findings
High Priority
Finding 1 —
GH_AW_WORKFLOWS_DIRenv override silently bypassed (Issue #32545)pkg/usefilepath.Join(*, ".github", "workflows")and do NOT honor the env-var override that landed in Run 10.dispatch_workflow_file_resolver.go:70(search dir),copilot_setup.go:186(MkdirAll target),init.go:214(Stat check).dispatch_workflow_validation.go:61,call_workflow_validation.go:75(error-message construction).filepath.Join(*, constants.GetWorkflowDir()).Medium Priority
Finding 2 — 3 stub init() functions in pkg/workflow (Issue #32546)
js.go:14-16andscripts.go:20-22both contain a singlelog.Print("Script registration completed (embedded scripts removed)")— comments admit the work was removed.expression_patterns.go:92-94logs "Initializing expression pattern regex compilation" but the regexes are compiled invar (...)blocks below; init() does no work.Low Priority (not filed)
time.After in retry loops — 4 prod sites total; 2 are inside retry loops where each iteration leaks a timer until it fires:
pkg/cli/add_interactive_workflow.go:41— 5 iterations × 2s = ~10s timer overhead worst casepkg/cli/docker_images.go:194— exponential backoff, multiplies effect with retriesRun 8 #aw_sg8a2 (HTTP timeout) — RE-CONFIRMED UNFIXED 10+ days later — still 4 prod sites use literal
30 * time.Secondforhttp.Client.Timeout; noDefaultHTTPClientTimeoutinpkg/constants. Cache already tracks this; not re-filing to avoid duplicate.defer-in-loop scan — ZERO confirmed cases in pkg/ non-test. Good Go discipline.
✅ Improvement Tasks Generated
Task 1: Replace
filepath.Join(*, ".github", "workflows")withfilepath.Join(*, constants.GetWorkflowDir())Issue Type: Helper-underadoption (shape mismatch variant)
Problem: 5 prod sites bypass the env-var override that
constants.GetWorkflowDir()honors.Locations:
pkg/workflow/dispatch_workflow_file_resolver.go:70(search dir — real bug)pkg/cli/copilot_setup.go:186(MkdirAll target — real bug)pkg/cli/init.go:214(Stat check — real bug)pkg/workflow/dispatch_workflow_validation.go:61(error msg)pkg/workflow/call_workflow_validation.go:75(error msg)Impact: High severity. Users setting
GH_AW_WORKFLOWS_DIR=custom/dirsee partial honor of the documented contract.Recommendation:
Validation:
GH_AW_WORKFLOWS_DIRand exercise copilot-setup, dispatch-workflow resolution, initfilepath.Join(*, ".github", "workflows")remainEstimated Effort: Small (mechanical, 5 sites)
Task 2: Delete 3 stub init() functions in pkg/workflow
Issue Type: Dead code / startup hygiene
Problem: 3 init() bodies do nothing but log; comments admit scripts were removed; regex compilation happens in
var (...)blocks, not init().Locations:
pkg/workflow/js.go:14-16pkg/workflow/scripts.go:20-22pkg/workflow/expression_patterns.go:92-94Recommendation: Delete the
init()functions. Keep the*Logpackage vars (used elsewhere).Validation:
go vet ./...,go test ./...show no regressionEstimated Effort: Small
📈 Success Metrics
This Run
Reasoning for Score
📊 Historical Context
Strategy Performance
The helper-underadoption theme is now in its 6th consecutive run (Runs 5/7/8/9/10/11) without exhausting its findings space. Each run uncovers a new shape:
Cumulative Statistics
🎯 Recommendations
Immediate Actions
filepath.Join(*, ".github", "workflows")withfilepath.Join(*, constants.GetWorkflowDir()). Fixes real env-var bypass bugs.DefaultHTTPClientTimeouttopkg/constantsand update 4 sites. This issue has been open 10+ days.Long-term Improvements
filepath.Join(".github", "workflows", ...)shapes and recommendsconstants.GetWorkflowDir(). This would prevent the shape of the helper bypass from re-emerging after a future literal cleanup.🔄 Next Run Preview
Suggested Focus Areas
AWFAuditDir,AWFProxyLogsDir, or other constants inpkg/constants/constants.go.Strategy Evolution
The helper-underadoption pattern has clear longevity. Next run should institutionalize it by classifying findings into:
A short taxonomy memo could codify these for repeat audits.
Generated by Sergo — Run 11 — Strategy: env-override-bypass-audit + init-stub-scan
Beta Was this translation helpful? Give feedback.
All reactions