Documentation
¶
Index ¶
- type ChangeStateInput
- type CreateExposureInput
- type CreateRemediationCampaignInput
- type ExposureService
- func (s *ExposureService) AcceptExposure(ctx context.Context, tenantID, exposureID, userID, notes string) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) BulkIngestExposures(ctx context.Context, inputs []CreateExposureInput) ([]*exposuredom.ExposureEvent, error)
- func (s *ExposureService) CreateExposure(ctx context.Context, input CreateExposureInput) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) DeleteExposure(ctx context.Context, exposureID, tenantID string) error
- func (s *ExposureService) GetExposure(ctx context.Context, eventID string) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) GetExposureSecure(ctx context.Context, tenantID, eventID string) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) GetExposureStats(ctx context.Context, tenantID string) (map[string]any, error)
- func (s *ExposureService) GetStateHistory(ctx context.Context, exposureID string) ([]*exposuredom.StateHistory, error)
- func (s *ExposureService) IngestExposure(ctx context.Context, input CreateExposureInput) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) ListExposures(ctx context.Context, input ListExposuresInput) (pagination.Result[*exposuredom.ExposureEvent], error)
- func (s *ExposureService) MarkFalsePositive(ctx context.Context, tenantID, exposureID, userID, notes string) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) ReactivateExposure(ctx context.Context, tenantID, exposureID, userID string) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) ResolveExposure(ctx context.Context, tenantID, exposureID, userID, notes string) (*exposuredom.ExposureEvent, error)
- func (s *ExposureService) SetOutboxService(db *sql.DB, svc *outbox.Service)
- type ListExposuresInput
- type RemediationCampaignService
- func (s *RemediationCampaignService) CreateCampaign(ctx context.Context, input CreateRemediationCampaignInput) (*remediation.Campaign, error)
- func (s *RemediationCampaignService) DeleteCampaign(ctx context.Context, tenantID, campaignID string) error
- func (s *RemediationCampaignService) GetCampaign(ctx context.Context, tenantID, campaignID string) (*remediation.Campaign, error)
- func (s *RemediationCampaignService) ListCampaigns(ctx context.Context, tenantID string, filter remediation.CampaignFilter, ...) (pagination.Result[*remediation.Campaign], error)
- func (s *RemediationCampaignService) UpdateCampaign(ctx context.Context, tenantID, campaignID string, ...) (*remediation.Campaign, error)
- func (s *RemediationCampaignService) UpdateCampaignStatus(ctx context.Context, tenantID, campaignID, newStatus string) (*remediation.Campaign, error)
- type UpdateRemediationCampaignInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeStateInput ¶
type ChangeStateInput struct {
ExposureID string `validate:"required,uuid"`
NewState string `validate:"required"`
UserID string `validate:"required,uuid"`
Reason string `validate:"max=500"`
}
ChangeStateInput represents the input for changing exposure state.
type CreateExposureInput ¶
type CreateExposureInput struct {
TenantID string `validate:"required,uuid"`
AssetID string `validate:"omitempty,uuid"`
EventType string `validate:"required"`
Severity string `validate:"required"`
Title string `validate:"required,min=1,max=500"`
Description string `validate:"max=2000"`
Source string `validate:"required,max=100"`
Details map[string]any `validate:"omitempty"`
}
CreateExposureInput represents the input for creating an exposure event.
type CreateRemediationCampaignInput ¶
type CreateRemediationCampaignInput struct {
TenantID string
Name string
Description string
Priority string
FindingFilter map[string]any
AssignedTo string
StartDate string
DueDate string
Tags []string
ActorID string
}
CreateRemediationCampaignInput holds input for creating a campaign.
type ExposureService ¶
type ExposureService struct {
// contains filtered or unexported fields
}
ExposureService handles exposure event business operations.
func NewExposureService ¶
func NewExposureService( repo exposuredom.Repository, historyRepo exposuredom.StateHistoryRepository, log *logger.Logger, ) *ExposureService
NewExposureService creates a new ExposureService.
func (*ExposureService) AcceptExposure ¶
func (s *ExposureService) AcceptExposure(ctx context.Context, tenantID, exposureID, userID, notes string) (*exposuredom.ExposureEvent, error)
AcceptExposure marks an exposure event as accepted risk.
func (*ExposureService) BulkIngestExposures ¶
func (s *ExposureService) BulkIngestExposures(ctx context.Context, inputs []CreateExposureInput) ([]*exposuredom.ExposureEvent, error)
BulkIngestExposures ingests multiple exposure events. OPTIMIZED: Uses batch upsert instead of individual upserts to reduce N+1 queries.
func (*ExposureService) CreateExposure ¶
func (s *ExposureService) CreateExposure(ctx context.Context, input CreateExposureInput) (*exposuredom.ExposureEvent, error)
CreateExposure creates a new exposure event.
func (*ExposureService) DeleteExposure ¶
func (s *ExposureService) DeleteExposure(ctx context.Context, exposureID, tenantID string) error
DeleteExposure deletes an exposure event.
func (*ExposureService) GetExposure ¶
func (s *ExposureService) GetExposure(ctx context.Context, eventID string) (*exposuredom.ExposureEvent, error)
GetExposure retrieves an exposure event by ID.
func (*ExposureService) GetExposureSecure ¶
func (s *ExposureService) GetExposureSecure(ctx context.Context, tenantID, eventID string) (*exposuredom.ExposureEvent, error)
GetExposureSecure retrieves an exposure event by tenant and ID (tenant-scoped access control).
func (*ExposureService) GetExposureStats ¶
func (s *ExposureService) GetExposureStats(ctx context.Context, tenantID string) (map[string]any, error)
GetExposureStats returns statistics for a tenant.
func (*ExposureService) GetStateHistory ¶
func (s *ExposureService) GetStateHistory(ctx context.Context, exposureID string) ([]*exposuredom.StateHistory, error)
GetStateHistory retrieves the state change history for an exposure event.
func (*ExposureService) IngestExposure ¶
func (s *ExposureService) IngestExposure(ctx context.Context, input CreateExposureInput) (*exposuredom.ExposureEvent, error)
IngestExposure creates or updates an exposure event based on fingerprint (deduplication).
func (*ExposureService) ListExposures ¶
func (s *ExposureService) ListExposures(ctx context.Context, input ListExposuresInput) (pagination.Result[*exposuredom.ExposureEvent], error)
ListExposures lists exposure events with filtering and pagination.
func (*ExposureService) MarkFalsePositive ¶
func (s *ExposureService) MarkFalsePositive(ctx context.Context, tenantID, exposureID, userID, notes string) (*exposuredom.ExposureEvent, error)
MarkFalsePositive marks an exposure event as a false positive.
func (*ExposureService) ReactivateExposure ¶
func (s *ExposureService) ReactivateExposure(ctx context.Context, tenantID, exposureID, userID string) (*exposuredom.ExposureEvent, error)
ReactivateExposure marks an exposure event as active again. tenantID is required — prevents IDOR where user in tenant A reactivates a resolved exposure in tenant B (restarts their SLA clock, floods their SOC with re-alerts).
func (*ExposureService) ResolveExposure ¶
func (s *ExposureService) ResolveExposure(ctx context.Context, tenantID, exposureID, userID, notes string) (*exposuredom.ExposureEvent, error)
ResolveExposure marks an exposure event as resolved. tenantID is required — the lookup is scoped to (tenantID, exposureID) so a caller from tenant A cannot flip an exposure owned by tenant B.
func (*ExposureService) SetOutboxService ¶
func (s *ExposureService) SetOutboxService(db *sql.DB, svc *outbox.Service)
SetOutboxService sets the notification service for transactional outbox pattern.
type ListExposuresInput ¶
type ListExposuresInput struct {
TenantID string
AssetID string
EventTypes []string
Severities []string
States []string
Sources []string
Search string
FirstSeenAfter int64
FirstSeenBefore int64
LastSeenAfter int64
LastSeenBefore int64
Page int
PerPage int
SortBy string
SortOrder string
}
ListExposuresInput represents the input for listing exposure events.
type RemediationCampaignService ¶
type RemediationCampaignService struct {
// contains filtered or unexported fields
}
RemediationCampaignService manages remediation campaigns.
func NewRemediationCampaignService ¶
func NewRemediationCampaignService(repo remediation.CampaignRepository, log *logger.Logger) *RemediationCampaignService
NewRemediationCampaignService creates a new service.
func (*RemediationCampaignService) CreateCampaign ¶
func (s *RemediationCampaignService) CreateCampaign(ctx context.Context, input CreateRemediationCampaignInput) (*remediation.Campaign, error)
CreateCampaign creates a new remediation campaign.
func (*RemediationCampaignService) DeleteCampaign ¶
func (s *RemediationCampaignService) DeleteCampaign(ctx context.Context, tenantID, campaignID string) error
DeleteCampaign deletes a campaign.
func (*RemediationCampaignService) GetCampaign ¶
func (s *RemediationCampaignService) GetCampaign(ctx context.Context, tenantID, campaignID string) (*remediation.Campaign, error)
GetCampaign retrieves a campaign.
func (*RemediationCampaignService) ListCampaigns ¶
func (s *RemediationCampaignService) ListCampaigns(ctx context.Context, tenantID string, filter remediation.CampaignFilter, page pagination.Pagination) (pagination.Result[*remediation.Campaign], error)
ListCampaigns lists campaigns with filtering.
func (*RemediationCampaignService) UpdateCampaign ¶
func (s *RemediationCampaignService) UpdateCampaign(ctx context.Context, tenantID, campaignID string, input UpdateRemediationCampaignInput) (*remediation.Campaign, error)
UpdateCampaign updates campaign fields (name, description, priority, tags, due_date).
func (*RemediationCampaignService) UpdateCampaignStatus ¶
func (s *RemediationCampaignService) UpdateCampaignStatus(ctx context.Context, tenantID, campaignID, newStatus string) (*remediation.Campaign, error)
UpdateCampaignStatus transitions campaign status.