[INS-355] Added Hashicorp vault token detector (#4819)
* added hashicorp vault token detector * added redacted field to result * bundled common logic
This commit is contained in:
@@ -559,6 +559,7 @@ func run(state overseer.State, logSync func() error) {
|
||||
feature.IPInfoDetectorEnabled.Store(true)
|
||||
feature.LobDetectorEnabled.Store(true)
|
||||
feature.HashiCorpVaultBatchTokenDetectorEnabled.Store(true)
|
||||
feature.HashiCorpVaultTokenDetectorEnabled.Store(true)
|
||||
|
||||
conf := &config.Config{}
|
||||
if *configFilename != "" {
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// Package hashicorpvault contains logic shared by the HashiCorp Vault
|
||||
// detectors (hashicorpvaulttoken, hashicorpvaultbatchtoken) for verifying
|
||||
// tokens against the /v1/auth/token/lookup-self endpoint.
|
||||
package hashicorpvault
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detector_typepb"
|
||||
)
|
||||
|
||||
type LookupResponse struct {
|
||||
Data struct {
|
||||
DisplayName string `json:"display_name"`
|
||||
EntityId string `json:"entity_id"`
|
||||
ExpireTime string `json:"expire_time"`
|
||||
Orphan bool `json:"orphan"`
|
||||
Policies []string `json:"policies"`
|
||||
Renewable bool `json:"renewable"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
}
|
||||
|
||||
// VerifyVaultToken looks up token against baseUrl's /v1/auth/token/lookup-self
|
||||
// endpoint. detType is used to scope request deduplication when client was
|
||||
// created with detectors.NewClientWithDedup; it has no effect otherwise.
|
||||
func VerifyVaultToken(
|
||||
ctx context.Context,
|
||||
client *http.Client,
|
||||
detType detector_typepb.DetectorType,
|
||||
baseUrl string,
|
||||
token string,
|
||||
) (bool, *LookupResponse, error) {
|
||||
lookupUrl, err := url.JoinPath(baseUrl, "/v1/auth/token/lookup-self")
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(
|
||||
ctx,
|
||||
http.MethodGet,
|
||||
lookupUrl,
|
||||
http.NoBody,
|
||||
)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("X-Vault-Token", token)
|
||||
|
||||
res, err := detectors.DoWithDedup(client, detType, fmt.Sprintf("%s:%s", baseUrl, token), req)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
var resp LookupResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&resp); err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
return true, &resp, nil
|
||||
|
||||
case http.StatusForbidden, http.StatusUnauthorized:
|
||||
return false, nil, nil
|
||||
|
||||
default:
|
||||
return false, nil, fmt.Errorf(
|
||||
"unexpected HTTP response status %d",
|
||||
res.StatusCode,
|
||||
)
|
||||
}
|
||||
}
|
||||
+3
-67
@@ -2,16 +2,14 @@ package hashicorpbatchtoken
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
regexp "github.com/wasilibs/go-re2"
|
||||
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hashicorpvault"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detector_typepb"
|
||||
)
|
||||
|
||||
@@ -90,9 +88,10 @@ func (s Scanner) FromData(
|
||||
}
|
||||
|
||||
if verify {
|
||||
verified, verificationResp, verificationErr := verifyVaultToken(
|
||||
verified, verificationResp, verificationErr := hashicorpvault.VerifyVaultToken(
|
||||
ctx,
|
||||
s.getClient(),
|
||||
s.Type(),
|
||||
endpoint,
|
||||
token,
|
||||
)
|
||||
@@ -117,69 +116,6 @@ func (s Scanner) FromData(
|
||||
return
|
||||
}
|
||||
|
||||
type lookupResponse struct {
|
||||
Data struct {
|
||||
DisplayName string `json:"display_name"`
|
||||
EntityId string `json:"entity_id"`
|
||||
ExpireTime string `json:"expire_time"`
|
||||
Orphan bool `json:"orphan"`
|
||||
Policies []string `json:"policies"`
|
||||
Renewable bool `json:"renewable"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
}
|
||||
|
||||
func verifyVaultToken(
|
||||
ctx context.Context,
|
||||
client *http.Client,
|
||||
baseUrl string,
|
||||
token string,
|
||||
) (bool, *lookupResponse, error) {
|
||||
url, err := url.JoinPath(baseUrl, "/v1/auth/token/lookup-self")
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(
|
||||
ctx,
|
||||
http.MethodGet,
|
||||
url,
|
||||
http.NoBody,
|
||||
)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("X-Vault-Token", token)
|
||||
|
||||
res, err := detectors.DoWithDedup(client, detector_typepb.DetectorType_HashiCorpVaultBatchToken, fmt.Sprintf("%s:%s", baseUrl, token), req)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
var resp lookupResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&resp); err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
return true, &resp, nil
|
||||
|
||||
case http.StatusForbidden, http.StatusUnauthorized:
|
||||
return false, nil, nil
|
||||
|
||||
default:
|
||||
return false, nil, fmt.Errorf(
|
||||
"unexpected HTTP response status %d",
|
||||
res.StatusCode,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (s Scanner) Type() detector_typepb.DetectorType {
|
||||
return detector_typepb.DetectorType_HashiCorpVaultBatchToken
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package hashicorpvaulttoken
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
regexp "github.com/wasilibs/go-re2"
|
||||
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hashicorpvault"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detector_typepb"
|
||||
)
|
||||
|
||||
type Scanner struct {
|
||||
client *http.Client
|
||||
detectors.DefaultMultiPartCredentialProvider
|
||||
detectors.EndpointSetter
|
||||
}
|
||||
|
||||
var _ detectors.Detector = (*Scanner)(nil)
|
||||
var _ detectors.EndpointCustomizer = (*Scanner)(nil)
|
||||
|
||||
var (
|
||||
defaultClient = detectors.NewClientWithDedup(detectors.DetectorHttpClientWithNoLocalAddresses)
|
||||
|
||||
// Vault tokens:
|
||||
// newer vault tokens are around 90-120 chars (exluding the prefix "hvs.") and start with hvs. (HashiCorp Vault Service token)
|
||||
// legacy tokens are around 18-40 chars (exluding the prefix "s.") and start with s.
|
||||
vaultTokenPat = regexp.MustCompile(
|
||||
`\b(hvs\.[A-Za-z0-9_-]{90,120}|s\.[A-Za-z0-9_-]{18,40})(?:$|[^A-Za-z0-9_-])`,
|
||||
)
|
||||
|
||||
vaultUrlPat = regexp.MustCompile(`(https?:\/\/[^\s\/]*\.hashicorp\.cloud(?::\d+)?)(?:\/[^\s]*)?`)
|
||||
)
|
||||
|
||||
func (s Scanner) Keywords() []string {
|
||||
// We cant use s. as a keyword because it is too broad so that's why we are using "vault".
|
||||
return []string{"hvs.", "vault"}
|
||||
}
|
||||
|
||||
func (Scanner) CloudEndpoint() string { return "" }
|
||||
|
||||
func (s Scanner) Description() string {
|
||||
return "HashiCorp Vault is a secrets management service. Vault tokens (periodic, service, and admin) can be used to access and manage stored secrets and resources."
|
||||
}
|
||||
|
||||
func (s Scanner) getClient() *http.Client {
|
||||
if s.client != nil {
|
||||
return s.client
|
||||
}
|
||||
return defaultClient
|
||||
}
|
||||
|
||||
func (s Scanner) FromData(
|
||||
ctx context.Context,
|
||||
verify bool,
|
||||
data []byte,
|
||||
) (results []detectors.Result, err error) {
|
||||
|
||||
dataStr := string(data)
|
||||
|
||||
uniqueTokens := make(map[string]struct{})
|
||||
for _, match := range vaultTokenPat.FindAllStringSubmatch(dataStr, -1) {
|
||||
uniqueTokens[match[1]] = struct{}{}
|
||||
}
|
||||
|
||||
var uniqueVaultUrls = make(map[string]struct{})
|
||||
for _, match := range vaultUrlPat.FindAllStringSubmatch(dataStr, -1) {
|
||||
url := strings.TrimSpace(match[1])
|
||||
uniqueVaultUrls[url] = struct{}{}
|
||||
}
|
||||
endpoints := make([]string, 0, len(uniqueVaultUrls))
|
||||
for endpoint := range uniqueVaultUrls {
|
||||
endpoints = append(endpoints, endpoint)
|
||||
}
|
||||
|
||||
for token := range uniqueTokens {
|
||||
for _, endpoint := range s.Endpoints(endpoints...) {
|
||||
result := detectors.Result{
|
||||
DetectorType: detector_typepb.DetectorType_HashiCorpVaultToken,
|
||||
Raw: []byte(token),
|
||||
RawV2: []byte(token + ":" + endpoint),
|
||||
Redacted: token[:8] + "...",
|
||||
SecretParts: map[string]string{
|
||||
"key": token,
|
||||
"url": endpoint,
|
||||
},
|
||||
}
|
||||
|
||||
if verify {
|
||||
verified, verificationResp, verificationErr := hashicorpvault.VerifyVaultToken(
|
||||
ctx,
|
||||
s.getClient(),
|
||||
s.Type(),
|
||||
endpoint,
|
||||
token,
|
||||
)
|
||||
result.SetVerificationError(verificationErr, token)
|
||||
result.Verified = verified
|
||||
if verificationResp != nil {
|
||||
result.ExtraData = map[string]string{
|
||||
"policies": strings.Join(verificationResp.Data.Policies, ", "),
|
||||
"orphan": fmt.Sprintf("%v", verificationResp.Data.Orphan),
|
||||
"renewable": fmt.Sprintf("%v", verificationResp.Data.Renewable),
|
||||
"type": verificationResp.Data.Type,
|
||||
"entity_id": verificationResp.Data.EntityId, // can be helpful in revoking the token
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results = append(results, result)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s Scanner) Type() detector_typepb.DetectorType {
|
||||
return detector_typepb.DetectorType_HashiCorpVaultToken
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
//go:build detectors
|
||||
// +build detectors
|
||||
|
||||
package hashicorpvaulttoken
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
|
||||
)
|
||||
|
||||
func TestVaultToken_FromData_Integration(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Fetch test secrets from TruffleHog test secret storage
|
||||
testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors6")
|
||||
if err != nil {
|
||||
t.Fatalf("could not get test secrets: %s", err)
|
||||
}
|
||||
|
||||
vaultURL := testSecrets.MustGetField("HASHICORPVAULT_CLOUD_URL")
|
||||
// Token has maximum TTL of 32days (768h), so it should still be valid by the time this test runs
|
||||
// but if the test fails due to an invalid token, this is the most likely culprit and the token may need to be regenerated.
|
||||
// To regenerate the token run this command in vault web cli:
|
||||
// write auth/token/create policies="test-policy" ttl="768h" display_name="integration-test-token"
|
||||
token := testSecrets.MustGetField("HASHICORPVAULT_TOKEN")
|
||||
|
||||
fakeToken := "hvs.CAESIDdRIXSyTRAmJ2nvTohWQOPZW4gtKBeuMCQ1amIgUcWtGigKImh2cy5wdEprMjdtZWNqRXJUeElXT0lXZ0lRZVQuV2JZVlgQ3_4Q" // invalid/unused token
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
verify bool
|
||||
wantTokens []string
|
||||
wantVerified []bool
|
||||
wantVerificationErr bool
|
||||
}{
|
||||
{
|
||||
name: "valid token with URL, verify",
|
||||
input: fmt.Sprintf("%s\n%s", token, vaultURL),
|
||||
verify: true,
|
||||
wantTokens: []string{
|
||||
token + ":" + vaultURL,
|
||||
},
|
||||
wantVerified: []bool{true},
|
||||
wantVerificationErr: false,
|
||||
},
|
||||
{
|
||||
name: "valid token without URL, verify",
|
||||
input: fmt.Sprintf("%s", token),
|
||||
verify: true,
|
||||
wantTokens: []string{},
|
||||
wantVerified: []bool{false},
|
||||
wantVerificationErr: false,
|
||||
},
|
||||
{
|
||||
name: "invalid token with URL, verify",
|
||||
input: fmt.Sprintf("%s\n%s", fakeToken, vaultURL),
|
||||
verify: true,
|
||||
wantTokens: []string{
|
||||
fakeToken + ":" + vaultURL,
|
||||
},
|
||||
wantVerified: []bool{false},
|
||||
wantVerificationErr: false, // invalid tokens are not errors, just not verified
|
||||
},
|
||||
{
|
||||
name: "valid token with URL, no verify",
|
||||
input: fmt.Sprintf("%s\n%s", token, vaultURL),
|
||||
verify: false,
|
||||
wantTokens: []string{
|
||||
token + ":" + vaultURL,
|
||||
},
|
||||
wantVerified: []bool{false},
|
||||
wantVerificationErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
scanner := Scanner{}
|
||||
scanner.UseFoundEndpoints(true)
|
||||
scanner.UseCloudEndpoint(true)
|
||||
results, err := scanner.FromData(ctx, tt.verify, []byte(tt.input))
|
||||
require.NoError(t, err)
|
||||
|
||||
if len(results) != len(tt.wantTokens) {
|
||||
t.Fatalf("expected %d results, got %d", len(tt.wantTokens), len(results))
|
||||
}
|
||||
|
||||
for i, r := range results {
|
||||
if string(r.RawV2) != tt.wantTokens[i] && string(r.Raw) != tt.wantTokens[i] {
|
||||
t.Errorf("expected token %s, got %s", tt.wantTokens[i], string(r.Raw))
|
||||
}
|
||||
|
||||
if r.Verified != tt.wantVerified[i] {
|
||||
t.Errorf("expected verified=%v, got %v", tt.wantVerified[i], r.Verified)
|
||||
}
|
||||
|
||||
if (r.VerificationError() != nil) != tt.wantVerificationErr {
|
||||
t.Errorf("expected verification error=%v, got %v", tt.wantVerificationErr, r.VerificationError())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkHashicorpVaultToken_FromData(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
s := Scanner{}
|
||||
|
||||
for name, data := range detectors.MustGetBenchmarkData() {
|
||||
b.Run(name, func(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
for n := 0; n < b.N; n++ {
|
||||
_, err := s.FromData(ctx, false, data)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package hashicorpvaulttoken
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/engine/ahocorasick"
|
||||
)
|
||||
|
||||
func TestVaultToken_PatternWithURL(t *testing.T) {
|
||||
d := Scanner{}
|
||||
ahoCorasickCore := ahocorasick.NewAhoCorasickCore([]detectors.Detector{d})
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
name: "valid hvs token with vault url",
|
||||
input: `
|
||||
X-Vault-Token=hvs.CAESIL37MuN9DnoD8RIri7rEi1TnNI2DCvyXNAC5X3a6qmpxGh4KHGh2cy5DR0loRzZXWm5MQlFYNmRQcFNsb1ZxYnc
|
||||
https://vault-cluster-abc123.hashicorp.cloud:8200
|
||||
`,
|
||||
want: []string{
|
||||
"hvs.CAESIL37MuN9DnoD8RIri7rEi1TnNI2DCvyXNAC5X3a6qmpxGh4KHGh2cy5DR0loRzZXWm5MQlFYNmRQcFNsb1ZxYnc:https://vault-cluster-abc123.hashicorp.cloud:8200",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid legacy s token with vault url",
|
||||
input: `
|
||||
s.1234567890abcdefddd
|
||||
https://vault-cluster-abc123.hashicorp.cloud:8200
|
||||
`,
|
||||
want: []string{
|
||||
"s.1234567890abcdefddd:https://vault-cluster-abc123.hashicorp.cloud:8200",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "token only, no URL",
|
||||
input: `
|
||||
hvs.abcdefghijklmnopqr
|
||||
`,
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "URL only, no token",
|
||||
input: `
|
||||
https://vault-cluster-abc123.hashicorp.cloud:8200
|
||||
`,
|
||||
want: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
matchedDetectors := ahoCorasickCore.FindDetectorMatches([]byte(test.input))
|
||||
if len(matchedDetectors) == 0 && len(test.want) > 0 {
|
||||
t.Errorf(
|
||||
"test %q failed: expected keywords %v to be found in the input",
|
||||
test.name,
|
||||
d.Keywords(),
|
||||
)
|
||||
return
|
||||
}
|
||||
d.UseFoundEndpoints(true)
|
||||
results, err := d.FromData(context.Background(), false, []byte(test.input))
|
||||
require.NoError(t, err)
|
||||
|
||||
if len(results) != len(test.want) {
|
||||
t.Errorf(
|
||||
"mismatch in result count: expected %d, got %d",
|
||||
len(test.want),
|
||||
len(results),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
actual := make(map[string]struct{}, len(results))
|
||||
for _, r := range results {
|
||||
if len(r.RawV2) > 0 {
|
||||
actual[string(r.RawV2)] = struct{}{}
|
||||
} else {
|
||||
actual[string(r.Raw)] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
expected := make(map[string]struct{}, len(test.want))
|
||||
for _, v := range test.want {
|
||||
expected[v] = struct{}{}
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||
t.Errorf("%s diff: (-want +got)\n%s", test.name, diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -365,8 +365,9 @@ import (
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/happyscribe"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/harness"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/harvest"
|
||||
hashicorpbatchtoken "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hashicorpvault/hashicorpvaultbatchtoken"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hashicorpvault/hashicorpvaulttoken"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hashicorpvaultauth"
|
||||
hashicorpbatchtoken "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hashicorpvaultbatchtoken"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hasura"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hellosign"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/helpcrunch"
|
||||
@@ -1264,8 +1265,9 @@ func buildDetectorList() []detectors.Detector {
|
||||
&happyscribe.Scanner{},
|
||||
&harness.Scanner{},
|
||||
&harvest.Scanner{},
|
||||
&hashicorpvaultauth.Scanner{},
|
||||
&hashicorpbatchtoken.Scanner{},
|
||||
&hashicorpvaultauth.Scanner{},
|
||||
&hashicorpvaulttoken.Scanner{},
|
||||
&hasura.Scanner{},
|
||||
&hellosign.Scanner{},
|
||||
&helpcrunch.Scanner{},
|
||||
@@ -1844,6 +1846,8 @@ func buildDetectorList() []detectors.Detector {
|
||||
return !feature.LobDetectorEnabled.Load()
|
||||
case *hashicorpbatchtoken.Scanner:
|
||||
return !feature.HashiCorpVaultBatchTokenDetectorEnabled.Load()
|
||||
case *hashicorpvaulttoken.Scanner:
|
||||
return !feature.HashiCorpVaultTokenDetectorEnabled.Load()
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ var excludedFromDefaultList = map[detector_typepb.DetectorType]struct{}{
|
||||
detector_typepb.DetectorType_IPInfo: {},
|
||||
detector_typepb.DetectorType_Lob: {},
|
||||
detector_typepb.DetectorType_HashiCorpVaultBatchToken: {},
|
||||
detector_typepb.DetectorType_HashiCorpVaultToken: {},
|
||||
|
||||
// Reserved / special types.
|
||||
detector_typepb.DetectorType_CustomRegex: {}, // added dynamically via engine config, not via buildDetectorList()
|
||||
|
||||
@@ -1478,6 +1478,7 @@ func TestEngineInitializesCloudProviderDetectors(t *testing.T) {
|
||||
detector_typepb.DetectorType_ConfluenceDataCenter: {},
|
||||
detector_typepb.DetectorType_BitbucketDataCenter: {},
|
||||
detector_typepb.DetectorType_HashiCorpVaultBatchToken: {},
|
||||
detector_typepb.DetectorType_HashiCorpVaultToken: {},
|
||||
// these do not have any cloud endpoint
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ var (
|
||||
IPInfoDetectorEnabled atomic.Bool
|
||||
LobDetectorEnabled atomic.Bool
|
||||
HashiCorpVaultBatchTokenDetectorEnabled atomic.Bool
|
||||
HashiCorpVaultTokenDetectorEnabled atomic.Bool
|
||||
)
|
||||
|
||||
type AtomicString struct {
|
||||
|
||||
@@ -1115,6 +1115,7 @@ const (
|
||||
DetectorType_DuffelToken DetectorType = 1059
|
||||
DetectorType_Shippo DetectorType = 1060
|
||||
DetectorType_HashiCorpVaultBatchToken DetectorType = 1061
|
||||
DetectorType_HashiCorpVaultToken DetectorType = 1062
|
||||
)
|
||||
|
||||
// Enum value maps for DetectorType.
|
||||
@@ -2178,6 +2179,7 @@ var (
|
||||
1059: "DuffelToken",
|
||||
1060: "Shippo",
|
||||
1061: "HashiCorpVaultBatchToken",
|
||||
1062: "HashiCorpVaultToken",
|
||||
}
|
||||
DetectorType_value = map[string]int32{
|
||||
"Alibaba": 0,
|
||||
@@ -3238,6 +3240,7 @@ var (
|
||||
"DuffelToken": 1059,
|
||||
"Shippo": 1060,
|
||||
"HashiCorpVaultBatchToken": 1061,
|
||||
"HashiCorpVaultToken": 1062,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3273,7 +3276,7 @@ var File_detector_type_proto protoreflect.FileDescriptor
|
||||
var file_detector_type_proto_rawDesc = []byte{
|
||||
0x0a, 0x13, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f,
|
||||
0x74, 0x79, 0x70, 0x65, 0x2a, 0xa5, 0x8a, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74,
|
||||
0x74, 0x79, 0x70, 0x65, 0x2a, 0xbf, 0x8a, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74,
|
||||
0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x6c, 0x69, 0x62, 0x61, 0x62,
|
||||
0x61, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x4d, 0x51, 0x50, 0x10, 0x01, 0x12, 0x07, 0x0a,
|
||||
0x03, 0x41, 0x57, 0x53, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x7a, 0x75, 0x72, 0x65, 0x10,
|
||||
@@ -4379,12 +4382,14 @@ var file_detector_type_proto_rawDesc = []byte{
|
||||
0x10, 0x0a, 0x0b, 0x44, 0x75, 0x66, 0x66, 0x65, 0x6c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10, 0xa3,
|
||||
0x08, 0x12, 0x0b, 0x0a, 0x06, 0x53, 0x68, 0x69, 0x70, 0x70, 0x6f, 0x10, 0xa4, 0x08, 0x12, 0x1d,
|
||||
0x0a, 0x18, 0x48, 0x61, 0x73, 0x68, 0x69, 0x43, 0x6f, 0x72, 0x70, 0x56, 0x61, 0x75, 0x6c, 0x74,
|
||||
0x42, 0x61, 0x74, 0x63, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10, 0xa5, 0x08, 0x42, 0x41, 0x5a,
|
||||
0x3f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66,
|
||||
0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66,
|
||||
0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62,
|
||||
0x2f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x70, 0x62,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x42, 0x61, 0x74, 0x63, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10, 0xa5, 0x08, 0x12, 0x18, 0x0a,
|
||||
0x13, 0x48, 0x61, 0x73, 0x68, 0x69, 0x43, 0x6f, 0x72, 0x70, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x54,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x10, 0xa6, 0x08, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63,
|
||||
0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67,
|
||||
0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x64, 0x65, 0x74, 0x65, 0x63,
|
||||
0x74, 0x6f, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -1063,4 +1063,5 @@ enum DetectorType {
|
||||
DuffelToken = 1059;
|
||||
Shippo = 1060;
|
||||
HashiCorpVaultBatchToken = 1061;
|
||||
HashiCorpVaultToken = 1062;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user