writing-skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
security-audit-codebasePerform a security audit of a codebase checking for exposed secrets, vulnerable dependencies, injection vulnerabilities, insecure configurations, and OWASP Top 10 issues. Use before publishing or deploying a project, for periodic security reviews, after adding authentication or API integration, before open-sourcing a private repository, or when preparing fo…
Independent GitHub snapshot · Automated classification · Original documentation governs
系察碼庫識弱與露密。
搜硬碼密之式:
# API keys and tokens
grep -rn "sk-\|ghp_\|gho_\|github_pat_\|hf_\|AKIA" --include="*.{md,js,ts,py,R,json,yml,yaml}" .
# Generic secret patterns
grep -rn "password\s*=\s*['\"]" --include="*.{js,ts,py,R,json}" .
grep -rn "api[_-]key\s*[=:]\s*['\"]" --include="*.{js,ts,py,R,json}" .
grep -rn "secret\s*[=:]\s*['\"]" --include="*.{js,ts,py,R,json}" .
# Connection strings
grep -rn "postgresql://\|mysql://\|mongodb://" .
# Private keys
grep -rn "BEGIN.*PRIVATE KEY" .
得:無實密—僅占如 YOUR_TOKEN_HERE 或 your.email@example.com。
敗:實密得→立除、轉露憑、用 git filter-branch 或 git-filter-repo 清史。視諸露密為破。
驗敏檔排:
# Check that these are git-ignored
git check-ignore .env .Renviron credentials.json node_modules/
# Look for tracked sensitive files
git ls-files | grep -i "\.env\|\.renviron\|credentials\|secret"
得:諸敏(.env、.Renviron、credentials.json)列於 .gitignore、git ls-files 無追敏檔返。
敗:敏檔追→git rm --cached <file> 解追、加 .gitignore、提。檔留於盤而不再控版。
Node.js:
npm audit
npx audit-ci --moderate
Python:
pip-audit
safety check
R:
# Check for known vulnerabilities in packages
# No built-in tool, but verify package sources
renv::status()
得:依無高或關弱。中低弱文錄以察。
敗:關弱得→立更影包以 npm audit fix 或 pip install --upgrade。更引破變→文錄弱、建補計。
SQL 注:
# Look for string concatenation in queries
grep -rn "paste.*SELECT\|paste.*INSERT\|paste.*UPDATE\|paste.*DELETE" --include="*.R" .
grep -rn "query.*\+.*\|query.*\$\{" --include="*.{js,ts}" .
諸庫詢宜參化、非串接。
命注:
# Look for shell execution with user input
grep -rn "system\(.*paste\|exec(\|spawn(" --include="*.{R,js,ts,py}" .
XSS:
# Look for unescaped user content in HTML
grep -rn "innerHTML\|dangerouslySetInnerHTML\|v-html" --include="*.{js,ts,jsx,tsx,vue}" .
得:無 SQL、命、XSS 注向。庫詢用參、命避用控、HTML 出正義。
敗:注弱得→詢串接代以參、殼前淨或義入、用框安繪代 innerHTML 或 dangerouslySetInnerHTML。
清單:
得:諸項過:密碼用強散、令隨有期、端強授、CORS 嚴、CSRF 活。
敗:按重排修:弱散與缺授為關、CORS 與 CSRF 為高。文錄諸發現附級。
# Debug mode in production configs
grep -rn "debug\s*[=:]\s*[Tt]rue\|DEBUG\s*=\s*1" --include="*.{json,yml,yaml,toml,cfg}" .
# Permissive CORS
grep -rn "Access-Control-Allow-Origin.*\*\|cors.*origin.*\*" --include="*.{js,ts}" .
# HTTP instead of HTTPS
grep -rn "http://" --include="*.{js,ts,py,R}" . | grep -v "localhost\|127.0.0.1\|http://"
得:產配除錯模禁、CORS 不用通配於產、諸外 URL 用 HTTPS。
敗:產除錯啟→立禁。通 CORS 代以顯許域。http:// 改 https:// 若端支。
建察報:
# Security Audit Report
**Date**: YYYY-MM-DD
**Auditor**: [Name]
**Scope**: [Repository/Project]
**Status**: [PASS/FAIL/CONDITIONAL]
## Findings Summary
| Category | Status | Details |
|----------|--------|---------|
| Exposed secrets | PASS | No secrets found |
| Dependencies | WARN | 2 moderate vulnerabilities |
## Detailed Findings
### Finding 1: [Title]
- **Severity**: Low / Medium / High / Critical
- **Location**: `path/to/file:line`
- **Description**: What was found
- **Recommendation**: How to fix
得:完 SECURITY_AUDIT_REPORT.md 存於項根、發現按重分各含具位、述、建。
敗:發現太多→按類組重關/高。無論果生報立基。
git log -p --all -S 'secret_pattern' 察.gitignore 假安:.gitignore 僅阻未追。已提之檔需 git rm --cacheddocker-compose.yml、CI 配、釋本常含密configure-git-repositorywrite-claude-mdsetup-gxp-r-project