Summary
Sergo Run 22 confirmed that two registered custom analyzers in cmd/linters/main.go produce zero diagnostics when run against ./cmd/... and ./pkg/... (non-test code only), but neither is listed in the CI-enforced LINTER_FLAGS at .github/workflows/cgo.yml:1040. Appending both flags is a zero-risk lockdown — current state stays passing, but any future violation breaks make golint-custom before merge. This is the same pattern that landed osexitinlibrary + rawloginlib (#35130) and manualmutexunlock (#35131) in R20–R21.
Affected analyzers
1. regexpcompileinfunction (cmd/linters/main.go:53)
Flags regexp.MustCompile / regexp.Compile calls inside function bodies / function literals / loops where the pattern argument is a compile-time-constant string. Skips test files and dynamic patterns (variable concatenation, regexp.QuoteMeta(x), fmt.Sprintf).
Audit method: grep ^\s+\S+\s*:?=\s*regexp\.(MustCompile|Compile)\( across pkg/**/*.go, then exclude _test.go and testdata/ and verify each remaining match is either inside a var (...) block (pkg-level — allowed) or has a dynamic pattern (linter-exempt).
Result: 0 prod violations.
pkg/parser/frontmatter_content.go:254 — dynamic (uses regexp.QuoteMeta(sectionName))
pkg/parser/schema_suggestions.go:506,511,516,531 — dynamic (uses escapedField / escapedParent)
pkg/parser/json_path_locator.go:175,273,403 — dynamic (uses regexp.QuoteMeta)
pkg/cli/codemod_activation_outputs.go:32 — dynamic (concat with output arg)
pkg/stringutil/sanitize.go:143 — dynamic (concat with allowedChars)
pkg/workflow/yaml.go:177,181 — dynamic (uses runtime pattern variable)
All non-dynamic prod regexps live in var (...) blocks at package level. Examples: pkg/workflow/markdown_security_scanner.go (28 patterns), pkg/cli/copilot_agent_logs.go (9 patterns), pkg/workflow/codex_engine.go (7 patterns), pkg/workflow/expression_patterns.go (21 patterns).
2. fprintlnsprintf (cmd/linters/main.go:43)
Flags fmt.Fprintln(w, fmt.Sprintf(...)) calls that should be rewritten as fmt.Fprintf(w, ...).
Audit method: grep fmt\.Fprintln\([^,]+,\s*fmt\.Sprintf\( across cmd/**/*.go and pkg/**/*.go.
Result: 0 prod violations. Only matches are in the linter's own source/testdata.
Recommendation
Append both flags to .github/workflows/cgo.yml:1040:
Before:
run: make golint-custom LINTER_FLAGS="-errstringmatch -panicinlibrarycode -manualmutexunlock -osexitinlibrary -rawloginlib -test=false"
After:
run: make golint-custom LINTER_FLAGS="-errstringmatch -panicinlibrarycode -manualmutexunlock -osexitinlibrary -rawloginlib -regexpcompileinfunction -fprintlnsprintf -test=false"
The -X flags are positive selectors in golint-custom: only the listed analyzers run, so adding a flag does not affect runtime of the other 10 registered analyzers.
Validation
Effort: Small (single-line YAML change, no Go code changes)
Generated by Sergo R22 — strategy reverify-plus-unenforced-linter-zero-violation-audit-v2
Generated by 🤖 Sergo - Serena Go Expert · opus47 23.5M · ◷
Summary
Sergo Run 22 confirmed that two registered custom analyzers in
cmd/linters/main.goproduce zero diagnostics when run against./cmd/...and./pkg/...(non-test code only), but neither is listed in the CI-enforcedLINTER_FLAGSat.github/workflows/cgo.yml:1040. Appending both flags is a zero-risk lockdown — current state stays passing, but any future violation breaksmake golint-custombefore merge. This is the same pattern that landedosexitinlibrary+rawloginlib(#35130) andmanualmutexunlock(#35131) in R20–R21.Affected analyzers
1.
regexpcompileinfunction(cmd/linters/main.go:53)Flags
regexp.MustCompile/regexp.Compilecalls inside function bodies / function literals / loops where the pattern argument is a compile-time-constant string. Skips test files and dynamic patterns (variable concatenation,regexp.QuoteMeta(x),fmt.Sprintf).Audit method: grep
^\s+\S+\s*:?=\s*regexp\.(MustCompile|Compile)\(acrosspkg/**/*.go, then exclude_test.goandtestdata/and verify each remaining match is either inside avar (...)block (pkg-level — allowed) or has a dynamic pattern (linter-exempt).Result: 0 prod violations.
pkg/parser/frontmatter_content.go:254— dynamic (usesregexp.QuoteMeta(sectionName))pkg/parser/schema_suggestions.go:506,511,516,531— dynamic (usesescapedField/escapedParent)pkg/parser/json_path_locator.go:175,273,403— dynamic (usesregexp.QuoteMeta)pkg/cli/codemod_activation_outputs.go:32— dynamic (concat withoutputarg)pkg/stringutil/sanitize.go:143— dynamic (concat withallowedChars)pkg/workflow/yaml.go:177,181— dynamic (uses runtimepatternvariable)All non-dynamic prod regexps live in
var (...)blocks at package level. Examples:pkg/workflow/markdown_security_scanner.go(28 patterns),pkg/cli/copilot_agent_logs.go(9 patterns),pkg/workflow/codex_engine.go(7 patterns),pkg/workflow/expression_patterns.go(21 patterns).2.
fprintlnsprintf(cmd/linters/main.go:43)Flags
fmt.Fprintln(w, fmt.Sprintf(...))calls that should be rewritten asfmt.Fprintf(w, ...).Audit method: grep
fmt\.Fprintln\([^,]+,\s*fmt\.Sprintf\(acrosscmd/**/*.goandpkg/**/*.go.Result: 0 prod violations. Only matches are in the linter's own source/testdata.
Recommendation
Append both flags to
.github/workflows/cgo.yml:1040:Before:
After:
The
-Xflags are positive selectors ingolint-custom: only the listed analyzers run, so adding a flag does not affect runtime of the other 10 registered analyzers.Validation
make golint-custom LINTER_FLAGS="-regexpcompileinfunction -fprintlnsprintf -test=false" ./cmd/... ./pkg/...→ expected: 0 diagnosticscgo.ymlpassesgolint-customstep//nolintcomments requiredEffort: Small (single-line YAML change, no Go code changes)
Generated by Sergo R22 — strategy
reverify-plus-unenforced-linter-zero-violation-audit-v2