Skip to content

Commit

Permalink
exclude file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ibreakthecloud committed Apr 25, 2024
1 parent 0f5a5ed commit fa97cbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
blacklisted_strings: [ ] # skip matches containing any of these strings (case sensitive)
blacklisted_extensions: [ ".exe", ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".psd", ".xcf", ".zip", ".tar", ".tar.gz", ".ttf", ".lock", ".pem", ".so", ".jar", ".gz" ]
blacklisted_paths: [ "{sep}var{sep}lib{sep}docker", "{sep}var{sep}lib{sep}containerd", "{sep}var{sep}lib{sep}containers", "{sep}var{sep}lib{sep}crio", "{sep}var{sep}run{sep}containers", "{sep}bin", "{sep}boot", "{sep}dev", "{sep}lib", "{sep}lib64", "{sep}media", "{sep}proc", "{sep}run", "{sep}sbin", "{sep}usr{sep}lib", "{sep}sys", "{sep}home{sep}kubernetes" ]
exclude_paths: [ "{sep}var{sep}lib{sep}docker", "{sep}var{name_sep}lib{name_sep}docker","{sep}var{sep}lib{sep}containerd", "{sep}var{name_sep}lib{name_sep}containerd", "lost+found" ] # use {sep} for the OS' path seperator and {name_sep} for - (i.e. / or \)
exclude_paths: [ "{sep}var{sep}lib{sep}docker", "{sep}var{name_sep}lib{name_sep}docker","{sep}var{sep}lib{sep}containerd", "{sep}var{name_sep}lib{name_sep}containerd", "lost+found", "{sep}bin", "{sep}boot", "{sep}dev", "{sep}lib", "{sep}lib64", "{sep}media", "{sep}proc", "{sep}run", "{sep}sbin", "{sep}usr{sep}lib", "{sep}sys", "{sep}home{sep}kubernetes" ] # use {sep} for the OS' path seperator and {name_sep} for - (i.e. / or \)


signatures:
Expand Down
5 changes: 5 additions & 0 deletions scan/process_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func ScanSecretsInDir(layer string, baseDir string, fullDir string,

walkErr := filepath.WalkDir(fullDir, func(path string, f os.DirEntry, err error) error {
if err != nil {
log.Debugf("Error in filepath.Walk: %s", err)
return err
}

Expand Down Expand Up @@ -231,6 +232,8 @@ func ScanSecretsInDir(layer string, baseDir string, fullDir string,
}
}

log.Debugf("attempting scanFile on: %+v, relPath: %s", file, relPath)

secrets, err := scanFile(file.Path, relPath, file.Filename, file.Extension, layer, &numSecrets, matchedRuleSet)
if err != nil {
log.Infof("relPath: %s, Filename: %s, Extension: %s, layer: %s", relPath, file.Filename, file.Extension, layer)
Expand All @@ -244,6 +247,8 @@ func ScanSecretsInDir(layer string, baseDir string, fullDir string,
secrets = signature.MatchSimpleSignatures(relPath, file.Filename, file.Extension, layer, &numSecrets)
secretsFound = append(secretsFound, secrets...)

log.Debugf("scan completed for file: %+v, numSecrets: %d", file, numSecrets)

// Don't report secrets if number of secrets exceeds MAX value
if numSecrets >= *session.Options.MaxSecrets {
return maxSecretsExceeded
Expand Down

0 comments on commit fa97cbc

Please sign in to comment.