@@ -19,7 +19,7 @@ var dummyCallback = func() {}
19
19
var filename = "filename"
20
20
21
21
func TestShouldNotFlagSafeText (t * testing.T ) {
22
- results := helpers .NewDetectionResults (talismanrc . HookMode )
22
+ results := helpers .NewDetectionResults ()
23
23
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte ("prettySafe" ))}
24
24
25
25
NewFileContentDetector (emptyTalismanRC ).
@@ -28,7 +28,7 @@ func TestShouldNotFlagSafeText(t *testing.T) {
28
28
}
29
29
30
30
func TestShouldIgnoreFileIfNeeded (t * testing.T ) {
31
- results := helpers .NewDetectionResults (talismanrc . HookMode )
31
+ results := helpers .NewDetectionResults ()
32
32
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte ("prettySafe" ))}
33
33
talismanRCIWithFilenameIgnore := & talismanrc.TalismanRC {
34
34
IgnoreConfigs : []talismanrc.IgnoreConfig {
@@ -47,7 +47,7 @@ func TestShouldNotFlag4CharSafeText(t *testing.T) {
47
47
input is actually a b64 encoded value. In other words, abcd will match, but it is not necessarily represent
48
48
the encoded value of i· rather just a plain abcd input see
49
49
stackoverflow.com/questions/8571501/how-to-check-whether-the-string-is-base64-encoded-or-not#comment23919648_8571649*/
50
- results := helpers .NewDetectionResults (talismanrc . HookMode )
50
+ results := helpers .NewDetectionResults ()
51
51
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte ("abcd" ))}
52
52
53
53
NewFileContentDetector (emptyTalismanRC ).
@@ -57,7 +57,7 @@ func TestShouldNotFlag4CharSafeText(t *testing.T) {
57
57
58
58
func TestShouldNotFlagLowEntropyBase64Text (t * testing.T ) {
59
59
const lowEntropyString string = "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWEK"
60
- results := helpers .NewDetectionResults (talismanrc . HookMode )
60
+ results := helpers .NewDetectionResults ()
61
61
content := []byte (lowEntropyString )
62
62
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , content )}
63
63
@@ -68,7 +68,7 @@ func TestShouldNotFlagLowEntropyBase64Text(t *testing.T) {
68
68
69
69
func TestShouldFlagPotentialAWSSecretKeys (t * testing.T ) {
70
70
const awsSecretAccessKey string = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
71
- results := helpers .NewDetectionResults (talismanrc . HookMode )
71
+ results := helpers .NewDetectionResults ()
72
72
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (awsSecretAccessKey ))}
73
73
filePath := additions [0 ].Path
74
74
@@ -84,7 +84,7 @@ func TestShouldFlagPotentialAWSSecretKeys(t *testing.T) {
84
84
85
85
func TestShouldFlagPotentialSecretWithoutTrimmingWhenLengthLessThan50Characters (t * testing.T ) {
86
86
const secret string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9asdfa"
87
- results := helpers .NewDetectionResults (talismanrc . HookMode )
87
+ results := helpers .NewDetectionResults ()
88
88
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (secret ))}
89
89
filePath := additions [0 ].Path
90
90
@@ -100,7 +100,7 @@ func TestShouldFlagPotentialSecretWithoutTrimmingWhenLengthLessThan50Characters(
100
100
func TestShouldFlagPotentialJWT (t * testing.T ) {
101
101
const jwt string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjEzMDA4MTkzODAsIm5hbWUi" +
102
102
"OiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f757"
103
- results := helpers .NewDetectionResults (talismanrc . HookMode )
103
+ results := helpers .NewDetectionResults ()
104
104
content := []byte (jwt )
105
105
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , content )}
106
106
filePath := additions [0 ].Path
@@ -123,7 +123,7 @@ func TestShouldFlagPotentialSecretsWithinJavaCode(t *testing.T) {
123
123
" System.out.println(\" Hello, World\" );\r \n " +
124
124
" }\r \n \r \n " +
125
125
"}"
126
- results := helpers .NewDetectionResults (talismanrc . HookMode )
126
+ results := helpers .NewDetectionResults ()
127
127
content := []byte (dangerousJavaCode )
128
128
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , content )}
129
129
filePath := additions [0 ].Path
@@ -144,7 +144,7 @@ func TestShouldNotFlagPotentialSecretsWithinSafeJavaCode(t *testing.T) {
144
144
" System.out.println(\" Hello, World\" );\r \n " +
145
145
" }\r \n \r \n " +
146
146
"}"
147
- results := helpers .NewDetectionResults (talismanrc . HookMode )
147
+ results := helpers .NewDetectionResults ()
148
148
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (safeJavaCode ))}
149
149
150
150
NewFileContentDetector (emptyTalismanRC ).
@@ -154,7 +154,7 @@ func TestShouldNotFlagPotentialSecretsWithinSafeJavaCode(t *testing.T) {
154
154
155
155
func TestShouldNotFlagPotentialSecretsWithinSafeLongMethodName (t * testing.T ) {
156
156
safeLongMethodName := "TestBase64DetectorShouldNotDetectLongMethodNamesEvenWithRidiculousHighEntropyWordsMightExist"
157
- results := helpers .NewDetectionResults (talismanrc . HookMode )
157
+ results := helpers .NewDetectionResults ()
158
158
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (safeLongMethodName ))}
159
159
160
160
NewFileContentDetector (emptyTalismanRC ).
@@ -164,7 +164,7 @@ func TestShouldNotFlagPotentialSecretsWithinSafeLongMethodName(t *testing.T) {
164
164
165
165
func TestShouldFlagPotentialSecretsEncodedInHex (t * testing.T ) {
166
166
const hex string = "68656C6C6F20776F726C6421"
167
- results := helpers .NewDetectionResults (talismanrc . HookMode )
167
+ results := helpers .NewDetectionResults ()
168
168
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (hex ))}
169
169
filePath := additions [0 ].Path
170
170
@@ -177,7 +177,7 @@ func TestShouldFlagPotentialSecretsEncodedInHex(t *testing.T) {
177
177
178
178
func TestShouldNotFlagPotentialCreditCardNumberIfAboveThreshold (t * testing.T ) {
179
179
const creditCardNumber string = "340000000000009"
180
- results := helpers .NewDetectionResults (talismanrc . HookMode )
180
+ results := helpers .NewDetectionResults ()
181
181
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (creditCardNumber ))}
182
182
talismanRCWithThreshold := & talismanrc.TalismanRC {Threshold : severity .High }
183
183
ignoreEvaluatorWithThreshold := helpers .BuildIgnoreEvaluator ("default" , talismanRCWithThreshold , gitrepo .RepoLocatedAt ("." ))
@@ -192,7 +192,7 @@ func TestShouldNotFlagPotentialSecretsIfIgnored(t *testing.T) {
192
192
const hex string = "68656C6C6F20776F726C6421"
193
193
talismanRCWithIgnores := & talismanrc.TalismanRC {
194
194
AllowedPatterns : []* regexp.Regexp {regexp .MustCompile ("[0-9a-fA-F]*" )}}
195
- results := helpers .NewDetectionResults (talismanrc . HookMode )
195
+ results := helpers .NewDetectionResults ()
196
196
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (hex ))}
197
197
198
198
NewFileContentDetector (emptyTalismanRC ).
@@ -203,7 +203,7 @@ func TestShouldNotFlagPotentialSecretsIfIgnored(t *testing.T) {
203
203
204
204
func TestResultsShouldNotFlagCreditCardNumberIfSpecifiedInFileIgnores (t * testing.T ) {
205
205
const creditCardNumber string = "340000000000009"
206
- results := helpers .NewDetectionResults (talismanrc . HookMode )
206
+ results := helpers .NewDetectionResults ()
207
207
fileIgnoreConfig := & talismanrc.FileIgnoreConfig {
208
208
FileName : filename , Checksum : "" ,
209
209
AllowedPatterns : []string {creditCardNumber },
@@ -224,7 +224,7 @@ func TestResultsShouldContainHexTextsIfHexAndBase64ExistInFile(t *testing.T) {
224
224
const hex string = "68656C6C6F20776F726C6421"
225
225
const base64 string = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
226
226
const hexAndBase64 = hex + "\n " + base64
227
- results := helpers .NewDetectionResults (talismanrc . HookMode )
227
+ results := helpers .NewDetectionResults ()
228
228
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (hexAndBase64 ))}
229
229
filePath := additions [0 ].Path
230
230
@@ -240,7 +240,7 @@ func TestResultsShouldContainBase64TextsIfHexAndBase64ExistInFile(t *testing.T)
240
240
const hex string = "68656C6C6F20776F726C6421"
241
241
const base64 string = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
242
242
const hexAndBase64 = hex + "\n " + base64
243
- results := helpers .NewDetectionResults (talismanrc . HookMode )
243
+ results := helpers .NewDetectionResults ()
244
244
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (hexAndBase64 ))}
245
245
filePath := additions [0 ].Path
246
246
@@ -255,7 +255,7 @@ func TestResultsShouldContainBase64TextsIfHexAndBase64ExistInFile(t *testing.T)
255
255
256
256
func TestResultsShouldContainCreditCardNumberIfCreditCardNumberExistInFile (t * testing.T ) {
257
257
const creditCardNumber string = "340000000000009"
258
- results := helpers .NewDetectionResults (talismanrc . HookMode )
258
+ results := helpers .NewDetectionResults ()
259
259
additions := []gitrepo.Addition {gitrepo .NewAddition (filename , []byte (creditCardNumber ))}
260
260
filePath := additions [0 ].Path
261
261
0 commit comments