activity

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MaxChangesSize = 15 * 1024

MaxChangesSize is the maximum allowed size for the changes JSONB field (15KB). Increased to support longer comments (up to 10000 chars) for technical discussions.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityBroadcaster

type ActivityBroadcaster interface {
	// BroadcastActivity sends an activity event to subscribers.
	// channel: the channel to broadcast to (e.g., "finding:{id}")
	// data: the activity data to broadcast
	// tenantID: tenant isolation for the broadcast
	BroadcastActivity(channel string, data any, tenantID string)
}

ActivityBroadcaster broadcasts activity events for real-time updates. This interface allows decoupling from the WebSocket implementation.

type FindingActivityService

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

FindingActivityService handles finding activity operations. Activities are APPEND-ONLY - once created, they should never be modified or deleted.

func NewFindingActivityService

func NewFindingActivityService(
	activityRepo vulnerability.FindingActivityRepository,
	findingRepo vulnerability.FindingRepository,
	log *logger.Logger,
) *FindingActivityService

NewFindingActivityService creates a new FindingActivityService.

func (*FindingActivityService) CountActivities

func (s *FindingActivityService) CountActivities(ctx context.Context, tenantID, findingID string, filter vulnerability.FindingActivityFilter) (int64, error)

CountActivities counts activities for a finding. Security: tenantID is required to ensure tenant isolation.

func (*FindingActivityService) DeleteActivityByCommentID

func (s *FindingActivityService) DeleteActivityByCommentID(ctx context.Context, tenantID string, commentID string) error

DeleteActivityByCommentID removes the comment_added activity for a given comment ID. This is called when a user deletes their comment to clean up the activity feed.

func (*FindingActivityService) GetActivity

func (s *FindingActivityService) GetActivity(ctx context.Context, activityID string) (*vulnerability.FindingActivity, error)

GetActivity retrieves a single activity by ID.

func (*FindingActivityService) ListActivities

ListActivities retrieves activities for a finding with pagination. Security: TenantID is required to ensure tenant isolation.

func (*FindingActivityService) RecordActivity

RecordActivity creates a new activity record for a finding. This is the primary method for recording any finding lifecycle event. Security: Changes field is limited to MaxChangesSize to prevent DoS attacks.

func (*FindingActivityService) RecordAssignment

func (s *FindingActivityService) RecordAssignment(
	ctx context.Context,
	tenantID, findingID string,
	actorID *string,
	assigneeID, assigneeName, assigneeEmail string,
	source string,
) (*vulnerability.FindingActivity, error)

RecordAssignment is a convenience method for recording assignment changes.

func (*FindingActivityService) RecordBatchAutoReopened

func (s *FindingActivityService) RecordBatchAutoReopened(
	ctx context.Context,
	tenantID shared.ID,
	findingIDs []shared.ID,
) error

RecordBatchAutoReopened creates activity records for findings that were auto-reopened during ingestion (previously auto-resolved findings seen again in a new scan).

func (*FindingActivityService) RecordBatchAutoResolved

func (s *FindingActivityService) RecordBatchAutoResolved(
	ctx context.Context,
	tenantID shared.ID,
	findingIDs []shared.ID,
	toolName string,
	scanID string,
) error

RecordBatchAutoResolved creates activity records for findings that were auto-resolved during ingestion. This provides an audit trail for the auto-resolve lifecycle event.

func (*FindingActivityService) RecordCommentAdded

func (s *FindingActivityService) RecordCommentAdded(
	ctx context.Context,
	tenantID, findingID string,
	actorID *string,
	commentID, content string,
	source string,
) (*vulnerability.FindingActivity, error)

RecordCommentAdded is a convenience method for recording comment additions. content is the full comment text, stored for display in activity feed.

func (*FindingActivityService) RecordCommentDeleted

func (s *FindingActivityService) RecordCommentDeleted(
	ctx context.Context,
	tenantID, findingID string,
	actorID *string,
	commentID string,
	source string,
) (*vulnerability.FindingActivity, error)

