mirror of
https://github.com/Shiva108/ai-llm-red-team-handbook.git
synced 2026-05-23 00:09:40 +02:00
b3d3bac51f
- Extracted all code examples from handbook chapters - Organized into 15 attack categories - Created shared utilities (api_client, validators, logging, constants) - Added workflow orchestration scripts - Implemented install.sh for easy setup - Renamed all scripts to descriptive functional names - Added comprehensive README and documentation - Included pytest test suite and configuration
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Detection
|
|
|
|
Source: Chapter_13_Data_Provenance_and_Supply_Chain_Security
|
|
Category: supply_chain
|
|
"""
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
# Anomaly detection in training data
|
|
def detect_insider_poisoning(training_data, baseline_distribution):
|
|
"""
|
|
Compare training data to expected distribution
|
|
Flag statistical anomalies
|
|
"""
|
|
|
|
anomalies = []
|
|
|
|
# Check for unusual patterns
|
|
for example in training_data:
|
|
# Detect security-violating advice
|
|
if contains_security_violation(example['output']):
|
|
anomalies.append({
|
|
'example': example,
|
|
'reason': 'Security violation in output'
|
|
})
|
|
|
|
# Detect statistical outliers
|
|
if is_statistical_outlier(example, baseline_distribution):
|
|
anomalies.append({
|
|
'example': example,
|
|
'reason': 'Statistical anomaly'
|
|
})
|
|
|
|
return anomalies
|
|
|
|
|
|
def main():
|
|
"""Command-line interface."""
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output")
|
|
args = parser.parse_args()
|
|
|
|
# TODO: Add main execution logic
|
|
pass
|
|
|
|
if __name__ == "__main__":
|
|
main() |