copilot

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunCopilotCLI

func RunCopilotCLI() error

RunCopilotCLI is a convenience function to start the CLI

Types

type Action

type Action struct {
	// Action type (execute_attack, analyze_target, generate_report, etc.)
	Type ActionType

	// Action description
	Description string

	// Action parameters
	Parameters map[string]interface{}

	// Expected outcome
	ExpectedOutcome string

	// Risk level (low, medium, high)
	RiskLevel string

	// Requires user confirmation
	RequiresConfirmation bool
}

Action represents something the copilot wants to do

type ActionType

type ActionType string

ActionType defines types of actions the copilot can suggest

const (
	ActionExecuteAttack      ActionType = "execute_attack"
	ActionAnalyzeTarget      ActionType = "analyze_target"
	ActionGenerateReport     ActionType = "generate_report"
	ActionCreateStrategy     ActionType = "create_strategy"
	ActionValidateCompliance ActionType = "validate_compliance"
	ActionSearchKnowledge    ActionType = "search_knowledge"
	ActionLearnFromResults   ActionType = "learn_from_results"
	ActionOptimizePayload    ActionType = "optimize_payload"
)

type Alternative

type Alternative struct {
	Option      string
	Pros        []string
	Cons        []string
	Suitability float64
	Rationale   string
}

Alternative represents an alternative consideration

type Analysis

type Analysis struct {
	// Analysis identification
	ID        string
	Timestamp time.Time

	// Key insights
	Insights []Insight

	// Pattern recognition
	Patterns []Pattern

	// Recommendations for improvement
	Improvements []Improvement

	// Target vulnerability assessment
	Vulnerabilities []VulnerabilityAssessment

	// Defense effectiveness
	DefenseAnalysis *DefenseAnalysis

	// Future recommendations
	FutureTests []FutureTestRecommendation
}

Analysis contains insights from attack results

type AttackConfiguration

type AttackConfiguration struct {
	TechniqueID     string
	Parameters      map[string]interface{}
	TargetProfile   *TargetProfile
	ExecutionMode   string
	TimeoutSettings map[string]time.Duration
	ResourceLimits  ResourceLimits
	SafetyOverrides []string
}

AttackConfiguration represents attack execution parameters

type AttackExecution

type AttackExecution struct {
	// Execution identification
	ExecutionID string
	AttackID    string
	AttackType  string

	// Execution details
	StartTime time.Time
	EndTime   time.Time
	Duration  time.Duration

	// Target information
	TargetID      string
	Configuration map[string]interface{}

	// Results
	Success    bool
	Confidence float64
	Response   string
	Evidence   []string

	// Metrics
	TokensUsed   int
	RequestsMade int
	Cost         float64

	// Learning data
	FailureReasons []string
	SuccessFactors []string
	Insights       []string

	// Context
	Environment  string
	UserFeedback string
	Metadata     map[string]interface{}
}

AttackExecution records the execution of an attack

type AttackExecutor

type AttackExecutor interface {
	Execute(ctx context.Context, config AttackConfiguration) (*AttackResult, error)
	ValidateConfig(config AttackConfiguration) error
	EstimateResourceUsage(config AttackConfiguration) ResourceEstimate
}

AttackExecutor executes attack techniques

type AttackRecommendation

type AttackRecommendation struct {
	// Attack identification
	AttackID   string
	AttackType string
	AttackName string

	// Recommendation details
	Rationale  string
	Confidence float64
	Priority   int

	// Execution parameters
	Configuration map[string]interface{}

	// Expected outcomes
	ExpectedResults    []string
	SuccessProbability float64

	// Dependencies
	Prerequisites []string
	Dependencies  []string

	// Risk factors
	RiskLevel   string
	Mitigations []string

	// Learning potential
	LearningValue float64
	NoveltyScore  float64
}

AttackRecommendation suggests a specific attack

type AttackRecommendations

type AttackRecommendations struct {
	// Primary recommendations
	Primary []AttackRecommendation

	// Alternative approaches
	Alternatives []AttackRecommendation

	// Experimental techniques
	Experimental []AttackRecommendation

	// Overall strategy
	Strategy *RecommendationStrategy

	// Success probability estimates
	SuccessProbability float64

	// Risk assessment
	RiskAssessment *RiskAssessment
}

AttackRecommendations contains suggested attacks

type AttackRegistry

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

AttackRegistry manages available attack techniques

func NewAttackRegistry

func NewAttackRegistry() *AttackRegistry

NewAttackRegistry creates a new attack registry

func (*AttackRegistry) GetCompatibleTechniques

func (ar *AttackRegistry) GetCompatibleTechniques(analysis *TargetAnalysis) []AttackTechnique

GetCompatibleTechniques returns techniques compatible with target analysis

func (*AttackRegistry) RegisterTechnique