RecordCommentDeleted is a convenience method for recording comment deletions.

func (*FindingActivityService) RecordCommentUpdated

func (s *FindingActivityService) RecordCommentUpdated(
	ctx context.Context,
	tenantID, findingID string,
	actorID *string,
	commentID string,
	source string,
) (*vulnerability.FindingActivity, error)

RecordCommentUpdated is a convenience method for recording comment updates.

func (*FindingActivityService) RecordCreated

func (s *FindingActivityService) RecordCreated(
	ctx context.Context,
	tenantID, findingID string,
	source string,
	sourceMetadata map[string]interface{},
) (*vulnerability.FindingActivity, error)

RecordCreated records that a finding was created.

func (*FindingActivityService) RecordScanDetected

func (s *FindingActivityService) RecordScanDetected(
	ctx context.Context,
	tenantID, findingID string,
	scanID, scanner, scanType string,
	sourceMetadata map[string]interface{},
) (*vulnerability.FindingActivity, error)

RecordScanDetected is a convenience method for recording scan detections.

func (*FindingActivityService) RecordSeverityChange

func (s *FindingActivityService) RecordSeverityChange(
	ctx context.Context,
	tenantID, findingID string,
	actorID *string,
	oldSeverity, newSeverity string,
	source string,
) (*vulnerability.FindingActivity, error)

RecordSeverityChange is a convenience method for recording severity changes.

func (*FindingActivityService) RecordStatusChange

func (s *FindingActivityService) RecordStatusChange(
	ctx context.Context,
	tenantID, findingID string,
	actorID *string,
	oldStatus, newStatus string,
	reason string,
	source string,
) (*vulnerability.FindingActivity, error)

RecordStatusChange is a convenience method for recording status changes.

func (*FindingActivityService) RecordUnassignment

func (s *FindingActivityService) RecordUnassignment(
	ctx context.Context,
	tenantID, findingID string,
	actorID *string,
	previousAssigneeName string,
	source string,
) (*vulnerability.FindingActivity, error)

RecordUnassignment is a convenience method for recording unassignment.

func (*FindingActivityService) SetBroadcaster

func (s *FindingActivityService) SetBroadcaster(broadcaster ActivityBroadcaster)

SetBroadcaster sets the activity broadcaster for real-time WebSocket updates. This is optional - if not set, real-time updates are disabled.

func (*FindingActivityService) SetUserRepo

func (s *FindingActivityService) SetUserRepo(repo user.Repository)

SetUserRepo sets the user repository for enriching actor info in broadcasts. This is optional - if not set, actor names won't be included in real-time updates.

func (*FindingActivityService) UpdateActivityContentByCommentID

func (s *FindingActivityService) UpdateActivityContentByCommentID(ctx context.Context, tenantID string, commentID string, content string) error

UpdateActivityContentByCommentID updates the content of a comment_added activity.

type ListActivitiesInput

type ListActivitiesInput struct {
	TenantID      string   `validate:"required,uuid"` // Security: Required for tenant isolation
	FindingID     string   `validate:"required,uuid"`
	ActivityTypes []string `validate:"omitempty"`
	Page          int      `validate:"gte=0"`
	PageSize      int      `validate:"gte=1,lte=100"`
}

ListActivitiesInput represents the input for listing activities.

type RecordActivityInput

type RecordActivityInput struct {
	TenantID       string                 `validate:"required,uuid"`
	FindingID      string                 `validate:"required,uuid"`
	ActivityType   string                 `validate:"required"`
	ActorID        *string                `validate:"omitempty,uuid"`
	ActorType      string                 `validate:"required"`
	Changes        map[string]interface{} `validate:"required"`
	Source         string
	SourceMetadata map[string]interface{}
}

RecordActivityInput represents the input for recording an activity.

Jump to

Keyboard shortcuts

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