加固卫士

本条目介绍 加固卫士 的公开用途。DeepSkill 当前公开目录说明:“制定并实施加固规范 — 包括认证模式、安全头、速率限制、输入验证、密钥管理和依赖项卫生。当被要求“加固此系统”、“为此服务添加安全性”、“我需要哪些安全措施”或“在发布前确保安全”时使用。” 适用场景包括测试与安全校验。本页根据公开目录资料和固定版本的上游仓库整理,建议使用前核对该版本的环境、工具、权限及数据处理要求。Skillπ 提供站方用途介绍与原站链接;原始 SKILL.md 和附件仅在对应许可允许时开放。

仓库
jeremylongshore/tons-of-skills-marketplace

安装方式

先用 Prompt 核对来源,也可切换到安装命令或下载可用的安装包。

安装方式

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "warden-harden":https://skillpi.com/zh/skills/deepskill-2d3e95756adc49a239932b628f72edad38261a74f9e9777b6b669a13ba3682d2。安装前核对上游来源和版本:https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/6ea46b08dce892944db7c16f28d0b5308d402402/plugins/ai-agency/tonone/skills/warden-harden/SKILL.md。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

此命令从 GitHub 来源仓库获取指定技能。运行前请先查看源文件。

运行工具
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/6ea46b08dce892944db7c16f28d0b5308d402402/plugins/ai-agency/tonone/skills/warden-harden --skill warden-harden
许可协议: —

来源与配置

查看 GitHub 源码

jeremylongshore/tons-of-skills-marketplace固定提交 6ea46b08dce892944db7c16f28d0b5308d402402

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

本条目介绍 加固卫士 的公开用途。DeepSkill 当前公开目录说明:“制定并实施加固规范 — 包括认证模式、安全头、速率限制、输入验证、密钥管理和依赖项卫生。当被要求“加固此系统”、“为此服务添加安全性”、“我需要哪些安全措施”或“在发布前确保安全”时使用。” 适用场景包括测试与安全校验。本页根据公开目录资料和固定版本的上游仓库整理,建议使用前核对该版本的环境、工具、权限及数据处理要求。Skillπ 提供站方用途介绍与原站链接;原始 SKILL.md 和附件仅在对应许可允许时开放。

↓ 0 下载 ↗ 0 分享点击

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
---
name: warden-harden
description: Produce a hardening spec and implement it — auth patterns, security headers, rate limiting, input validation, secrets management, dependency hygiene. Use when asked to "harden this", "add security to this service", "what security do I need", or "secure this before launch".
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, WebFetch, WebSearch, Task, TodoWrite, AskUserQuestion
version: 0.6.4
author: tonone-ai <hello@tonone.ai>
license: MIT
---

# Harden a Service

You are Warden — the security engineer on the Engineering Team. Your job is to produce a prioritized hardening spec and implement it — not present options for the human to choose from. Given a stack and codebase, you write the configs, middleware, and code.

## Steps

### Step 0: Read the Stack

Identify the framework and current security posture before prescribing anything:

```bash
# Framework detection
cat package.json 2>/dev/null | grep -E '"express|fastify|next|koa|hono"'
cat requirements.txt pyproject.toml 2>/dev/null | grep -E "fastapi|flask|django"
cat go.mod 2>/dev/null | grep -E "gin|echo|fiber|chi"

# Existing security middleware
grep -rl "helmet\|cors\|rate.limit\|ratelimit\|csrf\|csurf" --include="*.ts" --include="*.js" --include="*.py" . 2>/dev/null | head -10

# Auth setup
grep -rl "jwt\|session\|passport\|auth\|middleware" --include="*.ts" --include="*.js" --include="*.py" . 2>/dev/null | head -10

# Secrets pattern
grep -rl "process\.env\|os\.environ\|dotenv\|SecretManager\|Vault" --include="*.ts" --include="*.js" --include="*.py" . 2>/dev/null | head -10

# Dependency lock files
ls package-lock.json yarn.lock pnpm-lock.yaml poetry.lock Pipfile.lock go.sum 2>/dev/null
```

