circle-ir 3.1.1 → 3.3.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/README.md +2 -2
- package/configs/sinks/code_injection.yaml +136 -0
- package/configs/sinks/command.yaml +109 -0
- package/configs/sinks/path.yaml +113 -0
- package/configs/sources/http_sources.yaml +151 -0
- package/dist/analysis/index.d.ts +2 -5
- package/dist/analysis/index.js +2 -6
- package/dist/analysis/index.js.map +1 -1
- package/dist/analysis/taint-matcher.js +37 -1
- package/dist/analysis/taint-matcher.js.map +1 -1
- package/dist/analyzer.js +64 -1
- package/dist/analyzer.js.map +1 -1
- package/dist/browser/circle-ir.js +97 -95
- package/dist/core/circle-ir-core.cjs +17 -1
- package/dist/core/circle-ir-core.js +17 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/logger.d.ts +28 -40
- package/dist/utils/logger.js +64 -137
- package/dist/utils/logger.js.map +1 -1
- package/package.json +3 -5
- package/dist/analysis/advisory-db.d.ts +0 -86
- package/dist/analysis/advisory-db.js +0 -104
- package/dist/analysis/advisory-db.js.map +0 -1
- package/dist/analysis/cargo-parser.d.ts +0 -42
- package/dist/analysis/cargo-parser.js +0 -102
- package/dist/analysis/cargo-parser.js.map +0 -1
- package/dist/analysis/dependency-scanner.d.ts +0 -79
- package/dist/analysis/dependency-scanner.js +0 -122
- package/dist/analysis/dependency-scanner.js.map +0 -1
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RustSec Advisory Database Integration
|
|
3
|
-
*
|
|
4
|
-
* Provides vulnerability data from the RustSec advisory database.
|
|
5
|
-
* Advisory data is bundled at build time for offline/deterministic usage.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Bundled advisory database (loaded lazily)
|
|
9
|
-
*/
|
|
10
|
-
let bundledDb = null;
|
|
11
|
-
/**
|
|
12
|
-
* Load the bundled advisory database
|
|
13
|
-
*/
|
|
14
|
-
export function loadBundledAdvisories() {
|
|
15
|
-
if (bundledDb) {
|
|
16
|
-
return bundledDb;
|
|
17
|
-
}
|
|
18
|
-
// Try to load bundled advisories
|
|
19
|
-
try {
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
21
|
-
const json = require('../../advisory-db.json');
|
|
22
|
-
bundledDb = parseAdvisoryJson(json);
|
|
23
|
-
return bundledDb;
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
// Return empty database if bundled data not available
|
|
27
|
-
return {
|
|
28
|
-
advisories: new Map(),
|
|
29
|
-
lastUpdated: new Date().toISOString(),
|
|
30
|
-
source: 'bundled',
|
|
31
|
-
version: '1.0',
|
|
32
|
-
stats: { totalAdvisories: 0, uniqueCrates: 0 },
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Parse advisory JSON into database structure
|
|
38
|
-
*/
|
|
39
|
-
export function parseAdvisoryJson(json) {
|
|
40
|
-
const advisories = new Map();
|
|
41
|
-
for (const advisory of json.advisories) {
|
|
42
|
-
const existing = advisories.get(advisory.package) || [];
|
|
43
|
-
existing.push(advisory);
|
|
44
|
-
advisories.set(advisory.package, existing);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
advisories,
|
|
48
|
-
lastUpdated: json.lastUpdated,
|
|
49
|
-
source: 'bundled',
|
|
50
|
-
version: json.version,
|
|
51
|
-
stats: {
|
|
52
|
-
totalAdvisories: json.advisories.length,
|
|
53
|
-
uniqueCrates: advisories.size,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Map RustSec categories to severity levels
|
|
59
|
-
*/
|
|
60
|
-
export function categoryToSeverity(categories) {
|
|
61
|
-
const categorySet = new Set(categories);
|
|
62
|
-
// Critical: code execution, privilege escalation
|
|
63
|
-
if (categorySet.has('code-execution') ||
|
|
64
|
-
categorySet.has('privilege-escalation')) {
|
|
65
|
-
return 'critical';
|
|
66
|
-
}
|
|
67
|
-
// High: memory safety, denial of service
|
|
68
|
-
if (categorySet.has('memory-safety') || categorySet.has('denial-of-service')) {
|
|
69
|
-
return 'high';
|
|
70
|
-
}
|
|
71
|
-
// Medium: crypto issues, information disclosure
|
|
72
|
-
if (categorySet.has('crypto-failure') ||
|
|
73
|
-
categorySet.has('information-disclosure')) {
|
|
74
|
-
return 'medium';
|
|
75
|
-
}
|
|
76
|
-
// Default to medium for unknown categories
|
|
77
|
-
return 'medium';
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get advisories for a specific crate
|
|
81
|
-
*/
|
|
82
|
-
export function getAdvisoriesForCrate(db, crateName) {
|
|
83
|
-
return db.advisories.get(crateName) || [];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Search advisories by CVE ID
|
|
87
|
-
*/
|
|
88
|
-
export function findAdvisoryByCve(db, cveId) {
|
|
89
|
-
for (const advisories of db.advisories.values()) {
|
|
90
|
-
for (const advisory of advisories) {
|
|
91
|
-
if (advisory.aliases.includes(cveId)) {
|
|
92
|
-
return advisory;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get all unique crate names with advisories
|
|
100
|
-
*/
|
|
101
|
-
export function getVulnerableCrates(db) {
|
|
102
|
-
return Array.from(db.advisories.keys());
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=advisory-db.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advisory-db.js","sourceRoot":"","sources":["../../src/analysis/advisory-db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyDH;;GAEG;AACH,IAAI,SAAS,GAA4B,IAAI,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,SAAS,EAAE,CAAC;QACd,OAA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|
|
|
1
|
-
/**
|
|
2
|
-
* Cargo.lock parser for extracting crate dependencies and versions
|
|
3
|
-
*/
|
|
4
|
-
export interface CargoLockDependency {
|
|
5
|
-
name: string;
|
|
6
|
-
version: string;
|
|
7
|
-
source?: string;
|
|
8
|
-
checksum?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface CargoLock {
|
|
11
|
-
version: number;
|
|
12
|
-
dependencies: CargoLockDependency[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Parse Cargo.lock TOML file content
|
|
16
|
-
*/
|
|
17
|
-
export declare function parseCargoLock(content: string): CargoLock;
|
|
18
|
-
/**
|
|
19
|
-
* Parse Cargo.toml to extract direct dependencies
|
|
20
|
-
*/
|
|
21
|
-
export interface CargoTomlDependency {
|
|
22
|
-
name: string;
|
|
23
|
-
version?: string;
|
|
24
|
-
path?: string;
|
|
25
|
-
git?: string;
|
|
26
|
-
features?: string[];
|
|
27
|
-
}
|
|
28
|
-
export interface CargoToml {
|
|
29
|
-
name?: string;
|
|
30
|
-
version?: string;
|
|
31
|
-
dependencies: CargoTomlDependency[];
|
|
32
|
-
devDependencies: CargoTomlDependency[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Parse Cargo.toml file content
|
|
36
|
-
*/
|
|
37
|
-
export declare function parseCargoToml(content: string): CargoToml;
|
|
38
|
-
/**
|
|
39
|
-
* Filter dependencies to only include registry-sourced crates
|
|
40
|
-
* (excludes path and git dependencies which can't be vulnerability-checked)
|
|
41
|
-
*/
|
|
42
|
-
export declare function filterRegistryDeps(deps: CargoLockDependency[]): CargoLockDependency[];
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cargo.lock parser for extracting crate dependencies and versions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Parse Cargo.lock TOML file content
|
|
6
|
-
*/
|
|
7
|
-
export function parseCargoLock(content) {
|
|
8
|
-
const dependencies = [];
|
|
9
|
-
// Extract version from the file
|
|
10
|
-
const versionMatch = content.match(/^version\s*=\s*(\d+)/m);
|
|
11
|
-
const version = versionMatch ? parseInt(versionMatch[1], 10) : 3;
|
|
12
|
-
// Parse [[package]] sections
|
|
13
|
-
// Format:
|
|
14
|
-
// [[package]]
|
|
15
|
-
// name = "crate-name"
|
|
16
|
-
// version = "1.0.0"
|
|
17
|
-
// source = "registry+..."
|
|
18
|
-
// checksum = "abc123..."
|
|
19
|
-
const packagePattern = /\[\[package\]\]\s*\n((?:(?!^\[\[|\[package\]).*\n?)*)/gm;
|
|
20
|
-
let match;
|
|
21
|
-
while ((match = packagePattern.exec(content)) !== null) {
|
|
22
|
-
const block = match[1];
|
|
23
|
-
const nameMatch = block.match(/^name\s*=\s*"([^"]+)"/m);
|
|
24
|
-
const versionMatch = block.match(/^version\s*=\s*"([^"]+)"/m);
|
|
25
|
-
const sourceMatch = block.match(/^source\s*=\s*"([^"]+)"/m);
|
|
26
|
-
const checksumMatch = block.match(/^checksum\s*=\s*"([^"]+)"/m);
|
|
27
|
-
if (nameMatch && versionMatch) {
|
|
28
|
-
dependencies.push({
|
|
29
|
-
name: nameMatch[1],
|
|
30
|
-
version: versionMatch[1],
|
|
31
|
-
source: sourceMatch?.[1],
|
|
32
|
-
checksum: checksumMatch?.[1],
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return { version, dependencies };
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Parse Cargo.toml file content
|
|
40
|
-
*/
|
|
41
|
-
export function parseCargoToml(content) {
|
|
42
|
-
const dependencies = [];
|
|
43
|
-
const devDependencies = [];
|
|
44
|
-
// Extract package name and version
|
|
45
|
-
const nameMatch = content.match(/^\[package\][^[]*name\s*=\s*"([^"]+)"/ms);
|
|
46
|
-
const versionMatch = content.match(/^\[package\][^[]*version\s*=\s*"([^"]+)"/ms);
|
|
47
|
-
// Parse [dependencies] section
|
|
48
|
-
const depsMatch = content.match(/\[dependencies\]\s*\n((?:(?!\[(?!dependencies\.))[^\n]*\n?)*)/m);
|
|
49
|
-
if (depsMatch) {
|
|
50
|
-
parseDependencySection(depsMatch[1], dependencies);
|
|
51
|
-
}
|
|
52
|
-
// Parse [dev-dependencies] section
|
|
53
|
-
const devDepsMatch = content.match(/\[dev-dependencies\]\s*\n((?:(?!\[(?!dev-dependencies\.))[^\n]*\n?)*)/m);
|
|
54
|
-
if (devDepsMatch) {
|
|
55
|
-
parseDependencySection(devDepsMatch[1], devDependencies);
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
name: nameMatch?.[1],
|
|
59
|
-
version: versionMatch?.[1],
|
|
60
|
-
dependencies,
|
|
61
|
-
devDependencies,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function parseDependencySection(section, deps) {
|
|
65
|
-
// Simple dependency: crate = "1.0"
|
|
66
|
-
const simplePattern = /^(\w[\w-]*)\s*=\s*"([^"]+)"/gm;
|
|
67
|
-
let match;
|
|
68
|
-
while ((match = simplePattern.exec(section)) !== null) {
|
|
69
|
-
deps.push({
|
|
70
|
-
name: match[1],
|
|
71
|
-
version: match[2],
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// Complex dependency: crate = { version = "1.0", features = [...] }
|
|
75
|
-
const complexPattern = /^(\w[\w-]*)\s*=\s*\{([^}]+)\}/gm;
|
|
76
|
-
while ((match = complexPattern.exec(section)) !== null) {
|
|
77
|
-
const name = match[1];
|
|
78
|
-
const attrs = match[2];
|
|
79
|
-
const versionMatch = attrs.match(/version\s*=\s*"([^"]+)"/);
|
|
80
|
-
const pathMatch = attrs.match(/path\s*=\s*"([^"]+)"/);
|
|
81
|
-
const gitMatch = attrs.match(/git\s*=\s*"([^"]+)"/);
|
|
82
|
-
deps.push({
|
|
83
|
-
name,
|
|
84
|
-
version: versionMatch?.[1],
|
|
85
|
-
path: pathMatch?.[1],
|
|
86
|
-
git: gitMatch?.[1],
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Filter dependencies to only include registry-sourced crates
|
|
92
|
-
* (excludes path and git dependencies which can't be vulnerability-checked)
|
|
93
|
-
*/
|
|
94
|
-
export function filterRegistryDeps(deps) {
|
|
95
|
-
return deps.filter((dep) => {
|
|
96
|
-
// Include if no source (defaults to registry) or explicitly from registry
|
|
97
|
-
if (!dep.source)
|
|
98
|
-
return true;
|
|
99
|
-
return dep.source.startsWith('registry+');
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=cargo-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-parser.js","sourceRoot":"","sources":["../../src/analysis/cargo-parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,MAAM,YAAY,GAA0B,EAAE,CAAC;IAE/C,gCAAgC;IAChC,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjE,6BAA6B;IAC7B,UAAU;IACV,cAAc;IACd,sBAAsB;IACtB,oBAAoB;IACpB,0BAA0B;IAC1B,yBAAyB;IAEzB,MAAM,cAAc,GAClB,yDAAyD,CAAC;IAC5D,IAAI,KAAK,CAAC;IAEV,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEvB,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACxD,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,2BAA2B,CA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MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;QACzB,0EAA0E;QAC1E,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dependency vulnerability scanner for Rust projects
|
|
3
|
-
*
|
|
4
|
-
* Scans Cargo.lock files for known vulnerable crate versions
|
|
5
|
-
* using the RustSec Advisory Database.
|
|
6
|
-
*/
|
|
7
|
-
import type { Severity } from '../types/index.js';
|
|
8
|
-
import type { AdvisoryVulnerability, AdvisoryDatabase } from './advisory-db.js';
|
|
9
|
-
/**
|
|
10
|
-
* A finding for a vulnerable dependency
|
|
11
|
-
*/
|
|
12
|
-
export interface DependencyFinding {
|
|
13
|
-
type: 'vulnerable_dependency';
|
|
14
|
-
/** Crate name */
|
|
15
|
-
crate: string;
|
|
16
|
-
/** Installed version */
|
|
17
|
-
version: string;
|
|
18
|
-
/** Matching advisories */
|
|
19
|
-
vulnerabilities: AdvisoryVulnerability[];
|
|
20
|
-
/** Source file (Cargo.lock) */
|
|
21
|
-
source: string;
|
|
22
|
-
/** Location information */
|
|
23
|
-
location: {
|
|
24
|
-
file: string;
|
|
25
|
-
line?: number;
|
|
26
|
-
};
|
|
27
|
-
/** Severity level */
|
|
28
|
-
severity: Severity;
|
|
29
|
-
/** CWE IDs from advisories */
|
|
30
|
-
cwes: string[];
|
|
31
|
-
/** CVE IDs from advisories */
|
|
32
|
-
cves: string[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Options for dependency scanning
|
|
36
|
-
*/
|
|
37
|
-
export interface ScanOptions {
|
|
38
|
-
/** Path to Cargo.lock file */
|
|
39
|
-
cargoLockPath?: string;
|
|
40
|
-
/** Cargo.lock content (if already loaded) */
|
|
41
|
-
cargoLockContent?: string;
|
|
42
|
-
/** Custom advisory database (defaults to bundled) */
|
|
43
|
-
advisoryDb?: AdvisoryDatabase;
|
|
44
|
-
/** Include dev dependencies */
|
|
45
|
-
includeDevDeps?: boolean;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Scan result
|
|
49
|
-
*/
|
|
50
|
-
export interface ScanResult {
|
|
51
|
-
/** List of vulnerable dependencies */
|
|
52
|
-
findings: DependencyFinding[];
|
|
53
|
-
/** Total dependencies scanned */
|
|
54
|
-
totalDependencies: number;
|
|
55
|
-
/** Number of vulnerable dependencies */
|
|
56
|
-
vulnerableCount: number;
|
|
57
|
-
/** Advisory database info */
|
|
58
|
-
advisoryDbInfo: {
|
|
59
|
-
source: string;
|
|
60
|
-
lastUpdated: string;
|
|
61
|
-
totalAdvisories: number;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Check if a specific crate version is vulnerable
|
|
66
|
-
*/
|
|
67
|
-
export declare function checkCrateVulnerability(crateName: string, version: string, db: AdvisoryDatabase): AdvisoryVulnerability[];
|
|
68
|
-
/**
|
|
69
|
-
* Scan Cargo.lock content for vulnerable dependencies
|
|
70
|
-
*/
|
|
71
|
-
export declare function scanCargoLock(content: string, options?: ScanOptions): ScanResult;
|
|
72
|
-
/**
|
|
73
|
-
* Format a dependency finding as a human-readable string
|
|
74
|
-
*/
|
|
75
|
-
export declare function formatFinding(finding: DependencyFinding): string;
|
|
76
|
-
/**
|
|
77
|
-
* Format scan result as a human-readable report
|
|
78
|
-
*/
|
|
79
|
-
export declare function formatScanReport(result: ScanResult): string;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dependency vulnerability scanner for Rust projects
|
|
3
|
-
*
|
|
4
|
-
* Scans Cargo.lock files for known vulnerable crate versions
|
|
5
|
-
* using the RustSec Advisory Database.
|
|
6
|
-
*/
|
|
7
|
-
import { loadBundledAdvisories, getAdvisoriesForCrate, categoryToSeverity, } from './advisory-db.js';
|
|
8
|
-
import { parseCargoLock, filterRegistryDeps } from './cargo-parser.js';
|
|
9
|
-
import { isVersionVulnerable } from './semver.js';
|
|
10
|
-
/**
|
|
11
|
-
* Check if a specific crate version is vulnerable
|
|
12
|
-
*/
|
|
13
|
-
export function checkCrateVulnerability(crateName, version, db) {
|
|
14
|
-
const advisories = getAdvisoriesForCrate(db, crateName);
|
|
15
|
-
return advisories.filter((advisory) => {
|
|
16
|
-
return isVersionVulnerable(version, advisory.versions.patched, advisory.versions.unaffected);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Scan Cargo.lock content for vulnerable dependencies
|
|
21
|
-
*/
|
|
22
|
-
export function scanCargoLock(content, options = {}) {
|
|
23
|
-
const db = options.advisoryDb || loadBundledAdvisories();
|
|
24
|
-
const cargoLock = parseCargoLock(content);
|
|
25
|
-
const deps = filterRegistryDeps(cargoLock.dependencies);
|
|
26
|
-
const findings = [];
|
|
27
|
-
for (const dep of deps) {
|
|
28
|
-
const vulnerableAdvisories = checkCrateVulnerability(dep.name, dep.version, db);
|
|
29
|
-
if (vulnerableAdvisories.length > 0) {
|
|
30
|
-
// Extract CWEs and CVEs from advisories
|
|
31
|
-
const cwes = [];
|
|
32
|
-
const cves = [];
|
|
33
|
-
for (const advisory of vulnerableAdvisories) {
|
|
34
|
-
for (const alias of advisory.aliases) {
|
|
35
|
-
if (alias.startsWith('CVE-')) {
|
|
36
|
-
cves.push(alias);
|
|
37
|
-
}
|
|
38
|
-
else if (alias.startsWith('CWE-')) {
|
|
39
|
-
cwes.push(alias);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// Calculate severity from all advisories
|
|
44
|
-
const allCategories = vulnerableAdvisories.flatMap((a) => a.categories);
|
|
45
|
-
const severity = categoryToSeverity(allCategories);
|
|
46
|
-
findings.push({
|
|
47
|
-
type: 'vulnerable_dependency',
|
|
48
|
-
crate: dep.name,
|
|
49
|
-
version: dep.version,
|
|
50
|
-
vulnerabilities: vulnerableAdvisories,
|
|
51
|
-
source: 'Cargo.lock',
|
|
52
|
-
location: {
|
|
53
|
-
file: options.cargoLockPath || 'Cargo.lock',
|
|
54
|
-
},
|
|
55
|
-
severity,
|
|
56
|
-
cwes: [...new Set(cwes)],
|
|
57
|
-
cves: [...new Set(cves)],
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Sort findings by severity
|
|
62
|
-
const severityOrder = {
|
|
63
|
-
critical: 0,
|
|
64
|
-
high: 1,
|
|
65
|
-
medium: 2,
|
|
66
|
-
low: 3,
|
|
67
|
-
};
|
|
68
|
-
findings.sort((a, b) => severityOrder[a.severity] - severityOrder[b.severity]);
|
|
69
|
-
return {
|
|
70
|
-
findings,
|
|
71
|
-
totalDependencies: deps.length,
|
|
72
|
-
vulnerableCount: findings.length,
|
|
73
|
-
advisoryDbInfo: {
|
|
74
|
-
source: db.source,
|
|
75
|
-
lastUpdated: db.lastUpdated,
|
|
76
|
-
totalAdvisories: db.stats?.totalAdvisories || 0,
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Format a dependency finding as a human-readable string
|
|
82
|
-
*/
|
|
83
|
-
export function formatFinding(finding) {
|
|
84
|
-
const lines = [];
|
|
85
|
-
lines.push(`${finding.crate}@${finding.version} [${finding.severity.toUpperCase()}]`);
|
|
86
|
-
for (const vuln of finding.vulnerabilities) {
|
|
87
|
-
lines.push(` ${vuln.id}: ${vuln.title || vuln.description.slice(0, 80)}`);
|
|
88
|
-
if (vuln.aliases.length > 0) {
|
|
89
|
-
lines.push(` Aliases: ${vuln.aliases.join(', ')}`);
|
|
90
|
-
}
|
|
91
|
-
if (vuln.versions.patched && vuln.versions.patched.length > 0) {
|
|
92
|
-
lines.push(` Patched: ${vuln.versions.patched.join(', ')}`);
|
|
93
|
-
}
|
|
94
|
-
lines.push(` URL: ${vuln.url}`);
|
|
95
|
-
}
|
|
96
|
-
return lines.join('\n');
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Format scan result as a human-readable report
|
|
100
|
-
*/
|
|
101
|
-
export function formatScanReport(result) {
|
|
102
|
-
const lines = [];
|
|
103
|
-
lines.push('=== RUST DEPENDENCY VULNERABILITY SCAN ===');
|
|
104
|
-
lines.push('');
|
|
105
|
-
lines.push(`Dependencies scanned: ${result.totalDependencies}`);
|
|
106
|
-
lines.push(`Vulnerable packages: ${result.vulnerableCount}`);
|
|
107
|
-
lines.push(`Advisory DB: ${result.advisoryDbInfo.source} (${result.advisoryDbInfo.lastUpdated})`);
|
|
108
|
-
lines.push('');
|
|
109
|
-
if (result.findings.length === 0) {
|
|
110
|
-
lines.push('No known vulnerabilities found.');
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
lines.push('VULNERABLE DEPENDENCIES:');
|
|
114
|
-
lines.push('');
|
|
115
|
-
for (const finding of result.findings) {
|
|
116
|
-
lines.push(formatFinding(finding));
|
|
117
|
-
lines.push('');
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return lines.join('\n');
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=dependency-scanner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-scanner.js","sourceRoot":"","sources":["../../src/analysis/dependency-scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAA4B,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA4DlD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,SAAiB,EACjB,OAAe,EACf,EAAoB;IAEpB,MAAM,UAAU,GAAG,qBAAqB,CAAC,EAAE,EAAE,SAAS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