secretscan

package
v1.170.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 7 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 secretscan finds credentials in text the platform is about to keep or send somewhere (#2820, and #2800's skill promotion after it).

The audit sanitizer is key-based: it knows a "password" parameter is one. Text an agent writes in its own words has no keys, so this reads the text itself, two ways:

  • credential shapes: a PEM private key, a bearer token, a provider token with its well-known prefix, a JSON Web Token, credentials written into a URL, and a password-, secret- or token-style assignment;
  • the deployment's own secret values (stored secrets and encrypted connection fields), as written and in the encodings a value is carried in: base64, hex, URL-escaped and JSON-escaped.

A finding names the field and the kind of match, never the value, so a refusal built from it repeats nothing it found.

Index

Constants

View Source
const (
	KindPrivateKey = "a private key"
	KindBearer     = "a bearer token"
	KindToken      = "an access token"
	KindJWT        = "a signed web token"
	KindURLCreds   = "credentials in a URL"
	KindAssignment = "a password or secret assignment"
	KindKnown      = "a secret this deployment stores"
)

Kinds of finding.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector struct {
	// Known is the deployment's own secret values; nil checks shapes alone.
	Known Known
}

Detector finds credentials in fields.

func (Detector) Scan

func (d Detector) Scan(ctx context.Context, fields []Field) ([]Finding, error)

Scan reports every field holding a credential. An error reading the known values is returned, so a caller refuses rather than sends text it could not check.

type Field

type Field struct {
	Name  string
	Value string
}

Field is one named piece of text to scan.

type Finding

type Finding struct {
	Field string
	Kind  string
}

Finding is one field holding a credential, and what kind.

type Known

type Known func(ctx context.Context) ([]string, error)

Known lists the deployment's secret values for one scan. The values are held only while the scan runs and are never logged or returned.

Jump to

Keyboard shortcuts

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