mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 17:03:17 +01:00
* 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>
36 lines
953 B
Go
36 lines
953 B
Go
package file
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLineCounter_ReadRune(t *testing.T) {
|
|
counter := &newlineCounter{RuneReader: bufio.NewReader(strings.NewReader("hi\nwhat's the weather like today?\ndunno...\n"))}
|
|
var err error
|
|
for err == nil {
|
|
_, _, err = counter.ReadRune()
|
|
}
|
|
if err != io.EOF {
|
|
t.Fatalf("should have gotten an eof, got %+v", err)
|
|
}
|
|
assert.Equal(t, 3, len(counter.newLines), "bad line count")
|
|
assert.Equal(t, []int64{3, 34, 43}, counter.newLines, "bad line positions")
|
|
}
|
|
|
|
func TestLineCounter_newlinesBefore(t *testing.T) {
|
|
counter := &newlineCounter{RuneReader: bufio.NewReader(strings.NewReader("hi\nwhat's the weather like today?\ndunno...\n"))}
|
|
var err error
|
|
for err == nil {
|
|
_, _, err = counter.ReadRune()
|
|
}
|
|
if err != io.EOF {
|
|
t.Fatalf("should have gotten an eof, got %+v", err)
|
|
}
|
|
assert.Equal(t, 1, counter.newlinesBefore(10), "bad line count")
|
|
}
|