certfiles

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 16 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 certfiles is the sensor for X.509 certificates that a Linux host keeps as files: the system trust store, CA anchors, and the certificates of the services that run on it. It describes certificates, never keys.

What it will not do (ADR-0005, PRD-003 REQ-CERT-4, SECARCH-001 SR-06, SR-16):

  • It never opens a file whose name says it holds a key or a key store (*.key, *.p12, *.pfx, *.jks, "privkey", "private", ...), and never enters a directory called private. Those are counted, not read.
  • In a file it does open, it decodes CERTIFICATE blocks only. A block whose label names a private key is skipped without being decoded, copied or kept, and only noted ("a private key is stored alongside this certificate"). See scanPEM.
  • It follows a symbolic link only when the link stays inside the searched host root, names a regular file, and is followed once (no chains); every directory on the way must be a real directory. A link that fails any of these is refused and counted.
  • It reads only within the allow-listed directories below, with bounds on depth, entries, file size, certificates per file and certificates per run.

Each certificate becomes one host-stream observation at the `provisioned` rung (the host holds this certificate), keyed by its SHA-256 fingerprint so it is the same entity as the certificate a TLS scan sees on the wire.

Index

Constants

View Source
const (
	// Name is the sensor's registry name.
	Name = "cert-files"
	// Version is the version of this sensor's behaviour.
	Version = "0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PEMCertificates

type PEMCertificates struct {
	Certs     [][]byte
	KeyBlocks int
	Other     int
	Malformed int
	Truncated bool
}

PEMCertificates is the certificate-only PEM reader for callers outside this sensor (the private trust-anchor upload, the server-wide CA bundle): the same rules, so a private key in an upload is counted and refused, never decoded.

func ReadPEMCertificates

func ReadPEMCertificates(data []byte) PEMCertificates

ReadPEMCertificates scans text for certificate blocks.

type Sensor

type Sensor struct {
	// contains filtered or unexported fields
}

Sensor implements sense.Sensor.

func New

func New(env sense.Env) *Sensor

New returns a sensor reading the host described by env.

func (*Sensor) Collect

func (s *Sensor) Collect(ctx context.Context) (evidence.Batch, error)

Collect walks the searched locations and returns the observations.

func (*Sensor) Detect

func (s *Sensor) Detect(context.Context) (bool, error)

Detect reports whether this is a Linux host with any of the searched directories.

func (*Sensor) Info

func (*Sensor) Info() sense.Info

Info implements sense.Sensor.

Jump to

Keyboard shortcuts

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