slack

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package slack provides a Slack workspace scan source.

SlackSource implements the source.Source interface, listing channels and reading message history from a Slack workspace, emitting messages as chunks for secret scanning.

Package slack provides a Slack workspace scan source.

Package slack provides a Slack workspace scan source.

Index

Constants

View Source
const (
	// DefaultRateLimit matches Slack's lowest published conversations.history
	// contract for newly distributed non-Marketplace apps: one request/minute.
	// Marketplace and internal customer-built apps can raise it explicitly.
	DefaultRateLimit = 1.0 / 60.0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*SlackSource)

Option configures a SlackSource.

func WithBufferSize

func WithBufferSize(size int) Option

WithBufferSize sets the channel buffer size for the chunk channel.

func WithChannels

func WithChannels(channels []string) Option

WithChannels limits the scan to the specified channel names (e.g. "engineering"), matching the names shown in Slack and accepted by the --channels CLI flag.

func WithExcludeChannels

func WithExcludeChannels(channels []string) Option

WithExcludeChannels excludes the specified channel names from scanning, matching the names shown in Slack and accepted by the --exclude-channels CLI flag.

func WithIncludeDMs

func WithIncludeDMs(include bool) Option

WithIncludeDMs enables or disables scanning of direct messages.

func WithIncludeFiles

func WithIncludeFiles(include bool) Option

WithIncludeFiles enables bounded scanning of text-like files attached to messages. The token needs Slack's files:read scope.

func WithMaxFileSize added in v1.8.0

func WithMaxFileSize(size int64) Option

WithMaxFileSize sets the maximum attachment size buffered for scanning.

func WithRateLimit

func WithRateLimit(rps float64) Option

WithRateLimit overrides each operation-scoped Slack limiter with the same requests-per-second ceiling. Defaults remain operation-specific.

func WithSince

func WithSince(t time.Time) Option

WithSince limits the scan to messages after the given time.

type SlackSource

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

SlackSource scans messages in a Slack workspace for leaked secrets.

func New

func New(token string, opts ...Option) *SlackSource

New creates a new SlackSource for the given workspace token. Use functional options to configure channel filtering, rate limits, etc.

func (*SlackSource) Chunks

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

Chunks lists channels in the workspace and sends message contents over a channel. The channel is closed when all messages have been processed or the context is cancelled.

func (*SlackSource) Err added in v1.7.0

func (s *SlackSource) Err() error

Err returns the first terminal error that aborted the Slack scan, or nil if it completed normally. Any error stored here has the workspace token redacted, so it can never leak the credential. It must only be called after the channel returned by Chunks has been fully drained (closed).

func (*SlackSource) Type

func (s *SlackSource) Type() string

Type returns the source type identifier.

func (*SlackSource) Validate

func (s *SlackSource) Validate(ctx context.Context) error

Validate checks that the Slack token is valid by calling AuthTest. The operation is bounded even when the caller supplies no deadline, while an earlier caller deadline or cancellation always wins.

Jump to

Keyboard shortcuts

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