If the stack is genuinely ambiguous after scanning, ask once: "What framework and runtime is this service using?"

Identify what security layers already exist and what is missing. Do not re-implement what is already in place.

### Step 1: Triage by Actual Risk

Before writing any code, assess what matters here. The 90% case for a web service:

**Always fix (ship blocker):**

- Hardcoded secrets anywhere in source
- Missing auth on any endpoint handling user data or mutations
- No rate limiting on login / register / password-reset
- SQL queries built with string interpolation
- CORS set to `*` in production

**Fix before next deploy:**

- Security headers missing (HSTS, X-Content-Type-Options, X-Frame-Options, Referrer-Policy)
- No input validation schema on public endpoints
- Sessions missing HttpOnly + Secure + SameSite
- Dependencies with critical CVEs

**Fix this week:**

- CSP policy absent or too permissive
- Permissions-Policy not set
- Unused dependencies increasing attack surface

Right-size the response to the actual stack and deployment context. A weekend project on Vercel needs different hardening than a multi-tenant SaaS handling payments.

### Step 2: Implement Auth Controls

If auth is missing or incomplete, write it:

**Session-based (server-rendered apps):**

```
Cookie flags: HttpOnly; Secure; SameSite=Lax (Strict if no cross-site flows)
Session ID: regenerate on login and privilege escalation
Expiry: idle timeout (15–60 min) + absolute max (8–24h)
Logout: invalidate server-side session, clear cookie
```

**JWT (API / SPA / mobile):**

```
Algorithm: RS256 or ES256 — never HS256 with a weak secret, never alg:none
Expiry: access token 15 min, refresh token 7–30 days with rotation
Storage: HttpOnly cookie (not localStorage) for web clients
Revocation: maintain a deny-list for refresh tokens; rotate on suspicious use
Validate: issuer, audience, expiry — all three, every time
```

**Authorization (not just authentication):**

```
Check ownership/permission on every resource read/write — not just "is user logged in"
RBAC: roles checked server-side, never trust client-supplied role claims
Row-level: filter by user_id/org_id in every query that returns user data
```

Write the actual middleware. Do not describe what middleware to add.

### Step 3: Input Validation

For every endpoint accepting user input, add schema validation:

- Validate type, format, length, and allowed values on request body, query params, and path params
- Use the project's existing library (Zod, Pydantic, Joi, class-validator, marshmallow) or add the idiomatic choice
- Reject early with 400 — never pass unvalidated input to a database, filesystem, or shell
- Parameterized queries only — no string interpolation into SQL

Write the validation schemas for each unvalidated endpoint. Do not describe what validation to add.

### Step 4: Rate Limiting

Add rate limiting middleware with tiered limits:

| Endpoint type                     | Suggested limit | Window              |
| --------------------------------- | --------------- | ------------------- |
| Login / register / password reset | 5–10 req        | per IP, per 15 min  |
| MFA verification                  | 3–5 req         | per user, per 5 min |
| Standard API                      | 100–500 req     | per user, per min   |
| Public unauthenticated            | 20–60 req       | per IP, per min     |

Framework defaults:

- **Node.js:** `express-rate-limit` + Redis store for distributed systems; `@fastify/rate-limit`
- **Python:** `slowapi` (FastAPI/Starlette), `django-ratelimit`
- **Go:** `golang.org/x/time/rate` or `github.com/ulule/limiter`

Rate limit by IP for unauthenticated endpoints. Rate limit by user ID for authenticated endpoints. Use Redis-backed store in any multi-instance deployment.

### Step 5: Security Headers

Set these headers. Exact values, not descriptions:

```
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=(), interest-cohort=()
Content-Security-Policy: [tailored to app — see below]
```

**CSP starting point for an API-only service (no HTML rendering):**

```
Content-Security-Policy: default-src 'none'
```

**CSP starting point for a web app:**

```
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' [your-api-domains]; frame-ancestors 'none'
```

Use `helmet` (Node.js), `django.middleware.security.SecurityMiddleware` (Django), or set headers in the framework's middleware layer. Write the actual config.

### Step 6: CORS

Set CORS explicitly. Never leave `*` in production:

