plumber-linter 1.1.1 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +160 -142
  2. package/bin/plumber.js +144 -16
  3. package/package.json +44 -41
package/README.md CHANGED
@@ -1,142 +1,160 @@
1
- # Plumber
2
-
3
- CI/CD pipeline linter that flags hardcoded secrets, leaked credentials, and dead code — with fixes in plain English.
4
-
5
- [![npm version](https://img.shields.io/npm/v/plumber-linter.svg)](https://www.npmjs.com/package/plumber-linter)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/parasraju/plumber/blob/main/LICENSE)
7
-
8
- Plumber inspects codebases and git repositories in milliseconds without requiring an LLM. It enforces quality and security gates in CI/CD pipelines and git pre-commit hooks, exiting with non-zero status when critical or high-severity issues are found.
9
-
10
- ---
11
-
12
- ## Installation
13
-
14
- ```bash
15
- # Local project dependency
16
- npm install --save-dev plumber-linter
17
-
18
- # Global installation
19
- npm install -g plumber-linter
20
- ```
21
-
22
- ---
23
-
24
- ## Quick Start
25
-
26
- Run instantly with `npx` (no install required):
27
-
28
- ```bash
29
- # Scan current repository
30
- npx plumber-linter scan .
31
-
32
- # Enforce quality gate in CI (exit 1 on HIGH or CRITICAL issues)
33
- npx plumber-linter scan . --fail-on high
34
-
35
- # Export report as Markdown or JSON
36
- npx plumber-linter scan . --format md
37
- npx plumber-linter scan . --format json
38
-
39
- # View all 21 inspection rules
40
- npx plumber-linter rules
41
- ```
42
-
43
- ### In GitHub Actions
44
-
45
- ```yaml
46
- - name: Run Plumber Linter
47
- run: npx plumber-linter scan . --fail-on high
48
- ```
49
-
50
- ### In GitLab CI
51
-
52
- ```yaml
53
- plumber-lint:
54
- image: node:18
55
- script:
56
- - npx plumber-linter scan . --fail-on high
57
- ```
58
-
59
- ### Git Pre-Commit Hook
60
-
61
- Install a pre-commit hook that blocks commits containing secrets, `.env` files, or dead code:
62
-
63
- ```bash
64
- # Install hook (blocks staged secrets and issues >= HIGH)
65
- npx plumber-linter install-hook --fail-on high
66
-
67
- # Uninstall hook
68
- npx plumber-linter uninstall-hook
69
- ```
70
-
71
- ---
72
-
73
- ## What It Checks
74
-
75
- ### 1. Leaked Secrets & API Keys (`leak/api-key`, `leak/hardcoded-secret`)
76
- Detects exposed OpenAI (`sk-...`), GitHub (`ghp_...`), AWS (`AKIA...`), Slack tokens, and database credentials.
77
- - **Vulnerable:** `const client = new OpenAI({ apiKey: "sk-live1234567890abcdef1234567890" });`
78
- - **Fixed:** `const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });`
79
-
80
- ### 2. Committed Environment Files (`leak/committed-env`)
81
- Prevents committing `.env` files containing live secrets to version control.
82
- - **Vulnerable:** `.env` committed with production credentials.
83
- - **Fixed:** Add `.env` to `.gitignore` and commit `.env.example` with blank placeholders.
84
-
85
- ### 3. Swallowed Exceptions (`clog/swallowed-error`)
86
- Flags silent failure blocks that swallow exceptions and hide failures in CI/CD pipelines.
87
- - **Vulnerable:** `try { doWork(); } catch (err) {}`
88
- - **Fixed:** `try { doWork(); } catch (err) { logger.error(err); throw err; }`
89
-
90
- ### 4. Unreachable Dead Code (`clog/dead-code`)
91
- Detects unreachable statements following returns or inside constant-false branches.
92
- - **Vulnerable:** `return result; console.log("Done");`
93
- - **Fixed:** Delete unreachable statement (or run `npx plumber-linter clean . --write`).
94
-
95
- ### 5. AI-Elided Code Snippets (`clog/elided-code`)
96
- Flags lazy AI elision comments like `// ... existing code ...` left behind in source files.
97
- - **Vulnerable:** `// ... existing code ...`
98
- - **Fixed:** Restore the full function or component implementation.
99
-
100
- ### 6. Non-Semantic / Inaccessible Elements (`joint/clickable-div`)
101
- Identifies non-semantic clickable elements lacking accessible keyboard and screen-reader controls.
102
- - **Vulnerable:** `<div onClick={handleClick}>Submit</div>`
103
- - **Fixed:** `<button type="button" onClick={handleClick}>Submit</button>`
104
-
105
- ### 7. Hallucinated / Undeclared Dependencies (`pipe/phantom-import`)
106
- Spots hallucinated library imports invented by LLMs or packages missing from project manifests.
107
- - **Vulnerable:** `import { useFeature } from "next-auth-v5-helpers";`
108
- - **Fixed:** Use standard verified libraries and declare dependencies in manifests.
109
-
110
- ---
111
-
112
- ## Example Output
113
-
114
- ```text
115
- ================================================================
116
- PLUMBER INSPECTION REPORT: my-service
117
- Health Score: 87.4/100 | Grade: B | Files: 18
118
- Issues Detected: 2
119
- ================================================================
120
-
121
- [FILE] src/config.ts
122
- L14 [CRITICAL] Leaked OpenAI / Model API Key
123
- Found: const key = "sk-live9876543210..."
124
- Fix: Move secret to environment variable (.env).
125
-
126
- [FILE] src/pipeline.ts
127
- L58 [HIGH] Swallowed Exception (Silent Failure)
128
- Found: catch (e) {}
129
- Fix: Log the error or properly re-raise/handle it.
130
-
131
- ================================================================
132
-
133
- [FAILED] Found issues at or above severity: HIGH
134
- ```
135
-
136
- ---
137
-
138
- ## Links
139
-
140
- - **npm Package:** [https://www.npmjs.com/package/plumber-linter](https://www.npmjs.com/package/plumber-linter)
141
- - **Website & Documentation:** [https://plumber-7dv.pages.dev/](https://plumber-7dv.pages.dev/)
142
- - **GitHub Repository:** [https://github.com/parasraju/plumber](https://github.com/parasraju/plumber)
1
+ # Plumber
2
+
3
+ CI/CD pipeline linter that flags hardcoded secrets, leaked credentials, and dead code — with fixes in plain English.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/plumber-linter.svg)](https://www.npmjs.com/package/plumber-linter)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/parasraju/plumber/blob/main/LICENSE)
7
+
8
+ Plumber inspects codebases and git repositories in milliseconds without requiring an LLM. It enforces quality and security gates in CI/CD pipelines and git pre-commit hooks, exiting with non-zero status when critical or high-severity issues are found.
9
+
10
+ ---
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Local project dependency
16
+ npm install --save-dev plumber-linter
17
+
18
+ # Global installation
19
+ npm install -g plumber-linter
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Quick Start
25
+
26
+ Run instantly with `npx` (no install required):
27
+
28
+ ```bash
29
+ # Scan current repository
30
+ npx plumber-linter scan .
31
+
32
+ # Enforce quality gate in CI (exit 1 on HIGH or CRITICAL issues)
33
+ npx plumber-linter scan . --fail-on high
34
+
35
+ # Export report as Markdown or JSON
36
+ npx plumber-linter scan . --format md
37
+ npx plumber-linter scan . --format json
38
+
39
+ # View all 26 inspection rules
40
+ npx plumber-linter rules
41
+ ```
42
+
43
+ ### In GitHub Actions
44
+
45
+ ```yaml
46
+ - name: Run Plumber Linter
47
+ run: npx plumber-linter scan . --fail-on high
48
+ ```
49
+
50
+ ### In GitLab CI
51
+
52
+ ```yaml
53
+ plumber-lint:
54
+ image: node:18
55
+ script:
56
+ - npx plumber-linter scan . --fail-on high
57
+ ```
58
+
59
+ ### Git Pre-Commit Hook
60
+
61
+ Install a pre-commit hook that blocks commits containing secrets, `.env` files, or dead code:
62
+
63
+ ```bash
64
+ # Install hook (blocks staged secrets and issues >= HIGH)
65
+ npx plumber-linter install-hook --fail-on high
66
+
67
+ # Uninstall hook
68
+ npx plumber-linter uninstall-hook
69
+ ```
70
+
71
+ ---
72
+
73
+ ## What It Checks
74
+
75
+ ### 1. Leaked Secrets & API Keys (`leak/api-key`, `leak/hardcoded-secret`)
76
+ Detects exposed OpenAI (`sk-...`), GitHub (`ghp_...`), AWS (`AKIA...`), Slack tokens, and database credentials.
77
+ - **Vulnerable:** `const client = new OpenAI({ apiKey: "sk-live1234567890abcdef1234567890" });`
78
+ - **Fixed:** `const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });`
79
+
80
+ ### 2. Committed Environment Files (`leak/committed-env`)
81
+ Prevents committing `.env` files containing live secrets to version control.
82
+ - **Vulnerable:** `.env` committed with production credentials.
83
+ - **Fixed:** Add `.env` to `.gitignore` and commit `.env.example` with blank placeholders.
84
+
85
+ ### 3. Swallowed Exceptions (`clog/swallowed-error`)
86
+ Flags silent failure blocks that swallow exceptions and hide failures in CI/CD pipelines.
87
+ - **Vulnerable:** `try { doWork(); } catch (err) {}`
88
+ - **Fixed:** `try { doWork(); } catch (err) { logger.error(err); throw err; }`
89
+
90
+ ### 4. Unreachable Dead Code (`clog/dead-code`)
91
+ Detects unreachable statements following returns or inside constant-false branches.
92
+ - **Vulnerable:** `return result; console.log("Done");`
93
+ - **Fixed:** Delete unreachable statement (or run `npx plumber-linter clean . --write`).
94
+
95
+ ### 5. AI-Elided Code Snippets (`clog/elided-code`)
96
+ Flags lazy AI elision comments like `// ... existing code ...` left behind in source files.
97
+ - **Vulnerable:** `// ... existing code ...`
98
+ - **Fixed:** Restore the full function or component implementation.
99
+
100
+ ### 6. Non-Semantic / Inaccessible Elements (`joint/clickable-div`)
101
+ Identifies non-semantic clickable elements lacking accessible keyboard and screen-reader controls.
102
+ - **Vulnerable:** `<div onClick={handleClick}>Submit</div>`
103
+ - **Fixed:** `<button type="button" onClick={handleClick}>Submit</button>`
104
+
105
+ ### 7. Hallucinated / Undeclared Dependencies (`pipe/phantom-import`)
106
+ Spots hallucinated library imports invented by LLMs or packages missing from project manifests.
107
+ - **Vulnerable:** `import { useFeature } from "next-auth-v5-helpers";`
108
+ - **Fixed:** Use standard verified libraries and declare dependencies in manifests.
109
+
110
+ ### 8. CI/CD Supply-Chain & Pipeline Rules (v1.2.0)
111
+ - `pipe/docker-unpinned` — Flags unpinned Docker images (missing tag or `:latest`) in CI jobs or Dockerfiles (`MEDIUM`).
112
+ - `sec/curl-pipe-shell` — Flags `curl ... | bash` / `wget ... | sh` remote script execution in run steps (`CRITICAL`).
113
+ - `sec/permissions-write-all` — Flags overly broad workflow permissions (`permissions: write-all` or top-level `contents: write`) (`HIGH`).
114
+ - `leak/slack-webhook` — Flags hardcoded Slack or tokenized webhook URLs in workflow and source files (`CRITICAL`).
115
+ - `pipe/npm-unpinned` — Flags `npm install` steps in CI without `--save-exact` or `npm ci` lockfile enforcement (`MEDIUM`).
116
+
117
+ ---
118
+
119
+ ## Example Output
120
+
121
+ ```text
122
+ ================================================================
123
+ PLUMBER INSPECTION REPORT: my-service
124
+ Health Score: 87.4/100 | Grade: B | Files: 18
125
+ Issues Detected: 2
126
+ ================================================================
127
+
128
+ [FILE] src/config.ts
129
+ L14 [CRITICAL] Leaked OpenAI / Model API Key
130
+ Found: const key = "sk-live9876543210..."
131
+ Fix: Move secret to environment variable (.env).
132
+
133
+ [FILE] src/pipeline.ts
134
+ L58 [HIGH] Swallowed Exception (Silent Failure)
135
+ Found: catch (e) {}
136
+ Fix: Log the error or properly re-raise/handle it.
137
+
138
+ ================================================================
139
+
140
+ [FAILED] Found issues at or above severity: HIGH
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Links
146
+
147
+ - **npm Package:** [https://www.npmjs.com/package/plumber-linter](https://www.npmjs.com/package/plumber-linter)
148
+ - **Website & Documentation:** [https://plumber-7dv.pages.dev/](https://plumber-7dv.pages.dev/)
149
+ - **GitHub Repository:** [https://github.com/parasraju/plumber](https://github.com/parasraju/plumber)
150
+
151
+ ---
152
+
153
+ ## Changelog
154
+
155
+ ## 1.2.0
156
+ - `pipe/docker-unpinned`: Flag unpinned Docker images (no tag or `:latest`) in CI jobs and Dockerfiles (`MEDIUM`).
157
+ - `sec/curl-pipe-shell`: Flag `curl | bash` and `wget | sh` remote script execution in CI run steps (`CRITICAL`).
158
+ - `sec/permissions-write-all`: Flag overly broad workflow write permissions (`permissions: write-all`, `contents: write`) (`HIGH`).
159
+ - `leak/slack-webhook`: Flag hardcoded Slack and tokenized webhook URLs in workflows and code (`CRITICAL`).
160
+ - `pipe/npm-unpinned`: Flag `npm install` in CI steps without `--save-exact` or `npm ci` lockfile enforcement (`MEDIUM`).
package/bin/plumber.js CHANGED
@@ -16,7 +16,7 @@ const API_BASE = process.env.PLUMBER_API_URL || 'http://localhost:3100';
16
16
  const HOOK_MARKER = '# plumber-managed-hook';
17
17
  const HOOK_BACKUP_SUFFIX = '.pre-plumber';
18
18
  const ENV_TEMPLATE_RE = /\.(example|sample|template|dist)$/;
19
- const SCANNABLE_EXTS = new Set(['.py', '.js', '.jsx', '.ts', '.tsx', '.html', '.htm', '.css', '.scss', '.less', '.vue', '.svelte', '.astro', '.go', '.rs', '.java', '.env']);
19
+ const SCANNABLE_EXTS = new Set(['.py', '.js', '.jsx', '.ts', '.tsx', '.html', '.htm', '.css', '.scss', '.less', '.vue', '.svelte', '.astro', '.go', '.rs', '.java', '.env', '.yml', '.yaml', '.sh']);
20
20
 
21
21
  const PRE_COMMIT_SCRIPT = `#!/bin/sh
22
22
  ${HOOK_MARKER}
@@ -65,7 +65,12 @@ const RULES = [
65
65
  { id: 'slop/chatbot-residue', cat: 'AI Slop Tells', sev: 'MEDIUM', title: 'Pasted Chatbot Conversational Residue', fix: 'Delete conversational intro/outro boilerplate.' },
66
66
  { id: 'slop/neon-glow', cat: 'AI Slop Tells', sev: 'LOW', title: 'Colored Neon Glow Shadow', fix: 'Replace with subtle crisp 1px borders.' },
67
67
  { id: 'slop/gradient-text', cat: 'AI Slop Tells', sev: 'LOW', title: 'Gradient-Clipped Headline Text', fix: 'Use solid, high-contrast typography.' },
68
- { id: 'ui/important-abuse', cat: 'AI Slop Tells', sev: 'LOW', title: '!important Overrides in Stylesheet', fix: 'Structure CSS cascade cleanly without !important.' }
68
+ { id: 'ui/important-abuse', cat: 'AI Slop Tells', sev: 'LOW', title: '!important Overrides in Stylesheet', fix: 'Structure CSS cascade cleanly without !important.' },
69
+ { id: 'pipe/docker-unpinned', cat: 'Pipes & Dependencies', sev: 'MEDIUM', title: 'Unpinned Docker Image (Missing Tag or :latest)', fix: 'Pin image to an explicit version tag or SHA256 digest (e.g., node:20.11-alpine).' },
70
+ { id: 'sec/curl-pipe-shell', cat: 'Leaks & Secrets', sev: 'CRITICAL', title: 'Remote Script Piped Directly to Shell (curl | bash)', fix: 'Download script first, verify its SHA256 checksum or signature, then execute it.' },
71
+ { id: 'sec/permissions-write-all', cat: 'Leaks & Secrets', sev: 'HIGH', title: 'Overly Broad Workflow Write Permissions', fix: 'Use least-privilege permissions (e.g., permissions: { contents: read }).' },
72
+ { id: 'leak/slack-webhook', cat: 'Leaks & Secrets', sev: 'CRITICAL', title: 'Hardcoded Slack or Tokenized Webhook URL', fix: 'Move webhook URL to CI/CD encrypted secrets (e.g., ${{ secrets.SLACK_WEBHOOK_URL }}).' },
73
+ { id: 'pipe/npm-unpinned', cat: 'Pipes & Dependencies', sev: 'MEDIUM', title: 'Unpinned npm Install in CI Without Lockfile Enforcement', fix: 'Use npm ci to enforce lockfile versions or pass --save-exact when adding packages.' }
69
74
  ];
70
75
 
71
76
  const SEV_WEIGHT = { CRITICAL: 4, HIGH: 3, MEDIUM: 2, LOW: 1, INFO: 0 };
@@ -114,7 +119,7 @@ COMMANDS:
114
119
  install-hook Block git commits that contain secrets, .env files, or dead code
115
120
  uninstall-hook Remove the Plumber pre-commit hook
116
121
  clean [path] Remove unreachable dead code (dry run unless --write)
117
- rules Display catalogue of 21 inspection rules
122
+ rules Display catalogue of 26 inspection rules
118
123
  mcp Run stdio Model Context Protocol (MCP) server for Claude / Cursor
119
124
 
120
125
  OPTIONS:
@@ -158,7 +163,7 @@ async function runScan(target, fmt, failOn) {
158
163
  }
159
164
 
160
165
  function scanLocalDirectory(dirPath) {
161
- const scannableExts = new Set(['.py', '.js', '.jsx', '.ts', '.tsx', '.html', '.htm', '.css', '.scss', '.env']);
166
+ const scannableExts = new Set(['.py', '.js', '.jsx', '.ts', '.tsx', '.html', '.htm', '.css', '.scss', '.env', '.yml', '.yaml', '.sh']);
162
167
  const skipDirs = new Set(['.git', 'node_modules', 'dist', 'build', '.next', '.nuxt', 'vendor', '.venv', 'venv', '__pycache__']);
163
168
 
164
169
  const issues = [];
@@ -171,16 +176,19 @@ function scanLocalDirectory(dirPath) {
171
176
  if (stat.isFile()) {
172
177
  const ext = path.extname(current).toLowerCase();
173
178
  const base = path.basename(current);
174
- if (scannableExts.has(ext) || base.startsWith('.env')) {
179
+ const isDockerfile = base === 'Dockerfile' || base.startsWith('Dockerfile.');
180
+ const isGitlabCi = base === '.gitlab-ci.yml' || base === '.gitlab-ci.yaml';
181
+ if (scannableExts.has(ext) || base.startsWith('.env') || isDockerfile || isGitlabCi) {
175
182
  totalFiles++;
176
183
  try {
177
184
  const content = fs.readFileSync(current, 'utf-8');
178
185
  const lines = content.split('\n');
179
186
  totalLines += lines.length;
180
- const fileIssues = inspectFile(path.relative(dirPath, current).replace(/\\/g, '/'), content, lines, ext);
187
+ const rel = (current === dirPath ? base : path.relative(dirPath, current)).replace(/\\/g, '/');
188
+ const fileIssues = inspectFile(rel, content, lines, ext);
181
189
  if (fileIssues.length > 0) {
182
190
  issues.push(...fileIssues);
183
- fileReports.push({ path: path.relative(dirPath, current).replace(/\\/g, '/'), issues: fileIssues });
191
+ fileReports.push({ path: rel, issues: fileIssues });
184
192
  }
185
193
  } catch (err) {
186
194
  // Skip unreadable or locked files
@@ -191,7 +199,7 @@ function scanLocalDirectory(dirPath) {
191
199
 
192
200
  if (stat.isDirectory()) {
193
201
  const base = path.basename(current);
194
- if (skipDirs.has(base) || (base.startsWith('.') && base !== '.')) return;
202
+ if (skipDirs.has(base) || (base.startsWith('.') && base !== '.' && base !== '.github' && base !== '.circleci')) return;
195
203
  const entries = fs.readdirSync(current);
196
204
  for (const entry of entries) {
197
205
  walk(path.join(current, entry));
@@ -219,6 +227,7 @@ function inspectFile(relPath, content, lines, ext) {
219
227
  const issues = [];
220
228
  const lower = content.toLowerCase();
221
229
  const base = path.basename(relPath);
230
+ const isTest = relPath.toLowerCase().includes('test') || relPath.toLowerCase().includes('spec');
222
231
 
223
232
  // Environment files must never be committed
224
233
  if (base.startsWith('.env') && !ENV_TEMPLATE_RE.test(base)) {
@@ -226,7 +235,7 @@ function inspectFile(relPath, content, lines, ext) {
226
235
  }
227
236
 
228
237
  // Elided code
229
- if (/(?:\/\/|#|\/\*)\s*(?:\.\.\.|…)?\s*(?:existing\s+code|rest\s+of\s+code)/i.test(content)) {
238
+ if (!isTest && /(?:\/\/|#|\/\*)\s*(?:\.\.\.|…)?\s*(?:existing\s+code|rest\s+of\s+code)/i.test(content)) {
230
239
  lines.forEach((l, idx) => {
231
240
  if (/(?:\/\/|#|\/\*)\s*(?:\.\.\.|…)?\s*(?:existing\s+code|rest\s+of\s+code)/i.test(l)) {
232
241
  issues.push({ rule_id: 'clog/elided-code', title: 'AI-Elided Code Snippet Left in File', severity: 'HIGH', line: idx + 1, evidence: l.trim().slice(0, 90), fix: 'Restore the complete code implementation.' });
@@ -235,22 +244,28 @@ function inspectFile(relPath, content, lines, ext) {
235
244
  }
236
245
 
237
246
  // Swallowed error
238
- if (lower.includes('except') || lower.includes('catch')) {
247
+ if (!isTest && (ext === '.py' || ext === '.js' || ext === '.ts' || ext === '.jsx' || ext === '.tsx')) {
239
248
  lines.forEach((l, idx) => {
240
- if (/except(?:\s+\w+)?:\s*(?:pass|\.\.\.)/.test(l) || /catch\s*\([^)]*\)\s*\{\s*\}/.test(l)) {
241
- issues.push({ rule_id: 'clog/swallowed-error', title: 'Swallowed Exception (Silent Failure)', severity: 'HIGH', line: idx + 1, evidence: l.trim(), fix: 'Log the error or properly re-raise/handle it.' });
249
+ const trim = l.trim();
250
+ if (trim.startsWith('#') || trim.startsWith('//') || trim.startsWith('/*')) return;
251
+ if (ext === '.py' && /^\s*except(?:\s+\w+)?:\s*(?:pass|\.\.\.)/.test(l)) {
252
+ issues.push({ rule_id: 'clog/swallowed-error', title: 'Swallowed Exception (Silent Failure)', severity: 'HIGH', line: idx + 1, evidence: trim, fix: 'Log the error or properly re-raise/handle it.' });
253
+ } else if (ext !== '.py' && /catch\s*\([^)]*\)\s*\{\s*\}/.test(l)) {
254
+ issues.push({ rule_id: 'clog/swallowed-error', title: 'Swallowed Exception (Silent Failure)', severity: 'HIGH', line: idx + 1, evidence: trim, fix: 'Log the error or properly re-raise/handle it.' });
242
255
  }
243
256
  });
244
257
  }
245
258
 
246
259
  // API keys
247
- if (content.includes('sk-') || content.includes('ghp_') || content.includes('AKIA')) {
260
+ if (!isTest && (content.includes('sk-') || content.includes('ghp_') || content.includes('AKIA'))) {
248
261
  lines.forEach((l, idx) => {
262
+ const trim = l.trim();
263
+ if (trim.startsWith('#') || trim.startsWith('//')) return;
249
264
  if (/\b(sk-(?:live|test|proj)?[a-zA-Z0-9_-]{24,})\b/.test(l)) {
250
- issues.push({ rule_id: 'leak/api-key', title: 'Leaked OpenAI / Model API Key', severity: 'CRITICAL', line: idx + 1, evidence: l.trim().slice(0, 70), fix: 'Extract secret to .env file immediately.' });
265
+ issues.push({ rule_id: 'leak/api-key', title: 'Leaked OpenAI / Model API Key', severity: 'CRITICAL', line: idx + 1, evidence: trim.slice(0, 70), fix: 'Extract secret to .env file immediately.' });
251
266
  }
252
267
  if (/\b(ghp_[a-zA-Z0-9]{36})\b/.test(l)) {
253
- issues.push({ rule_id: 'leak/api-key', title: 'Leaked GitHub Personal Access Token', severity: 'CRITICAL', line: idx + 1, evidence: l.trim().slice(0, 70), fix: 'Revoke key and store in secrets manager.' });
268
+ issues.push({ rule_id: 'leak/api-key', title: 'Leaked GitHub Personal Access Token', severity: 'CRITICAL', line: idx + 1, evidence: trim.slice(0, 70), fix: 'Revoke key and store in secrets manager.' });
254
269
  }
255
270
  });
256
271
  }
@@ -285,6 +300,118 @@ function inspectFile(relPath, content, lines, ext) {
285
300
  });
286
301
  }
287
302
 
303
+ const isYaml = ext === '.yml' || ext === '.yaml';
304
+ const isDockerfile = base === 'Dockerfile' || base.startsWith('Dockerfile.');
305
+ const isShell = ext === '.sh';
306
+
307
+ // 1. Docker unpinned (pipe/docker-unpinned)
308
+ if (isYaml || isDockerfile) {
309
+ lines.forEach((l, idx) => {
310
+ const trim = l.trim();
311
+ if (!trim || trim.startsWith('#')) return;
312
+ let img = null;
313
+ if (isDockerfile) {
314
+ const m = /^FROM\s+(?:--platform=\S+\s+)?([^\s#]+)/i.exec(trim);
315
+ if (m && m[1].toLowerCase() !== 'scratch' && !m[1].startsWith('$')) img = m[1];
316
+ } else if (isYaml) {
317
+ const m = /^image:\s*['"]?([^\s'"#]+)['"]?/i.exec(trim);
318
+ if (m && !m[1].startsWith('$')) img = m[1];
319
+ const dm = /\bdocker:\/\/([^\s'"#]+)/i.exec(trim);
320
+ if (dm && !dm[1].startsWith('$')) img = dm[1];
321
+ }
322
+ if (img) {
323
+ const hasDigest = img.includes('@sha256:');
324
+ const lastSlash = img.lastIndexOf('/');
325
+ const tagPart = img.slice(lastSlash + 1);
326
+ const colonIdx = tagPart.indexOf(':');
327
+ const tag = colonIdx !== -1 ? tagPart.slice(colonIdx + 1) : '';
328
+ if (!hasDigest && (colonIdx === -1 || tag.toLowerCase() === 'latest')) {
329
+ issues.push({
330
+ rule_id: 'pipe/docker-unpinned',
331
+ title: 'Unpinned Docker Image (Missing Tag or :latest)',
332
+ severity: 'MEDIUM',
333
+ line: idx + 1,
334
+ evidence: trim.slice(0, 90),
335
+ fix: 'Pin image to an explicit version tag or SHA256 digest (e.g., node:20.11-alpine).'
336
+ });
337
+ }
338
+ }
339
+ });
340
+ }
341
+
342
+ // 2. curl piped to shell (sec/curl-pipe-shell)
343
+ if (!isTest && (isYaml || isDockerfile || isShell)) {
344
+ lines.forEach((l, idx) => {
345
+ const trim = l.trim();
346
+ if (!trim || trim.startsWith('#') || trim.startsWith('//')) return;
347
+ if (/\b(?:curl|wget)\b[^|\n]*\|\s*(?:sudo\s+)?(?:ba|z|da|k)?sh\b/i.test(l)) {
348
+ issues.push({
349
+ rule_id: 'sec/curl-pipe-shell',
350
+ title: 'Remote Script Piped Directly to Shell (curl | bash)',
351
+ severity: 'CRITICAL',
352
+ line: idx + 1,
353
+ evidence: trim.slice(0, 90),
354
+ fix: 'Download script first, verify its SHA256 checksum or signature, then execute it.'
355
+ });
356
+ }
357
+ });
358
+ }
359
+
360
+ // 3. Permissions write-all (sec/permissions-write-all)
361
+ if (isYaml) {
362
+ lines.forEach((l, idx) => {
363
+ const trim = l.trim();
364
+ if (!trim || trim.startsWith('#')) return;
365
+ if (/^permissions:\s*['"]?write-all['"]?\s*(?:#.*)?$/i.test(trim) || /^contents:\s*['"]?write['"]?\s*(?:#.*)?$/i.test(trim)) {
366
+ issues.push({
367
+ rule_id: 'sec/permissions-write-all',
368
+ title: 'Overly Broad Workflow Write Permissions',
369
+ severity: 'HIGH',
370
+ line: idx + 1,
371
+ evidence: trim.slice(0, 90),
372
+ fix: 'Use least-privilege permissions (e.g., permissions: { contents: read }).'
373
+ });
374
+ }
375
+ });
376
+ }
377
+
378
+ // 4. Slack webhook secret (leak/slack-webhook)
379
+ if (!isTest && (content.includes('hooks.slack.com/') || content.includes('discord.com/api/webhooks/') || content.includes('discordapp.com/api/webhooks/'))) {
380
+ lines.forEach((l, idx) => {
381
+ const trim = l.trim();
382
+ if (!trim || trim.startsWith('#') || trim.startsWith('//')) return;
383
+ if (/https:\/\/hooks\.slack\.com\/services\/T[A-Za-z0-9_]+\/B[A-Za-z0-9_]+\/[A-Za-z0-9_]+/.test(l) ||
384
+ /https:\/\/(?:ptb\.|canary\.)?discord(?:app)?\.com\/api\/webhooks\/\d+\/[A-Za-z0-9_-]+/.test(l)) {
385
+ issues.push({
386
+ rule_id: 'leak/slack-webhook',
387
+ title: 'Hardcoded Slack or Tokenized Webhook URL',
388
+ severity: 'CRITICAL',
389
+ line: idx + 1,
390
+ evidence: trim.slice(0, 90),
391
+ fix: 'Move webhook URL to CI/CD encrypted secrets (e.g., ${{ secrets.SLACK_WEBHOOK_URL }}).'
392
+ });
393
+ }
394
+ });
395
+ }
396
+
397
+ // 5. npm install without --save-exact (pipe/npm-unpinned)
398
+ if (isYaml || isDockerfile || isShell) {
399
+ lines.forEach((l, idx) => {
400
+ const trim = l.trim();
401
+ if (!trim || trim.startsWith('#')) return;
402
+ if (/\bnpm\s+(?:install|i)\b/.test(l) && !/--save-exact\b|\s-E\b|--package-lock-only\b/.test(l)) {
403
+ issues.push({
404
+ rule_id: 'pipe/npm-unpinned',
405
+ title: 'Unpinned npm Install in CI Without Lockfile Enforcement',
406
+ severity: 'MEDIUM',
407
+ line: idx + 1,
408
+ evidence: trim.slice(0, 90),
409
+ fix: 'Use npm ci to enforce lockfile versions or pass --save-exact when adding packages.'
410
+ });
411
+ }
412
+ });
413
+ }
414
+
288
415
  return issues;
289
416
  }
290
417
 
@@ -527,7 +654,8 @@ function runHook(argv) {
527
654
  const base = path.basename(rel);
528
655
  const ext = path.extname(rel).toLowerCase();
529
656
  const isEnv = base.startsWith('.env');
530
- if (!isEnv && !SCANNABLE_EXTS.has(ext)) continue;
657
+ const isDockerfile = base === 'Dockerfile' || base.startsWith('Dockerfile.');
658
+ if (!isEnv && !isDockerfile && !SCANNABLE_EXTS.has(ext)) continue;
531
659
 
532
660
  let content;
533
661
  try {
package/package.json CHANGED
@@ -1,41 +1,44 @@
1
- {
2
- "name": "plumber-linter",
3
- "version": "1.1.1",
4
- "description": "CI/CD pipeline linter that flags hardcoded secrets, leaked credentials, and dead code — with fixes in plain English.",
5
- "main": "bin/plumber.js",
6
- "bin": {
7
- "plumber": "bin/plumber.js",
8
- "plumber-linter": "bin/plumber.js"
9
- },
10
- "keywords": [
11
- "linter",
12
- "github-actions",
13
- "gitlab",
14
- "ci-cd",
15
- "pipeline-security",
16
- "secrets-detection",
17
- "code-quality",
18
- "devsecops",
19
- "security",
20
- "github",
21
- "workflow",
22
- "cli"
23
- ],
24
- "author": "Paras Raju",
25
- "license": "MIT",
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/parasraju/plumber.git"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/parasraju/plumber/issues"
32
- },
33
- "homepage": "https://github.com/parasraju/plumber#readme",
34
- "engines": {
35
- "node": ">=18.0.0"
36
- },
37
- "files": [
38
- "bin",
39
- "README.md"
40
- ]
41
- }
1
+ {
2
+ "name": "plumber-linter",
3
+ "version": "1.2.0",
4
+ "description": "CI/CD pipeline linter that flags hardcoded secrets, leaked credentials, and dead code — with fixes in plain English.",
5
+ "main": "bin/plumber.js",
6
+ "bin": {
7
+ "plumber": "bin/plumber.js",
8
+ "plumber-linter": "bin/plumber.js"
9
+ },
10
+ "keywords": [
11
+ "linter",
12
+ "github-actions",
13
+ "gitlab",
14
+ "ci-cd",
15
+ "pipeline-security",
16
+ "secrets-detection",
17
+ "code-quality",
18
+ "devsecops",
19
+ "security",
20
+ "github",
21
+ "workflow",
22
+ "cli",
23
+ "docker",
24
+ "supply-chain",
25
+ "slack"
26
+ ],
27
+ "author": "Paras Raju",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/parasraju/plumber.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/parasraju/plumber/issues"
35
+ },
36
+ "homepage": "https://github.com/parasraju/plumber#readme",
37
+ "engines": {
38
+ "node": ">=18.0.0"
39
+ },
40
+ "files": [
41
+ "bin",
42
+ "README.md"
43
+ ]
44
+ }