Skip to main content

input-validation-and-sanitization

Use this skill when implementing any endpoint, form handler, CLI tool, or function that accepts external input. Validate and sanitize all untrusted data before processing — never assume input is safe.

来源信息

仓库
aiming-lab/MetaClaw
最近来源活动
2026年3月10日 18:04
检测到的 SKILL.md 语言
英语
星标
3,456
分支
450

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
input-validation-and-sanitization
description
Use this skill when implementing any endpoint, form handler, CLI tool, or function that accepts external input. Validate and sanitize all untrusted data before processing — never assume input is safe.
category
security
# Input Validation and Sanitization **Validation principles:** - Validate at the system boundary (API layer, form handler) — not deep in business logic. - Validate type, range, length, and format explicitly. - Reject unexpected input by default (allowlist > denylist). **SQL injection prevention:** Always use parameterized queries or an ORM. **XSS prevention:** Escape HTML output; use Content-Security-Policy headers; avoid `innerHTML` with user data. **Path traversal prevention:** Resolve paths to canonical form and verify they are under the expected directory. ```python import os base = '/allowed/dir' canonical = os.path.realpath(os.path.join(base, user_input)) assert canonical.startswith(base + os.sep) ```
在 GitHub 查看