antinet-security-scan(测绘引擎)
本卡已收编为测绘引擎通用技能。打站 / 假支付 / Actuator / 芋道代付仍走专卡。
全文与脚本目录:docs/learning/skill-store/skills/antinet-security-scan/
溯源(仅标记):anbeime/skill-local
合规安检 Skill(锦衣卫)
使用方式
- 由锦衣卫 Worker 在收到文件/URL 时调用,作为流水线的第一道闸门。
- 输出结构化判定(
pass/reject),并写入 provenance 交由太史阁留痕。
输入(Input)
target:待检对象,二选一- 本地文件路径(PDF / PPT / Excel / Word / 图片)
- 外部 URL(需先解析域名)
policy_ref:(可选)覆盖默认策略的合规规则集引用
输出(Output)
verdict:pass或rejectreport:安全扫描报告,含命中的黑名单项、许可状态、风险等级trace_id:本次扫描的 provenance 追踪 ID(用于太史阁留痕)
依赖(Dependencies)
- Sci-Hub 等已知违规域名黑名单(本地 CSV/JSON)
- OA 文档许可校验库(本地规则)
- 文件类型探测(
python-magic)
失败处理(Failure Handling)
- 扫描服务不可用:拒绝文件并告警,绝不降级放行(零信任底线)。
- 文件类型无法识别:标记
reject并写入原因,交由管理员确认。 - 黑名单库读取失败:回退到「全拒 + 告警」保守策略,并提示运维修复。
复用价值(Reuse Value)
- 与具体业务解耦:任何文档处理系统(RAG、知识库、合同审查)均可直接挂载此 Skill 作入口安检。
- 判定标准可配置:通过替换
policy_ref适配不同行业的合规基线。
复赛代码包执行(runnable package)
- 真实入口:
scripts/run_security_scan.py - 执行等价于
core.runtime.AgentSession.run_stage("security-scan"),调用security.jinyiwei.JinYiWeiAgent(纯 Python,零外部依赖,可离线运行)。 - 运行:
python skills/security-scan/scripts/run_security_scan.py - 产物:
examples/snse_survey/skill_outputs/security_scan.json(黄卡 + 扫描报告)。
在测绘引擎作业中的实际用法
本卡在安全作业中用于文件上传/接收前的安全校验,以及URL/域名合规检查(防止误操作未授权目标)。
文件安全检查(上传前)
# 检查文件类型(python-magic)
python3 -c "
import magic
f = '<文件路径>'
mime = magic.from_file(f, mime=True)
print('MIME:', mime)
# 白名单检查
ALLOWED = {'application/pdf', 'text/plain', 'application/json', 'image/jpeg', 'image/png'}
if mime in ALLOWED:
print('PASS: file type allowed')
else:
print('REJECT: unexpected file type:', mime)
" 2>/dev/null || file '<文件路径>'
# 检查文件是否含嵌入式 payload(简单检查)
python3 -c "
import re
content = open('<文件路径>', 'rb').read()
patterns = [
(b'<script', 'XSS script tag'),
(b'<?php', 'PHP code'),
(b'system(', 'Shell command'),
(b'eval(', 'eval() call'),
(b'JFIF', 'JPEG header (OK)'),
]
for pattern, name in patterns:
if pattern.lower() in content.lower():
print(f'DETECTED: {name}')
"
域名/URL 合规检查(授权边界验证)
# 快速检查 URL 是否在授权 scope 内(不需要整文件读 scope)
python3 tools/ops/scope_expand.py \
--check-url https://<目标域名> \
--case <案卷>
# 或使用 in_scope() 函数
python3 -c "
import sys
sys.path.insert(0, 'tools/ops')
from scope_expand import in_scope
urls = [
'https://<目标>/api',
'https://<第三方>.com', # 应该是 out_of_scope
]
for url in urls:
result = in_scope(url)
status = 'IN_SCOPE ✓' if result else 'OUT_OF_SCOPE ✗'
print(f'{status}: {url}')
"
扫描目标合规性(打前必做)
# 检查目标 IP 归属(防止打到国内主体)
TARGET_IP=$(dig +short <目标> | head -1)
python3 -c "
import urllib.request, json
resp = urllib.request.urlopen(f'http://ip-api.com/json/$TARGET_IP?fields=status,country,countryCode,isp,org,as')
data = json.loads(resp.read())
print(json.dumps(data, indent=2, ensure_ascii=False))
# countryCode=CN = 停手(中国主体)
" 2>/dev/null
# 检查 CDN 类型(EdgeOne = 中国主体)
curl -sk -I "https://<目标>" 2>/dev/null | grep -iE 'eo-log-uuid|eo-cache-status|cf-ray|x-amz'