mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 23:16:30 +01:00
Add secrets search capability (#367)
* add initial secrets cataloger Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update ETUI elements with new catalogers (file metadata, digests, and secrets) Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update secrets cataloger to read full contents into memory for searching Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * quick prototype of parallelization secret regex search Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * quick prototype with single aggregated regex Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * quick prototype for secret search line-by-line Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * quick prototype hybrid secrets search Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add secrets cataloger with line strategy Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * adjust verbiage towards SearchResults instead of Secrets + add tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update json schema with secrets cataloger results Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * address PR comments Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update readme with secrets config options Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * ensure file catalogers call AllLocations once Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
@@ -12,6 +12,7 @@ type FileMetadata struct {
|
||||
UserID int
|
||||
GroupID int
|
||||
LinkDestination string
|
||||
Size int64
|
||||
}
|
||||
|
||||
func fileMetadataByLocation(img *image.Image, location Location) (FileMetadata, error) {
|
||||
@@ -26,5 +27,6 @@ func fileMetadataByLocation(img *image.Image, location Location) (FileMetadata,
|
||||
UserID: entry.Metadata.UserID,
|
||||
GroupID: entry.Metadata.GroupID,
|
||||
LinkDestination: entry.Metadata.Linkname,
|
||||
Size: entry.Metadata.Size,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -118,6 +118,23 @@ func (r MockResolver) AllLocations() <-chan Location {
|
||||
return results
|
||||
}
|
||||
|
||||
func (r MockResolver) FileMetadataByLocation(Location) (FileMetadata, error) {
|
||||
panic("not implemented")
|
||||
func (r MockResolver) FileMetadataByLocation(l Location) (FileMetadata, error) {
|
||||
info, err := os.Stat(l.RealPath)
|
||||
if err != nil {
|
||||
return FileMetadata{}, err
|
||||
}
|
||||
|
||||
// other types not supported
|
||||
ty := RegularFile
|
||||
if info.IsDir() {
|
||||
ty = Directory
|
||||
}
|
||||
|
||||
return FileMetadata{
|
||||
Mode: info.Mode(),
|
||||
Type: ty,
|
||||
UserID: 0, // not supported
|
||||
GroupID: 0, // not supported
|
||||
Size: info.Size(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user