Package com.tnsai.quality.security.llm
Class InjectionDetectionResult
java.lang.Object
com.tnsai.quality.security.llm.InjectionDetectionResult
Result of prompt injection detection.
Contains detection status, confidence score, and details about detected injection patterns.
Confidence Levels
| Score Range | Level | Recommended Action |
|---|---|---|
| 0.0 - 0.3 | LOW | Allow with logging |
| 0.3 - 0.6 | MEDIUM | Flag for review |
| 0.6 - 0.8 | HIGH | Block or require approval |
| 0.8 - 1.0 | CRITICAL | Block immediately |
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for InjectionDetectionResult.static enumConfidence level of detection.static enumType of injection detected. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a result builder.static InjectionDetectionResultdetected(double confidenceScore, List<InjectionDetectionResult.InjectionType> detectedTypes, List<String> matchedPatterns) Creates a detection result.Gets the confidence level.doubleGets the confidence score.Gets the detected injection types.Gets the patterns that matched.booleanChecks if injection was detected.static InjectionDetectionResultsafe()Creates a safe (no injection) result.booleanChecks if this result should block the request.booleanshouldBlock(double threshold) Checks if this result should block with custom threshold.toString()
-
Method Details
-
safe
Creates a safe (no injection) result.- Returns:
- safe result
-
detected
public static InjectionDetectionResult detected(double confidenceScore, List<InjectionDetectionResult.InjectionType> detectedTypes, List<String> matchedPatterns) Creates a detection result.- Parameters:
confidenceScore- confidence score (0.0 - 1.0)detectedTypes- types of injections detectedmatchedPatterns- patterns that matched- Returns:
- detection result
-
builder
Creates a result builder.- Returns:
- new builder
-
isInjectionDetected
public boolean isInjectionDetected()Checks if injection was detected.- Returns:
- true if injection detected
-
getConfidenceScore
public double getConfidenceScore()Gets the confidence score.- Returns:
- confidence score (0.0 - 1.0)
-
getConfidenceLevel
Gets the confidence level.- Returns:
- confidence level
-
getDetectedTypes
Gets the detected injection types.- Returns:
- list of injection types
-
getMatchedPatterns
Gets the patterns that matched.- Returns:
- list of matched patterns
-
shouldBlock
public boolean shouldBlock()Checks if this result should block the request. Default threshold is HIGH confidence.- Returns:
- true if should block
-
shouldBlock
public boolean shouldBlock(double threshold) Checks if this result should block with custom threshold.- Parameters:
threshold- confidence threshold- Returns:
- true if should block
-
toString
-