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
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
// Copyright (C) 2023 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 monitor
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"software.sslmate.com/src/certspotter/cttypes"
|
|
"software.sslmate.com/src/certspotter/loglist"
|
|
)
|
|
|
|
type LogID = cttypes.LogID
|
|
|
|
func getLogList(ctx context.Context, source string, token *loglist.ModificationToken) (map[LogID]*loglist.Log, *loglist.ModificationToken, error) {
|
|
list, newToken, err := loglist.LoadIfModified(ctx, source, token)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
logs := make(map[LogID]*loglist.Log)
|
|
for operatorIndex := range list.Operators {
|
|
for logIndex := range list.Operators[operatorIndex].Logs {
|
|
log := &list.Operators[operatorIndex].Logs[logIndex]
|
|
if _, exists := logs[log.LogID]; exists {
|
|
return nil, nil, fmt.Errorf("log list contains more than one entry with ID %s", log.LogID.Base64String())
|
|
}
|
|
logs[log.LogID] = log
|
|
}
|
|
for logIndex := range list.Operators[operatorIndex].TiledLogs {
|
|
log := &list.Operators[operatorIndex].TiledLogs[logIndex]
|
|
if _, exists := logs[log.LogID]; exists {
|
|
return nil, nil, fmt.Errorf("log list contains more than one entry with ID %s", log.LogID.Base64String())
|
|
}
|
|
logs[log.LogID] = log
|
|
}
|
|
}
|
|
return logs, newToken, nil
|
|
}
|