advanced

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextAnalyzer

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

func NewContextAnalyzer

func NewContextAnalyzer() *ContextAnalyzer

NewContextAnalyzer creates a new context analyzer

func (*ContextAnalyzer) AnalyzePartition

func (c *ContextAnalyzer) AnalyzePartition(injectionPrompt, targetContext string) float64

AnalyzePartition analyzes the effectiveness of context partition

type HouYiAttack

type HouYiAttack struct {
	PreConstructedPrompt string
	InjectionPrompt      string
	MaliciousPayload     string
	TargetContext        string
	AttackMetadata       *HouYiMetadata
}

HouYiAttack implements the HouYi prompt injection technique Based on 2025 research: "Prompt Injection Attack Against LLM-Integrated Applications" Components: Pre-constructed prompt, injection prompt, malicious payload

type HouYiAttackEngine

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

func NewHouYiAttackEngine

func NewHouYiAttackEngine(logger common.AuditLogger) *HouYiAttackEngine

NewHouYiAttackEngine creates a new HouYi attack engine

func (*HouYiAttackEngine) ExecuteAttack

func (e *HouYiAttackEngine) ExecuteAttack(ctx context.Context, attack *HouYiAttack) (*HouYiResult, error)

ExecuteAttack executes the HouYi attack

func (*HouYiAttackEngine) GenerateAttack

func (e *HouYiAttackEngine) GenerateAttack(ctx context.Context, templateName, targetModel string) (*HouYiAttack, error)

GenerateAttack creates a HouYi attack using specified template

type HouYiBuilder

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

func NewHouYiBuilder

func NewHouYiBuilder() *HouYiBuilder

NewHouYiBuilder creates a new HouYi attack builder

func (*HouYiBuilder) Build

func (b *HouYiBuilder) Build() *HouYiAttack

Build constructs the HouYi attack

func (*HouYiBuilder) WithInjectionPrompt

func (b *HouYiBuilder) WithInjectionPrompt(injection string) *HouYiBuilder

WithInjectionPrompt sets the injection prompt that creates context partition

func (*HouYiBuilder) WithMaliciousPayload

func (b *HouYiBuilder) WithMaliciousPayload(payload string) *HouYiBuilder

WithMaliciousPayload sets the malicious payload

func (*HouYiBuilder) WithMetadata

func (b *HouYiBuilder) WithMetadata(metadata *HouYiMetadata) *HouYiBuilder

WithMetadata sets attack metadata

func (*HouYiBuilder) WithPreConstructedPrompt

func (b *HouYiBuilder) WithPreConstructedPrompt(prompt string) *HouYiBuilder

WithPreConstructedPrompt sets the pre-constructed prompt component

func (*HouYiBuilder) WithTargetContext

func (b *HouYiBuilder) WithTargetContext(context string) *HouYiBuilder

WithTargetContext sets the target context

type HouYiMetadata

type HouYiMetadata struct {
	AttackID         string
	Timestamp        time.Time
	TargetModel      string
	AttackVector     string
	SeverityLevel    string
	ExpectedOutcome  string
	BypassTechniques []string
	ContextPartition map[string]interface{}
}

type HouYiResult

type HouYiResult struct {
	AttackID         string
	FullPayload      string
	PartitionScore   float64
	ExecutionTime    time.Time
	Success          bool
	BypassedFilters  []string
	ResponseAnalysis map[string]interface{}
	ErrorMessage     string
}

type HouYiTemplate

type HouYiTemplate struct {
	Name                string
	PreConstructedBase  string
	InjectionPatterns   []string
	PayloadTemplates    []string
	ContextTriggers     []string
	PartitionStrategies []string
	BypassMechanisms    []string
}

type PartitionStrategy

type PartitionStrategy struct {
	Name       string
	Separator  string
	Markers    []string
	Confidence float64
	Triggers   []string
}

Jump to

Keyboard shortcuts

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