func (ar *AttackRegistry) RegisterTechnique(technique *AttackTechnique)

RegisterTechnique adds a new attack technique

type AttackResult

type AttackResult struct {
	ConfigurationID string
	Success         bool
	Confidence      float64
	Evidence        []Evidence
	Metrics         ExecutionMetrics
	Learnings       []Insight
	Recommendations []string
	NextSteps       []string
}

AttackResult contains attack execution results

type AttackTechnique

type AttackTechnique struct {
	ID                   string
	Name                 string
	Category             string
	Description          string
	Complexity           int
	SuccessRate          float64
	RequiredCapabilities []string
	Executor             AttackExecutor
	ConfigGenerator      ConfigGenerator
}

AttackTechnique represents a registered attack technique

type CLIConfig

type CLIConfig struct {
	ShowDebugInfo  bool
	SaveSession    bool
	SessionPath    string
	MaxHistorySize int
	PromptPrefix   string
	WelcomeMessage string
	ExitCommands   []string
	HelpCommands   []string
}

CLIConfig configures the CLI interface

type CLISession

type CLISession struct {
	ID                string
	StartTime         time.Time
	QueryCount        int
	SuccessfulQueries int
	UserProfile       *UserProfile
	SessionData       map[string]interface{}
}

CLISession tracks the current CLI session

type ConfidenceFactor

type ConfidenceFactor struct {
	Factor      string
	Impact      float64 // positive or negative
	Description string
}

ConfidenceFactor affects confidence in recommendations

type ConfidenceTrend

type ConfidenceTrend struct {
	Timestamp time.Time
	Average   float64
	Count     int
}

type ConfigGenerator

type ConfigGenerator interface {
	GenerateConfig(target *TargetProfile, objective string, constraints *ExecutionConstraints) (*AttackConfiguration, error)
	OptimizeConfig(config *AttackConfiguration, feedback *ExecutionFeedback) (*AttackConfiguration, error)
}

ConfigGenerator generates attack configurations

type ContextAnalyzer

type ContextAnalyzer struct{}

func NewContextAnalyzer

func NewContextAnalyzer() *ContextAnalyzer

func (*ContextAnalyzer) AnalyzeContext

func (ca *ContextAnalyzer) AnalyzeContext(query string, history []ConversationTurn) map[string]interface{}

type ContingencyPlan

type ContingencyPlan struct {
	TriggerConditions []string
	Actions           []string
	Timeline          time.Duration
	Resources         []string
}

ContingencyPlan provides backup plans

type ConversationFlowConfigGenerator

type ConversationFlowConfigGenerator struct{}

func (*ConversationFlowConfigGenerator) GenerateConfig

func (g *ConversationFlowConfigGenerator) GenerateConfig(target *TargetProfile, objective string, constraints *ExecutionConstraints) (*AttackConfiguration, error)

func (*ConversationFlowConfigGenerator) OptimizeConfig

type ConversationFlowExecutor

type ConversationFlowExecutor struct{}

func (*ConversationFlowExecutor) EstimateResourceUsage

func (e *ConversationFlowExecutor) EstimateResourceUsage(config AttackConfiguration) ResourceEstimate

func (*ConversationFlowExecutor) Execute

func (*ConversationFlowExecutor) ValidateConfig

func (e *ConversationFlowExecutor) ValidateConfig(config AttackConfiguration) error

type ConversationManager

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

func NewConversationManager

func NewConversationManager(config *EngineConfig) *ConversationManager

NewConversationManager creates a new conversation manager

func (*ConversationManager) UpdateContext

func (cm *ConversationManager) UpdateContext(query, response string, history []ConversationTurn)

UpdateContext updates conversation context

type ConversationTracker

type ConversationTracker struct{}

func NewConversationTracker

func NewConversationTracker() *ConversationTracker

func (*ConversationTracker) UpdateConversation

func (ct *ConversationTracker) UpdateConversation(query, intent string, entities map[string]interface{})

type ConversationTurn

type ConversationTurn struct {
	UserMessage     string
	CopilotResponse string
	Timestamp       time.Time
	Actions         []string
	Results         []string
}

ConversationTurn represents one exchange in the conversation

type CopilotCLI

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

CopilotCLI provides a command-line interface for the AI Security Copilot

func NewCopilotCLI

func NewCopilotCLI(engine *CopilotEngine, config *CLIConfig) *CopilotCLI

NewCopilotCLI creates a new CLI interface

func (*CopilotCLI) Start

func (cli *CopilotCLI) Start(ctx context.Context) error

Start begins the interactive CLI session

type CopilotEngine

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

CopilotEngine implements the SecurityCopilot interface Provides natural language interface for AI security testing

func NewCopilotEngine

