Single stateless Go process that consumes CT logs via embedded (patched) CertSpotter internals, classifies cloud/database/storage DNS identifiers in-process with a zero-allocation classifier, enriches via round-robin DNS resolvers with CNAME following, and batch-writes useful findings to PostgreSQL. - third_party/certspotter: 2-hunk IdentifierSink patch, no stdout/JSON/files - internal/classify: AWS/Azure/GCP/Firebase/Cloudflare R2/DigitalOcean/Supabase/OCI - internal/dns: sharded bounded TTL cache, multi-resolver load balancing + failover - internal/pipeline: bounded queues, dedup, direct-priority load shedding - internal/store: pgx batch writer, Postgres CT checkpoints (no cert contents) - internal/probe: optional non-destructive reachability checks (off by default) - Docker: distroless non-root, read-only rootfs, no app volume, resource limits - tests enforce 0 allocs/op on the classifier and sink hot path
60 lines
2.1 KiB
Go
60 lines
2.1 KiB
Go
// Copyright (C) 2025 Opsmate, Inc.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
// Public License, v. 2.0. If a copy of the MPL was not distributed
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
//
|
|
// This software is distributed WITHOUT A WARRANTY OF ANY KIND.
|
|
// See the Mozilla Public License for details.
|
|
|
|
package ctclient
|
|
|
|
import (
|
|
"context"
|
|
|
|
"software.sslmate.com/src/certspotter/cttypes"
|
|
"software.sslmate.com/src/certspotter/merkletree"
|
|
)
|
|
|
|
type WritableLog interface {
|
|
AddChain(context.Context, [][]byte) (*cttypes.SignedCertificateTimestamp, error)
|
|
AddPreChain(context.Context, [][]byte) (*cttypes.SignedCertificateTimestamp, error)
|
|
GetRoots(context.Context) ([][]byte, error)
|
|
}
|
|
|
|
type Log interface {
|
|
GetSTH(context.Context) (*cttypes.SignedTreeHead, string, error)
|
|
GetRoots(context.Context) ([][]byte, error)
|
|
GetEntries(ctx context.Context, startInclusive, endInclusive uint64) ([]Entry, error)
|
|
ReconstructTree(context.Context, *cttypes.SignedTreeHead) (*merkletree.CollapsedTree, error)
|
|
}
|
|
|
|
// IssuerGetter represents a source of issuer certificates.
|
|
//
|
|
// If a [Log] also implements IssuerGetter, then it is mandatory to provide
|
|
// an IssuerGetter when using [Entry]s returned by the [Log]. The IssuerGetter
|
|
// may be the Log itself, or your own implementation which retrieves issuers
|
|
// from a different source, such as a cache.
|
|
//
|
|
// If a Log doesn't implement IssuerGetter, then you may pass a nil IssuerGetter
|
|
// when using the Log's Entrys.
|
|
type IssuerGetter interface {
|
|
GetIssuer(ctx context.Context, fingerprint *[32]byte) ([]byte, error)
|
|
}
|
|
|
|
type Entry interface {
|
|
LeafInput() []byte
|
|
|
|
// Returns error from IssuerGetter, otherwise infallible
|
|
ExtraData(context.Context, IssuerGetter) ([]byte, error)
|
|
|
|
// Returns an error if this is not a well-formed precert entry
|
|
Precertificate() (cttypes.ASN1Cert, error)
|
|
|
|
// Returns an error if this is not a well-formed x509 or precert entry
|
|
ChainFingerprints() ([][32]byte, error)
|
|
|
|
// Returns an error if this is not a well-formed x509 or precert entry, or if IssuerGetter failed
|
|
GetChain(context.Context, IssuerGetter) (cttypes.ASN1CertChain, error)
|
|
}
|