exposure

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: GPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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

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

IngestExposure creates or updates an exposure event based on fingerprint (deduplication).

func (*ExposureService) ListExposures

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

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

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.

type UpdateRemediationCampaignInput

type UpdateRemediationCampaignInput struct {
	Name        *string
	Description *string
	Priority    *string
	Tags        []string
	DueDate     *time.Time
}

UpdateRemediationCampaignInput holds fields for partial campaign update.

Jump to

Keyboard shortcuts

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