@theoptimalpartner/npm-security-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EXAMPLES.md +528 -0
- package/LICENSE +21 -0
- package/QUICK_START.md +291 -0
- package/README.md +495 -0
- package/bin/check.js +30 -0
- package/bin/install.js +36 -0
- package/bin/install.sh +324 -0
- package/package.json +52 -0
- package/src/index.js +71 -0
- package/template/.github/dependabot.yml +63 -0
- package/template/.github/workflows/security-audit.yml +218 -0
- package/template/.security/config.json +94 -0
- package/template/.security/malicious-packages-blacklist.json +259 -0
- package/template/scripts/check-malicious-packages.sh +118 -0
- package/template/scripts/security-check.sh +166 -0
package/QUICK_START.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Quick Start Guide - NPM Security Kit
|
|
2
|
+
|
|
3
|
+
## 3 Minutos para Proteger tu Proyecto
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Para Proyectos Existentes
|
|
8
|
+
|
|
9
|
+
### Opción A: Instalación Automática (Más Fácil)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# 1. Ir a tu proyecto
|
|
13
|
+
cd /ruta/a/tu-proyecto
|
|
14
|
+
|
|
15
|
+
# 2. Ejecutar instalación
|
|
16
|
+
bash /home/diego/projects/npm-security-kit/install.sh
|
|
17
|
+
|
|
18
|
+
# 3. Verificar
|
|
19
|
+
npm run security:check-malicious
|
|
20
|
+
|
|
21
|
+
# ¡Listo!
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Opción B: Instalación Manual
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# 1. Copiar archivos
|
|
28
|
+
cp -r /home/diego/projects/npm-security-kit/template/.security tu-proyecto/
|
|
29
|
+
cp -r /home/diego/projects/npm-security-kit/template/scripts tu-proyecto/
|
|
30
|
+
cp -r /home/diego/projects/npm-security-kit/template/.github tu-proyecto/
|
|
31
|
+
|
|
32
|
+
# 2. Hacer ejecutables
|
|
33
|
+
cd tu-proyecto
|
|
34
|
+
chmod +x scripts/*.sh
|
|
35
|
+
|
|
36
|
+
# 3. Agregar a package.json (ver abajo)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Scripts para agregar a package.json**:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"scripts": {
|
|
44
|
+
"security:check": "./scripts/security-check.sh",
|
|
45
|
+
"security:check-malicious": "./scripts/check-malicious-packages.sh",
|
|
46
|
+
"security:audit": "npm audit --audit-level=moderate",
|
|
47
|
+
"security:audit:fix": "npm audit fix",
|
|
48
|
+
"security:outdated": "npm outdated",
|
|
49
|
+
"security:licenses": "npm list --json | jq -r '.dependencies | to_entries[] | \"\\(.key): \\(.value.license)\"'",
|
|
50
|
+
"security:full": "npm run security:audit && npm run security:check"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Para Proyectos Nuevos
|
|
58
|
+
|
|
59
|
+
### Desde el Inicio
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# 1. Crear proyecto
|
|
63
|
+
mkdir mi-nuevo-proyecto
|
|
64
|
+
cd mi-nuevo-proyecto
|
|
65
|
+
npm init -y
|
|
66
|
+
|
|
67
|
+
# 2. Instalar security kit
|
|
68
|
+
bash /home/diego/projects/npm-security-kit/install.sh
|
|
69
|
+
|
|
70
|
+
# 3. Instalar dependencias
|
|
71
|
+
npm install
|
|
72
|
+
|
|
73
|
+
# 4. Verificar
|
|
74
|
+
npm run security:check-malicious
|
|
75
|
+
|
|
76
|
+
# Ahora tu proyecto nace protegido!
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Uso Diario
|
|
82
|
+
|
|
83
|
+
### Antes de Instalar un Paquete
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Ver info del paquete
|
|
87
|
+
npm info nombre-paquete
|
|
88
|
+
|
|
89
|
+
# Instalar
|
|
90
|
+
npm install nombre-paquete
|
|
91
|
+
|
|
92
|
+
# Verificar inmediatamente
|
|
93
|
+
npm run security:check-malicious
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Antes de Hacer Deploy
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm run security:full
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Si Hay Problemas
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Auto-fix
|
|
106
|
+
npm run security:audit:fix
|
|
107
|
+
|
|
108
|
+
# Verificar de nuevo
|
|
109
|
+
npm run security:full
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Comandos Importantes
|
|
115
|
+
|
|
116
|
+
| Comando | Cuándo Usarlo | Frecuencia |
|
|
117
|
+
|---------|---------------|------------|
|
|
118
|
+
| `npm run security:check-malicious` | Después de instalar paquetes | Cada instalación |
|
|
119
|
+
| `npm run security:audit` | Verificar vulnerabilidades | Diario |
|
|
120
|
+
| `npm run security:full` | Antes de deploy | Pre-deploy |
|
|
121
|
+
| `npm run security:audit:fix` | Cuando hay vulnerabilidades | Según necesidad |
|
|
122
|
+
| `npm run security:outdated` | Ver actualizaciones | Semanal |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Configuración Rápida
|
|
127
|
+
|
|
128
|
+
### Editar `.security/config.json`
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"projectName": "mi-proyecto", // Nombre de tu proyecto
|
|
133
|
+
"projectType": "react", // node, react, nextjs, etc.
|
|
134
|
+
"strictMode": true // Bloquear en CI si hay amenazas
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Tipos de Proyecto
|
|
139
|
+
|
|
140
|
+
- `node` - Backend Node.js
|
|
141
|
+
- `react` - React app
|
|
142
|
+
- `nextjs` - Next.js
|
|
143
|
+
- `vue` - Vue.js
|
|
144
|
+
- `express` - Express API
|
|
145
|
+
- `serverless` - Lambdas
|
|
146
|
+
- `library` - npm package
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## GitHub Actions (Automático)
|
|
151
|
+
|
|
152
|
+
Una vez que hagas push, GitHub Actions ejecutará:
|
|
153
|
+
|
|
154
|
+
- ✅ Verificación en cada PR
|
|
155
|
+
- ✅ Verificación en cada push
|
|
156
|
+
- ✅ Scan semanal automático (Lunes 9am)
|
|
157
|
+
|
|
158
|
+
No necesitas hacer nada más!
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Dependabot (Automático)
|
|
163
|
+
|
|
164
|
+
Dependabot abrirá PRs automáticos para:
|
|
165
|
+
|
|
166
|
+
- ✅ Security patches
|
|
167
|
+
- ✅ Actualizaciones de dependencias
|
|
168
|
+
- ✅ Agrupadas por categoría
|
|
169
|
+
|
|
170
|
+
Revisa y aprueba semanalmente.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Verificar que Todo Funciona
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# 1. Verificar blacklist
|
|
178
|
+
ls -la .security/malicious-packages-blacklist.json
|
|
179
|
+
|
|
180
|
+
# 2. Verificar scripts
|
|
181
|
+
ls -la scripts/*.sh
|
|
182
|
+
./scripts/check-malicious-packages.sh
|
|
183
|
+
|
|
184
|
+
# 3. Verificar GitHub Actions
|
|
185
|
+
ls -la .github/workflows/security-audit.yml
|
|
186
|
+
|
|
187
|
+
# 4. Verificar scripts npm
|
|
188
|
+
npm run security:check-malicious
|
|
189
|
+
|
|
190
|
+
# Si todo sale ✓ estás listo!
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Problemas Comunes
|
|
196
|
+
|
|
197
|
+
### "jq: command not found"
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Ubuntu/Debian
|
|
201
|
+
sudo apt-get install jq
|
|
202
|
+
|
|
203
|
+
# macOS
|
|
204
|
+
brew install jq
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### "Permission denied"
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
chmod +x scripts/*.sh
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Scripts npm no funcionan
|
|
214
|
+
|
|
215
|
+
Asegúrate de que package.json tenga los scripts. Verifica con:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
cat package.json | grep security
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Próximos Pasos
|
|
224
|
+
|
|
225
|
+
1. ✅ Instalar en proyecto actual
|
|
226
|
+
2. ✅ Ejecutar `npm run security:full`
|
|
227
|
+
3. ✅ Arreglar cualquier problema
|
|
228
|
+
4. ✅ Commit y push
|
|
229
|
+
5. ✅ Verificar GitHub Actions
|
|
230
|
+
6. ✅ Configurar Dependabot
|
|
231
|
+
7. ✅ Repetir en otros proyectos!
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## ¿Necesitas Ayuda?
|
|
236
|
+
|
|
237
|
+
- **Documentación completa**: `README.md`
|
|
238
|
+
- **Configuración avanzada**: `.security/config.json`
|
|
239
|
+
- **Issues**: GitHub Issues
|
|
240
|
+
- **Email**: security@tuempresa.com
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Ejemplos Reales
|
|
245
|
+
|
|
246
|
+
### Proyecto Backend (Express)
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
cd mi-api-express
|
|
250
|
+
bash /home/diego/projects/npm-security-kit/install.sh
|
|
251
|
+
npm run security:check-malicious
|
|
252
|
+
# ✓ No malicious packages detected
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Proyecto Frontend (React)
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
cd mi-app-react
|
|
259
|
+
bash /home/diego/projects/npm-security-kit/install.sh
|
|
260
|
+
npm run security:check-malicious
|
|
261
|
+
# ✓ No malicious packages detected
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Librería npm
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
cd mi-libreria
|
|
268
|
+
bash /home/diego/projects/npm-security-kit/install.sh
|
|
269
|
+
npm run security:check-malicious
|
|
270
|
+
# ✓ No malicious packages detected
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Checklist de Instalación
|
|
276
|
+
|
|
277
|
+
- [ ] Ejecutar `install.sh`
|
|
278
|
+
- [ ] Verificar archivos creados (`.security`, `scripts`, `.github`)
|
|
279
|
+
- [ ] Probar `npm run security:check-malicious`
|
|
280
|
+
- [ ] Probar `npm run security:full`
|
|
281
|
+
- [ ] Personalizar `.security/config.json`
|
|
282
|
+
- [ ] Commit archivos a git
|
|
283
|
+
- [ ] Push para activar GitHub Actions
|
|
284
|
+
- [ ] Verificar que Dependabot esté activo
|
|
285
|
+
- [ ] Documentar para el equipo
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
**¡Tu proyecto está protegido!** 🛡️
|
|
290
|
+
|
|
291
|
+
Repite este proceso en todos tus proyectos para mantener tu código seguro.
|