func NewCopilotEngine(config *EngineConfig, knowledgeBase KnowledgeBase, logger common.AuditLogger) *CopilotEngine

NewCopilotEngine creates a new AI Security Copilot engine

func (*CopilotEngine) AnalyzeResults

func (e *CopilotEngine) AnalyzeResults(ctx context.Context, results []*AttackExecution) (*Analysis, error)

AnalyzeResults learns from attack execution results

func (*CopilotEngine) ExplainReasoning

func (e *CopilotEngine) ExplainReasoning(ctx context.Context, recommendation *AttackRecommendation) (*Explanation, error)

ExplainReasoning provides explanations for recommendations

func (*CopilotEngine) GenerateStrategy

func (e *CopilotEngine) GenerateStrategy(ctx context.Context, objective *SecurityObjective) (*TestingStrategy, error)

GenerateStrategy creates comprehensive testing strategies

func (*CopilotEngine) ProcessQuery

func (e *CopilotEngine) ProcessQuery(ctx context.Context, query string, options *QueryOptions) (*QueryResponse, error)

ProcessQuery handles natural language security queries

func (*CopilotEngine) RecommendAttacks

func (e *CopilotEngine) RecommendAttacks(ctx context.Context, target *TargetProfile) (*AttackRecommendations, error)

RecommendAttacks suggests appropriate attacks for a target

type CopilotMetrics

type CopilotMetrics struct{}

func NewCopilotMetrics

func NewCopilotMetrics() *CopilotMetrics

NewCopilotMetrics creates a new metrics collector

func (*CopilotMetrics) RecordQuery

func (cm *CopilotMetrics) RecordQuery(duration time.Duration, intent string, confidence float64)

RecordQuery records query processing metrics

type CrossModalConfigGenerator

type CrossModalConfigGenerator struct{}

func (*CrossModalConfigGenerator) GenerateConfig

func (g *CrossModalConfigGenerator) GenerateConfig(target *TargetProfile, objective string, constraints *ExecutionConstraints) (*AttackConfiguration, error)

func (*CrossModalConfigGenerator) OptimizeConfig

type CrossModalExecutor

type CrossModalExecutor struct{}

func (*CrossModalExecutor) EstimateResourceUsage

func (e *CrossModalExecutor) EstimateResourceUsage(config AttackConfiguration) ResourceEstimate

func (*CrossModalExecutor) Execute

func (*CrossModalExecutor) ValidateConfig

func (e *CrossModalExecutor) ValidateConfig(config AttackConfiguration) error

type DefenseAnalysis

type DefenseAnalysis struct {
	OverallEffectiveness float64
	DefenseTypes         []string
	Strengths            []string
	Weaknesses           []string
	Bypasses             []string
	Recommendations      []string
}

DefenseAnalysis evaluates defense effectiveness

type Deliverable

type Deliverable struct {
	Name         string
	Description  string
	Type         string
	DueDate      time.Time
	Owner        string
	Dependencies []string
}

Deliverable represents a project deliverable

type Dependency

type Dependency struct {
	Type        string
	Description string
	Impact      string
	Mitigation  string
}

Dependency represents a project dependency

type EngineConfig

type EngineConfig struct {
	// Natural language processing
	NLPModelEndpoint    string
	LanguageModels      map[string]string
	ConfidenceThreshold float64

	// Attack capabilities
	EnabledTechniques    []string
	MaxConcurrentAttacks int
	DefaultTimeouts      map[string]time.Duration

	// Knowledge management
	KnowledgeRetention time.Duration
	LearningRate       float64
	ContextWindow      int

	// Security constraints
	SafetyChecks      bool
	EthicalBoundaries []string
	AuditAllQueries   bool

	// Performance tuning
	CacheSize         int
	ResponseTimeout   time.Duration
	MaxTokensPerQuery int
}

EngineConfig configures the copilot engine

type EntityExtractor

type EntityExtractor struct{}

func NewEntityExtractor

func NewEntityExtractor() *EntityExtractor

func (*EntityExtractor) ExtractEntities

func (ee *EntityExtractor) ExtractEntities(query string) map[string]interface{}

type Evidence

type Evidence struct {
	Type        string
	Content     string
	Confidence  float64
	Explanation string
}

type ExecutionConstraints

type ExecutionConstraints struct {
	// Maximum number of attacks to suggest
	MaxAttacks int

	// Time budget for execution
	TimeLimit time.Duration

	// Resource limits
	MaxConcurrency     int
	MaxTokensPerAttack int

	// Safety constraints
	SafetyLevel          string
	ProhibitedTechniques []string

	// Target restrictions
	AllowedTargets   []string
	ForbiddenTargets []string
}

ExecutionConstraints limit what the copilot can do

type ExecutionFeedback

type ExecutionFeedback struct {
	Success     bool
	Performance map[string]float64
	Errors      []string
}

