deepscan-cli 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/LICENSE +201 -0
- package/README.md +419 -0
- package/dist/bin/deepscan.d.ts +1 -0
- package/dist/bin/deepscan.js +393 -0
- package/dist/bin/deepscan.js.map +1 -0
- package/dist/chunk-OSYJXVNF.js +7268 -0
- package/dist/chunk-OSYJXVNF.js.map +1 -0
- package/dist/index.d.ts +470 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
- package/rules/built-in/converted-semgrep.yml +37 -0
- package/rules/built-in/default-config.yml +59 -0
- package/rules/built-in/quality.yml +117 -0
- package/rules/built-in/security.yml +383 -0
- package/rules/built-in/semgrep-apex.yml +336 -0
- package/rules/built-in/semgrep-bash.yml +362 -0
- package/rules/built-in/semgrep-c.yml +429 -0
- package/rules/built-in/semgrep-clojure.yml +166 -0
- package/rules/built-in/semgrep-csharp.yml +1260 -0
- package/rules/built-in/semgrep-dart.yml +21 -0
- package/rules/built-in/semgrep-dockerfile.yml +874 -0
- package/rules/built-in/semgrep-elixir.yml +146 -0
- package/rules/built-in/semgrep-generic.yml +2945 -0
- package/rules/built-in/semgrep-go.yml +2898 -0
- package/rules/built-in/semgrep-hcl.yml +8181 -0
- package/rules/built-in/semgrep-html.yml +94 -0
- package/rules/built-in/semgrep-java.yml +4219 -0
- package/rules/built-in/semgrep-javascript.yml +6243 -0
- package/rules/built-in/semgrep-json.yml +360 -0
- package/rules/built-in/semgrep-kotlin.yml +540 -0
- package/rules/built-in/semgrep-lua.yml +46 -0
- package/rules/built-in/semgrep-ocaml.yml +773 -0
- package/rules/built-in/semgrep-php.yml +1638 -0
- package/rules/built-in/semgrep-python.yml +11240 -0
- package/rules/built-in/semgrep-regex.yml +6444 -0
- package/rules/built-in/semgrep-ruby.yml +2687 -0
- package/rules/built-in/semgrep-rust.yml +278 -0
- package/rules/built-in/semgrep-scala.yml +807 -0
- package/rules/built-in/semgrep-sh.yml +46 -0
- package/rules/built-in/semgrep-solidity.yml +1046 -0
- package/rules/built-in/semgrep-swift.yml +200 -0
- package/rules/built-in/semgrep-terraform.yml +147 -0
- package/rules/built-in/semgrep-typescript.yml +6212 -0
- package/rules/built-in/semgrep-xml.yml +31 -0
- package/rules/built-in/semgrep-yaml.yml +2785 -0
- package/rules/examples/custom-api-security.yml +66 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { Tree, Parser } from 'web-tree-sitter';
|
|
2
|
+
|
|
3
|
+
/** Severity levels for scan findings */
|
|
4
|
+
type Severity = 'critical' | 'high' | 'medium' | 'low';
|
|
5
|
+
/** Confidence levels for findings */
|
|
6
|
+
type Confidence = 'high' | 'medium' | 'low';
|
|
7
|
+
/** Scanner engine types */
|
|
8
|
+
type ScannerType = 'security' | 'quality' | 'cve';
|
|
9
|
+
/** Source location in a file */
|
|
10
|
+
interface SourceLocation {
|
|
11
|
+
file: string;
|
|
12
|
+
startLine: number;
|
|
13
|
+
startColumn: number;
|
|
14
|
+
endLine: number;
|
|
15
|
+
endColumn: number;
|
|
16
|
+
snippet: string;
|
|
17
|
+
snippetStartLine?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Business logic context detected in code */
|
|
20
|
+
interface CodeContext {
|
|
21
|
+
type: 'auth' | 'payment' | 'data-handling' | 'api' | 'crypto' | 'file-io' | 'general';
|
|
22
|
+
confidence: number;
|
|
23
|
+
indicators: string[];
|
|
24
|
+
relatedFiles: string[];
|
|
25
|
+
}
|
|
26
|
+
/** A step in a taint flow trace */
|
|
27
|
+
interface TaintFlowStep {
|
|
28
|
+
location: SourceLocation;
|
|
29
|
+
label: string;
|
|
30
|
+
kind: 'source' | 'propagator' | 'sanitizer' | 'sink';
|
|
31
|
+
}
|
|
32
|
+
/** AI validation result for a finding */
|
|
33
|
+
interface AIValidationResult {
|
|
34
|
+
isValid: boolean;
|
|
35
|
+
explanation: string;
|
|
36
|
+
confidence: number;
|
|
37
|
+
fixSuggestion?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Fix suggestion for a finding */
|
|
40
|
+
interface FixSuggestion {
|
|
41
|
+
description: string;
|
|
42
|
+
suggestion?: string;
|
|
43
|
+
references: string[];
|
|
44
|
+
}
|
|
45
|
+
/** A single scan finding / issue */
|
|
46
|
+
interface Finding {
|
|
47
|
+
id: string;
|
|
48
|
+
ruleId: string;
|
|
49
|
+
scanner: ScannerType;
|
|
50
|
+
severity: Severity;
|
|
51
|
+
confidence: Confidence;
|
|
52
|
+
category: string;
|
|
53
|
+
subcategory?: string;
|
|
54
|
+
title: string;
|
|
55
|
+
message: string;
|
|
56
|
+
location: SourceLocation;
|
|
57
|
+
context?: CodeContext;
|
|
58
|
+
taintFlow?: TaintFlowStep[];
|
|
59
|
+
cwe?: string[];
|
|
60
|
+
owasp?: string[];
|
|
61
|
+
fix?: FixSuggestion;
|
|
62
|
+
references?: string[];
|
|
63
|
+
aiValidation?: AIValidationResult;
|
|
64
|
+
metadata: {
|
|
65
|
+
fingerprint: string;
|
|
66
|
+
firstSeen?: string;
|
|
67
|
+
tags: string[];
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Summary statistics for a scan */
|
|
71
|
+
interface ScanSummary {
|
|
72
|
+
totalFindings: number;
|
|
73
|
+
bySeverity: Record<Severity, number>;
|
|
74
|
+
byScanner: Record<ScannerType, number>;
|
|
75
|
+
byCategory: Record<string, number>;
|
|
76
|
+
filesScanned: number;
|
|
77
|
+
filesWithFindings: number;
|
|
78
|
+
scanDuration: number;
|
|
79
|
+
timestamp: string;
|
|
80
|
+
}
|
|
81
|
+
/** Complete scan result */
|
|
82
|
+
interface ScanResult {
|
|
83
|
+
version: string;
|
|
84
|
+
tool: {
|
|
85
|
+
name: string;
|
|
86
|
+
version: string;
|
|
87
|
+
};
|
|
88
|
+
target: string;
|
|
89
|
+
config: string;
|
|
90
|
+
summary: ScanSummary;
|
|
91
|
+
findings: Finding[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Scanner-specific configuration */
|
|
95
|
+
interface SecurityScannerConfig {
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
severity: Severity[];
|
|
98
|
+
}
|
|
99
|
+
interface QualityThresholds {
|
|
100
|
+
maxComplexity: number;
|
|
101
|
+
maxCognitiveComplexity: number;
|
|
102
|
+
maxFileLength: number;
|
|
103
|
+
maxFunctionLength: number;
|
|
104
|
+
maxNestingDepth: number;
|
|
105
|
+
minCommentRatio: number;
|
|
106
|
+
}
|
|
107
|
+
interface QualityScannerConfig {
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
thresholds: QualityThresholds;
|
|
110
|
+
}
|
|
111
|
+
interface CVEScannerConfig {
|
|
112
|
+
enabled: boolean;
|
|
113
|
+
sources: string[];
|
|
114
|
+
failOnSeverity?: Severity;
|
|
115
|
+
}
|
|
116
|
+
/** AI validation configuration */
|
|
117
|
+
interface AIConfig {
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
provider: 'openai' | 'anthropic' | 'ollama' | 'google';
|
|
120
|
+
model?: string;
|
|
121
|
+
apiKey?: string;
|
|
122
|
+
baseUrl?: string;
|
|
123
|
+
maxFindings?: number;
|
|
124
|
+
temperature?: number;
|
|
125
|
+
}
|
|
126
|
+
/** Project context configuration */
|
|
127
|
+
interface ContextConfig {
|
|
128
|
+
projectType: 'web' | 'api' | 'library' | 'mobile' | 'cli' | 'auto';
|
|
129
|
+
frameworks: string[];
|
|
130
|
+
sensitivePatterns: string[];
|
|
131
|
+
}
|
|
132
|
+
/** Output configuration */
|
|
133
|
+
interface OutputConfig {
|
|
134
|
+
format: OutputFormat;
|
|
135
|
+
file?: string;
|
|
136
|
+
verbose: boolean;
|
|
137
|
+
colors: boolean;
|
|
138
|
+
}
|
|
139
|
+
/** Supported output formats */
|
|
140
|
+
type OutputFormat = 'json' | 'csv' | 'html' | 'sarif' | 'console';
|
|
141
|
+
/** Rules configuration */
|
|
142
|
+
interface RulesConfig {
|
|
143
|
+
include: string[];
|
|
144
|
+
exclude: string[];
|
|
145
|
+
custom: string[];
|
|
146
|
+
}
|
|
147
|
+
/** Paths configuration */
|
|
148
|
+
interface PathsConfig {
|
|
149
|
+
include: string[];
|
|
150
|
+
exclude: string[];
|
|
151
|
+
}
|
|
152
|
+
/** Complete DeepScan configuration */
|
|
153
|
+
interface DeepScanConfig {
|
|
154
|
+
version: string;
|
|
155
|
+
scanners: {
|
|
156
|
+
security: SecurityScannerConfig;
|
|
157
|
+
quality: QualityScannerConfig;
|
|
158
|
+
cve: CVEScannerConfig;
|
|
159
|
+
};
|
|
160
|
+
rules: RulesConfig;
|
|
161
|
+
languages: string[];
|
|
162
|
+
paths: PathsConfig;
|
|
163
|
+
output: OutputConfig;
|
|
164
|
+
ai: AIConfig;
|
|
165
|
+
context: ContextConfig;
|
|
166
|
+
parallel: number;
|
|
167
|
+
incremental: boolean;
|
|
168
|
+
deep: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Pattern definition within a rule */
|
|
172
|
+
interface RulePattern {
|
|
173
|
+
/** Tree-sitter query or code pattern */
|
|
174
|
+
pattern?: string;
|
|
175
|
+
/** Message to display when this pattern matches */
|
|
176
|
+
message?: string;
|
|
177
|
+
/** Regex pattern (for non-AST matching) */
|
|
178
|
+
regex?: string;
|
|
179
|
+
/** Flags for regex */
|
|
180
|
+
regexFlags?: string;
|
|
181
|
+
}
|
|
182
|
+
/** Condition for advanced rule logic */
|
|
183
|
+
interface RuleCondition {
|
|
184
|
+
type: 'taint-check' | 'context-check' | 'scope-check' | 'ast-check';
|
|
185
|
+
/** For taint-check: source type */
|
|
186
|
+
source?: string;
|
|
187
|
+
/** For taint-check: sink variable */
|
|
188
|
+
sink?: string;
|
|
189
|
+
/** For context-check: contexts to include/exclude */
|
|
190
|
+
in?: string[];
|
|
191
|
+
notIn?: string[];
|
|
192
|
+
/** For scope-check */
|
|
193
|
+
scope?: string;
|
|
194
|
+
}
|
|
195
|
+
/** Fix suggestion within a rule */
|
|
196
|
+
interface RuleFix {
|
|
197
|
+
description: string;
|
|
198
|
+
replacement?: string;
|
|
199
|
+
}
|
|
200
|
+
/** A single rule definition */
|
|
201
|
+
interface Rule {
|
|
202
|
+
id: string;
|
|
203
|
+
name: string;
|
|
204
|
+
description: string;
|
|
205
|
+
category: string;
|
|
206
|
+
subcategory?: string;
|
|
207
|
+
severity: Severity;
|
|
208
|
+
confidence: Confidence;
|
|
209
|
+
cwe?: string[];
|
|
210
|
+
owasp?: string[];
|
|
211
|
+
languages: string[];
|
|
212
|
+
patterns: RulePattern[];
|
|
213
|
+
conditions?: RuleCondition[];
|
|
214
|
+
fix?: RuleFix;
|
|
215
|
+
tags?: string[];
|
|
216
|
+
references?: string[];
|
|
217
|
+
enabled?: boolean;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Context passed to scanners for each file */
|
|
221
|
+
interface ScanFileContext {
|
|
222
|
+
filePath: string;
|
|
223
|
+
content: string;
|
|
224
|
+
language: string;
|
|
225
|
+
tree: Tree | null;
|
|
226
|
+
parser: Parser | null;
|
|
227
|
+
config: DeepScanConfig;
|
|
228
|
+
rules: Rule[];
|
|
229
|
+
}
|
|
230
|
+
/** Interface that all scanner engines must implement */
|
|
231
|
+
interface IScanner {
|
|
232
|
+
name: string;
|
|
233
|
+
type: 'security' | 'quality' | 'cve';
|
|
234
|
+
/** Initialize the scanner with configuration */
|
|
235
|
+
initialize(config: DeepScanConfig): Promise<void>;
|
|
236
|
+
/** Scan a single file and return findings */
|
|
237
|
+
scanFile(context: ScanFileContext): Promise<Finding[]>;
|
|
238
|
+
/** Cleanup resources */
|
|
239
|
+
destroy(): Promise<void>;
|
|
240
|
+
}
|
|
241
|
+
/** Interface that all reporters must implement */
|
|
242
|
+
interface IReporter {
|
|
243
|
+
format: OutputFormat;
|
|
244
|
+
/** Generate report from scan results */
|
|
245
|
+
generate(result: ScanResult): Promise<string>;
|
|
246
|
+
/** Write report to file */
|
|
247
|
+
writeToFile(result: ScanResult, filePath: string): Promise<void>;
|
|
248
|
+
}
|
|
249
|
+
/** Taint source definition */
|
|
250
|
+
interface TaintSource {
|
|
251
|
+
pattern: string;
|
|
252
|
+
type: string;
|
|
253
|
+
description: string;
|
|
254
|
+
}
|
|
255
|
+
/** Taint sink definition */
|
|
256
|
+
interface TaintSink {
|
|
257
|
+
pattern: string;
|
|
258
|
+
type: string;
|
|
259
|
+
description: string;
|
|
260
|
+
}
|
|
261
|
+
/** Sanitizer definition */
|
|
262
|
+
interface Sanitizer {
|
|
263
|
+
pattern: string;
|
|
264
|
+
cleanses: string[];
|
|
265
|
+
description: string;
|
|
266
|
+
}
|
|
267
|
+
/** Language-specific configuration */
|
|
268
|
+
interface LanguageConfig {
|
|
269
|
+
id: string;
|
|
270
|
+
name: string;
|
|
271
|
+
extensions: string[];
|
|
272
|
+
treeSitterLanguage: string;
|
|
273
|
+
taintSources: TaintSource[];
|
|
274
|
+
taintSinks: TaintSink[];
|
|
275
|
+
sanitizers: Sanitizer[];
|
|
276
|
+
namingConventions: {
|
|
277
|
+
variables: string;
|
|
278
|
+
functions: string;
|
|
279
|
+
classes: string;
|
|
280
|
+
constants: string;
|
|
281
|
+
};
|
|
282
|
+
frameworks: string[];
|
|
283
|
+
commentPatterns: {
|
|
284
|
+
single: string;
|
|
285
|
+
multiStart: string;
|
|
286
|
+
multiEnd: string;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/** Progress callback */
|
|
290
|
+
type ProgressCallback = (current: number, total: number, file: string) => void;
|
|
291
|
+
/** Pipeline options */
|
|
292
|
+
interface PipelineOptions {
|
|
293
|
+
config: DeepScanConfig;
|
|
294
|
+
targetPath: string;
|
|
295
|
+
onProgress?: ProgressCallback;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Main scanning pipeline orchestrator
|
|
300
|
+
*/
|
|
301
|
+
declare class ScanPipeline {
|
|
302
|
+
private config;
|
|
303
|
+
private scanners;
|
|
304
|
+
private ruleEngine;
|
|
305
|
+
private astParser;
|
|
306
|
+
private findings;
|
|
307
|
+
constructor(config: DeepScanConfig);
|
|
308
|
+
/**
|
|
309
|
+
* Register a scanner engine
|
|
310
|
+
*/
|
|
311
|
+
addScanner(scanner: IScanner): void;
|
|
312
|
+
/**
|
|
313
|
+
* Run the full scanning pipeline
|
|
314
|
+
*/
|
|
315
|
+
run(options: PipelineOptions): Promise<ScanResult>;
|
|
316
|
+
/**
|
|
317
|
+
* Scan a single file with all registered scanners
|
|
318
|
+
*/
|
|
319
|
+
private scanFile;
|
|
320
|
+
/**
|
|
321
|
+
* Build the final scan result
|
|
322
|
+
*/
|
|
323
|
+
private buildResult;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Generate a unique fingerprint for a finding (for deduplication across scans)
|
|
327
|
+
*/
|
|
328
|
+
declare function generateFingerprint(ruleId: string, filePath: string, line: number, snippet: string): string;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Load and merge configuration from multiple sources.
|
|
332
|
+
* Priority: CLI args > project config file > preset > defaults
|
|
333
|
+
*/
|
|
334
|
+
declare function loadConfig(options: {
|
|
335
|
+
configPath?: string;
|
|
336
|
+
targetPath?: string;
|
|
337
|
+
cliOverrides?: Partial<DeepScanConfig>;
|
|
338
|
+
preset?: string;
|
|
339
|
+
}): Promise<DeepScanConfig>;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Rule Engine - loads, validates, filters, and manages rules
|
|
343
|
+
*/
|
|
344
|
+
declare class RuleEngine {
|
|
345
|
+
private rules;
|
|
346
|
+
private config;
|
|
347
|
+
constructor(config: DeepScanConfig);
|
|
348
|
+
/**
|
|
349
|
+
* Initialize the rule engine by loading built-in and custom rules
|
|
350
|
+
*/
|
|
351
|
+
initialize(): Promise<void>;
|
|
352
|
+
/**
|
|
353
|
+
* Get all active rules
|
|
354
|
+
*/
|
|
355
|
+
getAllRules(): Rule[];
|
|
356
|
+
/**
|
|
357
|
+
* Get rules for a specific language
|
|
358
|
+
*/
|
|
359
|
+
getRulesForLanguage(language: string): Rule[];
|
|
360
|
+
/**
|
|
361
|
+
* Get rules for a specific scanner type
|
|
362
|
+
*/
|
|
363
|
+
getRulesForScanner(scannerType: 'security' | 'quality'): Rule[];
|
|
364
|
+
/**
|
|
365
|
+
* Get a specific rule by ID
|
|
366
|
+
*/
|
|
367
|
+
getRule(id: string): Rule | undefined;
|
|
368
|
+
/**
|
|
369
|
+
* Load built-in rules from the rules directory
|
|
370
|
+
*/
|
|
371
|
+
private loadBuiltInRules;
|
|
372
|
+
/**
|
|
373
|
+
* Load rules from a file or directory
|
|
374
|
+
*/
|
|
375
|
+
private loadRulesFromPath;
|
|
376
|
+
/**
|
|
377
|
+
* Load and validate a single rule YAML file
|
|
378
|
+
*/
|
|
379
|
+
private loadRuleFile;
|
|
380
|
+
/**
|
|
381
|
+
* Apply include/exclude filters from configuration
|
|
382
|
+
*/
|
|
383
|
+
private applyFilters;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Instantiate the appropriate reporter for the given output format.
|
|
388
|
+
*
|
|
389
|
+
* @param format - One of the supported `OutputFormat` values.
|
|
390
|
+
* @returns A ready-to-use `IReporter` instance.
|
|
391
|
+
* @throws If an unsupported format is provided.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* const reporter = getReporter('html');
|
|
396
|
+
* const html = await reporter.generate(scanResult);
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
declare function getReporter(format: OutputFormat): IReporter;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Abstract base class that implements IScanner.
|
|
403
|
+
* Provides common rule matching, fingerprinting, and snippet extraction.
|
|
404
|
+
* Lớp cơ sở trừu tượng cung cấp các tiện ích chung cho scanner
|
|
405
|
+
*/
|
|
406
|
+
declare abstract class BaseScanner implements IScanner {
|
|
407
|
+
abstract name: string;
|
|
408
|
+
abstract type: 'security' | 'quality' | 'cve';
|
|
409
|
+
protected config: DeepScanConfig | null;
|
|
410
|
+
initialize(config: DeepScanConfig): Promise<void>;
|
|
411
|
+
abstract scanFile(context: ScanFileContext): Promise<Finding[]>;
|
|
412
|
+
destroy(): Promise<void>;
|
|
413
|
+
/**
|
|
414
|
+
* Match all rule patterns against source code and return findings.
|
|
415
|
+
* Khớp tất cả rule patterns với mã nguồn và trả về findings
|
|
416
|
+
*/
|
|
417
|
+
protected matchRulePatterns(context: ScanFileContext, rules: Rule[]): Finding[];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Security scanner engine that orchestrates all security analyzers.
|
|
422
|
+
* Bộ quét bảo mật điều phối tất cả analyzer: injection, XSS, secrets, auth, crypto, file-ops, api-security
|
|
423
|
+
*/
|
|
424
|
+
declare class SecurityScanner extends BaseScanner implements IScanner {
|
|
425
|
+
name: string;
|
|
426
|
+
type: "security";
|
|
427
|
+
private enabledSeverities;
|
|
428
|
+
initialize(config: DeepScanConfig): Promise<void>;
|
|
429
|
+
/**
|
|
430
|
+
* Scan a file through all security analyzers.
|
|
431
|
+
* Quét tệp qua tất cả analyzer bảo mật
|
|
432
|
+
*/
|
|
433
|
+
scanFile(context: ScanFileContext): Promise<Finding[]>;
|
|
434
|
+
destroy(): Promise<void>;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Quality Scanner - Orchestrates all code quality analyzers
|
|
439
|
+
*
|
|
440
|
+
* Analyzers:
|
|
441
|
+
* - Complexity: cyclomatic complexity, nesting depth, function length
|
|
442
|
+
* - Code Smells: long files, magic numbers, empty catch, console.log, TODO/FIXME
|
|
443
|
+
* - Duplication: token-based duplicate code detection
|
|
444
|
+
* - Metrics: LOC, comment ratio
|
|
445
|
+
*/
|
|
446
|
+
declare class QualityScanner implements IScanner {
|
|
447
|
+
name: string;
|
|
448
|
+
type: "quality";
|
|
449
|
+
private config;
|
|
450
|
+
initialize(config: DeepScanConfig): Promise<void>;
|
|
451
|
+
scanFile(context: ScanFileContext): Promise<Finding[]>;
|
|
452
|
+
destroy(): Promise<void>;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* CVE/SCA Scanner - Software Composition Analysis
|
|
457
|
+
*
|
|
458
|
+
* Parses dependency manifests and checks for known vulnerabilities
|
|
459
|
+
* using the OSV (Open Source Vulnerabilities) database.
|
|
460
|
+
*/
|
|
461
|
+
declare class CVEScanner implements IScanner {
|
|
462
|
+
name: string;
|
|
463
|
+
type: "cve";
|
|
464
|
+
private config;
|
|
465
|
+
initialize(config: DeepScanConfig): Promise<void>;
|
|
466
|
+
scanFile(context: ScanFileContext): Promise<Finding[]>;
|
|
467
|
+
destroy(): Promise<void>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export { type AIValidationResult, CVEScanner, type CodeContext, type Confidence, type DeepScanConfig, type Finding, type IReporter, type IScanner, type LanguageConfig, type OutputFormat, QualityScanner, type Rule, type RuleCondition, RuleEngine, type RulePattern, ScanPipeline, type ScanResult, type ScanSummary, type ScannerType, SecurityScanner, type Severity, type SourceLocation, type TaintFlowStep, generateFingerprint, getReporter, loadConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CVEScanner,
|
|
3
|
+
QualityScanner,
|
|
4
|
+
RuleEngine,
|
|
5
|
+
ScanPipeline,
|
|
6
|
+
SecurityScanner,
|
|
7
|
+
generateFingerprint,
|
|
8
|
+
getReporter,
|
|
9
|
+
loadConfig
|
|
10
|
+
} from "./chunk-OSYJXVNF.js";
|
|
11
|
+
export {
|
|
12
|
+
CVEScanner,
|
|
13
|
+
QualityScanner,
|
|
14
|
+
RuleEngine,
|
|
15
|
+
ScanPipeline,
|
|
16
|
+
SecurityScanner,
|
|
17
|
+
generateFingerprint,
|
|
18
|
+
getReporter,
|
|
19
|
+
loadConfig
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deepscan-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Open-source security & code quality scanner - combines SAST, SCA/CVE, and secrets detection in a single CLI tool",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"deepscan": "dist/bin/deepscan.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "tsx src/bin/deepscan.ts",
|
|
13
|
+
"rules:update": "tsx scripts/update-rules.ts",
|
|
14
|
+
"evaluate": "tsx scripts/evaluate.ts",
|
|
15
|
+
"build": "tsup",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest",
|
|
19
|
+
"lint": "eslint src/",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"security",
|
|
24
|
+
"scanner",
|
|
25
|
+
"static-analysis",
|
|
26
|
+
"sast",
|
|
27
|
+
"sca",
|
|
28
|
+
"cve",
|
|
29
|
+
"code-quality",
|
|
30
|
+
"vulnerability",
|
|
31
|
+
"deepscan",
|
|
32
|
+
"sonarqube-alternative"
|
|
33
|
+
],
|
|
34
|
+
"author": "",
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18.0.0"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"rules",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"chalk": "^5.3.0",
|
|
47
|
+
"commander": "^12.1.0",
|
|
48
|
+
"consola": "^3.2.3",
|
|
49
|
+
"glob": "^11.0.0",
|
|
50
|
+
"ignore": "^6.0.2",
|
|
51
|
+
"js-yaml": "^4.1.0",
|
|
52
|
+
"tree-sitter-go": "^0.25.0",
|
|
53
|
+
"tree-sitter-java": "^0.23.5",
|
|
54
|
+
"tree-sitter-javascript": "^0.25.0",
|
|
55
|
+
"tree-sitter-python": "^0.25.0",
|
|
56
|
+
"tree-sitter-typescript": "^0.23.2",
|
|
57
|
+
"web-tree-sitter": "^0.26.10",
|
|
58
|
+
"zod": "^3.23.8"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/js-yaml": "^4.0.9",
|
|
62
|
+
"@types/node": "^22.10.0",
|
|
63
|
+
"tsup": "^8.3.5",
|
|
64
|
+
"tsx": "^4.19.0",
|
|
65
|
+
"typescript": "^5.7.0",
|
|
66
|
+
"vitest": "^2.1.0"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
rules:
|
|
2
|
+
- id: javascript.express.security.audit.xss.direct-response-write
|
|
3
|
+
name: direct-response-write
|
|
4
|
+
description: User input directly written to response, potential XSS
|
|
5
|
+
category: xss
|
|
6
|
+
severity: high
|
|
7
|
+
confidence: medium
|
|
8
|
+
languages:
|
|
9
|
+
- javascript
|
|
10
|
+
- typescript
|
|
11
|
+
patterns:
|
|
12
|
+
- pattern: res.write(req.query.url)
|
|
13
|
+
message: User input directly written to response, potential XSS
|
|
14
|
+
cwe:
|
|
15
|
+
- CWE-79
|
|
16
|
+
owasp:
|
|
17
|
+
- A03:2021
|
|
18
|
+
references:
|
|
19
|
+
- https://owasp.org/www-community/attacks/xss/
|
|
20
|
+
tags: []
|
|
21
|
+
- id: python.lang.security.audit.crypto.weak-hash-md5
|
|
22
|
+
name: weak-hash-md5
|
|
23
|
+
description: MD5 hashing detected. Use SHA-256 or stronger.
|
|
24
|
+
category: crypto
|
|
25
|
+
severity: medium
|
|
26
|
+
confidence: medium
|
|
27
|
+
languages:
|
|
28
|
+
- python
|
|
29
|
+
patterns:
|
|
30
|
+
- regex: hashlib\.md5\(
|
|
31
|
+
message: MD5 hashing detected. Use SHA-256 or stronger.
|
|
32
|
+
cwe:
|
|
33
|
+
- CWE-328
|
|
34
|
+
owasp:
|
|
35
|
+
- A02:2021
|
|
36
|
+
references: []
|
|
37
|
+
tags: []
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
version: "1.0"
|
|
2
|
+
scanners:
|
|
3
|
+
security:
|
|
4
|
+
enabled: true
|
|
5
|
+
severity:
|
|
6
|
+
- critical
|
|
7
|
+
- high
|
|
8
|
+
- medium
|
|
9
|
+
- low
|
|
10
|
+
quality:
|
|
11
|
+
enabled: false
|
|
12
|
+
thresholds:
|
|
13
|
+
maxComplexity: 15
|
|
14
|
+
maxCognitiveComplexity: 20
|
|
15
|
+
maxFileLength: 500
|
|
16
|
+
maxFunctionLength: 50
|
|
17
|
+
maxNestingDepth: 4
|
|
18
|
+
minCommentRatio: 0.1
|
|
19
|
+
cve:
|
|
20
|
+
enabled: false
|
|
21
|
+
sources:
|
|
22
|
+
- osv
|
|
23
|
+
failOnSeverity: critical
|
|
24
|
+
rules:
|
|
25
|
+
include:
|
|
26
|
+
- "*"
|
|
27
|
+
exclude: []
|
|
28
|
+
custom: []
|
|
29
|
+
languages:
|
|
30
|
+
- auto
|
|
31
|
+
paths:
|
|
32
|
+
include:
|
|
33
|
+
- "**/*"
|
|
34
|
+
exclude:
|
|
35
|
+
- "node_modules/"
|
|
36
|
+
- ".git/"
|
|
37
|
+
- "**/node_modules/**"
|
|
38
|
+
- "**/.git/**"
|
|
39
|
+
- "**/*.min.js"
|
|
40
|
+
- "**/*.min.css"
|
|
41
|
+
- "**/*.map"
|
|
42
|
+
- "**/*.lock"
|
|
43
|
+
- "**/package-lock.json"
|
|
44
|
+
output:
|
|
45
|
+
format: console
|
|
46
|
+
verbose: false
|
|
47
|
+
colors: true
|
|
48
|
+
ai:
|
|
49
|
+
enabled: false
|
|
50
|
+
provider: openai
|
|
51
|
+
maxFindings: 20
|
|
52
|
+
temperature: 0.1
|
|
53
|
+
context:
|
|
54
|
+
projectType: auto
|
|
55
|
+
frameworks: []
|
|
56
|
+
sensitivePatterns: []
|
|
57
|
+
parallel: 4
|
|
58
|
+
incremental: false
|
|
59
|
+
deep: false
|