scanlog

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package scanlog ships raw per-chunk nuclei output (matched and unmatched) to one or more storage destinations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogDestinations

func LogDestinations()

LogDestinations records the resolved destinations once at boot. Without it the only evidence of a misconfigured bucket is a per-chunk upload warning during the first scan, which nobody is watching for.

func Upload

func Upload(ctx context.Context, dests []Uploader, m Meta, outputFile string) error

Upload gzips outputFile once and ships it to every destination. An empty output file is skipped without contacting any destination.

func ValidateS3Config

func ValidateS3Config() error

ValidateS3Config checks the environment at boot.

Types

type Meta

type Meta struct {
	TeamID    string
	ScanID    string
	ChunkID   string
	HistoryID int64
}

Meta identifies the chunk a scan log belongs to.

func (Meta) Validate

func (m Meta) Validate() error

Validate checks the identifiers that reach an object key or a request URL. natsrpc already rejects these at ingest; this is the second boundary, so a destination added later cannot be the one that forgets.

type PlatformUploader

type PlatformUploader struct{}

PlatformUploader stores scan logs in ProjectDiscovery-managed storage.

func NewPlatformUploader

func NewPlatformUploader() *PlatformUploader

NewPlatformUploader returns an uploader targeting PDCP-managed storage.

func (*PlatformUploader) Name

func (*PlatformUploader) Name() string

Name identifies the destination in logs.

func (*PlatformUploader) Upload

func (*PlatformUploader) Upload(ctx context.Context, m Meta, gzPath string, gzSize int64) (string, error)

Upload ships the gzipped scan log via:

  1. POST /v1/scans/{scan_id}/scan_log/upload-url?history_id=N with {"filename": ...}
  2. PUT the bytes to the signed URL with the response Headers verbatim.

The payload is an opaque .gz blob (no Content-Encoding) so the SigV4 signed headers never need to cover Content-Encoding; server gunzips on read.

type S3Config

type S3Config struct {
	Bucket       string
	Region       string
	AccessKeyID  string
	SecretKey    string
	Endpoint     string
	UsePathStyle bool
	Prefix       string
}

S3Config describes a customer-owned S3 destination. Credentials are always explicit: the AWS default chain is deliberately not consulted, so no ambient credential on the host can be used to write to the operator's bucket.

func S3ConfigFromEnv

func S3ConfigFromEnv() S3Config

S3ConfigFromEnv reads the destination config. Bucket empty means the destination is off.

Every field is trimmed, credentials included: a secret sourced from a Kubernetes secretRef built with --from-file keeps its trailing newline, and SigV4 would sign with it and fail every request.

func (S3Config) Enabled

func (c S3Config) Enabled() bool

Enabled reports whether a bucket was named.

func (S3Config) PlaintextWarning

func (c S3Config) PlaintextWarning() string

PlaintextWarning describes the exposure when the endpoint is plaintext and not loopback. The scan log is every finding for the customer's hosts, and over http:// it travels in the clear along with a replayable Authorization header. In-cluster MinIO over http:// is a legitimate setup, so this warns rather than rejects.

func (S3Config) Validate

func (c S3Config) Validate() error

Validate rejects a partial or malformed config so a typo stops the agent at boot. Anything that slips through here fails at upload time instead, where the only symptom is a per-chunk warning and a scan that still reports green.

type S3Uploader

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

S3Uploader writes scan logs to a customer-owned, S3-compatible bucket. Nothing about the object is reported back to the platform.

func NewS3Uploader

func NewS3Uploader(cfg S3Config) *S3Uploader

NewS3Uploader returns an uploader for cfg. Validate the config at boot; this constructor assumes it already passed.

func (*S3Uploader) Name

func (*S3Uploader) Name() string

Name identifies the destination in logs.

func (*S3Uploader) Upload

func (u *S3Uploader) Upload(ctx context.Context, m Meta, gzPath string, gzSize int64) (string, error)

Upload PUTs the gzipped scan log at gzPath to the configured bucket and returns the s3:// location it landed at.

type Uploader

type Uploader interface {
	Upload(ctx context.Context, m Meta, gzPath string, gzSize int64) (location string, err error)
	Name() string
}

Uploader ships one gzipped scan log. Implementations receive an already compressed file and return where the object landed.

func Destinations

func Destinations() []Uploader

Destinations resolves the configured upload targets. An empty slice means scan-log upload is off. The platform toggle and a customer-owned bucket are independent, so either, both or neither can be active.

Jump to

Keyboard shortcuts

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