security-review

Solid

Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment/sensitive features. Provides comprehensive security checklist and patterns.

AI & Automation 196,640 stars 30253 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 安全性審查技能 此技能確保所有程式碼遵循安全性最佳實務並識別潛在漏洞。 ## 何時啟用 - 實作認證或授權 - 處理使用者輸入或檔案上傳 - 建立新的 API 端點 - 處理密鑰或憑證 - 實作支付功能 - 儲存或傳輸敏感資料 - 整合第三方 API ## 安全性檢查清單 ### 1. 密鑰管理 #### FAIL: 絕不這樣做 ```typescript const apiKey = "sk-proj-xxxxx" // 寫死的密鑰 const dbPassword = "password123" // 在原始碼中 ``` #### PASS: 總是這樣做 ```typescript const apiKey = process.env.OPENAI_API_KEY const dbUrl = process.env.DATABASE_URL // 驗證密鑰存在 if (!apiKey) { throw new Error('OPENAI_API_KEY not configured') } ``` #### 驗證步驟 - [ ] 無寫死的 API 金鑰、Token 或密碼 - [ ] 所有密鑰在環境變數中 - [ ] `.env.local` 在 .gitignore 中 - [ ] git 歷史中無密鑰 - [ ] 生產密鑰在託管平台(Vercel、Railway)中 ### 2. 輸入驗證 #### 總是驗證使用者輸入 ```typescript import { z } from 'zod' // 定義驗證 schema const CreateUserSchema = z.object({ email: z.string().email(), name: z.string().min(1).max(100), age: z.number().int().min(0).max(150) }) // 處理前驗證 export async function createUser(input: unknown) { try { const validated = CreateUserSchema.parse(input) return await db.users.create(validated) } catch (error) { if (error instanceof z.ZodError) { return { success: false, errors: error.errors } } throw error } } ``` #### 檔案上傳驗證 ```typescript function validateFileUpload(file: File) { // 大小檢查(最大 5MB) const maxSize = 5 * 1024 * 1024 if (file.size > maxSize) { throw new Error('File too large (max 5MB)') } // 類型檢查 const allowedTypes = ['image/jpeg', 'image/png', 'image/gif'] if (!allowedTypes.includes(file.type)) { throw new Error('Invalid fil...

Details

Author
affaan-m
Repository
affaan-m/everything-claude-code
Created
4 months ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Integrates with

Related Skills