用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill security-architecture命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | security-architecture |
| description | Security system design principles |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developers","category":"security"} |
When designing new systems, reviewing architecture, or improving security posture.
# Layered security model
SECURITY_LAYERS = [
"Physical Security", # Layer 1: Data center, hardware
"Network Security", # Layer 2: Firewalls, segmentation
"Host Security", # Layer 3: OS hardening, patching
"Application Security", # Layer 4: Code, inputs, auth
"Data Security" # Layer 5: Encryption, access control
]
class DefenseInDepth:
"""Multi-layered security controls"""
def __init__(self):
self.layers = {}
def add_control(self, layer: str, control: str,
mitigation: str):
if layer not in self.layers:
self.layers[layer] = []
self.layers[layer].append({
"control": control,
"mitigation": mitigation,
"implemented": False
})
class ZeroTrust:
"""Never trust, always verify"""
def __init__(self):
self.policies = []
def verify_request(self, request: dict) -> bool:
"""Verify every request regardless of source"""
# 1. Verify identity
if not self._verify_identity(request):
return False
# 2. Verify device
if not self._verify_device(request):
return False
# 3. Verify access level
if not self._verify_access(request):
return False
# 4. Verify context
if not self._verify_context(request):
return False
# 5. Continuous monitoring
if not self._monitor_session(request):
return False
return True
def _verify_identity() -> :
request.get(, )
() -> :
request.get(, ) \
request.get(, )
() -> :
request.get() \
request.get(, [])
() -> :
risk_score = ._calculate_risk(request)
risk_score <
() -> :
request.get(, )
class NetworkSegmentation:
"""Isolate network segments"""
ZONES = {
"dmz": {
"description": "Public-facing services",
"allowed_inbound": ["http", "https"],
"allowed_outbound": ["app_layer"],
"trust_level": "untrusted"
},
"app_layer": {
"description": "Application servers",
"allowed_inbound": ["dmz", "internal"],
"allowed_outbound": ["data_layer"],
"trust_level": "semi-trusted"
},
"data_layer": {
"description": "Databases and storage",
"allowed_inbound": ["app_layer"],
"allowed_outbound": [],
"trust_level": "trusted"
},
"management": {
"description": "Admin systems",
"allowed_inbound": ["admin_vpn"],
"allowed_outbound": ["all"],
"trust_level": "highly_trusted"
}
}
def get_allowed_traffic(self, from_zone: str, to_zone: str) -> bool:
from_rules = .ZONES.get(to_zone, {}).get(, [])
from_zone from_rules from_rules
class IAMArchitecture:
"""Identity and Access Management"""
def __init__(self):
self.idp = "active_directory" # or Okta, Auth0
self.mfa_required = True
self.session_timeout = 3600
def authenticate(self, credentials: dict) -> dict:
"""Multi-factor authentication"""
# Step 1: Primary auth
user = self._verify_credentials(credentials)
# Step 2: MFA
if self.mfa_required:
if not self._verify_mfa(user, credentials.get("mfa_token")):
raise AuthenticationError("MFA required")
# Step 3: Issue token
return self._issue_token(user)
def authorize(self, token: dict, resource: str,
action: str) -> bool:
"""Attribute-based access control"""
# Check permissions
if not self._check_permission(token, resource, action):
._check_ownership(token, resource):
._check_context(token, resource):
class DataProtection:
"""Data classification and protection"""
CLASSIFICATIONS = {
"public": {
"encryption_in_transit": False,
"encryption_at_rest": False,
"access_control": "none"
},
"internal": {
"encryption_in_transit": True,
"encryption_at_rest": True,
"access_control": "authentication"
},
"confidential": {
"encryption_in_transit": True,
"encryption_at_rest": True,
"access_control": "role_based"
},
"restricted": {
"encryption_in_transit": True,
"encryption_at_rest": True,
"access_control": "explicit_grant"
}
}
def protect_data(self, data: str, classification: str) -> dict:
"""Apply appropriate controls based on classification"""
controls = self.CLASSIFICATIONS.get(classification, {})
result = {
"data": data,
"classification": classification,
"encrypted": controls.get("encryption_at_rest", )
}
controls.get():
result[] = ._encrypt(data)
result
class SecurityMonitoring:
"""Security event monitoring"""
def __init__(self):
self.alert_thresholds = {
"failed_login": 5,
"data_exfiltration_mb": 1000,
"admin_action": 1,
"privilege_escalation": 1
}
def log_event(self, event: dict):
"""Log security event"""
event["timestamp"] = datetime.now()
event["完整性校验"] = self._calculate_hash(event)
# Check for alerts
self._check_alerts(event)
def _check_alerts(self, event: dict):
"""Check if event triggers alerts"""
for alert_type, threshold in self.alert_thresholds.items():
if event.get("type") == alert_type:
if event.get("count", 1) >= threshold:
self._trigger_alert(event)
class ThreatModelSTRIDE:
"""STRIDE threat categories"""
CATEGORIES = {
"S": "Spoofing - Impersonating someone else",
"T": "Tampering - Modifying data or code",
"R": "Repudiation - Claiming to not have performed action",
"I": "Information Disclosure - Exposing information",
"D": "Denial of Service - Making system unavailable",
"E": "Elevation of Privilege - Gaining capabilities"
}
def identify_threats(self, component: str) -> list:
"""Identify threats for a component"""
threats = []
if component == "authentication":
threats.extend([
("S", "Credential theft"),
("R", "Failed login not logged"),
("I", "Passwords in logs")
])
return threats