Skip to content

gosec G122 lint failure in doc/man-docs/man_doc.go #729

@Sypher845

Description

@Sypher845

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)   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions