Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore vendored Go module files by default #423

Open
picatz opened this issue Jan 29, 2025 · 1 comment
Open

Ignore vendored Go module files by default #423

picatz opened this issue Jan 29, 2025 · 1 comment

Comments

@picatz
Copy link

picatz commented Jan 29, 2025

Similar to #147 for NPM, it would be nice of the Go module extractor ignored go.mod files from the vendor directory.

// FileRequired returns true if the specified file matches go.mod files.
func (e Extractor) FileRequired(api filesystem.FileAPI) bool {
return filepath.Base(api.Path()) == "go.mod"
}

I understand I can configure directories to be skipped in ScanConfig, but I think the vendor directory might be good to skip out-the-box?

osv-scalibr/scalibr.go

Lines 76 to 84 in abf6098

// Optional: Directories that the file system walk should ignore.
// Note that on real filesystems these are not relative to the ScanRoots and
// thus need to be in sub-directories of one of the ScanRoots.
// TODO(b/279413691): Also skip local paths, e.g. "Skip all .git dirs"
DirsToSkip []string
// Optional: If the regex matches a directory, it will be skipped.
SkipDirRegex *regexp.Regexp
// Optional: If the glob matches a directory, it will be skipped.
SkipDirGlob glob.Glob

@picatz picatz changed the title Ignore vendored Go modules by default Ignore vendored Go module files by default Jan 29, 2025
@samsalisbury
Copy link

Another directory to consider ignoring by default is testdata, as well as directory names beginning with a . or _, as these are all ignored by the go command, allowing them to contain e.g. invalid go code/go modules needed for testing.

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

No branches or pull requests

2 participants