Skip to content

Find, verify, and analyze leaked credentials

Added tests for new .msg and .doc file types to skipArchiverMimeTypes (#4546)

Jordan Tunstillbb3464ea8151
diff --git a/pkg/handlers/handlers_test.go b/pkg/handlers/handlers_test.go
index 87908de59..2513a4cb6 100644
--- a/pkg/handlers/handlers_test.go
+++ b/pkg/handlers/handlers_test.go
@@ -17,6 +17,7 @@ import (
"time"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
diskbufferreader "github.com/trufflesecurity/disk-buffer-reader"
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
@@ -294,6 +295,30 @@ func TestHandleFileAR(t *testing.T) {
assert.Equal(t, wantChunkCount, len(reporter.Ch))
}
+func TestHandleFileMSG(t *testing.T) {
+ wantChunkCount := 5
+ reporter := sources.ChanReporter{Ch: make(chan *sources.Chunk, wantChunkCount)}
+
+ file, err := os.Open("testdata/test.msg")
+ require.NoError(t, err)
+
+ assert.Empty(t, reporter.Ch)
+ assert.NoError(t, HandleFile(context.Background(), file, &sources.Chunk{}, reporter))
+ assert.Equal(t, wantChunkCount, len(reporter.Ch))
+}
+
+func TestHandleFileDOC(t *testing.T) {
+ wantChunkCount := 3
+ reporter := sources.ChanReporter{Ch: make(chan *sources.Chunk, wantChunkCount)}
+
+ file, err := os.Open("testdata/test.doc")
+ require.NoError(t, err)
+
+ assert.Empty(t, reporter.Ch)
+ assert.NoError(t, HandleFile(context.Background(), file, &sources.Chunk{}, reporter))
+ assert.Equal(t, wantChunkCount, len(reporter.Ch))
+}
+
func BenchmarkHandleAR(b *testing.B) {
file, err := os.Open("testdata/test.deb")
assert.Nil(b, err)
diff --git a/pkg/handlers/testdata/test.doc b/pkg/handlers/testdata/test.doc
new file mode 100644
index 000000000..f5c613941
Binary files /dev/null and b/pkg/handlers/testdata/test.doc differ
diff --git a/pkg/handlers/testdata/test.msg b/pkg/handlers/testdata/test.msg
new file mode 100644
index 000000000..10be49776
Binary files /dev/null and b/pkg/handlers/testdata/test.msg differ