gcs

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package gcs provides a Google Cloud Storage bucket scan source.

GCSSource implements the source.Source interface, listing and downloading objects from a GCS bucket and emitting them as chunks for secret scanning.

Package gcs provides a Google Cloud Storage bucket scan source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCSSource

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

GCSSource scans objects in a Google Cloud Storage bucket for leaked secrets.

func New

func New(bucket string, opts ...Option) *GCSSource

New creates a new GCSSource for the given bucket. Use functional options to configure prefix filtering, max file size, etc.

func (*GCSSource) Chunks

func (s *GCSSource) Chunks(ctx context.Context) <-chan source.Chunk

Chunks lists objects in the GCS bucket and sends their contents over a channel. The channel is closed when all objects have been processed or the context is cancelled.

func (*GCSSource) Err added in v1.7.0

func (s *GCSSource) Err() error

Err returns the first terminal error that aborted GCS listing, or nil if it completed normally. It must only be called after the channel returned by Chunks has been fully drained (closed).

func (*GCSSource) Type

func (s *GCSSource) Type() string

Type returns the source type identifier.

func (*GCSSource) Validate

func (s *GCSSource) Validate() error

Validate checks that the GCS bucket is accessible. It initializes the GCS client if not already set and checks bucket attributes.

type Option

type Option func(*GCSSource)

Option configures a GCSSource.

func WithBufferSize

func WithBufferSize(size int) Option

WithBufferSize sets the channel buffer size for the chunk channel.

func WithExcludePaths

func WithExcludePaths(patterns []string) Option

WithExcludePaths sets glob patterns for object names to exclude from scanning. Patterns are matched against each object's name (the object's path within the bucket), mirroring filesystem.WithExcludePaths semantics.

func WithMaxFileSize

func WithMaxFileSize(size int64) Option

WithMaxFileSize sets the maximum object size to download and scan. Objects larger than this value are skipped. Values less than or equal to zero are ignored, preserving the default.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix limits the scan to objects matching the given key prefix.

func WithProject

func WithProject(project string) Option

WithProject sets the GCP project ID for the storage client.

Jump to

Keyboard shortcuts

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