Skip to content

Commit

Permalink
ignore sensitive files in collection (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel authored Jun 28, 2024
1 parent 45dd6b7 commit ca849b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ The `--hide` flag can be used multiple times to hide sensitive data, it supports

`# support-collector --hide "Secret:.*" --hide "Password:.*"`

In addition, files and folders that follow a specific pattern are not collected. This affects all files that correspond to the following filters:
`.*`, `*~`, `*.key`, `*.csr`, `*.crt`, and `*.pem`

By default, we collect all we can find. You can control this by only enabling certain modules, or disabling some.

If you want to see what is collected, add `--verbose`
Expand Down
8 changes: 1 addition & 7 deletions internal/collection/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,7 @@ func (c *Collection) AddFilesIfFound(prefix string, sources ...string) {
return
}

c.Log.Debug("Collecting files from ", source)

for _, file := range files {
foundFiles++

_ = c.AddFileToOutput(file)
}
c.AddFiles(prefix, source)
}

if foundFiles == 0 {
Expand Down
6 changes: 4 additions & 2 deletions internal/collection/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type File struct {
io.Writer
}

var reIgnoreFiles = regexp.MustCompile(`(^\.|~$)`)
var reIgnoreFiles = regexp.MustCompile(`(^\.|~$|\.key$|\.csr$|\.crt$|\.pem$)`)

func NewFile(name string) *File {
return &File{
Expand Down Expand Up @@ -56,7 +56,9 @@ func LoadFiles(prefix, source string) (files []*File, err error) {
return
}

files = append(files, file)
if !reIgnoreFiles.MatchString(file.Name) {
files = append(files, file)
}

return
}
Expand Down

0 comments on commit ca849b7

Please sign in to comment.