scope

package
v0.0.0-...-d1533f9 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BugcrowdClient

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

BugcrowdClient implements the Bugcrowd API client

func NewBugcrowdClient

func NewBugcrowdClient(logger *logger.Logger) *BugcrowdClient

NewBugcrowdClient creates a new Bugcrowd client

func (*BugcrowdClient) Configure

func (c *BugcrowdClient) Configure(apiToken string)

Configure sets the API token

func (*BugcrowdClient) GetProgram

func (c *BugcrowdClient) GetProgram(ctx context.Context, handle string) (*Program, error)

GetProgram fetches a program's details including scope

func (*BugcrowdClient) ListPrograms

func (c *BugcrowdClient) ListPrograms(ctx context.Context) ([]*Program, error)

ListPrograms lists available programs

type Config

type Config struct {
	AutoSync         bool          `yaml:"auto_sync"`
	SyncInterval     time.Duration `yaml:"sync_interval"`
	CacheTTL         time.Duration `yaml:"cache_ttl"`
	ValidateWorkers  int           `yaml:"validate_workers"`
	StrictMode       bool          `yaml:"strict_mode"` // Fail closed on ambiguous cases
	EnableMonitoring bool          `yaml:"enable_monitoring"`
	MonitorInterval  time.Duration `yaml:"monitor_interval"`
}

Config contains scope manager configuration

type HackerOneClient

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

HackerOneClient implements the HackerOne API client

func NewHackerOneClient

func NewHackerOneClient(logger *logger.Logger) *HackerOneClient

NewHackerOneClient creates a new HackerOne client

func (*HackerOneClient) Configure

func (c *HackerOneClient) Configure(username, apiKey string)

Configure sets the API credentials

func (*HackerOneClient) GetProgram

func (c *HackerOneClient) GetProgram(ctx context.Context, handle string) (*Program, error)

GetProgram fetches a program's details including scope

func (*HackerOneClient) ListPrograms

func (c *HackerOneClient) ListPrograms(ctx context.Context) ([]*Program, error)

ListPrograms lists available programs

type Manager

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

Manager implements comprehensive scope management

func NewManager

func NewManager(db *sqlx.DB, logger *logger.Logger, config *Config) *Manager

NewManager creates a new scope manager

func (*Manager) AddProgram

func (m *Manager) AddProgram(program *Program) error

AddProgram adds a new bug bounty program

func (*Manager) GetAllInScopeItems

func (m *Manager) GetAllInScopeItems() ([]ScopeItem, error)

GetAllInScopeItems returns all in-scope items

func (*Manager) GetPlatformClient

func (m *Manager) GetPlatformClient(platform Platform) PlatformClient

GetPlatformClient returns a platform client

func (*Manager) GetProgram

func (m *Manager) GetProgram(programID string) (*Program, error)

GetProgram retrieves a program by ID

func (*Manager) GetScopeForProgram

func (m *Manager) GetScopeForProgram(programID string) ([]ScopeItem, error)

GetScopeForProgram returns scope items for a program

func (*Manager) IsInScope

func (m *Manager) IsInScope(asset string) (bool, error)

IsInScope is a simple helper to check if asset is in scope

func (*Manager) ListPrograms

func (m *Manager) ListPrograms() ([]*Program, error)

ListPrograms lists all programs

func (*Manager) RemoveProgram

func (m *Manager) RemoveProgram(programID string) error

RemoveProgram removes a program

func (*Manager) SearchScope

func (m *Manager) SearchScope(query string) ([]ScopeItem, error)

SearchScope searches for scope items matching a query

func (*Manager) SetMonitorInterval

func (m *Manager) SetMonitorInterval(interval time.Duration)

SetMonitorInterval sets the monitoring interval

func (*Manager) StartMonitoring

func (m *Manager) StartMonitoring() error

StartMonitoring starts the scope monitoring service

func (*Manager) StopMonitoring

func (m *Manager) StopMonitoring() error

StopMonitoring stops the scope monitoring service

func (*Manager) SyncAllPrograms

func (m *Manager) SyncAllPrograms() error

SyncAllPrograms syncs all active programs

func (*Manager) SyncProgram

func (m *Manager) SyncProgram(programID string) error

SyncProgram syncs a program's scope from the platform

func (*Manager) ValidateAsset

func (m *Manager) ValidateAsset(asset string) (*ValidationResult, error)

ValidateAsset validates if an asset is in scope

func (*Manager) ValidateBatch

func (m *Manager) ValidateBatch(assets []string) ([]*ValidationResult, error)

ValidateBatch validates multiple assets

type Platform

type Platform string

Platform represents a bug bounty platform

const (
	PlatformHackerOne Platform = "hackerone"
	PlatformBugcrowd  Platform = "bugcrowd"
	PlatformIntigriti Platform = "intigriti"
	PlatformYesWeHack Platform = "yeswehack"
	PlatformSynack    Platform = "synack"
	PlatformCustom    Platform = "custom"
)

type PlatformClient

type PlatformClient interface {
	GetProgram(ctx context.Context, handle string) (*Program, error)
	ListPrograms(ctx context.Context) ([]*Program, error)
}

PlatformClient is the interface all platform clients must implement

type Program

type Program struct {
	ID                string            `json:"id"`
	Platform          Platform          `json:"platform"`
	Name              string            `json:"name"`
	Handle            string            `json:"handle"` // HackerOne/Bugcrowd handle
	URL               string            `json:"url"`
	Scope             []ScopeItem       `json:"scope"`
	OutOfScope        []ScopeItem       `json:"out_of_scope"`
	Rules             []Rule            `json:"rules"`
	TestingGuidelines string            `json:"testing_guidelines,omitempty"`
	Credentials       map[string]string `json:"credentials,omitempty"`
	VPNRequired       bool              `json:"vpn_required"`
	MaxBounty         float64           `json:"max_bounty,omitempty"`
	LastSynced        time.Time         `json:"last_synced"`
	Metadata          map[string]string `json:"metadata,omitempty"`
	Active            bool              `json:"active"`
}

