按安全域自动宣称合规控制已被需求覆盖
原文依据:4 处映射器只要发现某需求属于对应安全域,就把该域关联的控制编号视为匹配;它不检查需求内容、控制版本、实现证据或测试结果。方法注释还将结果描述为“satisfy a compliance control”。
用户可能依据生成的矩阵误判 PCI DSS、HIPAA、GDPR 或 OWASP 控制已经满足,进而批准上线、缩小审计范围或遗漏实际控制差距。
该示例按需求的 security domain 直接返回预设控制编号,并把同域需求称为“satisfy”该控制;没有核对需求正文、框架版本、实现或测试证据。若用户把生成矩阵用于合规决策,可能高估覆盖情况。它是模板代码,并不证明已运行;用户可要求逐控制人工验证并提供适用版本与实施证据。
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 个位置
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 ) if not matching: gaps["missing_controls"].append(f"{framework.value}:{control}") elif len(matching) < 2: gaps["weak_coverage"].append(f"{framework.value}:{control}") 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]