verify

package
v0.167.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package verify checks whether credentials found by a secret scan are live, with one read-only identity call to the issuer:

  • AWS: STS GetCallerIdentity, signed with SigV4. The secret signs the request and is not sent.
  • Slack: auth.test, with the token in the Authorization header.
  • GCP API key: the Discovery API, with the key in the X-Goog-Api-Key header.
  • OCI API signing key: Identity ListApiKeys for the key's own user, signed with the private key (HTTP Signature, rsa-sha256). The key signs the request and is not sent.

Slack tokens and GCP API keys are bearer values, so those calls send the value itself to slack.com or googleapis.com.

Index

Constants

View Source
const (
	CodeRegionNotFound       = secrets.OCIProfileNoRegion
	CodeInvalidProfile       = secrets.OCIProfileInvalid
	CodeUnsupportedRealm     = secrets.OCIProfileUnsupportedRealm
	CodeClockSkew            = "clock_skew"
	CodeFingerprintNotListed = "fingerprint_not_listed"
)

Local reason codes for OCI.

View Source
const (
	CodeUnsupportedKeyType   = "unsupported_key_type"
	CodeSecretNotFound       = "secret_not_found"
	CodeSessionTokenNotFound = "session_token_not_found"
	CodeRequestFailed        = "request_failed"
)

Local reason codes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Status       Status
	Account      string
	AccountName  string
	URL          string
	ARN          string
	Identity     string
	IdentityName string
	Code         string
}

Result is the check outcome for one credential. Account is the AWS account, Slack team ID, GCP consumer project, or OCI tenancy OCID; ARN is the AWS caller; Identity is the Slack user ID or OCI user OCID. AccountName, URL, and IdentityName are the Slack workspace name, workspace URL, and user name. Code is the issuer's error code or a local reason, and on a valid GCP key the restriction that blocked the call.

type Status

type Status string

Status is the outcome of one credential check.

const (
	// StatusValid means the issuer accepted the credential at the time of
	// the call. For a GCP API key it also covers a key that exists but whose
	// restrictions block the call; Code then names the restriction.
	StatusValid Status = "valid"
	// StatusRejected means the issuer said the credential itself is invalid,
	// revoked, or expired. The global STS endpoint also rejects an AWS key
	// from another partition (China, GovCloud), and OCI gives the same 401
	// for a region the tenancy is not subscribed to.
	StatusRejected Status = "rejected"
	// StatusUnknown means the check ran but did not decide: a network error,
	// a rate limit, a timeout, or an answer that does not judge the
	// credential.
	StatusUnknown Status = "unknown"
	// StatusUnverifiable means no check ran: the key type is not supported,
	// or the AWS secret or session token was not found next to the key ID.
	StatusUnverifiable Status = "unverifiable"
)

type Verifier

type Verifier struct {
	AWSEndpoint   string
	SlackEndpoint string
	GCPEndpoint   string
	// OCIEndpoint replaces https://identity.{region}.oci.oraclecloud.com.
	OCIEndpoint string
	Client      *http.Client
	Now         func() time.Time
	Workers     int
}

Verifier sends the checks. Empty endpoints use the issuers' public ones.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, creds []*secrets.Credential) map[string]Result

Verify checks every distinct credential once and maps Credential.ID to its result. The same value found in several files or commits is merged, so a history scan does not repeat calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL