Skip to content

Commit

Permalink
Merge pull request #691 from Elizafox/binarylinter
Browse files Browse the repository at this point in the history
Disable linters on -compat packages
  • Loading branch information
kaniini authored Sep 18, 2023
2 parents 0a73872 + 79dfd73 commit 5ba8539
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/build/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,31 @@ var isVarEmptyRegex = regexp.MustCompile("^var/empty/")
var isTempDirRegex = regexp.MustCompile("^(var/)?(tmp|run)/")
var isCompatPackage = regexp.MustCompile("-compat$")

func usrLocalLinter(lctx LinterContext, path string, _ fs.DirEntry) error {
// If this is already a compat package, do nothing.
if isCompatPackage.MatchString(lctx.pkgname) {
return nil
}

func usrLocalLinter(_ LinterContext, path string, _ fs.DirEntry) error {
if isUsrLocalRegex.MatchString(path) {
return fmt.Errorf("/usr/local path found in non-compat package")
}

return nil
}

func varEmptyLinter(lctx LinterContext, path string, _ fs.DirEntry) error {
func varEmptyLinter(_ LinterContext, path string, _ fs.DirEntry) error {
if isVarEmptyRegex.MatchString(path) {
return fmt.Errorf("Package writes to /var/empty")
}

return nil
}

func tempDirLinter(lctx LinterContext, path string, _ fs.DirEntry) error {
func tempDirLinter(_ LinterContext, path string, _ fs.DirEntry) error {
if isTempDirRegex.MatchString(path) {
return fmt.Errorf("Package writes to a temp dir")
}

return nil
}

func isSetUidOrGidLinter(lctx LinterContext, path string, d fs.DirEntry) error {
func isSetUidOrGidLinter(_ LinterContext, _ string, d fs.DirEntry) error {
info, err := d.Info()
if err != nil {
return err
Expand All @@ -93,6 +88,11 @@ func isSetUidOrGidLinter(lctx LinterContext, path string, d fs.DirEntry) error {
}

func lintPackageFs(lctx LinterContext, fsys fs.FS, linters []string) error {
// If this is a compat package, do nothing.
if isCompatPackage.MatchString(lctx.pkgname) {
return nil
}

walkCb := func(path string, d fs.DirEntry, err error) error {
if err != nil {
return fmt.Errorf("Error traversing tree at %s: %w", path, err)
Expand Down

0 comments on commit 5ba8539

Please sign in to comment.