Skills Directory精选自 GitHub 的开源 Skills

content-security-policycommit 4b0ddb9SKILL.md · 安全加固

内容安全策略(CSP)

检查并实施严格的 CSP 响应头,配合 HTML 清理和 Trusted Types 防范 XSS 与注入。

npx skills add thedaviddias/Front-End-Checklist --skill content-security-policy
权限
  • read-repo
  • write-files
  • shell
  • network
兼容工具
Any SKILL.md agent
GitHub
74.6k
来源
社区 · David Dias
状态
扫描通过
许可证
MIT

核心规则

CSP 只缩小影响面,不能替代输出编码和 HTML 清理。

执行阶段

  1. 阶段 01检查现状

    检查是否存在 CSP 头及其指令,并审查 innerHTML、dangerouslySetInnerHTML 等注入点。

  2. 阶段 02先用仅报告模式

    先用 Content-Security-Policy-Report-Only 测试,收集违规报告,避免直接破坏站点。

  3. 阶段 03收紧策略

    设置严格的 default-src 再逐项放行;内联脚本用 nonce 或 hash,避免 unsafe-inline 和 unsafe-eval。

  4. 阶段 04在类生产环境验证

    在接近生产的环境中核对实际响应;较大的应用可加 Trusted Types 作为纵深防御。

权限说明(据 SKILL.md 整理)

能力是否需要说明
文件写入需要修改服务器或框架配置以设置 CSP 头,并在注入点加入清理逻辑。
命令执行不需要技能未要求运行特定命令。
网络外发部分需要仅为核对目标站点的实际响应头而访问该站点。

SKILL.md 头部信息(YAML)

SKILL.md 头部信息(YAML)commit 4b0ddb9
---
name: content-security-policy
description: "Use when reviewing headers, forms, cookies, or third-party integrations related to Implement a content security policy. Validate the effective browser and HTTP behavior in a production-like environment."
metadata:
  category: security
  priority: high
  difficulty: advanced
  estimatedTime: "45"
  source: frontendchecklist.io
  url: https://frontendchecklist.io/rules/security/content-security-policy
---

相关技能

规则扫描无法覆盖所有风险,安装前请阅读此技能的 SKILL.md,确认权限后再使用。