Documentation
¶
Index ¶
- Variables
- func MatchesPattern(targetType TargetType, pattern, value string) bool
- func ValidatePattern(targetType TargetType, pattern string) error
- type Coverage
- type Exclusion
- func (e *Exclusion) Activate()
- func (e *Exclusion) Approve(approvedBy string)
- func (e *Exclusion) ApprovedAt() *time.Time
- func (e *Exclusion) ApprovedBy() string
- func (e *Exclusion) CreatedAt() time.Time
- func (e *Exclusion) CreatedBy() string
- func (e *Exclusion) Deactivate()
- func (e *Exclusion) ExclusionType() ExclusionType
- func (e *Exclusion) ExpiresAt() *time.Time
- func (e *Exclusion) ID() shared.ID
- func (e *Exclusion) IsActive() bool
- func (e *Exclusion) IsApproved() bool
- func (e *Exclusion) MarkExpired()
- func (e *Exclusion) Matches(value string) bool
- func (e *Exclusion) Pattern() string
- func (e *Exclusion) Reason() string
- func (e *Exclusion) Status() Status
- func (e *Exclusion) TenantID() shared.ID
- func (e *Exclusion) UpdateExpiresAt(expiresAt *time.Time)
- func (e *Exclusion) UpdateReason(reason string)
- func (e *Exclusion) UpdatedAt() time.Time
- type ExclusionFilter
- type ExclusionRepository
- type ExclusionType
- type ListOptions
- type MatchResult
- type ScanType
- type Schedule
- func (s *Schedule) CreatedAt() time.Time
- func (s *Schedule) CreatedBy() string
- func (s *Schedule) CronExpression() string
- func (s *Schedule) Description() string
- func (s *Schedule) Disable()
- func (s *Schedule) Enable()
- func (s *Schedule) Enabled() bool
- func (s *Schedule) ID() shared.ID
- func (s *Schedule) IntervalHours() int
- func (s *Schedule) LastRunAt() *time.Time
- func (s *Schedule) LastRunStatus() string
- func (s *Schedule) Name() string
- func (s *Schedule) NextRunAt() *time.Time
- func (s *Schedule) NotificationChannels() []string
- func (s *Schedule) NotifyOnCompletion() bool
- func (s *Schedule) NotifyOnFindings() bool
- func (s *Schedule) RecordRun(status string, nextRunAt *time.Time)
- func (s *Schedule) ScanType() ScanType
- func (s *Schedule) ScannerConfigs() map[string]interface{}
- func (s *Schedule) ScheduleType() ScheduleType
- func (s *Schedule) SetCronSchedule(cronExpression string)
- func (s *Schedule) SetIntervalSchedule(hours int)
- func (s *Schedule) SetTargetScope(scope TargetScope, ids []shared.ID, tags []string)
- func (s *Schedule) TargetIDs() []shared.ID
- func (s *Schedule) TargetScope() TargetScope
- func (s *Schedule) TargetTags() []string
- func (s *Schedule) TenantID() shared.ID
- func (s *Schedule) UpdateDescription(description string)
- func (s *Schedule) UpdateName(name string)
- func (s *Schedule) UpdateNotifications(onCompletion, onFindings bool, channels []string)
- func (s *Schedule) UpdateScannerConfigs(configs map[string]interface{})
- func (s *Schedule) UpdatedAt() time.Time
- type ScheduleFilter
- type ScheduleRepository
- type ScheduleType
- type Stats
- type Status
- type Target
- func (t *Target) Activate()
- func (t *Target) CreatedAt() time.Time
- func (t *Target) CreatedBy() string
- func (t *Target) Deactivate()
- func (t *Target) Description() string
- func (t *Target) ID() shared.ID
- func (t *Target) IsActive() bool
- func (t *Target) Matches(value string) bool
- func (t *Target) Pattern() string
- func (t *Target) Priority() int
- func (t *Target) Status() Status
- func (t *Target) Tags() []string
- func (t *Target) TargetType() TargetType
- func (t *Target) TenantID() shared.ID
- func (t *Target) UpdateDescription(description string)
- func (t *Target) UpdatePriority(priority int)
- func (t *Target) UpdateTags(tags []string)
- func (t *Target) UpdatedAt() time.Time
- type TargetFilter
- type TargetRepository
- type TargetScope
- type TargetType
- type TypeCoverage
Constants ¶
This section is empty.
Variables ¶
var ( // Target errors ErrInvalidTenantID = errors.New("invalid tenant ID") ErrInvalidTargetType = errors.New("invalid target type") ErrTargetNotFound = errors.New("scope target not found") ErrTargetAlreadyExists = errors.New("scope target already exists") // Exclusion errors ErrInvalidExclusionType = errors.New("invalid exclusion type") ErrExclusionNotFound = errors.New("scope exclusion not found") ErrExclusionAlreadyExists = errors.New("scope exclusion already exists") ErrReasonRequired = errors.New("reason is required for exclusion") // Schedule errors ErrInvalidScanType = errors.New("invalid scan type") ErrInvalidScheduleType = errors.New("invalid schedule type") ErrScheduleNotFound = errors.New("scan schedule not found") ErrScheduleAlreadyExists = errors.New("scan schedule already exists") ErrNameRequired = errors.New("name is required") // Pattern errors ErrInvalidPattern = errors.New("invalid pattern") ErrPatternTooLong = errors.New("pattern too long") )
Domain errors for scope operations.
Functions ¶
func MatchesPattern ¶
func MatchesPattern(targetType TargetType, pattern, value string) bool
MatchesPattern checks if a value matches a pattern.
func ValidatePattern ¶
func ValidatePattern(targetType TargetType, pattern string) error
ValidatePattern validates a pattern for the given target type.
Types ¶
type Coverage ¶
type Coverage struct {
TotalAssets int64 `json:"total_assets"`
InScopeAssets int64 `json:"in_scope_assets"`
ExcludedAssets int64 `json:"excluded_assets"`
Percentage float64 `json:"percentage"`
ByType map[string]TypeCoverage `json:"by_type"`
}
Coverage represents scope coverage breakdown.
type Exclusion ¶
type Exclusion struct {
// contains filtered or unexported fields
}
Exclusion represents an exclusion from scope for security scanning.
func NewExclusion ¶
func NewExclusion( tenantID shared.ID, exclusionType ExclusionType, pattern string, reason string, expiresAt *time.Time, createdBy string, ) (*Exclusion, error)
NewExclusion creates a new scope exclusion.
func ReconstituteExclusion ¶
func ReconstituteExclusion( id shared.ID, tenantID shared.ID, exclusionType ExclusionType, pattern string, reason string, status Status, expiresAt *time.Time, approvedBy string, approvedAt *time.Time, createdBy string, createdAt time.Time, updatedAt time.Time, ) *Exclusion
ReconstituteExclusion creates an Exclusion from persistence data.
func (*Exclusion) ApprovedAt ¶
func (*Exclusion) ApprovedBy ¶
func (*Exclusion) Deactivate ¶
func (e *Exclusion) Deactivate()
func (*Exclusion) ExclusionType ¶
func (e *Exclusion) ExclusionType() ExclusionType
func (*Exclusion) IsApproved ¶
IsApproved returns true if the exclusion has been approved.
func (*Exclusion) MarkExpired ¶
func (e *Exclusion) MarkExpired()
func (*Exclusion) UpdateExpiresAt ¶
type ExclusionFilter ¶
type ExclusionFilter struct {
TenantID *string
ExclusionTypes []ExclusionType
Statuses []Status
IsApproved *bool
Search *string
}
ExclusionFilter defines the filtering options for listing exclusions.
type ExclusionRepository ¶
type ExclusionRepository interface {
// Create persists a new scope exclusion.
Create(ctx context.Context, exclusion *Exclusion) error
// GetByID retrieves a scope exclusion by its ID.
GetByID(ctx context.Context, id shared.ID) (*Exclusion, error)
// Update updates an existing scope exclusion.
Update(ctx context.Context, exclusion *Exclusion) error
// Delete removes a scope exclusion by its ID.
Delete(ctx context.Context, id shared.ID) error
// List retrieves scope exclusions with filtering and pagination.
List(ctx context.Context, filter ExclusionFilter, page pagination.Pagination) (pagination.Result[*Exclusion], error)
// ListActive retrieves all active scope exclusions for a tenant.
ListActive(ctx context.Context, tenantID shared.ID) ([]*Exclusion, error)
// Count returns the total number of scope exclusions matching the filter.
Count(ctx context.Context, filter ExclusionFilter) (int64, error)
// ExpireOld marks expired exclusions as expired.
ExpireOld(ctx context.Context) error
}
ExclusionRepository defines the interface for scope exclusion persistence.
type ExclusionType ¶
type ExclusionType string
ExclusionType represents the type of scope exclusion.
const ( ExclusionTypeDomain ExclusionType = "domain" ExclusionTypeSubdomain ExclusionType = "subdomain" ExclusionTypeIPAddress ExclusionType = "ip_address" ExclusionTypeIPRange ExclusionType = "ip_range" ExclusionTypeCIDR ExclusionType = "cidr" ExclusionTypeURL ExclusionType = "url" ExclusionTypePath ExclusionType = "path" ExclusionTypeRepository ExclusionType = "repository" ExclusionTypeFindingType ExclusionType = "finding_type" ExclusionTypeScanner ExclusionType = "scanner" )
func ParseExclusionType ¶
func ParseExclusionType(s string) (ExclusionType, error)
ParseExclusionType parses a string into an ExclusionType.
func (ExclusionType) IsValid ¶
func (t ExclusionType) IsValid() bool
IsValid returns true if the exclusion type is valid.
func (ExclusionType) String ¶
func (t ExclusionType) String() string
String returns the string representation of the exclusion type.
type ListOptions ¶
type ListOptions struct {
Sort *pagination.SortOption
}
ListOptions contains common options for listing (sorting).
func (ListOptions) WithSort ¶
func (o ListOptions) WithSort(sort *pagination.SortOption) ListOptions
WithSort adds sorting options.
type MatchResult ¶
type MatchResult struct {
InScope bool `json:"in_scope"`
Excluded bool `json:"excluded"`
MatchedTargetIDs []shared.ID `json:"matched_target_ids,omitempty"`
MatchedExclusionIDs []shared.ID `json:"matched_exclusion_ids,omitempty"`
}
MatchResult represents the result of matching an asset against scope.
type ScanType ¶
type ScanType string
ScanType represents the type of scan.
const ( ScanTypeFull ScanType = "full" ScanTypeIncremental ScanType = "incremental" ScanTypeTargeted ScanType = "targeted" ScanTypeVulnerability ScanType = "vulnerability" ScanTypeCompliance ScanType = "compliance" ScanTypeSecret ScanType = "secret" ScanTypeSAST ScanType = "sast" ScanTypeDAST ScanType = "dast" ScanTypeSCA ScanType = "sca" )
func ParseScanType ¶
ParseScanType parses a string into a ScanType.
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule represents an automated scan schedule.
func NewSchedule ¶
func NewSchedule( tenantID shared.ID, name string, scanType ScanType, scheduleType ScheduleType, createdBy string, ) (*Schedule, error)
NewSchedule creates a new scan schedule.
func ReconstituteSchedule ¶
func ReconstituteSchedule( id shared.ID, tenantID shared.ID, name string, description string, scanType ScanType, targetScope TargetScope, targetIDs []shared.ID, targetTags []string, scannerConfigs map[string]interface{}, scheduleType ScheduleType, cronExpression string, intervalHours int, enabled bool, lastRunAt *time.Time, lastRunStatus string, nextRunAt *time.Time, notifyOnCompletion bool, notifyOnFindings bool, notificationChannels []string, createdBy string, createdAt time.Time, updatedAt time.Time, ) *Schedule
ReconstituteSchedule creates a Schedule from persistence data.
func (*Schedule) CronExpression ¶
func (*Schedule) Description ¶
func (*Schedule) IntervalHours ¶
func (*Schedule) LastRunStatus ¶
func (*Schedule) NotificationChannels ¶
func (*Schedule) NotifyOnCompletion ¶
func (*Schedule) NotifyOnFindings ¶
func (*Schedule) ScannerConfigs ¶
func (*Schedule) ScheduleType ¶
func (s *Schedule) ScheduleType() ScheduleType
func (*Schedule) SetCronSchedule ¶
func (*Schedule) SetIntervalSchedule ¶
func (*Schedule) SetTargetScope ¶
func (s *Schedule) SetTargetScope(scope TargetScope, ids []shared.ID, tags []string)
func (*Schedule) TargetScope ¶
func (s *Schedule) TargetScope() TargetScope
func (*Schedule) TargetTags ¶
func (*Schedule) UpdateDescription ¶
func (*Schedule) UpdateNotifications ¶
func (*Schedule) UpdateScannerConfigs ¶
type ScheduleFilter ¶
type ScheduleFilter struct {
TenantID *string
ScanTypes []ScanType
ScheduleTypes []ScheduleType
Enabled *bool
Search *string
}
ScheduleFilter defines the filtering options for listing schedules.
type ScheduleRepository ¶
type ScheduleRepository interface {
// Create persists a new scan schedule.
Create(ctx context.Context, schedule *Schedule) error
// GetByID retrieves a scan schedule by its ID.
GetByID(ctx context.Context, id shared.ID) (*Schedule, error)
// Update updates an existing scan schedule.
Update(ctx context.Context, schedule *Schedule) error
// Delete removes a scan schedule by its ID.
Delete(ctx context.Context, id shared.ID) error
// List retrieves scan schedules with filtering and pagination.
List(ctx context.Context, filter ScheduleFilter, page pagination.Pagination) (pagination.Result[*Schedule], error)
// ListDue retrieves all enabled schedules that are due to run.
ListDue(ctx context.Context) ([]*Schedule, error)
// Count returns the total number of scan schedules matching the filter.
Count(ctx context.Context, filter ScheduleFilter) (int64, error)
}
ScheduleRepository defines the interface for scan schedule persistence.
type ScheduleType ¶
type ScheduleType string
ScheduleType represents how a scan is scheduled.
const ( ScheduleTypeCron ScheduleType = "cron" ScheduleTypeInterval ScheduleType = "interval" ScheduleTypeManual ScheduleType = "manual" )
func (ScheduleType) IsValid ¶
func (t ScheduleType) IsValid() bool
IsValid returns true if the schedule type is valid.
func (ScheduleType) String ¶
func (t ScheduleType) String() string
String returns the string representation of the schedule type.
type Stats ¶
type Stats struct {
TotalTargets int64 `json:"total_targets"`
ActiveTargets int64 `json:"active_targets"`
TotalExclusions int64 `json:"total_exclusions"`
ActiveExclusions int64 `json:"active_exclusions"`
TotalSchedules int64 `json:"total_schedules"`
EnabledSchedules int64 `json:"enabled_schedules"`
Coverage float64 `json:"coverage"`
}
Stats represents scope configuration statistics.
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target represents an in-scope target for security scanning.
func NewTarget ¶
func NewTarget( tenantID shared.ID, targetType TargetType, pattern string, description string, createdBy string, ) (*Target, error)
NewTarget creates a new scope target.
func ReconstituteTarget ¶
func ReconstituteTarget( id shared.ID, tenantID shared.ID, targetType TargetType, pattern string, description string, priority int, status Status, tags []string, createdBy string, createdAt time.Time, updatedAt time.Time, ) *Target
ReconstituteTarget creates a Target from persistence data.
func (*Target) Deactivate ¶
func (t *Target) Deactivate()
func (*Target) Description ¶
func (*Target) TargetType ¶
func (t *Target) TargetType() TargetType
func (*Target) UpdateDescription ¶
Update methods
func (*Target) UpdatePriority ¶
func (*Target) UpdateTags ¶
type TargetFilter ¶
type TargetFilter struct {
TenantID *string
TargetTypes []TargetType
Statuses []Status
Tags []string
Search *string
}
TargetFilter defines the filtering options for listing targets.
type TargetRepository ¶
type TargetRepository interface {
// Create persists a new scope target.
Create(ctx context.Context, target *Target) error
// GetByID retrieves a scope target by its ID.
GetByID(ctx context.Context, id shared.ID) (*Target, error)
// Update updates an existing scope target.
Update(ctx context.Context, target *Target) error
// Delete removes a scope target by its ID.
Delete(ctx context.Context, id shared.ID) error
// List retrieves scope targets with filtering and pagination.
List(ctx context.Context, filter TargetFilter, page pagination.Pagination) (pagination.Result[*Target], error)
// ListActive retrieves all active scope targets for a tenant.
ListActive(ctx context.Context, tenantID shared.ID) ([]*Target, error)
// Count returns the total number of scope targets matching the filter.
Count(ctx context.Context, filter TargetFilter) (int64, error)
// ExistsByPattern checks if a target with the given pattern exists.
ExistsByPattern(ctx context.Context, tenantID shared.ID, targetType TargetType, pattern string) (bool, error)
}
TargetRepository defines the interface for scope target persistence.
type TargetScope ¶
type TargetScope string
TargetScope defines what targets to include in a scan.
const ( TargetScopeAll TargetScope = "all" TargetScopeSelected TargetScope = "selected" TargetScopeTag TargetScope = "tag" )
func (TargetScope) String ¶
func (t TargetScope) String() string
String returns the string representation of the target scope.
type TargetType ¶
type TargetType string
TargetType represents the type of scope target.
const ( TargetTypeDomain TargetType = "domain" TargetTypeSubdomain TargetType = "subdomain" TargetTypeIPAddress TargetType = "ip_address" TargetTypeIPRange TargetType = "ip_range" TargetTypeCIDR TargetType = "cidr" TargetTypeURL TargetType = "url" TargetTypeAPI TargetType = "api" TargetTypeWebsite TargetType = "website" TargetTypeRepository TargetType = "repository" TargetTypeProject TargetType = "project" TargetTypeCloudAccount TargetType = "cloud_account" TargetTypeCloudResource TargetType = "cloud_resource" TargetTypeContainer TargetType = "container" TargetTypeHost TargetType = "host" TargetTypeDatabase TargetType = "database" TargetTypeNetwork TargetType = "network" TargetTypeCertificate TargetType = "certificate" TargetTypeMobileApp TargetType = "mobile_app" TargetTypeEmailDomain TargetType = "email_domain" )
func AllTargetTypes ¶
func AllTargetTypes() []TargetType
AllTargetTypes returns all valid target types.
func ParseTargetType ¶
func ParseTargetType(s string) (TargetType, error)
ParseTargetType parses a string into a TargetType.
func (TargetType) IsValid ¶
func (t TargetType) IsValid() bool
IsValid returns true if the target type is valid.
func (TargetType) String ¶
func (t TargetType) String() string
String returns the string representation of the target type.