Skip to main content

securing-nodejs-apps

Hardens Node.js HTTP services: input validation, secure headers, authentication/authorization basics, secret handling, and dependency hygiene. Use when shipping to production or reviewing a service for security gaps.

소스 정보

저장소
j4flmao/agent_skills_nodejs_nestjs
최근 소스 활동
2026년 5월 3일 03:46
감지된 SKILL.md 언어
영어
스타
1
포크
0

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

파일 탐색기
4 개 파일

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
securing-nodejs-apps
description
Hardens Node.js HTTP services: input validation, secure headers, authentication/authorization basics, secret handling, and dependency hygiene. Use when shipping to production or reviewing a service for security gaps.
# Securing Node.js Apps ## When to use - Shipping a service to production - Reviewing a service for security gaps - Adding authentication/authorization - Handling secrets properly ## Core rules 1. Input validation on all external boundaries (class-validator or Zod) 2. Secure headers: Helmet or equivalent 3. Secrets in env vars, never in code or logs 4. Authentication/authorization as ports, not hardcoded 5. Dependency hygiene: `npm audit`, no known vulnerabilities 6. Rate limiting on public endpoints ## Reference shape (TypeScript) ### Input Validation (Zod) ```typescript import { z } from 'zod'; export const CreateUserSchema = z.object({ email: z.string().email().toLowerCase(), password: z.string().min(12), name: z.string().min(2).max(100), }); export type CreateUserDto = z.infer<typeof CreateUserSchema>; ``` ### Secret Handling ```typescript // ❌ Never const jwtSecret = 'my-secret'; // ✅ Always import { config } from '@shared/config'; const jwtSecret = config.JWT_SECRET; // Loaded once, validated ``` ## Examples — Do ```typescript // Validate input at boundary const parsed = CreateUserSchema.safeParse(req.body); if (!parsed.success) return res.status(400).json({ errors: parsed.error.format() }); ``` ## Examples — Don't ```typescript // ❌ No validation app.post('/user', (req, res) => { db.save(req.body); }); // ❌ Secret in code const apiKey = 'sk_live_12345'; ``` ## Checklist - [ ] Input validation on all boundaries - [ ] Secure headers (Helmet) - [ ] Secrets in env vars only - [ ] Auth as injectable port - [ ] Rate limiting configured - [ ] `npm audit` passes See [reference/security-patterns.md](./reference/security-patterns.md) for full patterns.
GitHub에서 보기