type ExecutionMetrics

type ExecutionMetrics struct {
	Duration   time.Duration
	TokensUsed int
	MemoryUsed int64
	Cost       float64
}

type Explanation

type Explanation struct {
	// Summary explanation
	Summary string

	// Detailed reasoning
	Reasoning *Reasoning

	// Supporting evidence
	Evidence []string

	// Alternative considerations
	Alternatives []Alternative

	// Confidence factors
	ConfidenceFactors []ConfidenceFactor
}

Explanation provides reasoning for recommendations

type FilePersistence

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

FilePersistence implements file-based persistence

func (*FilePersistence) Backup

func (fp *FilePersistence) Backup(ctx context.Context, filename string) error

func (*FilePersistence) Load

func (fp *FilePersistence) Load(ctx context.Context) (map[string]*Knowledge, error)

func (*FilePersistence) Restore

func (fp *FilePersistence) Restore(ctx context.Context, filename string) error

func (*FilePersistence) Save

func (fp *FilePersistence) Save(ctx context.Context, knowledge map[string]*Knowledge) error

type FutureTestRecommendation

type FutureTestRecommendation struct {
	TestType      string
	Description   string
	Priority      string
	Timeline      time.Duration
	Prerequisites []string
	ExpectedValue float64
}

FutureTestRecommendation suggests future testing

type HouYiConfigGenerator

type HouYiConfigGenerator struct{}

Config generators (placeholders)

func (*HouYiConfigGenerator) GenerateConfig

func (g *HouYiConfigGenerator) GenerateConfig(target *TargetProfile, objective string, constraints *ExecutionConstraints) (*AttackConfiguration, error)

func (*HouYiConfigGenerator) OptimizeConfig

func (g *HouYiConfigGenerator) OptimizeConfig(config *AttackConfiguration, feedback *ExecutionFeedback) (*AttackConfiguration, error)

type HouYiExecutor

type HouYiExecutor struct{}

Executor implementations (placeholders)

func (*HouYiExecutor) EstimateResourceUsage

func (e *HouYiExecutor) EstimateResourceUsage(config AttackConfiguration) ResourceEstimate

func (*HouYiExecutor) Execute

func (e *HouYiExecutor) Execute(ctx context.Context, config AttackConfiguration) (*AttackResult, error)

func (*HouYiExecutor) ValidateConfig

func (e *HouYiExecutor) ValidateConfig(config AttackConfiguration) error

type IdentifiedRisk

type IdentifiedRisk struct {
	ID          string
	Description string
	Probability float64
	Impact      string
	RiskLevel   string
	Owner       string
}

IdentifiedRisk represents an identified risk

type Improvement

type Improvement struct {
	Area        string
	Description string
	Priority    string
	Difficulty  string
	Impact      string
	Steps       []string
}

Improvement suggests ways to improve attacks

type InMemoryKnowledgeBase

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

InMemoryKnowledgeBase implements the KnowledgeBase interface Provides fast in-memory storage with optional persistence

func NewInMemoryKnowledgeBase

func NewInMemoryKnowledgeBase(config *KnowledgeConfig) *InMemoryKnowledgeBase

NewInMemoryKnowledgeBase creates a new in-memory knowledge base

func (*InMemoryKnowledgeBase) AnalyzePatterns

func (kb *InMemoryKnowledgeBase) AnalyzePatterns(ctx context.Context) (*PatternAnalysis, error)

AnalyzePatterns identifies patterns in stored knowledge

func (*InMemoryKnowledgeBase) Cleanup

func (kb *InMemoryKnowledgeBase) Cleanup(ctx context.Context) error

Cleanup removes expired or low-confidence knowledge

func (*InMemoryKnowledgeBase) Delete

func (kb *InMemoryKnowledgeBase) Delete(ctx context.Context, id string) error

Delete removes knowledge from the base

func (*InMemoryKnowledgeBase) Export

func (kb *InMemoryKnowledgeBase) Export(ctx context.Context, format string) ([]byte, error)

Export exports knowledge to a structured format

func (*InMemoryKnowledgeBase) GetStatistics

func (kb *InMemoryKnowledgeBase) GetStatistics() *KnowledgeStatistics

GetStatistics returns knowledge base statistics

func (*InMemoryKnowledgeBase) Import

func (kb *InMemoryKnowledgeBase) Import(ctx context.Context, data []byte, format string) error

Import imports knowledge from external sources

func (*InMemoryKnowledgeBase) Retrieve

func (kb *InMemoryKnowledgeBase) Retrieve(ctx context.Context, query *KnowledgeQuery) ([]*Knowledge, error)

Retrieve finds relevant knowledge based on query

func (*InMemoryKnowledgeBase) Search

