webhook

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultScanner

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

DefaultScanner implements the Scanner interface

func (*DefaultScanner) Scan

func (ds *DefaultScanner) Scan(ctx context.Context, request *ScanRequest) (*types.ScanResult, error)

Scan performs a security scan

func (*DefaultScanner) ValidateRequest

func (ds *DefaultScanner) ValidateRequest(request *ScanRequest) error

ValidateRequest validates a scan request

type GenericWebhookPayload

type GenericWebhookPayload struct {
	Event      string                 `json:"event"`
	Repository string                 `json:"repository"`
	Branch     string                 `json:"branch"`
	Commit     string                 `json:"commit"`
	Paths      []string               `json:"paths"`
	Metadata   map[string]interface{} `json:"metadata"`
	Callback   string                 `json:"callback"`
	Priority   string                 `json:"priority"`
}

GenericWebhookPayload represents a generic webhook payload

type GitHubWebhookPayload

type GitHubWebhookPayload struct {
	Action     string `json:"action"`
	Repository struct {
		Name     string `json:"name"`
		FullName string `json:"full_name"`
		CloneURL string `json:"clone_url"`
		HTMLURL  string `json:"html_url"`
	} `json:"repository"`
	Ref     string `json:"ref"`
	Before  string `json:"before"`
	After   string `json:"after"`
	Commits []struct {
		ID       string   `json:"id"`
		Message  string   `json:"message"`
		Added    []string `json:"added"`
		Modified []string `json:"modified"`
		Removed  []string `json:"removed"`
	} `json:"commits"`
	PullRequest *struct {
		Number int    `json:"number"`
		Title  string `json:"title"`
		Head   struct {
			Ref string `json:"ref"`
			SHA string `json:"sha"`
		} `json:"head"`
		Base struct {
			Ref string `json:"ref"`
		} `json:"base"`
	} `json:"pull_request"`
}

GitHubWebhookPayload represents GitHub webhook payload

type GitLabWebhookPayload

type GitLabWebhookPayload struct {
	ObjectKind string `json:"object_kind"`
	Project    struct {
		Name              string `json:"name"`
		PathWithNamespace string `json:"path_with_namespace"`
		WebURL            string `json:"web_url"`
		HTTPURLToRepo     string `json:"http_url_to_repo"`
	} `json:"project"`
	Ref     string `json:"ref"`
	Before  string `json:"before"`
	After   string `json:"after"`
	Commits []struct {
		ID       string   `json:"id"`
		Message  string   `json:"message"`
		Added    []string `json:"added"`
		Modified []string `json:"modified"`
		Removed  []string `json:"removed"`
	} `json:"commits"`
	MergeRequest *struct {
		IID          int    `json:"iid"`
		Title        string `json:"title"`
		SourceBranch string `json:"source_branch"`
		TargetBranch string `json:"target_branch"`
	} `json:"merge_request"`
}

GitLabWebhookPayload represents GitLab webhook payload

type ProviderConfig

type ProviderConfig struct {
	Enabled         bool     `json:"enabled"`
	Secret          string   `json:"secret"`
	SignatureHeader string   `json:"signature_header"`
	Events          []string `json:"events"`
	Branches        []string `json:"branches"`
	Paths           []string `json:"paths"`
}

ProviderConfig configuration for specific webhook providers

type RateLimitConfig

type RateLimitConfig struct {
	Enabled     bool          `json:"enabled"`
	MaxRequests int           `json:"max_requests"`
	Window      time.Duration `json:"window"`
}

RateLimitConfig rate limiting configuration

type ScanRequest

type ScanRequest struct {
	ID         string                 `json:"id"`
	Repository string                 `json:"repository"`
	Branch     string                 `json:"branch"`
	Commit     string                 `json:"commit"`
	Paths      []string               `json:"paths"`
	Trigger    string                 `json:"trigger"`
	Provider   string                 `json:"provider"`
	Event      string                 `json:"event"`
	Metadata   map[string]interface{} `json:"metadata"`
	Priority   string                 `json:"priority"`
	Callback   string                 `json:"callback"`
	Timeout    time.Duration          `json:"timeout"`
}

