@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.
@@ -0,0 +1,218 @@
1
+ name: Security Audit
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main, develop]
6
+ push:
7
+ branches: [main, develop]
8
+ schedule:
9
+ # Ejecutar semanalmente los lunes a las 9am UTC
10
+ - cron: '0 9 * * 1'
11
+ workflow_dispatch: # Permitir ejecución manual
12
+
13
+ jobs:
14
+ npm-audit:
15
+ name: NPM Security Audit
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: '18'
26
+ cache: 'npm'
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Run npm audit
32
+ id: npm-audit
33
+ run: |
34
+ echo "Running npm audit..."
35
+ npm audit --audit-level=moderate || EXIT_CODE=$?
36
+
37
+ if [ $EXIT_CODE -ne 0 ]; then
38
+ echo "::warning::npm audit found vulnerabilities"
39
+ npm audit --json > npm-audit-report.json
40
+ echo "audit_failed=true" >> $GITHUB_OUTPUT
41
+ else
42
+ echo "::notice::No vulnerabilities found"
43
+ echo "audit_failed=false" >> $GITHUB_OUTPUT
44
+ fi
45
+
46
+ exit $EXIT_CODE
47
+ continue-on-error: true
48
+
49
+ - name: Upload audit report
50
+ if: steps.npm-audit.outputs.audit_failed == 'true'
51
+ uses: actions/upload-artifact@v4
52
+ with:
53
+ name: npm-audit-report
54
+ path: npm-audit-report.json
55
+ retention-days: 30
56
+
57
+ - name: Fail on critical vulnerabilities
58
+ if: steps.npm-audit.outputs.audit_failed == 'true'
59
+ run: |
60
+ echo "::error::Security vulnerabilities detected. Review the audit report."
61
+ exit 1
62
+
63
+ socket-security:
64
+ name: Socket.dev Security Scan
65
+ runs-on: ubuntu-latest
66
+
67
+ steps:
68
+ - name: Checkout code
69
+ uses: actions/checkout@v4
70
+
71
+ - name: Setup Node.js
72
+ uses: actions/setup-node@v4
73
+ with:
74
+ node-version: '18'
75
+
76
+ - name: Install Socket CLI
77
+ run: npm install -g @socketsecurity/cli
78
+
79
+ - name: Socket Security Scan
80
+ run: |
81
+ echo "Running Socket security scan..."
82
+ socket npm audit || EXIT_CODE=$?
83
+
84
+ if [ $EXIT_CODE -ne 0 ]; then
85
+ echo "::warning::Socket detected security issues"
86
+ else
87
+ echo "::notice::No security issues detected by Socket"
88
+ fi
89
+
90
+ dependency-review:
91
+ name: Dependency Review
92
+ runs-on: ubuntu-latest
93
+ if: github.event_name == 'pull_request'
94
+
95
+ steps:
96
+ - name: Checkout code
97
+ uses: actions/checkout@v4
98
+
99
+ - name: Dependency Review
100
+ uses: actions/dependency-review-action@v4
101
+ with:
102
+ fail-on-severity: moderate
103
+ deny-licenses: GPL-3.0, AGPL-3.0
104
+
105
+ license-check:
106
+ name: License Compliance Check
107
+ runs-on: ubuntu-latest
108
+
109
+ steps:
110
+ - name: Checkout code
111
+ uses: actions/checkout@v4
112
+
113
+ - name: Setup Node.js
114
+ uses: actions/setup-node@v4
115
+ with:
116
+ node-version: '18'
117
+ cache: 'npm'
118
+
119
+ - name: Install dependencies
120
+ run: npm ci
121
+
122
+ - name: Check for suspicious packages
123
+ run: |
124
+ echo "Checking for packages without licenses..."
125
+ npm list --json | jq -r '.dependencies | to_entries[] | select(.value.license == null or .value.license == "") | .key' || true
126
+
127
+ echo "Checking for deprecated packages..."
128
+ npm outdated || true
129
+
130
+ malicious-patterns:
131
+ name: Check for Malicious Patterns
132
+ runs-on: ubuntu-latest
133
+
134
+ steps:
135
+ - name: Checkout code
136
+ uses: actions/checkout@v4
137
+
138
+ - name: Check for suspicious install scripts
139
+ run: |
140
+ echo "Checking for suspicious preinstall/postinstall scripts..."
141
+ grep -r "preinstall\|postinstall" package.json || echo "No install scripts found"
142
+
143
+ if grep -r "preinstall\|postinstall" package.json; then
144
+ echo "::warning::Install scripts detected - review manually"
145
+ fi
146
+
147
+ - name: Check for hardcoded secrets
148
+ run: |
149
+ echo "Checking for hardcoded secrets..."
150
+ if grep -rE "(password|secret|api[_-]?key|token|auth).*=.*['\"]" --include="*.ts" --include="*.js" src/ 2>/dev/null; then
151
+ echo "::error::Potential hardcoded secrets found"
152
+ exit 1
153
+ else
154
+ echo "::notice::No hardcoded secrets detected"
155
+ fi
156
+
157
+ - name: Verify package-lock integrity
158
+ run: |
159
+ echo "Verifying package-lock.json integrity..."
160
+ if [ -f package-lock.json ]; then
161
+ npm ci --dry-run
162
+ echo "::notice::package-lock.json is valid"
163
+ else
164
+ echo "::error::package-lock.json not found"
165
+ exit 1
166
+ fi
167
+
168
+ known-malicious-packages:
169
+ name: Check Known Malicious Packages
170
+ runs-on: ubuntu-latest
171
+
172
+ steps:
173
+ - name: Checkout code
174
+ uses: actions/checkout@v4
175
+
176
+ - name: Setup Node.js
177
+ uses: actions/setup-node@v4
178
+ with:
179
+ node-version: '18'
180
+ cache: 'npm'
181
+
182
+ - name: Install dependencies
183
+ run: npm ci
184
+
185
+ - name: Install jq
186
+ run: sudo apt-get install -y jq
187
+
188
+ - name: Check against malicious package blacklist
189
+ run: |
190
+ chmod +x ./scripts/check-malicious-packages.sh
191
+ ./scripts/check-malicious-packages.sh || EXIT_CODE=$?
192
+
193
+ if [ $EXIT_CODE -ne 0 ]; then
194
+ echo "::error::CRITICAL - Malicious packages detected!"
195
+ exit 1
196
+ else
197
+ echo "::notice::No known malicious packages detected"
198
+ fi
199
+
200
+ summary:
201
+ name: Security Summary
202
+ runs-on: ubuntu-latest
203
+ needs: [npm-audit, socket-security, dependency-review, license-check, malicious-patterns, known-malicious-packages]
204
+ if: always()
205
+
206
+ steps:
207
+ - name: Security Summary
208
+ run: |
209
+ echo "## Security Audit Summary" >> $GITHUB_STEP_SUMMARY
210
+ echo "" >> $GITHUB_STEP_SUMMARY
211
+ echo "- NPM Audit: ${{ needs.npm-audit.result }}" >> $GITHUB_STEP_SUMMARY
212
+ echo "- Socket Security: ${{ needs.socket-security.result }}" >> $GITHUB_STEP_SUMMARY
213
+ echo "- Dependency Review: ${{ needs.dependency-review.result }}" >> $GITHUB_STEP_SUMMARY
214
+ echo "- License Check: ${{ needs.license-check.result }}" >> $GITHUB_STEP_SUMMARY
215
+ echo "- Malicious Patterns: ${{ needs.malicious-patterns.result }}" >> $GITHUB_STEP_SUMMARY
216
+ echo "- Known Malicious Packages: ${{ needs.known-malicious-packages.result }}" >> $GITHUB_STEP_SUMMARY
217
+ echo "" >> $GITHUB_STEP_SUMMARY
218
+ echo "Review the individual job logs for details." >> $GITHUB_STEP_SUMMARY
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema#",
3
+ "projectName": "my-project",
4
+ "projectType": "node",
5
+ "version": "1.0.0",
6
+ "lastUpdated": "2025-10-20",
7
+ "settings": {
8
+ "strictMode": true,
9
+ "excludeDirs": [
10
+ "node_modules",
11
+ "dist",
12
+ "build",
13
+ ".next",
14
+ "coverage",
15
+ ".cache"
16
+ ],
17
+ "checkPatterns": true,
18
+ "checkTransitiveDeps": true,
19
+ "autoFixVulnerabilities": false
20
+ },
21
+ "notifications": {
22
+ "enabled": false,
23
+ "channels": {
24
+ "email": {
25
+ "enabled": false,
26
+ "addresses": []
27
+ },
28
+ "slack": {
29
+ "enabled": false,
30
+ "webhook": ""
31
+ },
32
+ "discord": {
33
+ "enabled": false,
34
+ "webhook": ""
35
+ }
36
+ }
37
+ },
38
+ "thresholds": {
39
+ "maxVulnerabilities": {
40
+ "critical": 0,
41
+ "high": 0,
42
+ "moderate": 5,
43
+ "low": 10
44
+ },
45
+ "maxPackageAge": {
46
+ "enabled": false,
47
+ "months": 24
48
+ },
49
+ "minDownloadsPerWeek": {
50
+ "enabled": false,
51
+ "count": 1000
52
+ }
53
+ },
54
+ "whitelist": {
55
+ "enabled": false,
56
+ "packages": [],
57
+ "authors": [],
58
+ "organizations": [
59
+ "aws-sdk",
60
+ "types",
61
+ "typescript-eslint"
62
+ ]
63
+ },
64
+ "integrations": {
65
+ "githubActions": {
66
+ "enabled": true,
67
+ "schedule": "0 9 * * 1",
68
+ "onPullRequest": true,
69
+ "onPush": true
70
+ },
71
+ "dependabot": {
72
+ "enabled": true,
73
+ "schedule": "weekly",
74
+ "automerge": false
75
+ },
76
+ "preCommitHooks": {
77
+ "enabled": false,
78
+ "blocking": false
79
+ }
80
+ },
81
+ "reporting": {
82
+ "format": "json",
83
+ "verbosity": "normal",
84
+ "includeTransitiveDeps": true,
85
+ "includeLicenses": true
86
+ },
87
+ "customBlacklist": {
88
+ "enabled": false,
89
+ "packages": [],
90
+ "patterns": [],
91
+ "domains": [],
92
+ "authors": []
93
+ }
94
+ }
@@ -0,0 +1,259 @@
1
+ {
2
+ "lastUpdated": "2025-10-20",
3
+ "source": "Socket.dev - 175 Malicious npm Packages Host Phishing Infrastructure",
4
+ "url": "https://socket.dev/blog/175-malicious-npm-packages-host-phishing-infrastructure",
5
+ "threatLevel": "CRITICAL",
6
+ "attackType": "Supply Chain Compromise + Phishing Campaign",
7
+ "mitreAttack": [
8
+ "T1195.002 - Supply Chain Compromise: Compromise Software Supply Chain",
9
+ "T1583.001 - Acquire Infrastructure: Domains",
10
+ "T1584.004 - Compromise Infrastructure: Server",
11
+ "T1566.001 - Phishing: Spearphishing Attachment",
12
+ "T1566.002 - Phishing: Spearphishing Link",
13
+ "T1056.003 - Input Capture: Web Portal Capture"
14
+ ],
15
+ "patterns": [
16
+ {
17
+ "pattern": "^redirect-[a-z0-9]{6}$",
18
+ "description": "Malicious redirect packages with random 6-character suffix",
19
+ "action": "BLOCK",
20
+ "severity": "CRITICAL"
21
+ }
22
+ ],
23
+ "blacklistedPackages": [
24
+ "redirect-04g1my",
25
+ "redirect-0g91q6",
26
+ "redirect-0vaxnw",
27
+ "redirect-1akzwg",
28
+ "redirect-1hvx9g",
29
+ "redirect-1knxok",
30
+ "redirect-1p89nj",
31
+ "redirect-1st7z7",
32
+ "redirect-1tokin",
33
+ "redirect-1ubpyu",
34
+ "redirect-1wc4gw",
35
+ "redirect-24nt59",
36
+ "redirect-24srjd",
37
+ "redirect-297vpk",
38
+ "redirect-2aie58",
39
+ "redirect-3viu68",
40
+ "redirect-406s9z",
41
+ "redirect-47cprv",
42
+ "redirect-4a6uhw",
43
+ "redirect-4dcjkh",
44
+ "redirect-4iyfat",
45
+ "redirect-4nwrkg",
46
+ "redirect-4r6ynv",
47
+ "redirect-53bw0r",
48
+ "redirect-57j5wb",
49
+ "redirect-594t6h",
50
+ "redirect-5cxzgs",
51
+ "redirect-5iqds5",
52
+ "redirect-5lpuku",
53
+ "redirect-5r42if",
54
+ "redirect-63cl4f",
55
+ "redirect-6lvcjm",
56
+ "redirect-7bqfg6",
57
+ "redirect-7qnew0",
58
+ "redirect-7vw41m",
59
+ "redirect-7yqujr",
60
+ "redirect-8f3x70",
61
+ "redirect-8py8qs",
62
+ "redirect-8ynd96",
63
+ "redirect-95fl17",
64
+ "redirect-9iak88",
65
+ "redirect-a1gs61",
66
+ "redirect-a1jnfo",
67
+ "redirect-aw9itj",
68
+ "redirect-b9diha",
69
+ "redirect-b9fv9e",
70
+ "redirect-byj4f5",
71
+ "redirect-c1n05c",
72
+ "redirect-ch5ayp",
73
+ "redirect-ci4ynt",
74
+ "redirect-cj50k2",
75
+ "redirect-cn040w",
76
+ "redirect-colaux",
77
+ "redirect-cuvccp",
78
+ "redirect-cwfpnz",
79
+ "redirect-cx4vm0",
80
+ "redirect-d0qfku",
81
+ "redirect-dna9sd",
82
+ "redirect-dravb9",
83
+ "redirect-e19jye",
84
+ "redirect-e761hq",
85
+ "redirect-eeu53f",
86
+ "redirect-elvwba",
87
+ "redirect-eqtqym",
88
+ "redirect-evb9wa",
89
+ "redirect-ewce43",
90
+ "redirect-f1wut9",
91
+ "redirect-f72kyw",
92
+ "redirect-fd91u6",
93
+ "redirect-fhelhf",
94
+ "redirect-fohapy",
95
+ "redirect-fwx2y7",
96
+ "redirect-g0ew1n",
97
+ "redirect-g7gn31",
98
+ "redirect-g7v030",
99
+ "redirect-gbgbgh",
100
+ "redirect-gjl674",
101
+ "redirect-gzixvc",
102
+ "redirect-gzkgcn",
103
+ "redirect-h0i672",
104
+ "redirect-h4y8f0",
105
+ "redirect-hi5ag9",
106
+ "redirect-ht8x82",
107
+ "redirect-hx522h",
108
+ "redirect-icp3vd",
109
+ "redirect-igk4sd",
110
+ "redirect-iocz0a",
111
+ "redirect-j0rs4a",
112
+ "redirect-j5blfb",
113
+ "redirect-j8m62u",
114
+ "redirect-jr2idt",
115
+ "redirect-jw31kl",
116
+ "redirect-k1jlsf",
117
+ "redirect-k4s26t",
118
+ "redirect-k5j1u7",
119
+ "redirect-klea4q",
120
+ "redirect-ksm5w7",
121
+ "redirect-kz5pf4",
122
+ "redirect-l0m7on",
123
+ "redirect-l3td5c",
124
+ "redirect-l6qi9e",
125
+ "redirect-lbgja3",
126
+ "redirect-ld0k2a",
127
+ "redirect-lp2xe6",
128
+ "redirect-ltlpoj",
129
+ "redirect-lxzc6c",
130
+ "redirect-m92q7h",
131
+ "redirect-mop8sg",
132
+ "redirect-mrdlde",
133
+ "redirect-mz4116",
134
+ "redirect-n06xhl",
135
+ "redirect-n0c0pt",
136
+ "redirect-n2wvec",
137
+ "redirect-n79iht",
138
+ "redirect-n95xyv",
139
+ "redirect-nf0qo1",
140
+ "redirect-nixl3q",
141
+ "redirect-njmr1g",
142
+ "redirect-noyuan",
143
+ "redirect-nq70u6",
144
+ "redirect-nqfhsn",
145
+ "redirect-nron9d",
146
+ "redirect-nuyvwk",
147
+ "redirect-nzoblt",
148
+ "redirect-o92d2h",
149
+ "redirect-oroq43",
150
+ "redirect-p8ris1",
151
+ "redirect-pkkd5s",
152
+ "redirect-pqigpl",
153
+ "redirect-prhts6",
154
+ "redirect-q2htwu",
155
+ "redirect-q4vs8m",
156
+ "redirect-q84l3v",
157
+ "redirect-qbzqro",
158
+ "redirect-qrah57",
159
+ "redirect-qx2www",
160
+ "redirect-r0ajvl",
161
+ "redirect-r3s2jv",
162
+ "redirect-rc2ewa",
163
+ "redirect-rmunkl",
164
+ "redirect-rrfeb9",
165
+ "redirect-s7usff",
166
+ "redirect-shqv6v",
167
+ "redirect-sjcr8c",
168
+ "redirect-sormfb",
169
+ "redirect-sr2min",
170
+ "redirect-sykre1",
171
+ "redirect-t09ul0",
172
+ "redirect-t65vz6",
173
+ "redirect-t8kcsk",
174
+ "redirect-u0e2q7",
175
+ "redirect-ubp4cs",
176
+ "redirect-uc8xfg",
177
+ "redirect-udmf0u",
178
+ "redirect-uplctp",
179
+ "redirect-uxwcv8",
180
+ "redirect-v74zee",
181
+ "redirect-vlgk2c",
182
+ "redirect-vpvoos",
183
+ "redirect-w9cx9u",
184
+ "redirect-whb6rt",
185
+ "redirect-wu8gx9",
186
+ "redirect-x2giv7",
187
+ "redirect-x4imdv",
188
+ "redirect-xgcv6j",
189
+ "redirect-xi84nq",
190
+ "redirect-xs13nr",
191
+ "redirect-y8p47m",
192
+ "redirect-ystrj5",
193
+ "redirect-ytimeb",
194
+ "redirect-za4566",
195
+ "redirect-zbhdm7",
196
+ "redirect-zfwzmc",
197
+ "redirect-zoju4g",
198
+ "redirect-homer-flajpt"
199
+ ],
200
+ "maliciousDomains": [
201
+ "cfn.jackpotmastersdanske.com",
202
+ "musicboxcr.com",
203
+ "villasmbuva.co.mz",
204
+ "cfn.fejyhy.com",
205
+ "cfn.fenamu.com",
206
+ "cfn.notwinningbutpartici.com",
207
+ "elkendinsc.com"
208
+ ],
209
+ "suspiciousNpmAccounts": [
210
+ {
211
+ "username": "zamaniboss",
212
+ "email": "frankmease22@gmail.com"
213
+ },
214
+ {
215
+ "username": "ghoxt",
216
+ "email": "harimetal@squbee.com"
217
+ },
218
+ {
219
+ "username": "smfcs",
220
+ "email": "Lee.Ja@bi-energykr.net"
221
+ },
222
+ {
223
+ "username": "doggymugu",
224
+ "email": "r99990077@gmail.com"
225
+ },
226
+ {
227
+ "username": "flajpt",
228
+ "email": "homerstreetgy@proton.me"
229
+ },
230
+ {
231
+ "username": "milotank",
232
+ "email": "inf@mail.legaldispensarysearch.com"
233
+ },
234
+ {
235
+ "username": "remdd100",
236
+ "email": "remmdd@smartmode.j.pl"
237
+ },
238
+ {
239
+ "username": "remdd101",
240
+ "email": "remmdd1@smartmode.j.pl"
241
+ },
242
+ {
243
+ "username": "remdd1012",
244
+ "email": "remmdd12@smartmode.j.pl"
245
+ }
246
+ ],
247
+ "indicators": {
248
+ "htmlMetaTag": "nb830r6x",
249
+ "description": "HTML meta tag used in phishing pages"
250
+ },
251
+ "attackDescription": "Phishing campaign weaponizing the npm ecosystem. Threat actors seeded 175+ throwaway packages as disposable hosting for JavaScript that auto-redirects victims to credential-harvesting sites. Targets spanning 135+ organizations.",
252
+ "recommendations": [
253
+ "Block all packages matching pattern ^redirect-[a-z0-9]{6}$",
254
+ "Verify package author reputation before installation",
255
+ "Use Socket.dev CLI to detect malicious packages before installation",
256
+ "Monitor for unexpected redirects in application behavior",
257
+ "Implement CSP (Content Security Policy) to prevent unauthorized redirects"
258
+ ]
259
+ }
@@ -0,0 +1,118 @@
1
+ #!/bin/bash
2
+
3
+ # Check for Malicious Packages Script
4
+ # Verifica si hay paquetes maliciosos instalados contra la blacklist conocida
5
+
6
+ set -e
7
+
8
+ # Colors
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ NC='\033[0m' # No Color
13
+
14
+ BLACKLIST_FILE=".security/malicious-packages-blacklist.json"
15
+
16
+ echo "========================================"
17
+ echo "Malicious Package Detection"
18
+ echo "========================================"
19
+ echo ""
20
+
21
+ # Check if blacklist file exists
22
+ if [ ! -f "$BLACKLIST_FILE" ]; then
23
+ echo -e "${RED}✗ Blacklist file not found: $BLACKLIST_FILE${NC}"
24
+ exit 1
25
+ fi
26
+
27
+ echo "Loading blacklist..."
28
+ BLACKLIST_COUNT=$(jq -r '.blacklistedPackages | length' "$BLACKLIST_FILE")
29
+ LAST_UPDATED=$(jq -r '.lastUpdated' "$BLACKLIST_FILE")
30
+ SOURCE=$(jq -r '.source' "$BLACKLIST_FILE")
31
+
32
+ echo -e "${GREEN}✓ Loaded $BLACKLIST_COUNT malicious packages${NC}"
33
+ echo " Source: $SOURCE"
34
+ echo " Last Updated: $LAST_UPDATED"
35
+ echo ""
36
+
37
+ # Get installed packages
38
+ echo "Analyzing installed packages..."
39
+ INSTALLED_PACKAGES=$(npm list --json 2>/dev/null | jq -r '.. | .dependencies? // {} | keys[]' 2>/dev/null || echo "")
40
+
41
+ if [ -z "$INSTALLED_PACKAGES" ]; then
42
+ echo -e "${YELLOW}⚠ Could not retrieve installed packages${NC}"
43
+ exit 1
44
+ fi
45
+
46
+ TOTAL_INSTALLED=$(echo "$INSTALLED_PACKAGES" | wc -l)
47
+ echo " Total installed packages: $TOTAL_INSTALLED"
48
+ echo ""
49
+
50
+ # Check against blacklist
51
+ echo "Checking against blacklist..."
52
+ FOUND_MALICIOUS=0
53
+ MALICIOUS_FOUND=""
54
+
55
+ while IFS= read -r package; do
56
+ if jq -e ".blacklistedPackages | index(\"$package\")" "$BLACKLIST_FILE" > /dev/null 2>&1; then
57
+ echo -e "${RED}✗ MALICIOUS PACKAGE DETECTED: $package${NC}"
58
+ FOUND_MALICIOUS=$((FOUND_MALICIOUS + 1))
59
+ MALICIOUS_FOUND="$MALICIOUS_FOUND\n - $package"
60
+ fi
61
+ done <<< "$INSTALLED_PACKAGES"
62
+
63
+ # Check against patterns
64
+ echo ""
65
+ echo "Checking against malicious patterns..."
66
+ PATTERN_MATCHES=0
67
+
68
+ PATTERNS=$(jq -r '.patterns[].pattern' "$BLACKLIST_FILE")
69
+ while IFS= read -r pattern; do
70
+ while IFS= read -r package; do
71
+ if echo "$package" | grep -qE "$pattern"; then
72
+ PATTERN_DESC=$(jq -r ".patterns[] | select(.pattern == \"$pattern\") | .description" "$BLACKLIST_FILE")
73
+ echo -e "${RED}✗ PATTERN MATCH: $package${NC}"
74
+ echo " Pattern: $pattern"
75
+ echo " Description: $PATTERN_DESC"
76
+ PATTERN_MATCHES=$((PATTERN_MATCHES + 1))
77
+ MALICIOUS_FOUND="$MALICIOUS_FOUND\n - $package (pattern match)"
78
+ fi
79
+ done <<< "$INSTALLED_PACKAGES"
80
+ done <<< "$PATTERNS"
81
+
82
+ echo ""
83
+ echo "========================================"
84
+ echo "Results"
85
+ echo "========================================"
86
+
87
+ if [ $FOUND_MALICIOUS -eq 0 ] && [ $PATTERN_MATCHES -eq 0 ]; then
88
+ echo -e "${GREEN}✓ No malicious packages detected${NC}"
89
+ echo ""
90
+ echo "Summary:"
91
+ echo " - Checked: $TOTAL_INSTALLED packages"
92
+ echo " - Against: $BLACKLIST_COUNT known malicious packages"
93
+ echo " - Found: 0 threats"
94
+ exit 0
95
+ else
96
+ echo -e "${RED}✗ MALICIOUS PACKAGES FOUND!${NC}"
97
+ echo ""
98
+ echo "Summary:"
99
+ echo " - Direct matches: $FOUND_MALICIOUS"
100
+ echo " - Pattern matches: $PATTERN_MATCHES"
101
+ echo " - Total threats: $((FOUND_MALICIOUS + PATTERN_MATCHES))"
102
+ echo ""
103
+ echo "Malicious packages found:"
104
+ echo -e "$MALICIOUS_FOUND"
105
+ echo ""
106
+ echo "IMMEDIATE ACTIONS REQUIRED:"
107
+ echo "1. DO NOT use this application"
108
+ echo "2. Uninstall malicious packages immediately"
109
+ echo "3. Review application logs for suspicious activity"
110
+ echo "4. Check for data exfiltration"
111
+ echo "5. Report to security team"
112
+ echo "6. Review package-lock.json for when it was added"
113
+ echo ""
114
+ echo "To remove:"
115
+ echo " npm uninstall <package-name>"
116
+ echo ""
117
+ exit 1
118
+ fi