Lint / golangci-lint (push) Waiting to run
Lint / man-page-staleness (push) Waiting to run
Lint / semgrep (push) Waiting to run
Lint / checksecretparts (push) Waiting to run
Scan for secrets / test (push) Waiting to run
Test / test (push) Waiting to run
Test / test-community (push) Waiting to run
Release / mark-latest (push) Canceled after 0s
Release / Release (push) Canceled after 0s
This PR aims to zero out secret areas of a result before caching it.
32 lines
878 B
Go
32 lines
878 B
Go
package detectors
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestClearSecrets(t *testing.T) {
|
|
result := Result{
|
|
Raw: []byte("raw-secret"),
|
|
RawV2: []byte("raw-secret-v2"),
|
|
Redacted: "redacted",
|
|
SecretParts: map[string]string{"key": "raw-secret"},
|
|
ExtraData: map[string]string{"account": "123"},
|
|
}
|
|
result.SetPrimarySecretValue("secret-value")
|
|
result.SetPrimarySecretLine(12)
|
|
result.SetVerificationError(assert.AnError)
|
|
|
|
result.ClearSecrets()
|
|
|
|
assert.Nil(t, result.Raw)
|
|
assert.Nil(t, result.RawV2)
|
|
assert.Nil(t, result.SecretParts)
|
|
assert.Empty(t, result.GetPrimarySecretValue())
|
|
assert.Zero(t, result.primarySecret.Line)
|
|
assert.Equal(t, "redacted", result.Redacted)
|
|
assert.Equal(t, map[string]string{"account": "123"}, result.ExtraData)
|
|
assert.EqualError(t, result.VerificationError(), assert.AnError.Error())
|
|
}
|