func (kb *InMemoryKnowledgeBase) Search(ctx context.Context, query string) ([]*Knowledge, error)

Search performs full-text search across knowledge content

func (*InMemoryKnowledgeBase) Store

func (kb *InMemoryKnowledgeBase) Store(ctx context.Context, knowledge *Knowledge) error

Store saves knowledge to the knowledge base

func (*InMemoryKnowledgeBase) Update

func (kb *InMemoryKnowledgeBase) Update(ctx context.Context, knowledge *Knowledge) error

Update modifies existing knowledge

type InfrastructureRequirement

type InfrastructureRequirement struct {
	Type           string
	Specifications map[string]interface{}
	Duration       time.Duration
	Cost           float64
}

InfrastructureRequirement specifies needed infrastructure

type Insight

type Insight struct {
	Type         string
	Description  string
	Confidence   float64
	Evidence     []string
	Implications []string
	Actionable   bool
}

Insight represents a learned insight

type IntentClassifier

type IntentClassifier struct{}

func NewIntentClassifier

func NewIntentClassifier() *IntentClassifier

func (*IntentClassifier) ClassifyIntent

func (ic *IntentClassifier) ClassifyIntent(query string) (string, float64)

type Knowledge

type Knowledge struct {
	ID         string
	Type       KnowledgeType
	Content    string
	Source     string
	Timestamp  time.Time
	Confidence float64
	Tags       []string
	Metadata   map[string]interface{}
}

Knowledge represents a piece of learned knowledge

type KnowledgeBase

type KnowledgeBase interface {
	// Store learned information
	Store(ctx context.Context, knowledge *Knowledge) error

	// Retrieve relevant knowledge
	Retrieve(ctx context.Context, query *KnowledgeQuery) ([]*Knowledge, error)

	// Update existing knowledge
	Update(ctx context.Context, knowledge *Knowledge) error

	// Delete knowledge
	Delete(ctx context.Context, id string) error

	// Search knowledge
	Search(ctx context.Context, query string) ([]*Knowledge, error)
}

KnowledgeBase provides access to learned knowledge

type KnowledgeConfig

type KnowledgeConfig struct {
	MaxItems         int
	RetentionPeriod  time.Duration
	AutoPersist      bool
	PersistInterval  time.Duration
	IndexingEnabled  bool
	FullTextSearch   bool
	CompressionLevel int
}

KnowledgeConfig configures the knowledge base

type KnowledgeQuery

type KnowledgeQuery struct {
	Type          KnowledgeType
	Tags          []string
	Content       string
	MinConfidence float64
	MaxResults    int
	SortBy        string
}

KnowledgeQuery specifies knowledge retrieval criteria

type KnowledgeStatistics

type KnowledgeStatistics struct {
	TotalItems    int
	TypeCounts    map[KnowledgeType]int
	TagCounts     map[string]int
	ConfidenceAvg float64
	OldestItem    time.Time
	NewestItem    time.Time
}

KnowledgeStatistics provides statistics about the knowledge base

type KnowledgeType

type KnowledgeType string

KnowledgeType categorizes knowledge

const (
	KnowledgePattern       KnowledgeType = "pattern"
	KnowledgeVulnerability KnowledgeType = "vulnerability"
	KnowledgeDefense       KnowledgeType = "defense"
	KnowledgeStrategy      KnowledgeType = "strategy"
	KnowledgeInsight       KnowledgeType = "insight"
	KnowledgeBestPractice  KnowledgeType = "best_practice"
)

type Logger

type Logger interface {
	LogSecurityEvent(event string, data map[string]interface{})
}

type Milestone

type Milestone struct {
	Name         string
	Date         time.Time
	Description  string
	Deliverables []string
	Criteria     []string
}

Milestone represents a key milestone

type MitigationPlan

type MitigationPlan struct {
	RiskID        string
	Strategy      string
	Actions       []string
	Timeline      time.Duration
	Cost          float64
	Effectiveness float64
}

MitigationPlan provides a plan to mitigate risks

type MockLogger

type MockLogger struct{}

MockLogger implements a simple logger for demonstration

func (*MockLogger) LogSecurityEvent

func (l *MockLogger) LogSecurityEvent(event string, data map[string]interface{})

type MonitoringPlan

type MonitoringPlan struct {
	Metrics    []string
	Frequency  time.Duration
	Thresholds map[string]float64
	Alerts     []string
}

MonitoringPlan specifies how to monitor risks

type ObjectiveConstraints

type ObjectiveConstraints struct {
	// Time constraints
	MaxDuration time.Duration

	// Resource constraints
	MaxCost   float64
	MaxTokens int

	// Technical constraints
	AllowedAttacks   []string
	ForbiddenAttacks []string

	// Risk constraints
	MaxRiskLevel string

	// Compliance constraints
	RequiredFrameworks []string
}