ScanRequest represents a scan request

type ScanResponse

type ScanResponse struct {
	ScanID    string    `json:"scan_id"`
	Status    string    `json:"status"`
	Message   string    `json:"message"`
	StartedAt time.Time `json:"started_at"`
	ETA       string    `json:"eta,omitempty"`
	Callback  string    `json:"callback,omitempty"`
}

ScanResponse represents a scan response

type ScanStatus

type ScanStatus struct {
	ScanID      string                 `json:"scan_id"`
	Status      string                 `json:"status"`
	Progress    float64                `json:"progress"`
	StartedAt   time.Time              `json:"started_at"`
	CompletedAt *time.Time             `json:"completed_at,omitempty"`
	Results     *types.ScanResult      `json:"results,omitempty"`
	Error       string                 `json:"error,omitempty"`
	Metadata    map[string]interface{} `json:"metadata"`
}

ScanStatus represents scan status

type ScanTrigger

type ScanTrigger interface {
	TriggerScan(ctx context.Context, request *ScanRequest) (*ScanResponse, error)
	GetScanStatus(ctx context.Context, scanID string) (*ScanStatus, error)
}

ScanTrigger interface for triggering scans

type ScanTriggerConfig

type ScanTriggerConfig struct {
	MaxConcurrentScans int           `json:"max_concurrent_scans"`
	DefaultTimeout     time.Duration `json:"default_timeout"`
	QueueSize          int           `json:"queue_size"`
	RetryAttempts      int           `json:"retry_attempts"`
	RetryDelay         time.Duration `json:"retry_delay"`
}

ScanTriggerConfig configuration for scan trigger

type ScanTriggerImpl

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

ScanTriggerImpl implements the ScanTrigger interface

func NewScanTriggerImpl

func NewScanTriggerImpl(logger logger.Logger, scanner Scanner, config *ScanTriggerConfig) *ScanTriggerImpl

NewScanTriggerImpl creates a new scan trigger implementation

func (*ScanTriggerImpl) CleanupCompletedScans

func (st *ScanTriggerImpl) CleanupCompletedScans(maxAge time.Duration)

CleanupCompletedScans removes old completed scans from memory

func (*ScanTriggerImpl) GetScanStatistics

func (st *ScanTriggerImpl) GetScanStatistics() map[string]interface{}

GetScanStatistics returns scan statistics

func (*ScanTriggerImpl) GetScanStatus

func (st *ScanTriggerImpl) GetScanStatus(ctx context.Context, scanID string) (*ScanStatus, error)

GetScanStatus returns the status of a scan

func (*ScanTriggerImpl) TriggerScan

func (st *ScanTriggerImpl) TriggerScan(ctx context.Context, request *ScanRequest) (*ScanResponse, error)

TriggerScan triggers a new scan

type Scanner

type Scanner interface {
	Scan(ctx context.Context, request *ScanRequest) (*types.ScanResult, error)
	ValidateRequest(request *ScanRequest) error
}

Scanner interface for performing scans

type WebhookConfig

type WebhookConfig struct {
	Enabled         bool                      `json:"enabled"`
	Secret          string                    `json:"secret"`
	SignatureHeader string                    `json:"signature_header"`
	Providers       map[string]ProviderConfig `json:"providers"`
	RateLimit       RateLimitConfig           `json:"rate_limit"`
	Timeout         time.Duration             `json:"timeout"`
}

WebhookConfig configuration for webhook handlers

type WebhookHandler

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

WebhookHandler handles incoming webhook requests for scan triggers

func NewWebhookHandler

func NewWebhookHandler(logger logger.Logger, scanTrigger ScanTrigger, config *WebhookConfig) *WebhookHandler

NewWebhookHandler creates a new webhook handler

func (*WebhookHandler) RegisterRoutes

func (h *WebhookHandler) RegisterRoutes(router *gin.Engine)

RegisterRoutes registers webhook routes

Jump to

Keyboard shortcuts

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