跳转到正文
报告库
用途分类 / 其他用途

Security Requirement Extraction Skill 安全审计

作者说它能做什么(原文)

Derive security requirements from threat models and business context. Use when translating threats into actionable requirements, creating security user stories, or building security test cases.

第三方安全检查结论

发现安全风险

已检查文件
2
发现的风险
4
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。未发现风险
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。未发现风险
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 3 项风险
中风险

按安全域自动宣称合规控制已被需求覆盖

原文依据:4 处
发现了什么

映射器只要发现某需求属于对应安全域,就把该域关联的控制编号视为匹配;它不检查需求内容、控制版本、实现证据或测试结果。方法注释还将结果描述为“satisfy a compliance control”。

为什么需要注意

用户可能依据生成的矩阵误判 PCI DSS、HIPAA、GDPR 或 OWASP 控制已经满足,进而批准上线、缩小审计范围或遗漏实际控制差距。

该示例按需求的 security domain 直接返回预设控制编号,并把同域需求称为“satisfy”该控制;没有核对需求正文、框架版本、实现或测试证据。若用户把生成矩阵用于合规决策,可能高估覆盖情况。它是模板代码,并不证明已运行;用户可要求逐控制人工验证并提供适用版本与实施证据。

references/details.md:426来自说明文档打开原文件
    def map_requirement_to_compliance(        self,        requirement: SecurityRequirement,        frameworks: List[ComplianceFramework]    ) -> Dict[str, List[str]]:        """Map a requirement to compliance controls."""        mapping = {}        for framework in frameworks:            controls = self.FRAMEWORK_CONTROLS.get(framework, {})            domain_controls = controls.get(requirement.domain, [])            if domain_controls:                mapping[framework.value] = domain_controls        return mapping
查看另外 3 个位置
references/details.md:440来自说明文档打开原文件
    def get_requirements_for_control(        self,        requirement_set: RequirementSet,        framework: ComplianceFramework,        control_id: str    ) -> List[SecurityRequirement]:        """Find requirements that satisfy a compliance control."""        matching = []        framework_controls = self.FRAMEWORK_CONTROLS.get(framework, {})        for domain, controls in framework_controls.items():            if control_id in controls:                matching.extend(requirement_set.get_by_domain(domain))        return matching
references/details.md:493来自说明文档打开原文件
                )                if not matching:                    gaps["missing_controls"].append(f"{framework.value}:{control}")                elif len(matching) < 2:                    gaps["weak_coverage"].append(f"{framework.value}:{control}")
references/details.md:468来自说明文档打开原文件
            for domain, controls in framework_controls.items():                for control in controls:                    reqs = self.get_requirements_for_control(                        requirement_set, framework, control                    )                    if reqs:                        matrix[framework.value][control] = [r.id for r in reqs]
中风险

未知或大小写不符的威胁类别会被静默丢弃

原文依据:6 处
发现了什么

类别查找使用区分大小写的精确键;找不到时得到空模式列表,转换函数随后返回空需求列表,没有错误、警告或人工复核标记。验收标准和测试用例查找也采用同样的精确匹配。

为什么需要注意

拼写错误、小写输入或未覆盖的威胁类型可能完全消失在需求集里,使用户误以为威胁已处理,而实际上没有产生任何控制或测试。

STRIDE 映射键均为大写,而查找直接使用原始 category;未识别类别会得到空 patterns,循环不执行并返回空需求。验收标准与测试用例也使用精确键查找并默认为空列表。若输入含小写、拼写错误或新类别,相关威胁可能无提示地不产生要求。代码是参考模板,未证明实际处理过数据;用户可要求类别校验、规范化和未知值报错或人工复核。

references/details.md:262来自说明文档打开原文件
        """Convert a single threat to requirements."""        requirements = []        mapping = self.STRIDE_MAPPINGS.get(threat.category, {})        domains = mapping.get("domains", [])        patterns = mapping.get("patterns", [])        priority = self._calculate_priority(threat.impact, threat.likelihood)        for i, (title_pattern, desc_pattern) in enumerate(patterns):            req = SecurityRequirement(
查看另外 5 个位置
references/details.md:269来自说明文档打开原文件
        for i, (title_pattern, desc_pattern) in enumerate(patterns):            req = SecurityRequirement(                id=f"SR-{start_id + i:03d}",                title=title_pattern.format(target=threat.target),                description=desc_pattern.format(target=threat.target),                req_type=RequirementType.FUNCTIONAL,                domain=domains[i % len(domains)] if domains else SecurityDomain.DATA_PROTECTION,                priority=priority,                rationale=f"Mitigates threat: {threat.title}",                threat_refs=[threat.id],                acceptance_criteria=self._generate_acceptance_criteria(                    threat.category, threat.target                ),                test_cases=self._generate_test_cases(                    threat.category, threat.target                )            )            requirements.append(req)        return requirements
references/details.md:343来自说明文档打开原文件
            ],        }        return criteria_templates.get(category, [])