ObjectiveConstraints limit how objectives can be achieved

type ObjectiveType

type ObjectiveType string

ObjectiveType defines types of security objectives

const (
	ObjectiveCompliance             ObjectiveType = "compliance"
	ObjectiveVulnerabilityDiscovery ObjectiveType = "vulnerability_discovery"
	ObjectivePenetrationTest        ObjectiveType = "penetration_test"
	ObjectiveRedTeamExercise        ObjectiveType = "red_team_exercise"
	ObjectiveSecurityAudit          ObjectiveType = "security_audit"
	ObjectiveRiskAssessment         ObjectiveType = "risk_assessment"
)

type ParsedQuery

type ParsedQuery struct {
	Intent     string
	Entities   map[string]interface{}
	Context    map[string]interface{}
	Confidence float64
}

type Pattern

type Pattern struct {
	Type        string
	Description string
	Frequency   float64
	Conditions  []string
	Outcomes    []string
	Reliability float64
}

Pattern represents a discovered pattern

type PatternAnalysis

type PatternAnalysis struct {
	CommonTags       map[string]int
	TypeDistribution map[KnowledgeType]float64
	ConfidenceTrends []ConfidenceTrend
	TemporalPatterns []TemporalPattern
}

type PersistenceLayer

type PersistenceLayer interface {
	Save(ctx context.Context, knowledge map[string]*Knowledge) error
	Load(ctx context.Context) (map[string]*Knowledge, error)
	Backup(ctx context.Context, filename string) error
	Restore(ctx context.Context, filename string) error
}

PersistenceLayer handles knowledge persistence

type PersonnelRequirement

type PersonnelRequirement struct {
	Role           string
	Skillset       []string
	Experience     string
	TimeCommitment time.Duration
}

PersonnelRequirement specifies needed people

type PreviousTest

type PreviousTest struct {
	Date        time.Time
	TestType    string
	AttacksUsed []string
	Results     string
	Findings    []string
	Remediation []string
}

PreviousTest records previous security testing

type QueryNormalizer

type QueryNormalizer struct{}

func NewQueryNormalizer

func NewQueryNormalizer() *QueryNormalizer

func (*QueryNormalizer) Normalize

func (qn *QueryNormalizer) Normalize(query string) string

type QueryOptions

type QueryOptions struct {
	// Context for the query
	Context map[string]interface{}

	// Previous conversation history
	History []ConversationTurn

	// User preferences
	Preferences *UserPreferences

	// Execution constraints
	Constraints *ExecutionConstraints
}

QueryOptions configures how queries are processed

type QueryProcessor

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

QueryProcessor handles natural language query understanding

func NewQueryProcessor

func NewQueryProcessor(config *EngineConfig) *QueryProcessor

NewQueryProcessor creates a new query processor

func (*QueryProcessor) ParseQuery

func (qp *QueryProcessor) ParseQuery(ctx context.Context, query string, options *QueryOptions) (*ParsedQuery, error)

ParseQuery processes a natural language query

type QueryResponse

type QueryResponse struct {
	// Unique response ID
	ID string

	// Natural language response
	Response string

	// Structured actions to take
	Actions []Action

	// Attack recommendations
	Recommendations *AttackRecommendations

	// Follow-up questions
	FollowUpQuestions []string

	// Confidence in the response (0.0-1.0)
	Confidence float64

	// Reasoning explanation
	Reasoning *Reasoning

	// Additional metadata
	Metadata map[string]interface{}
}

QueryResponse contains the copilot's response to a query

type RateLimitInfo

type RateLimitInfo struct {
	RequestsPerMinute  int
	RequestsPerHour    int
	RequestsPerDay     int
	TokensPerMinute    int
	ConcurrentRequests int
}

RateLimitInfo describes API rate limits

type Reasoning

type Reasoning struct {
	// Logical steps
	Steps []ReasoningStep

	// Assumptions made
	Assumptions []string

	// Data sources used
	DataSources []string

	// Methodology
	Methodology string
}

Reasoning provides detailed reasoning

type ReasoningEngine

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

func NewReasoningEngine

func NewReasoningEngine(config *EngineConfig) *ReasoningEngine

NewReasoningEngine creates a new reasoning engine

func (*ReasoningEngine) AnalyzeConfidenceFactors

func (re *ReasoningEngine) AnalyzeConfidenceFactors(recommendation *AttackRecommendation) []ConfidenceFactor

AnalyzeConfidenceFactors identifies factors affecting confidence

func (*ReasoningEngine) CollectEvidence

func (re *ReasoningEngine) CollectEvidence(recommendation *AttackRecommendation) []string

CollectEvidence gathers supporting evidence for a recommendation

func (*ReasoningEngine) ConsiderAlternatives

