@trust-assurance-protocol/owaspscan 1.0.0 → 1.0.1

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 (2) hide show
  1. package/README.md +413 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,413 @@
1
+ <p align="center">
2
+ <img src="https://img.shields.io/npm/v/@trust-assurance-protocol/owaspscan?color=blue&label=npm" alt="npm version" />
3
+ <img src="https://img.shields.io/badge/OWASP-Top%2010%20%2B%20LLM%20Top%2010-orange" alt="OWASP Coverage" />
4
+ <img src="https://img.shields.io/badge/languages-10-green" alt="Languages" />
5
+ <img src="https://img.shields.io/badge/rules-30%2B-red" alt="Rules" />
6
+ <img src="https://img.shields.io/badge/license-MIT-blue" alt="License" />
7
+ </p>
8
+
9
+ # OWASPScan
10
+
11
+ **Security code auditor covering OWASP Top 10 + LLM Top 10.** Detects vulnerabilities in AI-generated and human-written code using AST analysis, taint tracking, and optional AI verification.
12
+
13
+ Built for developers who ship fast and security teams who need coverage across the full OWASP attack surface — including AI-specific threats.
14
+
15
+ ```bash
16
+ npx @trust-assurance-protocol/owaspscan scan ./src
17
+ ```
18
+
19
+ ```
20
+ [CRITICAL] OWASP-A03-001 A03:2021 SQL Injection via String Concatenation
21
+ src/db/users.ts:42 | db.query(`SELECT * FROM users WHERE id = ${req.params.id}`)
22
+ Confidence: HIGH Method: ast CWE-89
23
+
24
+ [HIGH] OWASP-A02-001 A02:2021 Hardcoded API Key / Secret
25
+ src/config.ts:8 | const API_KEY = "sk-live-abc123..."
26
+ Confidence: HIGH Method: regex CWE-798
27
+
28
+ Score: 35/100 | 12 findings | 2 CRITICAL, 4 HIGH, 6 MEDIUM
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Why OWASPScan
34
+
35
+ - **AI-aware.** First scanner with native OWASP LLM Top 10 rules — catches prompt injection, sensitive data leakage to LLMs, excessive agency, and more.
36
+ - **Deep analysis.** Three-tier detection: regex patterns, tree-sitter AST analysis with cross-file taint tracking, and optional Claude AI verification.
37
+ - **10 languages.** JavaScript, TypeScript, Python, Java, Go, PHP, Ruby, C#, C/C++, Rust.
38
+ - **CI/CD native.** SARIF output for GitHub Code Scanning, `--fail-on` for pipeline gates, JSON for dashboards.
39
+ - **MCP server.** Plug directly into Claude Desktop, Cursor, or any MCP client — scan code from your AI assistant.
40
+ - **Zero config.** Works out of the box. One command, instant results.
41
+
42
+ ---
43
+
44
+ ## Quick Start
45
+
46
+ ### Install globally
47
+
48
+ ```bash
49
+ npm install -g @trust-assurance-protocol/owaspscan
50
+ ```
51
+
52
+ ### Scan a project
53
+
54
+ ```bash
55
+ owaspscan scan ./my-project
56
+ ```
57
+
58
+ ### Scan a single file
59
+
60
+ ```bash
61
+ owaspscan scan src/auth/login.ts
62
+ ```
63
+
64
+ ### Scan code from stdin
65
+
66
+ ```bash
67
+ cat src/handler.js | owaspscan check --lang javascript
68
+ ```
69
+
70
+ ### Use without installing
71
+
72
+ ```bash
73
+ npx @trust-assurance-protocol/owaspscan scan ./src
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Usage
79
+
80
+ ### CLI Commands
81
+
82
+ ```bash
83
+ # Scan with specific OWASP categories
84
+ owaspscan scan ./src --rules A03,A07,LLM01
85
+
86
+ # Output as SARIF for GitHub Code Scanning
87
+ owaspscan scan ./src --format sarif > results.sarif
88
+
89
+ # Fail CI if critical or high findings exist
90
+ owaspscan scan ./src --fail-on high
91
+
92
+ # Run with SCA dependency scanning
93
+ owaspscan scan ./src --sca
94
+
95
+ # AI-powered verification (requires ANTHROPIC_API_KEY)
96
+ owaspscan scan ./src --ai-verify
97
+
98
+ # Filter by confidence level
99
+ owaspscan scan ./src --min-confidence HIGH
100
+
101
+ # List all rules
102
+ owaspscan rules
103
+ owaspscan rules --category A03 --severity HIGH
104
+ ```
105
+
106
+ ### Full CLI Reference
107
+
108
+ | Flag | Description |
109
+ |------|-------------|
110
+ | `-r, --rules <categories>` | Filter by OWASP categories (e.g., `A01,A03,LLM01`) |
111
+ | `-f, --format <format>` | Output: `console`, `json`, `sarif`, `llm` |
112
+ | `--fail-on <severity>` | Exit code 1 at threshold: `critical`, `high`, `medium`, `low` |
113
+ | `--sca` | Scan dependencies against OSV CVE database |
114
+ | `--ai-verify` | Verify findings with Claude AI |
115
+ | `--ai-verify-limit <n>` | Max AI verification calls (default: 50) |
116
+ | `--min-confidence <level>` | Minimum confidence: `HIGH`, `MEDIUM`, `LOW` |
117
+ | `--exclude <patterns>` | Glob patterns to exclude |
118
+ | `--max-findings <n>` | Stop after N findings |
119
+ | `--verbose` | Show fix suggestions and references |
120
+ | `--config <path>` | Path to config file |
121
+
122
+ ---
123
+
124
+ ## CI/CD Integration
125
+
126
+ ### GitHub Actions
127
+
128
+ ```yaml
129
+ - name: Security Scan
130
+ run: |
131
+ npx @trust-assurance-protocol/owaspscan scan ./src \
132
+ --format sarif \
133
+ --fail-on high \
134
+ > results.sarif
135
+
136
+ - name: Upload SARIF
137
+ uses: github/codeql-action/upload-sarif@v3
138
+ with:
139
+ sarif_file: results.sarif
140
+ ```
141
+
142
+ ### GitLab CI
143
+
144
+ ```yaml
145
+ security-scan:
146
+ script:
147
+ - npx @trust-assurance-protocol/owaspscan scan ./src --format sarif --fail-on high > gl-sast-report.sarif
148
+ artifacts:
149
+ reports:
150
+ sast: gl-sast-report.sarif
151
+ ```
152
+
153
+ ### Pre-commit Hook
154
+
155
+ ```bash
156
+ # .husky/pre-commit
157
+ npx @trust-assurance-protocol/owaspscan scan ./src --fail-on critical --format console
158
+ ```
159
+
160
+ ---
161
+
162
+ ## MCP Server — AI Assistant Integration
163
+
164
+ OWASPScan runs as an [MCP](https://modelcontextprotocol.io) server, letting AI assistants scan code directly.
165
+
166
+ ### Claude Desktop / Cursor / Cline
167
+
168
+ Add to your MCP config:
169
+
170
+ ```json
171
+ {
172
+ "mcpServers": {
173
+ "owaspscan": {
174
+ "command": "npx",
175
+ "args": ["@trust-assurance-protocol/owaspscan", "scan", "--mcp"]
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ ### Available MCP Tools
182
+
183
+ | Tool | Description |
184
+ |------|-------------|
185
+ | `scan_file` | Scan a single file for vulnerabilities |
186
+ | `scan_directory` | Recursively scan a project directory |
187
+ | `scan_code` | Scan a code snippet — ideal for reviewing AI-generated code before committing |
188
+ | `get_rules` | List rules with filtering by category, language, severity |
189
+ | `explain_finding` | Get detailed explanation and fix for a rule |
190
+ | `get_owasp_category` | Describe an OWASP category with related rules |
191
+
192
+ ---
193
+
194
+ ## Detection Coverage
195
+
196
+ ### OWASP Top 10:2021
197
+
198
+ | Category | Rules | Examples |
199
+ |----------|-------|----------|
200
+ | **A01** Broken Access Control | 3 | Missing auth middleware, path traversal, IDOR |
201
+ | **A02** Cryptographic Failures | 4 | Hardcoded secrets, weak hashing, insecure TLS |
202
+ | **A03** Injection | 6 | SQL, command, NoSQL, XSS, template, LDAP injection |
203
+ | **A04** Insecure Design | 2 | Missing rate limiting, mass assignment |
204
+ | **A05** Security Misconfiguration | 4 | Debug mode, CORS wildcard, default credentials |
205
+ | **A06** Vulnerable Components | 1 | Outdated packages (via SCA) |
206
+ | **A07** Auth Failures | 4 | JWT none algorithm, no password hashing, weak sessions |
207
+ | **A08** Data Integrity | 2 | Unsafe deserialization, dynamic code execution |
208
+ | **A09** Logging Failures | 2 | Sensitive data in logs, missing error handling |
209
+ | **A10** SSRF | 2 | Unvalidated fetch, open redirect |
210
+
211
+ ### Analysis Methods
212
+
213
+ OWASPScan uses a tiered approach — each method adds confidence:
214
+
215
+ | Tier | Method | Languages | Confidence |
216
+ |------|--------|-----------|------------|
217
+ | 1 | **Regex patterns** | All 10 languages | MEDIUM |
218
+ | 2 | **AST analysis** (tree-sitter) | JS, TS, Python | HIGH |
219
+ | 3 | **Taint tracking** | All (regex-based for non-AST languages) | HIGH |
220
+ | 4 | **AI verification** (Claude) | All | HIGH (verified) |
221
+
222
+ **Cross-file taint tracking**: For JS/TS projects, OWASPScan traces data flows across module boundaries — if one file exports a function that returns user input, downstream files using that function are flagged.
223
+
224
+ ---
225
+
226
+ ## Programmatic API
227
+
228
+ Use OWASPScan as a library in your own tools:
229
+
230
+ ```typescript
231
+ import { scanDirectory, scanCode, scanFile, registry } from '@trust-assurance-protocol/owaspscan';
232
+
233
+ // Scan a directory
234
+ const result = await scanDirectory('./src', {
235
+ rules: ['A03', 'A07'],
236
+ recursive: true,
237
+ failOn: 'high',
238
+ verbose: false,
239
+ });
240
+
241
+ console.log(`Score: ${result.securityScore}/100`);
242
+ console.log(`Findings: ${result.totalFindings}`);
243
+
244
+ // Scan inline code
245
+ const codeResult = await scanCode(
246
+ 'db.query("SELECT * FROM users WHERE id = " + userId)',
247
+ 'javascript',
248
+ );
249
+
250
+ // Access rule metadata
251
+ const allRules = registry.getAll();
252
+ const injectionRules = registry.filterByCategories(['A03']);
253
+ ```
254
+
255
+ ### Types
256
+
257
+ ```typescript
258
+ import type {
259
+ Rule,
260
+ Finding,
261
+ ScanResult,
262
+ FileResult,
263
+ Severity,
264
+ OWASPCategory,
265
+ SupportedLanguage,
266
+ } from '@trust-assurance-protocol/owaspscan/types';
267
+ ```
268
+
269
+ ---
270
+
271
+ ## Configuration
272
+
273
+ Create `owaspscan.config.json` in your project root:
274
+
275
+ ```json
276
+ {
277
+ "rules": ["A01", "A02", "A03", "A07"],
278
+ "exclude": ["**/*.test.ts", "**/*.spec.js", "migrations/**"],
279
+ "failOn": "high",
280
+ "minConfidence": "MEDIUM",
281
+ "format": "console",
282
+ "verbose": true,
283
+ "sca": true,
284
+ "aiVerify": false,
285
+ "aiVerifyLimit": 50
286
+ }
287
+ ```
288
+
289
+ CLI flags override config file values. Config is auto-discovered from the scan target directory.
290
+
291
+ ---
292
+
293
+ ## Plugin System
294
+
295
+ OWASPScan supports external rule packages. Create custom rules that integrate seamlessly:
296
+
297
+ ```typescript
298
+ import type { Rule } from '@trust-assurance-protocol/owaspscan/types';
299
+ import { registry } from '@trust-assurance-protocol/owaspscan';
300
+
301
+ const myRule: Rule = {
302
+ id: 'CUSTOM-001',
303
+ name: 'My Custom Rule',
304
+ owasp: 'A03:2021',
305
+ cwe: 'CWE-89',
306
+ severity: 'HIGH',
307
+ languages: ['javascript', 'typescript'],
308
+ description: 'Detects a custom vulnerability pattern',
309
+ patterns: [{ pattern: /dangerousFunction\(/ }],
310
+ fix: 'Use safeFunction() instead',
311
+ references: ['https://example.com/docs'],
312
+ tags: ['custom', 'injection'],
313
+ };
314
+
315
+ registry.registerRules([myRule]);
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Supported Languages
321
+
322
+ | Language | Extensions | AST Analysis | Taint Tracking |
323
+ |----------|-----------|:------------:|:--------------:|
324
+ | JavaScript | `.js`, `.mjs`, `.cjs`, `.jsx` | Yes | Yes (AST) |
325
+ | TypeScript | `.ts`, `.tsx`, `.mts`, `.cts` | Yes | Yes (AST) |
326
+ | Python | `.py`, `.pyw` | Yes | Yes (AST) |
327
+ | Java | `.java` | — | Yes (regex) |
328
+ | Go | `.go` | — | Yes (regex) |
329
+ | PHP | `.php` | — | Yes (regex) |
330
+ | Ruby | `.rb`, `.rake` | — | Yes (regex) |
331
+ | C# | `.cs` | — | Yes (regex) |
332
+ | C/C++ | `.c`, `.cpp`, `.h` | — | Yes (regex) |
333
+ | Rust | `.rs` | — | Yes (regex) |
334
+
335
+ ---
336
+
337
+ ## Inline Suppression
338
+
339
+ Suppress specific findings with comments:
340
+
341
+ ```javascript
342
+ // owaspscan-suppress OWASP-A03-001
343
+ db.query(trustedInternalQuery); // Known safe usage
344
+ ```
345
+
346
+ ---
347
+
348
+ ## Output Formats
349
+
350
+ ### Console (default)
351
+ Human-readable colored output with severity grouping.
352
+
353
+ ### JSON
354
+ ```bash
355
+ owaspscan scan ./src --format json | jq '.securityScore'
356
+ ```
357
+
358
+ ### SARIF
359
+ GitHub Code Scanning and GitLab SAST compatible.
360
+ ```bash
361
+ owaspscan scan ./src --format sarif > results.sarif
362
+ ```
363
+
364
+ ### LLM
365
+ Compact, token-efficient format optimized for AI agents.
366
+ ```bash
367
+ owaspscan scan ./src --format llm
368
+ ```
369
+
370
+ ---
371
+
372
+ ## SCA — Dependency Scanning
373
+
374
+ Scan your dependencies for known CVEs using the [OSV](https://osv.dev) database:
375
+
376
+ ```bash
377
+ owaspscan scan ./my-project --sca
378
+ ```
379
+
380
+ Supports:
381
+ - `package-lock.json` (npm)
382
+ - `requirements.txt` (Python)
383
+
384
+ No API key required. Results are integrated into the main scan output.
385
+
386
+ ---
387
+
388
+ ## AI Verification
389
+
390
+ Use Claude to verify low-confidence findings and eliminate false positives:
391
+
392
+ ```bash
393
+ export ANTHROPIC_API_KEY=sk-ant-...
394
+ owaspscan scan ./src --ai-verify --ai-verify-limit 25
395
+ ```
396
+
397
+ - Reviews code context (surrounding lines) to confirm real vulnerabilities
398
+ - Detects sanitization, parameterization, and safe patterns
399
+ - Upgrades confirmed findings from MEDIUM to HIGH confidence
400
+ - Results cached for 24 hours to minimize API costs
401
+
402
+ ---
403
+
404
+ ## Requirements
405
+
406
+ - Node.js >= 18.0.0
407
+ - Optional: `ANTHROPIC_API_KEY` for AI verification
408
+
409
+ ---
410
+
411
+ ## License
412
+
413
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trust-assurance-protocol/owaspscan",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Professional OWASP Top 10 + LLM Top 10 security auditor for AI-generated and human-written code",
5
5
  "keywords": [
6
6
  "owasp",