Program represents a bug bounty program

type Rule

type Rule struct {
	ID          string   `json:"id"`
	Type        string   `json:"type"` // rate_limit, testing_hours, auth_required, etc.
	Description string   `json:"description"`
	Value       string   `json:"value"`
	Applies     []string `json:"applies_to,omitempty"` // specific scope items this applies to
}

Rule represents a program-specific rule

type ScopeCache

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

ScopeCache provides caching for scope validations

func NewScopeCache

func NewScopeCache(ttl time.Duration) *ScopeCache

NewScopeCache creates a new cache

func (*ScopeCache) Clear

func (c *ScopeCache) Clear()

Clear clears the cache

func (*ScopeCache) GetValidation

func (c *ScopeCache) GetValidation(asset string) *ValidationResult

GetValidation retrieves a cached validation result

func (*ScopeCache) Stop

func (c *ScopeCache) Stop()

Stop stops the cleanup routine

func (*ScopeCache) StoreValidation

func (c *ScopeCache) StoreValidation(asset string, result *ValidationResult)

StoreValidation stores a validation result

type ScopeItem

type ScopeItem struct {
	ID              string            `json:"id"`
	Type            ScopeType         `json:"type"`
	Value           string            `json:"value"`
	Status          ScopeStatus       `json:"status"`
	Description     string            `json:"description,omitempty"`
	Severity        string            `json:"severity,omitempty"`
	EnvironmentType string            `json:"environment_type,omitempty"` // production, staging, dev
	MaxSeverity     string            `json:"max_severity,omitempty"`
	Restrictions    []string          `json:"restrictions,omitempty"`
	Instructions    string            `json:"instructions,omitempty"`
	Metadata        map[string]string `json:"metadata,omitempty"`
	CompiledPattern *regexp.Regexp    `json:"-"`
	LastUpdated     time.Time         `json:"last_updated"`
}

ScopeItem represents a single scope entry

type ScopeManager

type ScopeManager interface {
	// Program management
	AddProgram(program *Program) error
	RemoveProgram(programID string) error
	GetProgram(programID string) (*Program, error)
	ListPrograms() ([]*Program, error)
	SyncProgram(programID string) error
	SyncAllPrograms() error

	// Validation
	ValidateAsset(asset string) (*ValidationResult, error)
	ValidateBatch(assets []string) ([]*ValidationResult, error)
	IsInScope(asset string) (bool, error)

	// Scope queries
	GetScopeForProgram(programID string) ([]ScopeItem, error)
	GetAllInScopeItems() ([]ScopeItem, error)
	SearchScope(query string) ([]ScopeItem, error)

	// Real-time monitoring
	StartMonitoring() error
	StopMonitoring() error
}

ScopeManager is the main interface for scope management

type ScopeMonitor

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

ScopeMonitor monitors for scope changes

func NewScopeMonitor

func NewScopeMonitor(manager *Manager, logger *logger.Logger, interval time.Duration) *ScopeMonitor

NewScopeMonitor creates a new scope monitor

func (*ScopeMonitor) SetInterval

func (m *ScopeMonitor) SetInterval(interval time.Duration)

SetInterval sets the monitoring interval

func (*ScopeMonitor) Start

func (m *ScopeMonitor) Start() error

Start starts the monitoring

func (*ScopeMonitor) Stop

func (m *ScopeMonitor) Stop() error

Stop stops the monitoring

type ScopeStatus

type ScopeStatus string

ScopeStatus represents if an item is in or out of scope

const (
	ScopeStatusInScope    ScopeStatus = "in_scope"
	ScopeStatusOutOfScope ScopeStatus = "out_of_scope"
	ScopeStatusUnknown    ScopeStatus = "unknown"
)

type ScopeType

type ScopeType string

ScopeType represents the type of scope item

const (
	ScopeTypeDomain      ScopeType = "domain"
	ScopeTypeURL         ScopeType = "url"
	ScopeTypeIP          ScopeType = "ip"
	ScopeTypeIPRange     ScopeType = "ip_range"
	ScopeTypeApplication ScopeType = "application"
	ScopeTypeAPI         ScopeType = "api"
	ScopeTypeWildcard    ScopeType = "wildcard"
	ScopeTypeMobile      ScopeType = "mobile"
	ScopeTypeSource      ScopeType = "source_code"
	ScopeTypeExecutable  ScopeType = "executable"
	ScopeTypeHardware    ScopeType = "hardware"
	ScopeTypeOther       ScopeType = "other"
)

type ValidationResult

type ValidationResult struct {
	Asset           string      `json:"asset"`
	Status          ScopeStatus `json:"status"`
	MatchedItem     *ScopeItem  `json:"matched_item,omitempty"`
	Program         *Program    `json:"program,omitempty"`
	Reason          string      `json:"reason,omitempty"`
	Restrictions    []string    `json:"restrictions,omitempty"`
	ApplicableRules []Rule      `json:"applicable_rules,omitempty"`
	ValidatedAt     time.Time   `json:"validated_at"`
}

ValidationResult contains the result of scope validation

type Validator

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

Validator validates assets against scope

func NewValidator

func NewValidator(manager *Manager, logger *logger.Logger) *Validator

NewValidator creates a new validator

func (*Validator) Validate

func (v *Validator) Validate(asset string) *ValidationResult

Validate checks if an asset is in scope

Jump to

Keyboard shortcuts

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