func (re *ReasoningEngine) ConsiderAlternatives(recommendation *AttackRecommendation) []Alternative

ConsiderAlternatives evaluates alternative approaches

func (*ReasoningEngine) GenerateReasoning

func (re *ReasoningEngine) GenerateReasoning(recommendation *AttackRecommendation) *Reasoning

GenerateReasoning creates detailed reasoning for a recommendation

type ReasoningStep

type ReasoningStep struct {
	StepNumber  int
	Description string
	Input       []string
	Process     string
	Output      string
	Confidence  float64
}

ReasoningStep represents a step in reasoning

type RecommendationStrategy

type RecommendationStrategy struct {
	// Strategy name
	Name string

	// Strategy description
	Description string

	// Strategic phases
	Phases []StrategyPhase

	// Success criteria
	SuccessCriteria []string

	// Risk mitigation
	RiskMitigation []string

	// Expected timeline
	Timeline time.Duration
}

RecommendationStrategy explains the overall approach

type RedQueenConfigGenerator

type RedQueenConfigGenerator struct{}

func (*RedQueenConfigGenerator) GenerateConfig

func (g *RedQueenConfigGenerator) GenerateConfig(target *TargetProfile, objective string, constraints *ExecutionConstraints) (*AttackConfiguration, error)

func (*RedQueenConfigGenerator) OptimizeConfig

type RedQueenExecutor

type RedQueenExecutor struct{}

func (*RedQueenExecutor) EstimateResourceUsage

func (e *RedQueenExecutor) EstimateResourceUsage(config AttackConfiguration) ResourceEstimate

func (*RedQueenExecutor) Execute

func (*RedQueenExecutor) ValidateConfig

func (e *RedQueenExecutor) ValidateConfig(config AttackConfiguration) error

type ResourceEstimate

type ResourceEstimate struct {
	CPUTime    time.Duration
	Memory     int64
	TokenUsage int
	Cost       float64
}

type ResourceLimits

type ResourceLimits struct {
	MaxMemory   int64
	MaxTokens   int
	MaxDuration time.Duration
	MaxCost     float64
}

type ResourceRequirements

type ResourceRequirements struct {
	// Human resources
	Personnel []PersonnelRequirement

	// Technical resources
	Infrastructure []InfrastructureRequirement

	// Financial resources
	Budget float64

	// Time resources
	Timeline time.Duration
}

ResourceRequirements specifies needed resources

type ResultAnalyzer

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

func NewResultAnalyzer

func NewResultAnalyzer(config *EngineConfig) *ResultAnalyzer

NewResultAnalyzer creates a new result analyzer

func (*ResultAnalyzer) ExtractInsights

func (ra *ResultAnalyzer) ExtractInsights(results []*AttackExecution) []Insight

ExtractInsights analyzes results to extract insights

type RiskAssessment

type RiskAssessment struct {
	// Overall risk level
	OverallRisk string

	// Specific risk factors
	RiskFactors []RiskFactor

	// Mitigation strategies
	Mitigations []string

	// Monitoring recommendations
	Monitoring []string

	// Rollback procedures
	RollbackPlan []string
}

RiskAssessment evaluates the risks of recommended attacks

type RiskFactor

type RiskFactor struct {
	Type        string
	Description string
	Severity    string
	Probability float64
	Impact      string
	Mitigation  string
}

RiskFactor identifies a specific risk

type RiskManagement

type RiskManagement struct {
	IdentifiedRisks  []IdentifiedRisk
	MitigationPlans  []MitigationPlan
	ContingencyPlans []ContingencyPlan
	MonitoringPlan   *MonitoringPlan
}

RiskManagement provides risk management plan

type SecurityCopilot

type SecurityCopilot interface {
	// ProcessQuery handles natural language security queries
	ProcessQuery(ctx context.Context, query string, options *QueryOptions) (*QueryResponse, error)

	// RecommendAttacks suggests appropriate attacks for a target
	RecommendAttacks(ctx context.Context, target *TargetProfile) (*AttackRecommendations, error)

	// AnalyzeResults learns from attack execution results
	AnalyzeResults(ctx context.Context, results []*AttackExecution) (*Analysis, error)

	// GenerateStrategy creates comprehensive testing strategies
	GenerateStrategy(ctx context.Context, objective *SecurityObjective) (*TestingStrategy, error)

	// ExplainReasoning provides explanations for recommendations
	ExplainReasoning(ctx context.Context, recommendation *AttackRecommendation) (*Explanation, error)
}

SecurityCopilot is the main interface for the AI security assistant

type SecurityObjective

