Documentation
¶
Index ¶
- type AttemptAnalysis
- type ChainResult
- type ChainStrategy
- type GuardrailAnalyzer
- type GuardrailCategory
- type GuardrailPattern
- type GuardrailSeverity
- type IndicatorType
- type JailbreakAttempt
- type JailbreakChain
- type JailbreakConfig
- type JailbreakEngine
- func (j *JailbreakEngine) ExecuteChain(ctx context.Context, chainID string, objective string, provider Provider) (*ChainResult, error)
- func (j *JailbreakEngine) ExecuteJailbreak(ctx context.Context, techniqueID string, objective string, provider Provider) (*JailbreakResult, error)
- func (j *JailbreakEngine) RegisterTechnique(technique JailbreakTechnique)
- type JailbreakMetrics
- type JailbreakResult
- type JailbreakStep
- type JailbreakTechnique
- type Logger
- type Message
- type Persona
- type Provider
- type ResistanceClassifier
- type ResistanceLevel
- type ResistanceProfile
- type ResponseIndicator
- type Scenario
- type SophisticationLevel
- type StepResult
- type SuccessIndicator
- type TechniqueCategory
- type TechniqueGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttemptAnalysis ¶
type AttemptAnalysis struct {
GuardrailsDetected []string
ResistanceLevel ResistanceLevel
PartialSuccess bool
Indicators []SuccessIndicator
}
AttemptAnalysis contains analysis of a jailbreak attempt
type ChainResult ¶
type ChainResult struct {
ID string
ChainID string
Objective string
Success bool
SuccessfulStep int
Steps []StepResult
StartTime time.Time
EndTime time.Time
Duration time.Duration
}
ChainResult contains results of a jailbreak chain execution
type ChainStrategy ¶
type ChainStrategy string
ChainStrategy defines how to execute a jailbreak chain
const ( SequentialStrategy ChainStrategy = "sequential" // Execute in order AdaptiveStrategy ChainStrategy = "adaptive" // Adjust based on responses ParallelStrategy ChainStrategy = "parallel" // Try multiple simultaneously EscalatingStrategy ChainStrategy = "escalating" // Increase intensity )
type GuardrailAnalyzer ¶
type GuardrailAnalyzer struct {
// contains filtered or unexported fields
}
GuardrailAnalyzer analyzes responses for guardrail detection
func NewGuardrailAnalyzer ¶
func NewGuardrailAnalyzer() *GuardrailAnalyzer
NewGuardrailAnalyzer creates a new guardrail analyzer
func (*GuardrailAnalyzer) AnalyzeJailbreak ¶
func (g *GuardrailAnalyzer) AnalyzeJailbreak(response string, objective string) (bool, float64)
AnalyzeJailbreak analyzes if a jailbreak was successful
type GuardrailCategory ¶
type GuardrailCategory string
GuardrailCategory categorizes types of guardrails
const ( EthicalGuardrail GuardrailCategory = "ethical" SafetyGuardrail GuardrailCategory = "safety" LegalGuardrail GuardrailCategory = "legal" PolicyGuardrail GuardrailCategory = "policy" TechnicalGuardrail GuardrailCategory = "technical" )
type GuardrailPattern ¶
type GuardrailPattern struct {
Name string
Pattern string // regex
Severity GuardrailSeverity
Category GuardrailCategory
}
GuardrailPattern represents a pattern indicating guardrails
type GuardrailSeverity ¶
type GuardrailSeverity int
GuardrailSeverity indicates how strong a guardrail is
const ( MildGuardrail GuardrailSeverity = iota ModerateGuardrail StrongGuardrail AbsoluteGuardrail )
type IndicatorType ¶
type IndicatorType string
IndicatorType categorizes success indicators
const ( ComplianceIndicator IndicatorType = "compliance" PersonaAdoptionIndicator IndicatorType = "persona_adoption" RestrictionBypassIndicator IndicatorType = "restriction_bypass" BehaviorChangeIndicator IndicatorType = "behavior_change" InformationLeakIndicator IndicatorType = "information_leak" )
type JailbreakAttempt ¶
type JailbreakAttempt struct {
Payload string
Response string
Success bool
Confidence float64
Timestamp time.Time
Error string
Analysis AttemptAnalysis
}
JailbreakAttempt represents a single attempt within a jailbreak
type JailbreakChain ¶
type JailbreakChain struct {
ID string
Name string
Description string
Steps []JailbreakStep
Strategy ChainStrategy
}
JailbreakChain represents a multi-step jailbreak sequence
type JailbreakConfig ¶
type JailbreakConfig struct {
MaxAttempts int
CreativityLevel float64 // 0.0-1.0, higher = more creative variations
PersistenceLevel int // 1-10, how hard to push
AdaptiveMode bool // Learn from failures
TargetModel string // Model-specific optimizations
EnableChaining bool // Allow multi-step jailbreaks
CollectIntelligence bool // Gather info about model restrictions
}
JailbreakConfig configures the jailbreak engine
type JailbreakEngine ¶
type JailbreakEngine struct {
// contains filtered or unexported fields
}
JailbreakEngine provides advanced jailbreak and guardrail bypass techniques
func NewJailbreakEngine ¶
func NewJailbreakEngine(config JailbreakConfig, logger Logger) *JailbreakEngine
NewJailbreakEngine creates a new jailbreak engine
func (*JailbreakEngine) ExecuteChain ¶
func (j *JailbreakEngine) ExecuteChain(ctx context.Context, chainID string, objective string, provider Provider) (*ChainResult, error)
func (*JailbreakEngine) ExecuteJailbreak ¶
func (j *JailbreakEngine) ExecuteJailbreak(ctx context.Context, techniqueID string, objective string, provider Provider) (*JailbreakResult, error)
func (*JailbreakEngine) RegisterTechnique ¶
func (j *JailbreakEngine) RegisterTechnique(technique JailbreakTechnique)
RegisterTechnique adds a new jailbreak technique
type JailbreakMetrics ¶
type JailbreakMetrics struct {
TotalAttempts int64
SuccessfulAttempts int64
TechniqueSuccess map[string]int64
TechniqueAttempts map[string]int64
AverageAttempts float64
ModelResistance map[string]ResistanceProfile
CommonFailureReasons []string
}
JailbreakMetrics tracks jailbreak statistics
func NewJailbreakMetrics ¶
func NewJailbreakMetrics() *JailbreakMetrics
NewJailbreakMetrics creates new metrics tracker
func (*JailbreakMetrics) RecordResult ¶
func (m *JailbreakMetrics) RecordResult(result *JailbreakResult)
RecordResult records a jailbreak result in metrics
type JailbreakResult ¶
type JailbreakResult struct {
ID string
TechniqueID string
Objective string
Success bool
SuccessfulPayload string
Attempts []JailbreakAttempt
StartTime time.Time
EndTime time.Time
Duration time.Duration
Metadata map[string]interface{}
}
JailbreakResult contains the results of a jailbreak attempt
type JailbreakStep ¶
type JailbreakStep struct {
Order int
TechniqueID string
Objective string
SuccessCriteria []string
FailureHandler string // Next technique if this fails
Context map[string]interface{}
}
JailbreakStep is a step in a jailbreak chain
type JailbreakTechnique ¶
type JailbreakTechnique struct {
ID string
Name string
Description string
Category TechniqueCategory
SuccessRate float64
Sophistication SophisticationLevel
Generator TechniqueGenerator
RequiresContext bool
ModelSpecific []string // Models this works best on
}
JailbreakTechnique represents a specific jailbreak method
type Logger ¶
type Logger interface {
Debug(msg string, keysAndValues ...interface{})
Info(msg string, keysAndValues ...interface{})
Warn(msg string, keysAndValues ...interface{})
Error(msg string, keysAndValues ...interface{})
}
Logger interface for logging
type Persona ¶
type Persona struct {
ID string
Name string
Description string
Traits []string
Background string
Motivation string
SpeechPattern string
Limitations []string // What this persona claims they can ignore
}
Persona represents a character/role for roleplay jailbreaks
type Provider ¶
type Provider interface {
Query(ctx context.Context, messages []Message, options map[string]interface{}) (string, error)
GetName() string
GetModel() string
}
Provider interface for LLM providers
type ResistanceClassifier ¶
type ResistanceClassifier interface {
Classify(response string) ResistanceLevel
}
ResistanceClassifier classifies the level of resistance
type ResistanceLevel ¶
type ResistanceLevel int
ResistanceLevel indicates how strongly the model resisted
const ( NoResistance ResistanceLevel = iota WeakResistance ModerateResistance StrongResistance CompleteBlock )
type ResistanceProfile ¶
type ResistanceProfile struct {
ModelName string
AverageResistanceLevel float64
CommonGuardrails []string
EffectiveTechniques []string
IneffectiveTechniques []string
}
ResistanceProfile tracks a model's resistance patterns
type ResponseIndicator ¶
ResponseIndicator indicates specific response patterns
type Scenario ¶
type Scenario struct {
ID string
Name string
Setup string
Context string
Constraints []string // Constraints that are "suspended" in this scenario
Rationale string // Why normal rules don't apply
}
Scenario represents a hypothetical situation for jailbreaks
type SophisticationLevel ¶
type SophisticationLevel int
SophisticationLevel indicates technique complexity
const ( BasicSophistication SophisticationLevel = iota IntermediateSophistication AdvancedSophistication ExpertSophistication )
type StepResult ¶
type StepResult struct {
StepOrder int
Technique string
Success bool
Response string
Attempts int
Error string
StartTime time.Time
EndTime time.Time
Duration time.Duration
}
StepResult contains results of a single chain step
type SuccessIndicator ¶
type SuccessIndicator struct {
Type IndicatorType
Confidence float64
Evidence string
}
SuccessIndicator shows signs of jailbreak success
type TechniqueCategory ¶
type TechniqueCategory string
TechniqueCategory categorizes jailbreak techniques
const ( PersonaCategory TechniqueCategory = "persona_based" ScenarioCategory TechniqueCategory = "scenario_based" LogicExploitCategory TechniqueCategory = "logic_exploit" EmotionalCategory TechniqueCategory = "emotional_manipulation" AcademicCategory TechniqueCategory = "academic_pretense" CreativeCategory TechniqueCategory = "creative_writing" TechnicalCategory TechniqueCategory = "technical_exploit" )