references/details.md:383来自说明文档打开原文件
            ],        }        return test_templates.get(category, [])```
references/details.md:163来自说明文档打开原文件
class RequirementExtractor:    """Extract security requirements from threats."""    # Mapping of STRIDE categories to security domains and requirement patterns    STRIDE_MAPPINGS = {        "SPOOFING": {            "domains": [SecurityDomain.AUTHENTICATION, SecurityDomain.SESSION_MANAGEMENT],
references/details.md:286来自说明文档打开原文件
            )            requirements.append(req)        return requirements
中风险

无效风险值被默认为 MEDIUM,可能静默扭曲优先级

原文依据:2 处
发现了什么

影响和可能性不是受限枚举,而是自由字符串;无法识别的值统一按分值 2 处理。代码不会提示缺失、拼写错误或不兼容的评分尺度。

为什么需要注意

错误输入可能把风险升高或降低。例如未知值会获得与 MEDIUM 相同的权重,影响哪些需求被标为关键或优先实施,进而影响安全资源和发布决策。

ThreatInput 将 impact 和 likelihood 定义为普通字符串。评分函数对无法识别的值使用默认分值 2,相当于 MEDIUM,且不返回警告;缺失约束或拼写错误可能改变最终优先级并影响用户的处置顺序。这是模板逻辑而非执行证据。用户可要求受限枚举、显式校验,并在未知评分时停止或标记人工复核。

references/details.md:290来自说明文档打开原文件
    def _calculate_priority(self, impact: str, likelihood: str) -> Priority:        """Calculate requirement priority from threat attributes."""        score_map = {"LOW": 1, "MEDIUM": 2, "HIGH": 3, "CRITICAL": 4}        impact_score = score_map.get(impact.upper(), 2)        likelihood_score = score_map.get(likelihood.upper(), 2)        combined = impact_score * likelihood_score        if combined >= 12:            return Priority.CRITICAL        elif combined >= 6:            return Priority.HIGH        elif combined >= 3:            return Priority.MEDIUM        return Priority.LOW
查看另外 1 个位置
references/details.md:152来自说明文档打开原文件
@dataclassclass ThreatInput:    id: str    category: str  # STRIDE category    title: str    description: str    target: str    impact: str    likelihood: str
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。发现 1 项风险
低风险

未经转义的威胁文本被嵌入后续 Markdown 文档

原文依据:4 处
发现了什么

威胁的 target、title 和 id 会直接格式化进需求标题、理由和追溯字段,之后又直接插入 Markdown 用户故事。输入中的 Markdown、伪造复选框或面向后续 AI 的指令不会被引用、转义或标记为不可信。

为什么需要注意

恶意或意外构造的威胁文本可以改变生成文档的视觉结构、伪造审批状态,或在文档交给另一个 AI 处理时被误当作指令,从而影响人的安全判断或后续自动化。

模板把 threat.target 格式化进标题和描述,把 threat.title 放入理由,并原样保留 threat.id;这些字段随后直接进入 Markdown 用户故事和追溯列表。若威胁数据来自不可信来源,其中的 Markdown、伪造任务项或提示文本会出现在供人或后续 AI 阅读的文档中,可能误导判断,但源码不表明这些文字会自动执行。用户可要求转义或明确标注不可信字段,并限制下游自动化解释生成内容。

references/details.md:270来自说明文档打开原文件
        for i, (title_pattern, desc_pattern) in enumerate(patterns):            req = SecurityRequirement(                id=f"SR-{start_id + i:03d}",                title=title_pattern.format(target=threat.target),                description=desc_pattern.format(target=threat.target),                req_type=RequirementType.FUNCTIONAL,                domain=domains[i % len(domains)] if domains else SecurityDomain.DATA_PROTECTION,                priority=priority,                rationale=f"Mitigates threat: {threat.title}",                threat_refs=[threat.id],                acceptance_criteria=self._generate_acceptance_criteria(
查看另外 3 个位置
references/details.md:537来自说明文档打开原文件
        story = f"""## {requirement.id}: {requirement.title}**User Story:**As a {template['as_a']},I want the system to {requirement.description.lower()},So that {template['so_that']}.**Priority:** {requirement.priority.name}**Type:** {requirement.req_type.value}**Domain:** {requirement.domain.value}**Acceptance Criteria:**{self._format_acceptance_criteria(requirement.acceptance_criteria)}**Definition of Done:**- [ ] Implementation complete- [ ] Security tests pass- [ ] Code review complete- [ ] Security review approved- [ ] Documentation updated**Security Test Cases:**{self._format_test_cases(requirement.test_cases)}**Traceability:**- Threats: {', '.join(requirement.threat_refs) or 'N/A'}- Compliance: {', '.join(requirement.compliance_refs) or 'N/A'}"""
references/details.md:269来自说明文档打开原文件
        for i, (title_pattern, desc_pattern) in enumerate(patterns):            req = SecurityRequirement(                id=f"SR-{start_id + i:03d}",                title=title_pattern.format(target=threat.target),                description=desc_pattern.format(target=threat.target),                req_type=RequirementType.FUNCTIONAL,                domain=domains[i % len(domains)] if domains else SecurityDomain.DATA_PROTECTION,                priority=priority,                rationale=f"Mitigates threat: {threat.title}",                threat_refs=[threat.id],                acceptance_criteria=self._generate_acceptance_criteria(                    threat.category, threat.target                ),                test_cases=self._generate_test_cases(                    threat.category, threat.target                )            )
references/details.md:69来自说明文档打开原文件
        """Convert to user story format."""        return f"""**{self.id}: {self.title}**As a security-conscious system,I need to {self.description.lower()},So that {self.rationale.lower()}.**Acceptance Criteria:**{chr(10).join(f'- [ ] {ac}' for ac in self.acceptance_criteria)}**Priority:** {self.priority.name}**Domain:** {self.domain.value}**Threat References:** {', '.join(self.threat_refs)}"""
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

4 个说明模块

该 Skill 的用途是把威胁模型转换为安全需求、用户故事、验收标准和测试用例,并强调可追溯性、可测试性、优先级和风险等级。

查看原文
SKILL.md:8来自说明文档打开原文件
Transform threat analysis into actionable security requirements.
SKILL.md:40来自说明文档打开原文件
| Attribute        | Description                 || ---------------- | --------------------------- || **Traceability** | Links to threats/compliance || **Testability**  | Can be verified             || **Priority**     | Business importance         || **Risk Level**   | Impact if not met           |

参考实现按 STRIDE 类别套用固定的安全域和需求文本;每个输入威胁可生成多条需求,并保留威胁 ID 作为追溯引用。

查看原文
references/details.md:166来自说明文档打开原文件
    # Mapping of STRIDE categories to security domains and requirement patterns    STRIDE_MAPPINGS = {        "SPOOFING": {            "domains": [SecurityDomain.AUTHENTICATION, SecurityDomain.SESSION_MANAGEMENT],            "patterns": [                ("Implement strong authentication for {target}",
references/details.md:269来自说明文档打开原文件
        for i, (title_pattern, desc_pattern) in enumerate(patterns):            req = SecurityRequirement(                id=f"SR-{start_id + i:03d}",                title=title_pattern.format(target=threat.target),                description=desc_pattern.format(target=threat.target),                req_type=RequirementType.FUNCTIONAL,                domain=domains[i % len(domains)] if domains else SecurityDomain.DATA_PROTECTION,                priority=priority,                rationale=f"Mitigates threat: {threat.title}",                threat_refs=[threat.id],                acceptance_criteria=self._generate_acceptance_criteria(                    threat.category, threat.target                ),                test_cases=self._generate_test_cases(                    threat.category, threat.target                )            )

提供的内容是 Markdown 中的 Python 模板;可见代码构造并返回字符串和内存对象,没有展示网络请求、命令执行、凭据读取或直接写入用户文件。

查看原文
references/details.md:121来自说明文档打开原文件
    def export_markdown(self) -> str:        """Export all requirements as markdown."""        lines = [f"# Security Requirements: {self.name}\n"]        lines.append(f"Version: {self.version}\n")        for domain in SecurityDomain:            domain_reqs = self.get_by_domain(domain)            if domain_reqs:                lines.append(f"\n## {domain.value.replace('_', ' ').title()}\n")                for req in domain_reqs:                    lines.append(req.to_user_story())        return "\n".join(lines)
从这里开始 · 工作说明SKILL.md
security-requirement-extraction
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。

文件引用关系图

1 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录2 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • references/details.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
  • references/details.md配套文件

代码和说明中提到的操作

读取文件
SKILL.md:49来自说明文档打开原文件
Full template library lives in `references/details.md`. Read that file when you need concrete templates for this skill.
读取密钥或账号配置
references/details.md:355来自说明文档打开原文件
                f"Test: Unauthenticated access to {target} is denied",                "Test: Invalid credentials are rejected",                "Test: Session tokens cannot be forged",
读取了多少行
680
文件校验值(用于核对版本)
ca4391937d88a932a5023d4b0f309d99682a9be111ed9547a957053a80910402