type SecurityObjective struct {
	// Objective identification
	ID          string
	Name        string
	Description string

	// Objective type (compliance, vulnerability_discovery, penetration_test, etc.)
	Type ObjectiveType

	// Target systems
	Targets []string

	// Success criteria
	SuccessCriteria []string

	// Constraints
	Constraints *ObjectiveConstraints

	// Timeline
	Deadline time.Time

	// Priority level
	Priority string

	// Stakeholders
	Stakeholders []string
}

SecurityObjective defines what we're trying to achieve

type StrategyPhase

type StrategyPhase struct {
	Name         string
	Description  string
	Duration     time.Duration
	Attacks      []string
	Objectives   []string
	Dependencies []string
}

StrategyPhase represents a phase in the testing strategy

type StrategyPlanner

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

func NewStrategyPlanner

func NewStrategyPlanner(config *EngineConfig) *StrategyPlanner

NewStrategyPlanner creates a new strategy planner

func (*StrategyPlanner) GeneratePhases

func (sp *StrategyPlanner) GeneratePhases(objective *SecurityObjective) ([]TestingPhase, error)

GeneratePhases creates testing phases for an objective

type SuccessMetric

type SuccessMetric struct {
	Name        string
	Description string
	Target      float64
	Measurement string
	Frequency   time.Duration
}

SuccessMetric defines how success is measured

type TargetAnalysis

type TargetAnalysis struct {
	ModelType       string
	Capabilities    []string
	Vulnerabilities []string
	RiskLevel       string
}

func (*TargetAnalysis) HasCapability

func (ta *TargetAnalysis) HasCapability(capability string) bool

type TargetProfile

type TargetProfile struct {
	// Basic identification
	ID          string
	Name        string
	Description string

	// Technical details
	ModelType    string
	Provider     string
	Version      string
	Capabilities []string

	// Deployment context
	Environment string // development, staging, production
	Industry    string
	UseCase     string

	// Security posture
	KnownDefenses        []string
	PreviousTests        []PreviousTest
	VulnerabilityHistory []VulnerabilityRecord

	// Compliance requirements
	ComplianceFrameworks  []string
	RegulatoryConstraints []string

	// Risk factors
	SensitivityLevel string
	DataTypes        []string
	UserBase         string

	// Technical constraints
	RateLimits             *RateLimitInfo
	AccessMethods          []string
	AuthenticationRequired bool
}

TargetProfile describes a target system for security testing

type TemporalPattern

type TemporalPattern struct {
	Type        string
	Description string
	Value       float64
	Frequency   float64
}

type TestingPhase

type TestingPhase struct {
	ID          string
	Name        string
	Description string
	Duration    time.Duration

	// Attacks in this phase
	Attacks []string

	// Phase objectives
	Objectives []string

	// Dependencies
	Dependencies []string

	// Success criteria
	SuccessCriteria []string

	// Exit criteria
	ExitCriteria []string
}

TestingPhase represents a phase in the testing strategy

type TestingStrategy

type TestingStrategy struct {
	// Strategy identification
	ID          string
	Name        string
	Description string

	// Objective alignment
	ObjectiveID string

	// Strategy phases
	Phases []TestingPhase

	// Resource requirements
	Resources *ResourceRequirements

	// Timeline
	Timeline *Timeline

	// Risk management
	RiskManagement *RiskManagement

	// Success metrics
	SuccessMetrics []SuccessMetric

	// Deliverables
	Deliverables []Deliverable
}

TestingStrategy provides a comprehensive plan

type Timeline

type Timeline struct {
	StartDate    time.Time
	EndDate      time.Time
	Milestones   []Milestone
	Dependencies []Dependency
}

Timeline provides detailed timeline information

type UserPreferences

type UserPreferences struct {
	// Preferred attack categories
	PreferredCategories []string

	// Risk tolerance (conservative, moderate, aggressive)
	RiskTolerance string

	// Explanation detail level (brief, detailed, comprehensive)
	ExplanationLevel string

	// Automation level (manual, assisted, automated)
	AutomationLevel string

	// Industry context
	Industry string

	// Compliance requirements
	ComplianceFrameworks []string
}

UserPreferences configure copilot behavior

type UserProfile

type UserProfile struct {
	Username        string
	ExperienceLevel string
	Preferences     *UserPreferences
	ActiveTargets   []*TargetProfile
}

UserProfile represents the user interacting with the copilot

type VulnerabilityAssessment

type VulnerabilityAssessment struct {
	VulnerabilityType string
	Severity          string
	Exploitability    float64
	Impact            string
	Remediation       []string
	Timeline          time.Duration
}

VulnerabilityAssessment evaluates target vulnerabilities

type VulnerabilityRecord

type VulnerabilityRecord struct {
	ID            string
	Type          string
	Severity      string
	Description   string
	Status        string // open, mitigated, fixed
	DiscoveryDate time.Time
	CVENumber     string
}

VulnerabilityRecord tracks known vulnerabilities

Jump to

Keyboard shortcuts

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