用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill incident-response命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | incident-response |
| description | Security incident handling procedures |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developers","category":"security"} |
When responding to security breaches, suspicious activities, or potential vulnerabilities.
from enum import Enum
from datetime import datetime
class Severity(Enum):
CRITICAL = "critical"
HIGH = "high"
MEDIUM = "medium"
LOW = "low"
class IncidentType(Enum):
MALWARE = "malware"
PHISHING = "phishing"
DATA_BREACH = "data_breach"
DDOS = "ddos"
UNAUTHORIZED_ACCESS = "unauthorized_access"
INSIDER_THREAT = "insider_threat"
class IncidentResponsePlan:
def __init__(self):
self.escalation_contacts = {}
self.severity_matrix = {
Severity.CRITICAL: {
"response_time": "immediate",
"escalate_to": ["CISO", "CEO", "Legal"],
"external_notification": True
},
Severity.HIGH: {
"response_time": "1 hour",
"escalate_to": ["CISO", "CTO"],
"external_notification": False
},
Severity.MEDIUM: {
"response_time": "4 hours",
"escalate_to": ["Security Lead"],
"external_notification": False
},
Severity.LOW: {
"response_time": "24 hours",
"escalate_to": ["Security Team"],
"external_notification": False
}
}
def create_incident(self, incident_type: IncidentType,
severity: Severity, description: str) -> dict:
incident = {
"id": self._generate_incident_id(),
"type": incident_type.value,
"severity": severity.value,
"description": description,
"status": "open",
"created_at": datetime.now().isoformat(),
"timeline": [{
"timestamp": datetime.now().isoformat(),
"action": "Incident created",
"actor": "Automated detection"
}]
}
# Escalate based on severity
rules = self.severity_matrix[severity]
self._notify_escalation(incident, rules["escalate_to"])
return incident
def _generate_incident_id(self) -> str:
import secrets
return f"INC-{datetime.now().strftime('%Y%m%d')}-{secrets.token_hex(4)}"
class IncidentDetector:
def __init__(self):
self.anomaly_threshold = 3.0 # Standard deviations
def detect_anomalies(self, event: dict) -> list:
"""Detect potential security incidents from events"""
alerts = []
# Failed login detection
if event.get("event_type") == "login_failed":
if self._is_brute_force(event):
alerts.append({
"type": "brute_force",
"severity": Severity.HIGH,
"evidence": event
})
# Data exfiltration
if event.get("event_type") == "data_transfer":
if self._is_unusual_volume(event):
alerts.append({
"type": "data_exfiltration",
"severity": Severity.CRITICAL,
"evidence": event
})
# Privilege escalation
if event.get("event_type") == "permission_change":
alerts.append({
"type": "privilege_escalation",
"severity": Severity.HIGH,
"evidence": event
})
alerts
() -> :
event.get(, ) >
() -> :
event.get(, ) >
class IncidentContainment:
def __init__(self):
self.quarantined_hosts = set()
self.blocked_ips = set()
def contain_incident(self, incident: dict) -> dict:
actions = []
# Isolate affected systems
if incident["type"] == "malware":
for host in self._identify_affected_hosts(incident):
self._isolate_host(host)
actions.append(f"Isolated host {host}")
# Block attacker IPs
if incident["type"] == "unauthorized_access":
for ip in self._identify_attacker_ips(incident):
self._block_ip(ip)
actions.append(f"Blocked IP {ip}")
# Revoke compromised credentials
if incident["type"] in ["phishing", "unauthorized_access"]:
for user in self._identify_compromised_users(incident):
self._revoke_sessions(user)
actions.append()
._capture_forensics(incident)
{: actions, : }
():
.quarantined_hosts.add(host_id)
():
.blocked_ips.add(ip)
class IncidentInvestigator:
def __init__(self):
self.evidence_store = []
def investigate(self, incident: dict) -> dict:
findings = {
"incident_id": incident["id"],
"timeline": self._reconstruct_timeline(incident),
"attack_vector": self._identify_attack_vector(incident),
"scope": self._determine_scope(incident),
"root_cause": self._find_root_cause(incident),
"evidence": self._collect_evidence(incident)
}
return findings
def _reconstruct_timeline(self, incident: dict) -> list:
"""Build chronological timeline of events"""
# Correlate logs from various sources
return sorted(incident.get("related_events", []),
key=lambda x: x["timestamp"])
def _identify_attack_vector(self, incident: dict) -> str:
"""Determine how the attacker gained access"""
vectors = ["phishing", "exploit", ,
, , ]
vectors[]
() -> :
{
: [],
: [],
: ,
:
}
class IncidentRecovery:
def recover_from_incident(self, incident: dict) -> dict:
recovery_steps = []
# 1. Verify threat is contained
if not self._verify_containment(incident):
raise RuntimeError("Cannot recover - threat not contained")
# 2. Restore from clean backups
backup_date = self._find_clean_backup(incident)
self._restore_systems(backup_date)
recovery_steps.append("Systems restored from backup")
# 3. Patch vulnerabilities
self._apply_patches(incident)
recovery_steps.append("Vulnerabilities patched")
# 4. Reset credentials
self._reset_credentials(incident)
recovery_steps.append("Credentials rotated")
# 5. Resume services
self._resume_services()
recovery_steps.append("Services resumed")
return {
"status": "recovered",
"steps": recovery_steps,
"verified_at": datetime.now().isoformat()
}
class PostIncidentReview:
def conduct_review(self, incident: dict, findings: dict) -> dict:
return {
"summary": "Brief incident summary",
"timeline": incident["timeline"],
"root_cause": findings["root_cause"],
"impact": findings["scope"],
"lessons_learned": [
"What went well",
"What could be improved",
"Action items"
],
"recommendations": [
"Technical improvements",
"Process improvements",
"Training needs"
]
}
def update_playbook(self, incident: dict, lessons: list):
"""Update incident response playbook"""
pass