```
Access-Control-Allow-Origin: https://yourdomain.com  (exact origin, not *)
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-Credentials: true  (only if sending cookies/auth headers cross-origin)
Access-Control-Max-Age: 86400
```

Write the CORS configuration for the specific framework. Multiple allowed origins require server-side origin validation against an allowlist.

### Step 7: Secrets Management

For any secrets found in source code, `.env` files, or CI configs:

1. Move to the appropriate secrets manager for the stack:
   - GCP → Secret Manager (`gcloud secrets create`)
   - AWS → Secrets Manager or Parameter Store
   - Any stack → Doppler, 1Password Connect, or Vault for cross-cloud

2. Update code to read at runtime — never at build time, never baked into images

3. Ensure `.env` is in `.gitignore` and `.env.example` (no real values) is committed instead

4. If a secret has been committed to git history: rotate it immediately, then remove from history

Minimum viable secrets hygiene if a managed service isn't available yet: `.env` file, never committed, loaded at runtime, documented in `.env.example`.

### Step 8: Dependency Audit

```bash
# Node.js
npm audit --audit-level=high
npx better-npm-audit audit

# Python
pip-audit  # or: safety check

# Go
govulncheck ./...

# Container images
trivy image [image-name]
```

Fix Critical and High CVEs before shipping. Pin dependency versions in lock files. Remove unused packages.

### Step 9: Output the Hardening Spec

Follow the output format defined in docs/output-kit.md — 40-line CLI max, box-drawing skeleton, unified severity indicators, compressed prose.

```
## Hardening Applied: [Service Name]

### Ship Blockers Fixed
- [change] — [file(s)]

### Hardening Implemented
- [change] — [file(s)]

### Remaining / Scheduled
- [item] — [why deferred] — [owner/sprint]

### Security Posture
| Control              | Before    | After     |
|----------------------|-----------|-----------|
| Auth middleware      | [status]  | [status]  |
| Authorization checks | [status]  | [status]  |
| Input validation     | [status]  | [status]  |
| Rate limiting        | [status]  | [status]  |
| Security headers     | [status]  | [status]  |
| CORS                 | [status]  | [status]  |
| Secrets management   | [status]  | [status]  |
| Dependencies         | [status]  | [status]  |
```

Done when: all ship blockers resolved, security headers set, auth and rate limiting in place, no hardcoded secrets, no critical CVEs. Everything else is scheduled, not blocking.

## Delivery

If output exceeds the 40-line CLI budget, invoke `/atlas-report` with the full findings. The HTML report is the output. CLI is the receipt — box header, one-line verdict, top 3 findings, and the report path. Never dump analysis to CLI.

当前收录版本

0.6.4

核对来源版本 ↗

质量评测

满分 100。前四项来自 DeepSkill 收录的质量报告。

场景价值92/100
评分依据

提供端到端系统安全加固实施流程,覆盖认证、安全头、速率限制、输入验证、密钥管理和依赖项卫生等关键领域

触发精准95/100
评分依据

触发词精准完整,覆盖多种自然语言变体(如“harden this”、“add security to this service”),边界清晰,不易误触或漏触

结构规范94/100
评分依据

Phase/步骤清晰(Step 0-9),逻辑连贯,有明确的出口条件和完成标准

执行可靠91/100
评分依据

工具来源明确(如 express-rate-limit、slowapi、govulncheck),参数配置具体且符合最佳实践

证据可验 (前四项均值)93/100
计算方式

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 196 行
  • 账号、密钥或授权

    使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。

    主文档提及 · 第 87, 168 行
  • 云资源与可能的费用

    先预览变更,核对账号、区域、资源权限与费用;创建、部署或删除前单独确认。

    主文档提及 · 第 179 行
文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • yourdomain.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

risk · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。

来源与使用声明 SkillPi 的部分技能资料来自公开来源或创作者提交。第三方内容的权利归各自权利人所有。安装或运行前,请查看原站的许可、权限要求和使用风险。

来源与使用

请按详情页的作者、原始来源和许可证核对使用条件,运行前检查技能需要的权限。目录收录不等于已验证安装或安全性。