The latest golangci-lint image introduces gosec v2.24, which adds a new rule G122 , detecting TOCTOU (Time-of-Check/Time-of-Use) race conditions.
This causes the lint pipeline to fail on main:
doc/man-docs/man_doc.go:71:31: G122: Filesystem operation in filepath.Walk/WalkDir callback uses race-prone path; consider root-scoped APIs (e.g. os.Root) to prevent symlink TOCTOU traversal (gosec)
content, err := os.ReadFile(path)
^
doc/man-docs/man_doc.go:93:22: G122: Filesystem operation in filepath.Walk/WalkDir callback uses race-prone path; consider root-scoped APIs (e.g. os.Root) to prevent symlink TOCTOU traversal (gosec)
err = os.WriteFile(path, []byte(cleanedContent), 0600)
The latest golangci-lint image introduces
gosec v2.24, which adds a new ruleG122, detectingTOCTOU (Time-of-Check/Time-of-Use)race conditions.This causes the lint pipeline to fail on main: