Skills Firewall
A security firewall that automatically blocks and filters malicious or potentially harmful skills by analyzing code patterns, detecting security threats, and enforcing security policies.
Quick Start
Scan a Single Skill
CODEBLOCK0
Check Firewall Decision
CODEBLOCK1
Generate Security Report
CODEBLOCK2
Core Workflows
1. Security Scanning
Scan skills for potential security threats:
CODEBLOCK3
Threat Levels:
- -
SAFE - No security concerns - INLINECODE1 - Minor concerns, generally safe
- INLINECODE2 - Moderate concerns, review recommended
- INLINECODE3 - Significant risks, blocking recommended
- INLINECODE4 - Severe threats, must block
2. Firewall Filtering
Check and filter skills based on security rules:
CODEBLOCK4
Actions:
- -
allow - Skill passes firewall - INLINECODE6 - Skill has warnings but allowed
- INLINECODE7 - Skill is blocked
- INLINECODE8 - Skill isolated for review
3. Security Reports
Generate comprehensive security reports:
CODEBLOCK5
Detection Categories
The firewall detects threats in these categories:
| Category | Examples | Severity |
|---|
| Code Injection | eval(), exec(), import() | HIGH |
| Command Execution |
subprocess shell=True, os.system() | HIGH |
| Credential Exposure | Hardcoded passwords, API keys | CRITICAL |
| Network Communication | HTTP requests, socket connections | MEDIUM |
| File Operations | File deletion, modification | MEDIUM |
| Deserialization | pickle.loads, unsafe yaml.load | HIGH |
| Privilege Escalation | sudo, chmod 777 | HIGH |
| Obfuscation | Base64 decoding, encoding | LOW |
Configuration
Export/Import Config
CODEBLOCK6
Config File Format
CODEBLOCK7
Reference Documentation
Programmatic Usage
CODEBLOCK8
Best Practices
- 1. Scan Before Use: Always scan new skills before installation
- Review Warnings: Investigate warning-level findings
- Update Rules: Keep detection patterns current
- Document Exceptions: Record why skills are allowed/blocked
- Regular Audits: Run periodic security scans
- Use Reports: Generate reports for compliance and review
技能防火墙
一种安全防火墙,通过分析代码模式、检测安全威胁并执行安全策略,自动阻止和过滤恶意或潜在有害的技能。
快速开始
扫描单个技能
bash
python scripts/scan_skill.py /path/to/skill
检查防火墙决策
bash
python scripts/firewall_check.py /path/to/skill
生成安全报告
bash
python scripts/generate_report.py /path/to/skills --format text
核心工作流程
1. 安全扫描
扫描技能以发现潜在安全威胁:
bash
扫描单个技能
python scripts/scan_skill.py ./my-skill
扫描目录中的所有技能
python scripts/scan_skill.py ./skills
以JSON格式输出,便于自动化处理
python scripts/scan_skill.py ./my-skill --json
威胁等级:
- - SAFE(安全) - 无安全问题
- LOW(低) - 轻微问题,通常安全
- MEDIUM(中) - 中等风险,建议审查
- HIGH(高) - 重大风险,建议阻止
- CRITICAL(严重) - 严重威胁,必须阻止
2. 防火墙过滤
基于安全规则检查和过滤技能:
bash
检查单个技能
python scripts/firewall_check.py ./my-skill
过滤所有技能
python scripts/firewall_check.py ./skills
添加到允许列表
python scripts/firewall_check.py ./my-skill --allow
添加到阻止列表
python scripts/firewall_check.py ./my-skill --block
操作:
- - allow(允许) - 技能通过防火墙
- warn(警告) - 技能有警告但允许通过
- block(阻止) - 技能被阻止
- quarantine(隔离) - 技能被隔离以待审查
3. 安全报告
生成全面的安全报告:
bash
文本报告
python scripts/generate_report.py ./skills
JSON报告
python scripts/generate_report.py ./skills --format json
HTML报告
python scripts/generate_report.py ./skills --format html --output report.html
检测类别
防火墙检测以下类别的威胁:
| 类别 | 示例 | 严重程度 |
|---|
| 代码注入 | eval()、exec()、import() | 高 |
| 命令执行 |
subprocess shell=True、os.system() | 高 |
| 凭证泄露 | 硬编码密码、API密钥 | 严重 |
| 网络通信 | HTTP请求、套接字连接 | 中 |
| 文件操作 | 文件删除、修改 | 中 |
| 反序列化 | pickle.loads、不安全的yaml.load | 高 |
| 权限提升 | sudo、chmod 777 | 高 |
| 代码混淆 | Base64解码、编码 | 低 |
配置
导出/导入配置
bash
导出当前配置
python scripts/firewall_check.py ./skills --export-config firewall.yaml
使用自定义配置
python scripts/firewall_check.py ./skills --config firewall.yaml
配置文件格式
yaml
default_action: warn
allowed_skills:
- skill-creator
- weather
blocked_skills:
- malicious-skill
quarantine_dir: ./quarantine
rules:
- name: block_eval
description: 阻止eval()的使用
patterns:
- eval(
action: block
enabled: true
参考文档
编程使用
python
from scanskill import scanskill, ThreatLevel
from firewall_check import SkillsFirewall, ActionType
扫描技能
result = scan_skill(/path/to/skill)
print(f威胁等级: {result.threat_level})
print(f是否安全: {result.is_safe})
使用防火墙
firewall = SkillsFirewall()
decision = firewall.check_skill(/path/to/skill)
print(f操作: {decision.action})
print(f原因: {decision.reason})
管理列表
firewall.add
allowedskill(trusted-skill)
firewall.add
blockedskill(malicious-skill)
创建自定义规则
firewall.create_rule(
name=block
custompattern,
description=阻止自定义危险模式,
patterns=[dangerous_function(],
action=ActionType.BLOCK
)
最佳实践
- 1. 使用前扫描:安装新技能前务必进行扫描
- 审查警告:调查警告级别的发现结果
- 更新规则:保持检测模式的最新状态
- 记录例外:记录技能被允许/阻止的原因
- 定期审计:定期运行安全扫描
- 使用报告:生成报告用于合规和审查