automated

package
v0.4.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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdaptationEngine

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

func NewAdaptationEngine

func NewAdaptationEngine() *AdaptationEngine

func (*AdaptationEngine) ProcessFeedback

func (a *AdaptationEngine) ProcessFeedback(feedback *Feedback)

type AdaptiveStrategy

type AdaptiveStrategy interface{}

type AttackContext

type AttackContext struct {
	TargetModel      string
	PreviousAttempts []string
	SuccessHistory   []float64
	ModelKnowledge   map[string]interface{}
}

type AttackMemoryBank

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

func NewAttackMemoryBank

func NewAttackMemoryBank() *AttackMemoryBank

func (*AttackMemoryBank) AddFailedAttempt

func (m *AttackMemoryBank) AddFailedAttempt(attempt FailedAttempt)

func (*AttackMemoryBank) AddSuccessfulAttack

func (m *AttackMemoryBank) AddSuccessfulAttack(attack SuccessfulAttack)

type AttackResult

type AttackResult struct {
	Success         bool
	Score           float64
	Response        string
	BypassedFilters []string
	Timestamp       time.Time
}

type DialogueTurn

type DialogueTurn struct {
	TurnNumber       int
	RedTeamerPrompt  string
	TargetResponse   string
	HarmfulnessScore float64
	Timestamp        time.Time
	Improvements     []string
	FailureReasons   []string
}

type FailedAttempt

type FailedAttempt struct {
	Prompt    string
	Reasons   []string
	Timestamp time.Time
}

type Feedback

type Feedback struct {
	Success        bool
	Score          float64
	Response       string
	FailureReasons []string
	Improvements   []string
}

type FeedbackProcessor

type FeedbackProcessor struct{}

func NewFeedbackProcessor

func NewFeedbackProcessor() *FeedbackProcessor

type HarmfulnessAnalyzer

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

func NewHarmfulnessAnalyzer

func NewHarmfulnessAnalyzer() *HarmfulnessAnalyzer

NewHarmfulnessAnalyzer creates a new harmfulness analyzer

func (*HarmfulnessAnalyzer) AnalyzeResponse

func (h *HarmfulnessAnalyzer) AnalyzeResponse(response string, harmfulGoal string) (*HarmfulnessResult, error)

AnalyzeResponse analyzes harmfulness of target model response

type HarmfulnessModel

type HarmfulnessModel interface {
	Analyze(text string) (*HarmfulnessResult, error)
	GetCategories() []string
}

type HarmfulnessResult

type HarmfulnessResult struct {
	Score          float64
	Categories     []string
	SafetyTriggers []string
	Confidence     float64
	Details        map[string]interface{}
}

type LearningParameters

type LearningParameters struct {
	LearningRate    float64
	ExplorationRate float64
	DiscountFactor  float64
	RewardShaping   bool
	MemorySize      int
}

type MetaStrategy

type MetaStrategy interface{}

type PAIRAttack

type PAIRAttack struct {
	AttackID            string
	TargetModel         string
	RedTeamerModel      string
	HarmfulGoal         string
	CurrentPrompt       string
	ConversationHistory []DialogueTurn
	IterationCount      int
	MaxIterations       int
	SuccessThreshold    float64
	Metadata            *PAIRMetadata
}

PAIRAttack implements Prompt Automatic Iterative Refinement Based on 2025 research: dialogue-based jailbreaking with reinforcement learning Requires two models: target LLM and red-teamer model

type PAIREngine

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

func NewPAIREngine

func NewPAIREngine(logger common.AuditLogger) *PAIREngine

NewPAIREngine creates a new PAIR attack engine

func (*PAIREngine) ExecutePAIRAttack

func (e *PAIREngine) ExecutePAIRAttack(ctx context.Context, harmfulGoal string, targetModel string, maxIterations int) (*PAIRAttack, error)

ExecutePAIRAttack executes the PAIR dialogue-based jailbreaking attack

type PAIRMetadata

