Documentation
¶
Index ¶
- type AuditEvent
- type AuditEventType
- type ComplianceReport
- type ComplianceReporter
- func (c *ComplianceReporter) Clear()
- func (c *ComplianceReporter) Close() error
- func (c *ComplianceReporter) EventCount() int
- func (c *ComplianceReporter) ExportCSV(ctx context.Context, criteria QueryCriteria, outputPath string) error
- func (c *ComplianceReporter) ExportJSON(report *ComplianceReport, outputPath string) error
- func (c *ComplianceReporter) GenerateReport(ctx context.Context, period ReportPeriod) (*ComplianceReport, error)
- func (c *ComplianceReporter) Persist() error
- func (c *ComplianceReporter) QueryEvents(ctx context.Context, criteria QueryCriteria) ([]AuditEvent, error)
- func (c *ComplianceReporter) RecordAnalysis(actor, symbolID, projectRoot, riskLevel string, callerCount int) error
- func (c *ComplianceReporter) RecordBlock(actor, symbolID, reason string) error
- func (c *ComplianceReporter) RecordEvent(event AuditEvent) error
- func (c *ComplianceReporter) RecordOverride(actor, symbolID, reason, approver string) error
- func (c *ComplianceReporter) RecordRuleMatch(actor, symbolID, ruleName, severity, action string) error
- type QueryCriteria
- type ReportPeriod
- type ReportSummary
- type ReporterOptions
- type RuleViolation
- type SecurityFinding
- type SymbolRisk
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEvent ¶
type AuditEvent struct {
// ID is the unique event identifier.
ID string `json:"id"`
// Timestamp is when the event occurred.
Timestamp time.Time `json:"timestamp"`
// EventType is the type of event.
EventType AuditEventType `json:"event_type"`
// Actor is who performed the action.
Actor string `json:"actor"`
// TargetSymbol is the symbol involved.
TargetSymbol string `json:"target_symbol,omitempty"`
// ProjectRoot is the project identifier.
ProjectRoot string `json:"project_root,omitempty"`
// Action is the action performed.
Action string `json:"action"`
// Outcome is the result of the action.
Outcome string `json:"outcome"`
// RiskLevel is the assessed risk level.
RiskLevel string `json:"risk_level,omitempty"`
// Details contains additional event details.
Details map[string]interface{} `json:"details,omitempty"`
// Metadata contains additional metadata.
Metadata map[string]string `json:"metadata,omitempty"`
}
AuditEvent represents an auditable event.
type AuditEventType ¶
type AuditEventType string
AuditEventType categorizes audit events.
const ( AuditEventAnalysis AuditEventType = "ANALYSIS" AuditEventRuleMatch AuditEventType = "RULE_MATCH" AuditEventBlock AuditEventType = "BLOCK" AuditEventApproval AuditEventType = "APPROVAL" AuditEventOverride AuditEventType = "OVERRIDE" AuditEventConfigChange AuditEventType = "CONFIG_CHANGE" )
type ComplianceReport ¶
type ComplianceReport struct {
// GeneratedAt is when the report was generated.
GeneratedAt time.Time `json:"generated_at"`
// ReportPeriod is the period covered.
ReportPeriod ReportPeriod `json:"report_period"`
// Summary contains summary statistics.
Summary ReportSummary `json:"summary"`
// Events contains the audit events.
Events []AuditEvent `json:"events"`
// RuleViolations contains rule violations.
RuleViolations []RuleViolation `json:"rule_violations"`
// SecurityFindings contains security-related findings.
SecurityFindings []SecurityFinding `json:"security_findings"`
}
ComplianceReport represents a compliance report.
type ComplianceReporter ¶
type ComplianceReporter struct {
// contains filtered or unexported fields
}
ComplianceReporter generates compliance reports and audit logs.
Description ¶
Maintains in-memory audit trails of blast radius analyses and generates reports suitable for compliance requirements (SOC2, ISO27001, etc.). Data is stored in-memory with optional JSON file persistence.
NO external dependencies (no SQLite, no Redis).
Thread Safety ¶
Safe for concurrent use.
func NewComplianceReporter ¶
func NewComplianceReporter(dataDir string) (*ComplianceReporter, error)
NewComplianceReporter creates a new compliance reporter.
Inputs ¶
- dataDir: Directory for optional JSON persistence. Empty for memory-only.
Outputs ¶
- *ComplianceReporter: Ready-to-use reporter.
- error: Non-nil if loading persisted data failed.
func NewComplianceReporterWithOptions ¶
func NewComplianceReporterWithOptions(dataDir string, opts *ReporterOptions) (*ComplianceReporter, error)
NewComplianceReporterWithOptions creates a reporter with options.
func (*ComplianceReporter) Close ¶
func (c *ComplianceReporter) Close() error
Close persists data and cleans up.
func (*ComplianceReporter) EventCount ¶
func (c *ComplianceReporter) EventCount() int
EventCount returns the current number of events.
func (*ComplianceReporter) ExportCSV ¶
func (c *ComplianceReporter) ExportCSV(ctx context.Context, criteria QueryCriteria, outputPath string) error
ExportCSV exports audit events to CSV.
Inputs ¶
- ctx: Context for cancellation.
- criteria: Query criteria.
- outputPath: Path for the CSV file.
Outputs ¶
- error: Non-nil on failure.
func (*ComplianceReporter) ExportJSON ¶
func (c *ComplianceReporter) ExportJSON(report *ComplianceReport, outputPath string) error
ExportJSON exports a compliance report to JSON.
Inputs ¶
- report: The report to export.
- outputPath: Path for the JSON file.
Outputs ¶
- error: Non-nil on failure.
func (*ComplianceReporter) GenerateReport ¶
func (c *ComplianceReporter) GenerateReport(ctx context.Context, period ReportPeriod) (*ComplianceReport, error)
GenerateReport generates a compliance report.
Inputs ¶
- ctx: Context for cancellation.
- period: The report period.
Outputs ¶
- *ComplianceReport: The generated report.
- error: Non-nil on failure.
func (*ComplianceReporter) Persist ¶
func (c *ComplianceReporter) Persist() error
Persist saves data to JSON file (if dataDir was provided).
func (*ComplianceReporter) QueryEvents ¶
func (c *ComplianceReporter) QueryEvents(ctx context.Context, criteria QueryCriteria) ([]AuditEvent, error)
QueryEvents retrieves audit events matching criteria.
Inputs ¶
- ctx: Context for cancellation.
- criteria: Query criteria.
Outputs ¶
- []AuditEvent: Matching events.
- error: Non-nil on failure.
func (*ComplianceReporter) RecordAnalysis ¶
func (c *ComplianceReporter) RecordAnalysis(actor, symbolID, projectRoot, riskLevel string, callerCount int) error
RecordAnalysis records an analysis event.
func (*ComplianceReporter) RecordBlock ¶
func (c *ComplianceReporter) RecordBlock(actor, symbolID, reason string) error
RecordBlock records a block event.
func (*ComplianceReporter) RecordEvent ¶
func (c *ComplianceReporter) RecordEvent(event AuditEvent) error
RecordEvent records an audit event.
Inputs ¶
- event: The event to record.
Outputs ¶
- error: Non-nil if recording failed.
func (*ComplianceReporter) RecordOverride ¶
func (c *ComplianceReporter) RecordOverride(actor, symbolID, reason, approver string) error
RecordOverride records an override event.
func (*ComplianceReporter) RecordRuleMatch ¶
func (c *ComplianceReporter) RecordRuleMatch(actor, symbolID, ruleName, severity, action string) error
RecordRuleMatch records a rule match event.
type QueryCriteria ¶
type QueryCriteria struct {
StartTime time.Time
EndTime time.Time
EventType AuditEventType
Actor string
SymbolID string
Limit int
}
QueryCriteria specifies audit event query criteria.
type ReportPeriod ¶
ReportPeriod defines the report time range.
type ReportSummary ¶
type ReportSummary struct {
TotalAnalyses int `json:"total_analyses"`
TotalRuleMatches int `json:"total_rule_matches"`
TotalBlocks int `json:"total_blocks"`
TotalOverrides int `json:"total_overrides"`
RiskDistribution map[string]int `json:"risk_distribution"`
TopRiskySymbols []SymbolRisk `json:"top_risky_symbols"`
AverageCallerCount float64 `json:"average_caller_count"`
SecurityPathsAffected int `json:"security_paths_affected"`
}
ReportSummary contains summary statistics.
type ReporterOptions ¶
type ReporterOptions struct {
// MaxEvents is the maximum number of events to keep in memory.
// Default: 10000
MaxEvents int
// PersistPath is the optional path for JSON persistence.
// If empty, data is memory-only.
PersistPath string
}
ReporterOptions configures the compliance reporter.
func DefaultReporterOptions ¶
func DefaultReporterOptions() ReporterOptions
DefaultReporterOptions returns sensible defaults.
type RuleViolation ¶
type RuleViolation struct {
Timestamp time.Time `json:"timestamp"`
RuleName string `json:"rule_name"`
SymbolID string `json:"symbol_id"`
Actor string `json:"actor"`
Severity string `json:"severity"`
Outcome string `json:"outcome"`
}
RuleViolation represents a rule violation.
type SecurityFinding ¶
type SecurityFinding struct {
Timestamp time.Time `json:"timestamp"`
SymbolID string `json:"symbol_id"`
SecurityPath string `json:"security_path"`
RiskLevel string `json:"risk_level"`
Actor string `json:"actor"`
Mitigated bool `json:"mitigated"`
}
SecurityFinding represents a security-related finding.
type SymbolRisk ¶
type SymbolRisk struct {
SymbolID string `json:"symbol_id"`
RiskLevel string `json:"risk_level"`
MatchCount int `json:"match_count"`
}
SymbolRisk represents a symbol's risk summary.