cognium-ai 2.7.18 → 2.7.19
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/dist/cli.js +0 -0
- package/package.json +3 -3
- package/dist/config.d.ts +0 -80
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -110
- package/dist/config.js.map +0 -1
- package/dist/formatters.d.ts +0 -22
- package/dist/formatters.d.ts.map +0 -1
- package/dist/formatters.js +0 -220
- package/dist/formatters.js.map +0 -1
- package/dist/utils/args.d.ts +0 -12
- package/dist/utils/args.d.ts.map +0 -1
- package/dist/utils/args.js +0 -179
- package/dist/utils/args.js.map +0 -1
package/dist/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-ai",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.19",
|
|
4
4
|
"description": "AI-powered static analysis CLI with LLM-enhanced vulnerability detection",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"LICENSE"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"circle-ir": "^3.
|
|
45
|
-
"circle-ir-ai": "
|
|
44
|
+
"circle-ir": "^3.23.3",
|
|
45
|
+
"circle-ir-ai": "2.7.19",
|
|
46
46
|
"commander": "^14.0.3",
|
|
47
47
|
"minimatch": "^10.2.5"
|
|
48
48
|
},
|
package/dist/config.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cognium.config.json — project-level configuration
|
|
3
|
-
*
|
|
4
|
-
* Shared schema with cognium CLI (cognium/src/cli.ts).
|
|
5
|
-
* Controls SAST pass options, pass disabling, trust pass filtering,
|
|
6
|
-
* and finding suppressions.
|
|
7
|
-
*/
|
|
8
|
-
import type { PassOptions } from 'circle-ir-ai';
|
|
9
|
-
/**
|
|
10
|
-
* Suppression entry to exclude specific findings.
|
|
11
|
-
*/
|
|
12
|
-
export interface Suppression {
|
|
13
|
-
/** Pass name to suppress (e.g., 'naming-convention', 'unbounded-collection') */
|
|
14
|
-
pass: string;
|
|
15
|
-
/** File path (relative or absolute) — if omitted, applies to all files */
|
|
16
|
-
file?: string;
|
|
17
|
-
/** Specific line number — if omitted, applies to all lines in the file */
|
|
18
|
-
line?: number;
|
|
19
|
-
/** Reason for suppression (for documentation) */
|
|
20
|
-
reason?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* cognium.config.json schema
|
|
24
|
-
*/
|
|
25
|
-
export interface CogniumConfig {
|
|
26
|
-
/** Config version for future compatibility */
|
|
27
|
-
version?: string;
|
|
28
|
-
/** Glob patterns to include */
|
|
29
|
-
include?: string[];
|
|
30
|
-
/** Glob patterns to exclude */
|
|
31
|
-
exclude?: string[];
|
|
32
|
-
/** Pass-specific options (passed to circle-ir via analyze() 4th arg) */
|
|
33
|
-
passes?: {
|
|
34
|
-
[passName: string]: boolean | {
|
|
35
|
-
enabled?: boolean;
|
|
36
|
-
threshold?: number;
|
|
37
|
-
skipPatterns?: string[];
|
|
38
|
-
enforceIPrefix?: boolean;
|
|
39
|
-
[key: string]: unknown;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
/** Trust-specific configuration */
|
|
43
|
-
trust?: {
|
|
44
|
-
/** Trust passes to skip (e.g., 'god-class', 'naming-convention') */
|
|
45
|
-
disabledPasses?: string[];
|
|
46
|
-
};
|
|
47
|
-
/** Findings to suppress */
|
|
48
|
-
suppressions?: Suppression[];
|
|
49
|
-
/** Minimum severity filter */
|
|
50
|
-
severity?: string;
|
|
51
|
-
/** Category filter */
|
|
52
|
-
categories?: string[];
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Load configuration from cognium.config.json or a custom path.
|
|
56
|
-
*/
|
|
57
|
-
export declare function loadConfig(profilePath?: string): CogniumConfig | null;
|
|
58
|
-
/**
|
|
59
|
-
* Convert config passes to circle-ir PassOptions and disabledPasses.
|
|
60
|
-
*/
|
|
61
|
-
export declare function convertConfigToPassOptions(config: CogniumConfig): {
|
|
62
|
-
passOptions: PassOptions;
|
|
63
|
-
disabledPasses: string[];
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Structural type for scan results — compatible with ScanResult in cli.ts.
|
|
67
|
-
*/
|
|
68
|
-
export interface SuppressableResult {
|
|
69
|
-
file: string;
|
|
70
|
-
vulnerabilities: Array<{
|
|
71
|
-
type: string;
|
|
72
|
-
line?: number;
|
|
73
|
-
[key: string]: unknown;
|
|
74
|
-
}>;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Apply suppressions to filter out findings.
|
|
78
|
-
*/
|
|
79
|
-
export declare function applySuppressionsToResults<T extends SuppressableResult>(results: T[], suppressions: Suppression[], basePath: string): T[];
|
|
80
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,M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CAAC,EAAE,CA4BL"}
|
package/dist/config.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cognium.config.json — project-level configuration
|
|
3
|
-
*
|
|
4
|
-
* Shared schema with cognium CLI (cognium/src/cli.ts).
|
|
5
|
-
* Controls SAST pass options, pass disabling, trust pass filtering,
|
|
6
|
-
* and finding suppressions.
|
|
7
|
-
*/
|
|
8
|
-
import { existsSync, readFileSync } from 'fs';
|
|
9
|
-
import { relative } from 'path';
|
|
10
|
-
// =============================================================================
|
|
11
|
-
// Loader
|
|
12
|
-
// =============================================================================
|
|
13
|
-
/**
|
|
14
|
-
* Load configuration from cognium.config.json or a custom path.
|
|
15
|
-
*/
|
|
16
|
-
export function loadConfig(profilePath) {
|
|
17
|
-
const configPath = profilePath || 'cognium.config.json';
|
|
18
|
-
if (!existsSync(configPath)) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const content = readFileSync(configPath, 'utf-8');
|
|
23
|
-
return JSON.parse(content);
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
console.error(`Warning: Failed to parse ${configPath}: ${err}`);
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// =============================================================================
|
|
31
|
-
// Converter
|
|
32
|
-
// =============================================================================
|
|
33
|
-
/**
|
|
34
|
-
* Convert config passes to circle-ir PassOptions and disabledPasses.
|
|
35
|
-
*/
|
|
36
|
-
export function convertConfigToPassOptions(config) {
|
|
37
|
-
const passOptions = {};
|
|
38
|
-
const disabledPasses = [];
|
|
39
|
-
if (!config.passes) {
|
|
40
|
-
return { passOptions, disabledPasses };
|
|
41
|
-
}
|
|
42
|
-
for (const [passName, passConfig] of Object.entries(config.passes)) {
|
|
43
|
-
// Boolean false = disabled
|
|
44
|
-
if (passConfig === false) {
|
|
45
|
-
disabledPasses.push(passName);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
// Boolean true = enabled with defaults
|
|
49
|
-
if (passConfig === true) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
// Object config
|
|
53
|
-
if (typeof passConfig === 'object') {
|
|
54
|
-
if (passConfig.enabled === false) {
|
|
55
|
-
disabledPasses.push(passName);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
// Map pass-specific options to circle-ir PassOptions
|
|
59
|
-
switch (passName) {
|
|
60
|
-
case 'dependency-fan-out':
|
|
61
|
-
if (passConfig.threshold !== undefined) {
|
|
62
|
-
passOptions.dependencyFanOut = { threshold: passConfig.threshold };
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
case 'unbounded-collection':
|
|
66
|
-
if (passConfig.skipPatterns !== undefined) {
|
|
67
|
-
passOptions.unboundedCollection = { skipPatterns: passConfig.skipPatterns };
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
case 'naming-convention':
|
|
71
|
-
if (passConfig.enforceIPrefix !== undefined) {
|
|
72
|
-
passOptions.namingConvention = { enforceIPrefix: passConfig.enforceIPrefix };
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return { passOptions, disabledPasses };
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Apply suppressions to filter out findings.
|
|
82
|
-
*/
|
|
83
|
-
export function applySuppressionsToResults(results, suppressions, basePath) {
|
|
84
|
-
if (suppressions.length === 0)
|
|
85
|
-
return results;
|
|
86
|
-
return results.map(result => {
|
|
87
|
-
const relativeFile = relative(basePath, result.file) || result.file;
|
|
88
|
-
const filteredVulns = result.vulnerabilities.filter(vuln => {
|
|
89
|
-
for (const supp of suppressions) {
|
|
90
|
-
// Pass must match
|
|
91
|
-
if (supp.pass !== vuln.type)
|
|
92
|
-
continue;
|
|
93
|
-
// If file specified, it must match
|
|
94
|
-
if (supp.file) {
|
|
95
|
-
const suppFile = supp.file.replace(/^\.\//, ''); // normalize
|
|
96
|
-
if (suppFile !== relativeFile && suppFile !== result.file)
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
// If line specified, it must match
|
|
100
|
-
if (supp.line !== undefined && supp.line !== vuln.line)
|
|
101
|
-
continue;
|
|
102
|
-
// All conditions matched — suppress this finding
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
return true;
|
|
106
|
-
});
|
|
107
|
-
return { ...result, vulnerabilities: filteredVulns };
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAsDhC,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,WAAoB;IAC7C,MAAM,UAAU,GAAG,WAAW,IAAI,qBAAqB,CAAC;IAExD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAkB,CAAC;IAC9C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,UAAU,KAAK,GAAG,EAAE,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAqB;IAI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C,CAAC,CAAC;AACL,CAAC"}
|
package/dist/formatters.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output formatters for CLI results
|
|
3
|
-
*/
|
|
4
|
-
interface Vulnerability {
|
|
5
|
-
type: string;
|
|
6
|
-
severity: string;
|
|
7
|
-
message: string;
|
|
8
|
-
line: number;
|
|
9
|
-
cwe?: string;
|
|
10
|
-
category?: string;
|
|
11
|
-
fix?: string;
|
|
12
|
-
}
|
|
13
|
-
interface ScanResult {
|
|
14
|
-
file: string;
|
|
15
|
-
vulnerabilities: Vulnerability[];
|
|
16
|
-
error?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare function formatResults(results: ScanResult[], verbose?: boolean): string;
|
|
19
|
-
export declare function formatJSON(results: ScanResult[]): string;
|
|
20
|
-
export declare function formatSARIF(results: ScanResult[]): string;
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=formatters.d.ts.map
|
package/dist/formatters.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,aAAa,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA+FD,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CA+C9E;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CA6BxD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CA+DzD"}
|
package/dist/formatters.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output formatters for CLI results
|
|
3
|
-
*/
|
|
4
|
-
import { colors } from './utils/colors.js';
|
|
5
|
-
const VULNERABILITY_HELP = {
|
|
6
|
-
sql_injection: {
|
|
7
|
-
description: 'User input is used in SQL query without sanitization',
|
|
8
|
-
fix: 'Use PreparedStatement with parameterized queries instead of string concatenation',
|
|
9
|
-
},
|
|
10
|
-
nosql_injection: {
|
|
11
|
-
description: 'User input is used in NoSQL query without sanitization',
|
|
12
|
-
fix: 'Use parameterized queries or properly escape user input before using in queries',
|
|
13
|
-
},
|
|
14
|
-
command_injection: {
|
|
15
|
-
description: 'User input is used in system command without sanitization',
|
|
16
|
-
fix: 'Avoid Runtime.exec() with user input. Use ProcessBuilder with argument arrays instead',
|
|
17
|
-
},
|
|
18
|
-
path_traversal: {
|
|
19
|
-
description: 'User input is used in file path without validation',
|
|
20
|
-
fix: 'Validate file paths against allowlist, use canonical paths, and check for ".." sequences',
|
|
21
|
-
},
|
|
22
|
-
xss: {
|
|
23
|
-
description: 'User input is rendered in HTML without proper encoding',
|
|
24
|
-
fix: 'Use HTML encoding/escaping functions before rendering user input in web pages',
|
|
25
|
-
},
|
|
26
|
-
xxe: {
|
|
27
|
-
description: 'XML parser may process external entities from untrusted input',
|
|
28
|
-
fix: 'Disable external entity processing in XML parsers',
|
|
29
|
-
},
|
|
30
|
-
deserialization: {
|
|
31
|
-
description: 'Untrusted data is deserialized which can lead to remote code execution',
|
|
32
|
-
fix: 'Avoid deserializing untrusted data. Use safe formats like JSON instead of Java serialization',
|
|
33
|
-
},
|
|
34
|
-
ldap_injection: {
|
|
35
|
-
description: 'User input is used in LDAP query without sanitization',
|
|
36
|
-
fix: 'Escape LDAP special characters or use parameterized LDAP queries',
|
|
37
|
-
},
|
|
38
|
-
xpath_injection: {
|
|
39
|
-
description: 'User input is used in XPath query without sanitization',
|
|
40
|
-
fix: 'Use parameterized XPath queries or properly escape user input',
|
|
41
|
-
},
|
|
42
|
-
ssrf: {
|
|
43
|
-
description: 'Server-Side Request Forgery: user controls URL in server-side request',
|
|
44
|
-
fix: 'Validate URLs against allowlist of domains, block internal IPs',
|
|
45
|
-
},
|
|
46
|
-
open_redirect: {
|
|
47
|
-
description: 'User input controls redirect destination which can be abused for phishing',
|
|
48
|
-
fix: 'Validate redirect URLs against allowlist or use relative paths only',
|
|
49
|
-
},
|
|
50
|
-
code_injection: {
|
|
51
|
-
description: 'User input is evaluated as code (eval, script execution, etc.)',
|
|
52
|
-
fix: 'Never execute user input as code. Use safe alternatives like JSON parsing',
|
|
53
|
-
},
|
|
54
|
-
log_injection: {
|
|
55
|
-
description: 'User input in logs can inject fake log entries or exploit log viewers',
|
|
56
|
-
fix: 'Sanitize newlines and special characters from user input before logging',
|
|
57
|
-
},
|
|
58
|
-
weak_random: {
|
|
59
|
-
description: 'Cryptographically weak random number generator used for security purposes',
|
|
60
|
-
fix: 'Use SecureRandom instead of Random for security-sensitive operations',
|
|
61
|
-
},
|
|
62
|
-
weak_hash: {
|
|
63
|
-
description: 'Weak hashing algorithm (MD5, SHA1) used for security purposes',
|
|
64
|
-
fix: 'Use SHA-256 or stronger hashing algorithms',
|
|
65
|
-
},
|
|
66
|
-
weak_crypto: {
|
|
67
|
-
description: 'Weak cryptographic algorithm or configuration',
|
|
68
|
-
fix: 'Use strong encryption algorithms (AES-256) and secure configurations',
|
|
69
|
-
},
|
|
70
|
-
insecure_cookie: {
|
|
71
|
-
description: 'Cookie without Secure or HttpOnly flags exposes it to attacks',
|
|
72
|
-
fix: 'Set Secure and HttpOnly flags on sensitive cookies',
|
|
73
|
-
},
|
|
74
|
-
trust_boundary: {
|
|
75
|
-
description: 'Data crosses trust boundary without validation',
|
|
76
|
-
fix: 'Validate and sanitize data when crossing trust boundaries',
|
|
77
|
-
},
|
|
78
|
-
external_taint_escape: {
|
|
79
|
-
description: 'External input reaches a sensitive sink without proper validation',
|
|
80
|
-
fix: 'Validate, sanitize, or escape external input before use in sensitive operations',
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
const SEVERITY_COLORS = {
|
|
84
|
-
critical: colors.red,
|
|
85
|
-
high: colors.red,
|
|
86
|
-
medium: colors.yellow,
|
|
87
|
-
low: colors.cyan,
|
|
88
|
-
};
|
|
89
|
-
const SEVERITY_ICONS = {
|
|
90
|
-
critical: '!!!',
|
|
91
|
-
high: '!!',
|
|
92
|
-
medium: '!',
|
|
93
|
-
low: 'i',
|
|
94
|
-
};
|
|
95
|
-
export function formatResults(results, verbose) {
|
|
96
|
-
const lines = [];
|
|
97
|
-
for (const result of results) {
|
|
98
|
-
if (result.error) {
|
|
99
|
-
lines.push(colors.red(`[ERROR] ${result.file}: ${result.error}`));
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (result.vulnerabilities.length === 0) {
|
|
103
|
-
if (verbose) {
|
|
104
|
-
lines.push(colors.green(`[OK] ${result.file}`));
|
|
105
|
-
}
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
lines.push(colors.bold(result.file));
|
|
109
|
-
for (const vuln of result.vulnerabilities) {
|
|
110
|
-
const colorFn = SEVERITY_COLORS[vuln.severity] || ((text) => text);
|
|
111
|
-
const icon = SEVERITY_ICONS[vuln.severity] || '?';
|
|
112
|
-
const cweTag = vuln.cwe ? ` [${vuln.cwe}]` : '';
|
|
113
|
-
const catTag = vuln.category && vuln.category !== 'security' ? ` (${vuln.category})` : '';
|
|
114
|
-
const severityUpper = vuln.severity.charAt(0).toUpperCase() + vuln.severity.slice(1);
|
|
115
|
-
lines.push(` ${colorFn(`[${icon}]`)} ${colorFn(vuln.type)} (${severityUpper})${cweTag}${catTag}`);
|
|
116
|
-
lines.push(` Line ${vuln.line}: ${vuln.message}`);
|
|
117
|
-
// Use finding-specific fix from circle-ir, fall back to hardcoded help
|
|
118
|
-
if (vuln.fix) {
|
|
119
|
-
lines.push(colors.cyan(` -> Fix: ${vuln.fix}`));
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const help = VULNERABILITY_HELP[vuln.type];
|
|
123
|
-
if (help) {
|
|
124
|
-
lines.push(` ${help.description}`);
|
|
125
|
-
lines.push(colors.cyan(` -> Fix: ${help.fix}`));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
lines.push('');
|
|
130
|
-
}
|
|
131
|
-
return lines.join('\n');
|
|
132
|
-
}
|
|
133
|
-
export function formatJSON(results) {
|
|
134
|
-
const allVulns = results.flatMap(r => r.vulnerabilities);
|
|
135
|
-
const securityCount = allVulns.filter(v => !v.category || v.category === 'security').length;
|
|
136
|
-
const byCategory = {};
|
|
137
|
-
for (const v of allVulns) {
|
|
138
|
-
const cat = v.category || 'security';
|
|
139
|
-
byCategory[cat] = (byCategory[cat] || 0) + 1;
|
|
140
|
-
}
|
|
141
|
-
const output = {
|
|
142
|
-
version: '1.0.0',
|
|
143
|
-
timestamp: new Date().toISOString(),
|
|
144
|
-
results: results.map((r) => ({
|
|
145
|
-
file: r.file,
|
|
146
|
-
vulnerabilities: r.vulnerabilities,
|
|
147
|
-
error: r.error,
|
|
148
|
-
})),
|
|
149
|
-
summary: {
|
|
150
|
-
filesScanned: results.length,
|
|
151
|
-
filesWithFindings: results.filter((r) => r.vulnerabilities.length > 0).length,
|
|
152
|
-
totalFindings: allVulns.length,
|
|
153
|
-
securityFindings: securityCount,
|
|
154
|
-
qualityFindings: allVulns.length - securityCount,
|
|
155
|
-
byCategory,
|
|
156
|
-
errors: results.filter((r) => r.error).length,
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
return JSON.stringify(output, null, 2);
|
|
160
|
-
}
|
|
161
|
-
export function formatSARIF(results) {
|
|
162
|
-
const ruleSet = new Map();
|
|
163
|
-
const sarifResults = [];
|
|
164
|
-
for (const result of results) {
|
|
165
|
-
for (const vuln of result.vulnerabilities) {
|
|
166
|
-
if (!ruleSet.has(vuln.type)) {
|
|
167
|
-
ruleSet.set(vuln.type, {
|
|
168
|
-
id: vuln.type.replace(/\s+/g, '-').toLowerCase(),
|
|
169
|
-
name: vuln.type,
|
|
170
|
-
shortDescription: { text: vuln.type },
|
|
171
|
-
defaultConfiguration: {
|
|
172
|
-
level: vuln.severity === 'critical' || vuln.severity === 'high' ? 'error' : 'warning',
|
|
173
|
-
},
|
|
174
|
-
properties: {
|
|
175
|
-
'security-severity': vuln.severity === 'critical' ? '9.0' :
|
|
176
|
-
vuln.severity === 'high' ? '7.0' :
|
|
177
|
-
vuln.severity === 'medium' ? '5.0' : '3.0',
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
sarifResults.push({
|
|
182
|
-
ruleId: vuln.type.replace(/\s+/g, '-').toLowerCase(),
|
|
183
|
-
level: vuln.severity === 'critical' || vuln.severity === 'high' ? 'error' : 'warning',
|
|
184
|
-
message: { text: vuln.message },
|
|
185
|
-
locations: [
|
|
186
|
-
{
|
|
187
|
-
physicalLocation: {
|
|
188
|
-
artifactLocation: { uri: result.file },
|
|
189
|
-
region: { startLine: vuln.line },
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
properties: {
|
|
194
|
-
cwe: vuln.cwe,
|
|
195
|
-
severity: vuln.severity,
|
|
196
|
-
category: vuln.category || 'security',
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
const sarif = {
|
|
202
|
-
$schema: 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json',
|
|
203
|
-
version: '2.1.0',
|
|
204
|
-
runs: [
|
|
205
|
-
{
|
|
206
|
-
tool: {
|
|
207
|
-
driver: {
|
|
208
|
-
name: 'cognium-ai',
|
|
209
|
-
version: '1.0.0',
|
|
210
|
-
informationUri: 'https://cognium.dev',
|
|
211
|
-
rules: Array.from(ruleSet.values()),
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
results: sarifResults,
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
};
|
|
218
|
-
return JSON.stringify(sarif, null, 2);
|
|
219
|
-
}
|
|
220
|
-
//# sourceMappingURL=formatters.js.map
|
package/dist/formatters.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAkB3C,MAAM,kBAAkB,GAAyD;IAC/E,aAAa,EAAE;QACb,WAAW,EAAE,sDAAsD;QACnE,GAAG,EAAE,kFAAkF;KACxF;IACD,eAAe,EAAE;QACf,WAAW,EAAE,wDAAwD;QACrE,GAAG,EAAE,iFAAiF;KACvF;IACD,iBAAiB,EAAE;QACjB,WAAW,EAAE,2DAA2D;QACxE,GAAG,EAAE,uFAAuF;KAC7F;IACD,cAAc,EAAE;QACd,WAAW,EAAE,oDAAoD;QACjE,GAAG,EAAE,0FAA0F;KAChG;IACD,GAAG,EAAE;QACH,WAAW,EAAE,wDAAwD;QACrE,GAAG,EAAE,+EAA+E;KACrF;IACD,GAAG,EAAE;QACH,WAAW,EAAE,+DAA+D;QAC5E,GAAG,EAAE,mDAAmD;KACzD;IACD,eAAe,EAAE;QACf,WAAW,EAAE,wEAAwE;QACrF,GAAG,EAAE,8FAA8F;KACpG;IACD,cAAc,EAAE;QACd,WAAW,EAAE,uDAAuD;QACpE,GAAG,EAAE,kEAAkE;KACxE;IACD,eAAe,EAAE;QACf,WAAW,EAAE,wDAAwD;QACrE,GAAG,EAAE,+DAA+D;KACrE;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,uEAAuE;QACpF,GAAG,EAAE,gEAAg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,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE;yBACjC;qBACF;iBACF;gBACD,UAAU,EAAE;oBACV,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,UAAU;iBACtC;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG;QACZ,OAAO,EAAE,gGAAgG;QACzG,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE;YACJ;gBACE,IAAI,EAAE;oBACJ,MAAM,EAAE;wBACN,IAAI,EAAE,YAAY;wBAClB,OAAO,EAAE,OAAO;wBAChB,cAAc,EAAE,qBAAqB;wBACrC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;qBACpC;iBACF;gBACD,OAAO,EAAE,YAAY;aACtB;SACF;KACF,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/utils/args.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight argument parser
|
|
3
|
-
*/
|
|
4
|
-
export interface ParsedArgs {
|
|
5
|
-
command?: string;
|
|
6
|
-
args: string[];
|
|
7
|
-
options: Record<string, string | boolean>;
|
|
8
|
-
}
|
|
9
|
-
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
10
|
-
export declare function showHelp(): void;
|
|
11
|
-
export declare function showVersion(version: string): void;
|
|
12
|
-
//# sourceMappingURL=args.d.ts.map
|
package/dist/utils/args.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/utils/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;CAC3C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAyCpD;AAED,wBAAgB,QAAQ,IAAI,IAAI,CA6H/B;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGjD"}
|
package/dist/utils/args.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight argument parser
|
|
3
|
-
*/
|
|
4
|
-
export function parseArgs(argv) {
|
|
5
|
-
const args = [];
|
|
6
|
-
const options = {};
|
|
7
|
-
let command;
|
|
8
|
-
for (let i = 0; i < argv.length; i++) {
|
|
9
|
-
const arg = argv[i];
|
|
10
|
-
if (arg.startsWith('--')) {
|
|
11
|
-
const key = arg.slice(2);
|
|
12
|
-
if (key.includes('=')) {
|
|
13
|
-
const [k, v] = key.split('=', 2);
|
|
14
|
-
options[k] = v;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
const nextArg = argv[i + 1];
|
|
18
|
-
if (nextArg && !nextArg.startsWith('-')) {
|
|
19
|
-
options[key] = nextArg;
|
|
20
|
-
i++;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
options[key] = true;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else if (arg.startsWith('-') && arg.length === 2) {
|
|
28
|
-
const key = arg.slice(1);
|
|
29
|
-
const nextArg = argv[i + 1];
|
|
30
|
-
if (nextArg && !nextArg.startsWith('-')) {
|
|
31
|
-
options[key] = nextArg;
|
|
32
|
-
i++;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
options[key] = true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
if (!command) {
|
|
40
|
-
command = arg;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
args.push(arg);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return { command, args, options };
|
|
48
|
-
}
|
|
49
|
-
export function showHelp() {
|
|
50
|
-
console.log(`
|
|
51
|
-
cognium-ai - AI-powered static analysis with LLM-enhanced vulnerability detection
|
|
52
|
-
|
|
53
|
-
USAGE:
|
|
54
|
-
cognium-ai <command> [options]
|
|
55
|
-
|
|
56
|
-
COMMANDS:
|
|
57
|
-
scan <path> Scan for security vulnerabilities (LLM-enhanced by default)
|
|
58
|
-
dead-code <path> Detect dead/unreachable code
|
|
59
|
-
secrets <path> Scan for secrets and credentials
|
|
60
|
-
health <path> Calculate codebase health score
|
|
61
|
-
metrics <path> Compute software metrics (CK suite, Halstead, composites)
|
|
62
|
-
skill <path> Analyze AI skill bundle security
|
|
63
|
-
trust <path> Run trust score analysis (27 security/supply-chain passes)
|
|
64
|
-
compare <A> <B> Compare trust scores between two paths
|
|
65
|
-
quality <path> Calculate quality score (5 quality passes)
|
|
66
|
-
understand <path> Semantic understanding (functions, roles, side effects)
|
|
67
|
-
spec-diff <path> Spec-gap analysis (code vs spec alignment)
|
|
68
|
-
cluster <path> Component clustering and architecture analysis
|
|
69
|
-
generate-spec <file> Generate Specifica specification from code
|
|
70
|
-
init Initialize a configuration file
|
|
71
|
-
version Display version information
|
|
72
|
-
|
|
73
|
-
SCAN OPTIONS:
|
|
74
|
-
-l, --language <lang> Force language (bash|java|javascript|typescript|python|rust)
|
|
75
|
-
-f, --format <format> Output format (text|json|sarif) [default: text]
|
|
76
|
-
--threads <n> Parallel analysis threads [default: 4]
|
|
77
|
-
--severity <level> Minimum severity to report (low|medium|high|critical)
|
|
78
|
-
--exclude-tests Exclude test files and directories
|
|
79
|
-
--exclude-cwe <cwes> Exclude specific CWEs (comma-separated)
|
|
80
|
-
-o, --output <file> Write results to file
|
|
81
|
-
-q, --quiet Suppress progress output
|
|
82
|
-
-v, --verbose Show detailed output
|
|
83
|
-
--no-llm Static SAST only (no LLM enrichment)
|
|
84
|
-
--llm-discovery Enable LLM discovery mode (deeper analysis)
|
|
85
|
-
|
|
86
|
-
DEAD-CODE / SECRETS / HEALTH OPTIONS:
|
|
87
|
-
-f, --format <format> Output format (text|json) [default: text]
|
|
88
|
-
-o, --output <file> Write results to file
|
|
89
|
-
-q, --quiet Suppress progress output
|
|
90
|
-
|
|
91
|
-
SKILL OPTIONS:
|
|
92
|
-
-o, --output <file> Write results to file
|
|
93
|
-
|
|
94
|
-
TRUST OPTIONS:
|
|
95
|
-
-f, --format <format> Output format (text|json|sarif|badge) [default: text]
|
|
96
|
-
-o, --output <file> Write results to file
|
|
97
|
-
-q, --quiet Suppress progress output
|
|
98
|
-
--disable-pass <names> Disable specific trust passes (comma-separated)
|
|
99
|
-
|
|
100
|
-
METRICS OPTIONS:
|
|
101
|
-
-f, --format <format> Output format (text|json) [default: text]
|
|
102
|
-
-o, --output <file> Write results to file
|
|
103
|
-
-q, --quiet Suppress progress output
|
|
104
|
-
|
|
105
|
-
UNDERSTAND / SPEC-DIFF / CLUSTER OPTIONS:
|
|
106
|
-
-f, --format <format> Output format (text|json) [default: text]
|
|
107
|
-
-o, --output <file> Write results to file
|
|
108
|
-
-q, --quiet Suppress progress output
|
|
109
|
-
--spec <dir> Spec directory for spec-diff [default: <path>/.specifica/]
|
|
110
|
-
--llm Enable LLM-enhanced clustering (cluster command)
|
|
111
|
-
|
|
112
|
-
GENERATE-SPEC OPTIONS:
|
|
113
|
-
--spec-model <model> LLM model for spec generation
|
|
114
|
-
--spec-overwrite Overwrite existing spec files
|
|
115
|
-
-f, --format <format> Output format (text|json) [default: text]
|
|
116
|
-
-o, --output <file> Write results to file
|
|
117
|
-
|
|
118
|
-
CONFIG OPTIONS:
|
|
119
|
-
--config <path> Path to cognium.config.json [default: cognium.config.json]
|
|
120
|
-
--disable-pass <names> Disable specific passes (comma-separated)
|
|
121
|
-
|
|
122
|
-
LLM OPTIONS:
|
|
123
|
-
--llm-base-url <url> LLM API base URL (any OpenAI-compatible endpoint)
|
|
124
|
-
--llm-api-key <key> LLM API key (overrides LLM_API_KEY env var)
|
|
125
|
-
--llm-model <model> LLM model name (overrides LLM_ENRICHMENT_MODEL env var)
|
|
126
|
-
--no-llm Static SAST only (no LLM enrichment)
|
|
127
|
-
--llm-discovery Enable LLM discovery mode (deeper analysis)
|
|
128
|
-
|
|
129
|
-
CLI flags override environment variables. Supported providers:
|
|
130
|
-
OpenAI: --llm-base-url https://api.openai.com/v1 --llm-model gpt-4o
|
|
131
|
-
GitHub Models: --llm-base-url https://models.github.ai/inference --llm-model openai/gpt-5
|
|
132
|
-
Azure OpenAI: --llm-base-url https://YOUR.openai.azure.com/... --llm-model gpt-4o
|
|
133
|
-
Ollama: --llm-base-url http://localhost:11434/v1 --llm-model llama3
|
|
134
|
-
|
|
135
|
-
Environment variables (used as defaults when flags are not set):
|
|
136
|
-
LLM_API_KEY API key for LLM provider
|
|
137
|
-
LLM_BASE_URL LLM API base URL [default: http://localhost:4000/v1]
|
|
138
|
-
LLM_ENRICHMENT_MODEL Model to use [default: cognium/gpt-oss-120b]
|
|
139
|
-
|
|
140
|
-
EXAMPLES:
|
|
141
|
-
cognium-ai scan src/ # LLM-enhanced scan
|
|
142
|
-
cognium-ai scan src/ --no-llm # Static-only scan
|
|
143
|
-
cognium-ai scan app.java -f json -o out.json # JSON output to file
|
|
144
|
-
cognium-ai scan . --severity high # High+ severity only
|
|
145
|
-
cognium-ai dead-code src/ # Find dead code
|
|
146
|
-
cognium-ai secrets . # Find secrets
|
|
147
|
-
cognium-ai health src/ # Health score
|
|
148
|
-
cognium-ai skill ./my-mcp-server # Analyze AI skill
|
|
149
|
-
cognium-ai trust . # Trust score report
|
|
150
|
-
cognium-ai trust . -f json -o trust.json # Trust score as JSON
|
|
151
|
-
cognium-ai trust . -f badge -o badge.svg # Trust badge SVG
|
|
152
|
-
cognium-ai compare ./src ./other-src # Compare trust scores
|
|
153
|
-
cognium-ai quality src/ # Quality score report
|
|
154
|
-
cognium-ai quality src/ -f badge -o q.svg # Quality badge SVG
|
|
155
|
-
cognium-ai metrics src/ # Software metrics (CK, Halstead)
|
|
156
|
-
cognium-ai metrics src/ -f json -o metrics.json
|
|
157
|
-
cognium-ai understand src/ # Semantic understanding report
|
|
158
|
-
cognium-ai understand src/ -f json -o understand.json
|
|
159
|
-
cognium-ai spec-diff src/ # Spec-gap analysis (needs .specifica/)
|
|
160
|
-
cognium-ai spec-diff src/ --spec ./specs # Custom spec directory
|
|
161
|
-
cognium-ai cluster src/ # Component clustering (static)
|
|
162
|
-
cognium-ai cluster src/ --llm # LLM-enhanced clustering
|
|
163
|
-
cognium-ai generate-spec App.java # Generate spec from code
|
|
164
|
-
cognium-ai generate-spec App.java --spec-model gpt-4o
|
|
165
|
-
|
|
166
|
-
# Use OpenAI directly
|
|
167
|
-
cognium-ai scan src/ --llm-base-url https://api.openai.com/v1 --llm-api-key sk-... --llm-model gpt-4o
|
|
168
|
-
|
|
169
|
-
# Use GitHub Models (free in CI)
|
|
170
|
-
cognium-ai scan src/ --llm-base-url https://models.github.ai/inference --llm-api-key "$GITHUB_TOKEN" --llm-model openai/gpt-5
|
|
171
|
-
|
|
172
|
-
For more information, visit: https://cognium.dev
|
|
173
|
-
`);
|
|
174
|
-
}
|
|
175
|
-
export function showVersion(version) {
|
|
176
|
-
console.log(`cognium-ai v${version}`);
|
|
177
|
-
console.log(`Powered by Cognium Labs (circle-ir + circle-ir-ai)`);
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=args.js.map
|
package/dist/utils/args.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/utils/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAqC,EAAE,CAA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