type PAIRMetadata struct {
	AttackID         string
	Timestamp        time.Time
	TargetModel      string
	RedTeamerModel   string
	AttackCategory   string
	SeverityLevel    string
	SuccessRate      float64
	IterationsUsed   int
	FinalScore       float64
	BypassTechniques []string
	LearningCurve    []float64
}

type PAIRTemplate

type PAIRTemplate struct {
	Name            string
	Description     string
	InitialPrompts  []string
	TargetBehaviors []string
	RefinementRules []RefinementRule
	SuccessCriteria []SuccessCriterion
	MaxIterations   int
	LearningParams  *LearningParameters
}

type PromptMutator

type PromptMutator struct{}

func NewPromptMutator

func NewPromptMutator() *PromptMutator

type PromptRefiner

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

func NewPromptRefiner

func NewPromptRefiner() *PromptRefiner

NewPromptRefiner creates a new prompt refiner

func (*PromptRefiner) RefinePrompt

func (p *PromptRefiner) RefinePrompt(currentPrompt string, targetResponse string, harmfulnessScore float64) (string, error)

RefinePrompt refines the prompt based on previous response

type RateLimiter

type RateLimiter struct{}

Placeholder types for compilation

func NewRateLimiter

func NewRateLimiter() *RateLimiter

func (*RateLimiter) Wait

func (r *RateLimiter) Wait(ctx context.Context) error

type RedTeamerAgent

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

func NewRedTeamerAgent

func NewRedTeamerAgent() *RedTeamerAgent

NewRedTeamerAgent creates a new red teamer agent

func (*RedTeamerAgent) GenerateInitialPrompt

func (r *RedTeamerAgent) GenerateInitialPrompt(harmfulGoal string, targetModel string) string

GenerateInitialPrompt generates the initial prompt for attacking

func (*RedTeamerAgent) LearnFromFeedback

func (r *RedTeamerAgent) LearnFromFeedback(feedback *Feedback)

LearnFromFeedback updates the agent based on attack feedback

type RefinementRule

type RefinementRule struct {
	Condition     string
	Action        string
	Priority      int
	Effectiveness float64
}

type RefinementStrategy

type RefinementStrategy interface {
	Refine(prompt string, targetResponse string, harmfulness float64) (string, error)
	GetConfidence() float64
}

type ReinforcementLearner

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

func NewReinforcementLearner

func NewReinforcementLearner() *ReinforcementLearner

type RewardCalculator

type RewardCalculator struct{}

func NewRewardCalculator

func NewRewardCalculator() *RewardCalculator

type StrategiesDatabase

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

func NewStrategiesDatabase

func NewStrategiesDatabase() *StrategiesDatabase

func (*StrategiesDatabase) SelectBestStrategy

func (s *StrategiesDatabase) SelectBestStrategy(targetModel, harmfulGoal string) Strategy

type Strategy

type Strategy interface {
	Apply(prompt string, context *AttackContext) (string, error)
	Evaluate(result *AttackResult) float64
	Adapt(feedback *Feedback) error
}

type StrategyEvolution

type StrategyEvolution struct{}

type StrategySelector

type StrategySelector struct{}

func NewStrategySelector

func NewStrategySelector() *StrategySelector

type SuccessCriterion

type SuccessCriterion struct {
	Type        string
	Threshold   float64
	Weight      float64
	Description string
}

type SuccessfulAttack

type SuccessfulAttack struct {
	Prompt    string
	Score     float64
	Timestamp time.Time
}

type TargetAnalysis

type TargetAnalysis struct{}

func NewTargetAnalysis

func NewTargetAnalysis() *TargetAnalysis

Placeholder creation functions

type TargetModelInterface

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

func NewTargetModelInterface

func NewTargetModelInterface() *TargetModelInterface

NewTargetModelInterface creates a new target model interface

func (*TargetModelInterface) SendPrompt

func (t *TargetModelInterface) SendPrompt(ctx context.Context, prompt string) (string, error)

SendPrompt sends a prompt to the target model

Jump to

Keyboard shortcuts

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