postquant 0.5.0 → 0.7.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 +45 -27
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +18 -23
- package/dist/commands/analyze.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/output/cbom.d.ts.map +1 -1
- package/dist/output/cbom.js +1 -13
- package/dist/output/cbom.js.map +1 -1
- package/dist/output/json-code.d.ts.map +1 -1
- package/dist/output/json-code.js +2 -13
- package/dist/output/json-code.js.map +1 -1
- package/dist/output/json.d.ts.map +1 -1
- package/dist/output/json.js +2 -13
- package/dist/output/json.js.map +1 -1
- package/dist/output/sarif.d.ts.map +1 -1
- package/dist/output/sarif.js +1 -13
- package/dist/output/sarif.js.map +1 -1
- package/dist/output/terminal-code.d.ts.map +1 -1
- package/dist/output/terminal-code.js +6 -13
- package/dist/output/terminal-code.js.map +1 -1
- package/dist/output/terminal.d.ts.map +1 -1
- package/dist/output/terminal.js +6 -13
- package/dist/output/terminal.js.map +1 -1
- package/dist/scanner/code/ast/analyzer.d.ts +8 -0
- package/dist/scanner/code/ast/analyzer.d.ts.map +1 -0
- package/dist/scanner/code/ast/analyzer.js +117 -0
- package/dist/scanner/code/ast/analyzer.js.map +1 -0
- package/dist/scanner/code/ast/import-resolver.d.ts +13 -0
- package/dist/scanner/code/ast/import-resolver.d.ts.map +1 -0
- package/dist/scanner/code/ast/import-resolver.js +198 -0
- package/dist/scanner/code/ast/import-resolver.js.map +1 -0
- package/dist/scanner/code/ast/merge.d.ts +11 -0
- package/dist/scanner/code/ast/merge.d.ts.map +1 -0
- package/dist/scanner/code/ast/merge.js +50 -0
- package/dist/scanner/code/ast/merge.js.map +1 -0
- package/dist/scanner/code/ast/parser.d.ts +9 -0
- package/dist/scanner/code/ast/parser.d.ts.map +1 -0
- package/dist/scanner/code/ast/parser.js +58 -0
- package/dist/scanner/code/ast/parser.js.map +1 -0
- package/dist/scanner/code/ast/patterns/index.d.ts +5 -0
- package/dist/scanner/code/ast/patterns/index.d.ts.map +1 -0
- package/dist/scanner/code/ast/patterns/index.js +13 -0
- package/dist/scanner/code/ast/patterns/index.js.map +1 -0
- package/dist/scanner/code/ast/patterns/javascript.d.ts +3 -0
- package/dist/scanner/code/ast/patterns/javascript.d.ts.map +1 -0
- package/dist/scanner/code/ast/patterns/javascript.js +113 -0
- package/dist/scanner/code/ast/patterns/javascript.js.map +1 -0
- package/dist/scanner/code/ast/patterns/python.d.ts +3 -0
- package/dist/scanner/code/ast/patterns/python.d.ts.map +1 -0
- package/dist/scanner/code/ast/patterns/python.js +165 -0
- package/dist/scanner/code/ast/patterns/python.js.map +1 -0
- package/dist/scanner/code/ast/patterns/types.d.ts +23 -0
- package/dist/scanner/code/ast/patterns/types.d.ts.map +1 -0
- package/dist/scanner/code/ast/patterns/types.js +2 -0
- package/dist/scanner/code/ast/patterns/types.js.map +1 -0
- package/dist/scanner/code/ast/scope-detector.d.ts +8 -0
- package/dist/scanner/code/ast/scope-detector.d.ts.map +1 -0
- package/dist/scanner/code/ast/scope-detector.js +116 -0
- package/dist/scanner/code/ast/scope-detector.js.map +1 -0
- package/dist/scanner/code/ast/variable-resolver.d.ts +11 -0
- package/dist/scanner/code/ast/variable-resolver.d.ts.map +1 -0
- package/dist/scanner/code/ast/variable-resolver.js +115 -0
- package/dist/scanner/code/ast/variable-resolver.js.map +1 -0
- package/dist/scanner/code/discovery.d.ts +2 -0
- package/dist/scanner/code/discovery.d.ts.map +1 -1
- package/dist/scanner/code/discovery.js +1 -1
- package/dist/scanner/code/discovery.js.map +1 -1
- package/dist/scanner/code/grader.d.ts.map +1 -1
- package/dist/scanner/code/grader.js +2 -0
- package/dist/scanner/code/grader.js.map +1 -1
- package/dist/scanner/code/patterns/c.d.ts.map +1 -1
- package/dist/scanner/code/patterns/c.js +40 -4
- package/dist/scanner/code/patterns/c.js.map +1 -1
- package/dist/scanner/code/patterns/go.d.ts.map +1 -1
- package/dist/scanner/code/patterns/go.js +54 -0
- package/dist/scanner/code/patterns/go.js.map +1 -1
- package/dist/scanner/code/patterns/java.d.ts.map +1 -1
- package/dist/scanner/code/patterns/java.js +46 -0
- package/dist/scanner/code/patterns/java.js.map +1 -1
- package/dist/scanner/code/patterns/javascript.d.ts.map +1 -1
- package/dist/scanner/code/patterns/javascript.js +58 -0
- package/dist/scanner/code/patterns/javascript.js.map +1 -1
- package/dist/scanner/code/patterns/python.d.ts.map +1 -1
- package/dist/scanner/code/patterns/python.js +59 -0
- package/dist/scanner/code/patterns/python.js.map +1 -1
- package/dist/scanner/code/patterns/rust.d.ts.map +1 -1
- package/dist/scanner/code/patterns/rust.js +34 -0
- package/dist/scanner/code/patterns/rust.js.map +1 -1
- package/dist/scanner/code/risk-assessor.d.ts.map +1 -1
- package/dist/scanner/code/risk-assessor.js +30 -0
- package/dist/scanner/code/risk-assessor.js.map +1 -1
- package/dist/scanner/grader.d.ts.map +1 -1
- package/dist/scanner/grader.js +2 -0
- package/dist/scanner/grader.js.map +1 -1
- package/dist/types/index.d.ts +21 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/version.d.ts +2 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +19 -0
- package/dist/utils/version.js.map +1 -0
- package/grammars/tree-sitter-python.wasm +0 -0
- package/grammars/tree-sitter-typescript.wasm +0 -0
- package/package.json +4 -2
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** Generic query matching obj.method(...) calls in JS/TS */
|
|
2
|
+
const METHOD_CALL_QUERY = `
|
|
3
|
+
(call_expression
|
|
4
|
+
function: (member_expression
|
|
5
|
+
object: (identifier) @obj
|
|
6
|
+
property: (property_identifier) @method)
|
|
7
|
+
arguments: (arguments) @args)
|
|
8
|
+
`;
|
|
9
|
+
export const javascriptASTPatterns = [
|
|
10
|
+
{
|
|
11
|
+
id: 'js-rsa-keygen',
|
|
12
|
+
language: 'javascript',
|
|
13
|
+
category: 'asymmetric-encryption',
|
|
14
|
+
algorithm: 'RSA',
|
|
15
|
+
risk: 'critical',
|
|
16
|
+
query: METHOD_CALL_QUERY,
|
|
17
|
+
requiredImports: [
|
|
18
|
+
{ module: 'crypto', allowAlias: true },
|
|
19
|
+
],
|
|
20
|
+
methodNames: ['generateKeyPairSync', 'generateKeyPair'],
|
|
21
|
+
firstArgPattern: /['"]rsa['"]/i,
|
|
22
|
+
description: "RSA key generation is vulnerable to quantum attacks via Shor's algorithm",
|
|
23
|
+
migration: 'Migrate to ML-KEM (FIPS 203) for encryption or ML-DSA (FIPS 204) for signatures',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'js-ec-keygen',
|
|
27
|
+
language: 'javascript',
|
|
28
|
+
category: 'asymmetric-encryption',
|
|
29
|
+
algorithm: 'ECDSA',
|
|
30
|
+
risk: 'critical',
|
|
31
|
+
query: METHOD_CALL_QUERY,
|
|
32
|
+
requiredImports: [
|
|
33
|
+
{ module: 'crypto', allowAlias: true },
|
|
34
|
+
],
|
|
35
|
+
methodNames: ['generateKeyPairSync', 'generateKeyPair'],
|
|
36
|
+
firstArgPattern: /['"]ec['"]/i,
|
|
37
|
+
description: "EC key generation is vulnerable to quantum attacks via Shor's algorithm",
|
|
38
|
+
migration: 'Migrate to ML-DSA (FIPS 204) for signatures or ML-KEM (FIPS 203) for key exchange',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'js-dh-exchange',
|
|
42
|
+
language: 'javascript',
|
|
43
|
+
category: 'key-exchange',
|
|
44
|
+
algorithm: 'DH',
|
|
45
|
+
risk: 'critical',
|
|
46
|
+
query: METHOD_CALL_QUERY,
|
|
47
|
+
requiredImports: [
|
|
48
|
+
{ module: 'crypto', allowAlias: true },
|
|
49
|
+
],
|
|
50
|
+
methodNames: ['createDiffieHellman'],
|
|
51
|
+
description: "Diffie-Hellman key exchange is vulnerable to quantum attacks via Shor's algorithm",
|
|
52
|
+
migration: 'Migrate to ML-KEM (FIPS 203) for key exchange',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'js-ecdh-exchange',
|
|
56
|
+
language: 'javascript',
|
|
57
|
+
category: 'key-exchange',
|
|
58
|
+
algorithm: 'ECDH',
|
|
59
|
+
risk: 'critical',
|
|
60
|
+
query: METHOD_CALL_QUERY,
|
|
61
|
+
requiredImports: [
|
|
62
|
+
{ module: 'crypto', allowAlias: true },
|
|
63
|
+
],
|
|
64
|
+
methodNames: ['createECDH'],
|
|
65
|
+
description: "ECDH key exchange is vulnerable to quantum attacks via Shor's algorithm",
|
|
66
|
+
migration: 'Migrate to ML-KEM (FIPS 203) for key exchange',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'js-md5-hash',
|
|
70
|
+
language: 'javascript',
|
|
71
|
+
category: 'weak-hash',
|
|
72
|
+
algorithm: 'MD5',
|
|
73
|
+
risk: 'critical',
|
|
74
|
+
query: METHOD_CALL_QUERY,
|
|
75
|
+
requiredImports: [
|
|
76
|
+
{ module: 'crypto', allowAlias: true },
|
|
77
|
+
],
|
|
78
|
+
methodNames: ['createHash'],
|
|
79
|
+
firstArgPattern: /['"]md5['"]/i,
|
|
80
|
+
description: 'MD5 is cryptographically broken and unsuitable for any security use',
|
|
81
|
+
migration: 'Migrate to SHA-256 or SHA-3 for hashing',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'js-sha1-hash',
|
|
85
|
+
language: 'javascript',
|
|
86
|
+
category: 'weak-hash',
|
|
87
|
+
algorithm: 'SHA-1',
|
|
88
|
+
risk: 'critical',
|
|
89
|
+
query: METHOD_CALL_QUERY,
|
|
90
|
+
requiredImports: [
|
|
91
|
+
{ module: 'crypto', allowAlias: true },
|
|
92
|
+
],
|
|
93
|
+
methodNames: ['createHash'],
|
|
94
|
+
firstArgPattern: /['"]sha-?1['"]/i,
|
|
95
|
+
description: 'SHA-1 is cryptographically broken with practical collision attacks',
|
|
96
|
+
migration: 'Migrate to SHA-256 or SHA-3 for hashing',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'js-jwt-sign',
|
|
100
|
+
language: 'javascript',
|
|
101
|
+
category: 'digital-signature',
|
|
102
|
+
algorithm: 'RSA/ECDSA',
|
|
103
|
+
risk: 'critical',
|
|
104
|
+
query: METHOD_CALL_QUERY,
|
|
105
|
+
requiredImports: [
|
|
106
|
+
{ module: 'jsonwebtoken', allowAlias: true },
|
|
107
|
+
],
|
|
108
|
+
methodNames: ['sign'],
|
|
109
|
+
description: 'JWT signing with RSA/ECDSA algorithms is vulnerable to quantum attacks',
|
|
110
|
+
migration: 'Migrate to post-quantum JWT algorithms when standardized',
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
//# sourceMappingURL=javascript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../../../src/scanner/code/ast/patterns/javascript.ts"],"names":[],"mappings":"AAEA,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG;;;;;;CAMzB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD;QACE,EAAE,EAAE,eAAe;QACnB,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,uBAAuB;QACjC,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,iBAAiB;QACxB,eAAe,EAAE;YACf,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE;SACvC;QACD,WAAW,EAAE,CAAC,qBAAqB,EAAE,iBAAiB,CAAC;QACvD,eAAe,EAAE,cAAc;QAC/B,WAAW,EAAE,0EAA0E;QACvF,SAAS,EAAE,iFAAiF;KAC7F;IACD;QACE,EAAE,EAAE,cAAc;QAClB,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,uBAAuB;QACjC,SAAS,EAAE,OAAO;Q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,cAAc;QAC/B,WAAW,EAAE,qEAAqE;QAClF,SAAS,EAAE,yCAAyC;KACrD;IACD;QACE,EAAE,EAAE,cAAc;QAClB,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,WAAW;QACrB,SAAS,EAAE,OAAO;QAClB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,iBAAiB;QACxB,eAAe,EAAE;YACf,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE;SACvC;QACD,WAAW,EAAE,CAAC,YAAY,CAAC;QAC3B,eAAe,EAAE,iBAAiB;QAClC,WAAW,EAAE,oEAAoE;QACjF,SAAS,EAAE,yCAAyC;KACrD;IACD;QACE,EAAE,EAAE,aAAa;QACjB,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,mBAAmB;QAC7B,SAAS,EAAE,WAAW;QACtB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,iBAAiB;QACxB,eAAe,EAAE;YACf,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE;SAC7C;QACD,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,WAAW,EAAE,wEAAwE;QACrF,SAAS,EAAE,0DAA0D;KACtE;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../../../src/scanner/code/ast/patterns/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAW7C,eAAO,MAAM,iBAAiB,EAAE,UAAU,EA2JzC,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/** Generic query matching obj.method(...) calls */
|
|
2
|
+
const METHOD_CALL_QUERY = `
|
|
3
|
+
(call
|
|
4
|
+
function: (attribute
|
|
5
|
+
object: (identifier) @obj
|
|
6
|
+
attribute: (identifier) @method)
|
|
7
|
+
arguments: (argument_list) @args)
|
|
8
|
+
`;
|
|
9
|
+
export const pythonASTPatterns = [
|
|
10
|
+
{
|
|
11
|
+
id: 'python-rsa-keygen',
|
|
12
|
+
language: 'python',
|
|
13
|
+
category: 'asymmetric-encryption',
|
|
14
|
+
algorithm: 'RSA',
|
|
15
|
+
risk: 'critical',
|
|
16
|
+
query: METHOD_CALL_QUERY,
|
|
17
|
+
requiredImports: [
|
|
18
|
+
{ module: 'cryptography.hazmat.primitives.asymmetric', symbol: 'rsa', allowAlias: true },
|
|
19
|
+
],
|
|
20
|
+
methodNames: ['generate_private_key'],
|
|
21
|
+
description: "RSA key generation is vulnerable to quantum attacks via Shor's algorithm",
|
|
22
|
+
migration: 'Migrate to ML-KEM (FIPS 203) for encryption or ML-DSA (FIPS 204) for signatures',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'python-rsa-sign',
|
|
26
|
+
language: 'python',
|
|
27
|
+
category: 'digital-signature',
|
|
28
|
+
algorithm: 'RSA',
|
|
29
|
+
risk: 'critical',
|
|
30
|
+
query: METHOD_CALL_QUERY,
|
|
31
|
+
requiredImports: [
|
|
32
|
+
{ module: 'Crypto.PublicKey', symbol: 'RSA', allowAlias: true },
|
|
33
|
+
],
|
|
34
|
+
methodNames: ['generate'],
|
|
35
|
+
description: "RSA key generation (PyCryptodome) is vulnerable to quantum attacks",
|
|
36
|
+
migration: 'Migrate to ML-DSA (FIPS 204) for signatures',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'python-ec-keygen',
|
|
40
|
+
language: 'python',
|
|
41
|
+
category: 'asymmetric-encryption',
|
|
42
|
+
algorithm: 'ECDSA',
|
|
43
|
+
risk: 'critical',
|
|
44
|
+
query: METHOD_CALL_QUERY,
|
|
45
|
+
requiredImports: [
|
|
46
|
+
{ module: 'cryptography.hazmat.primitives.asymmetric', symbol: 'ec', allowAlias: true },
|
|
47
|
+
],
|
|
48
|
+
methodNames: ['generate_private_key'],
|
|
49
|
+
description: "Elliptic curve key generation is vulnerable to quantum attacks via Shor's algorithm",
|
|
50
|
+
migration: 'Migrate to ML-DSA (FIPS 204) for signatures or ML-KEM (FIPS 203) for key exchange',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'python-ecdsa-sign',
|
|
54
|
+
language: 'python',
|
|
55
|
+
category: 'digital-signature',
|
|
56
|
+
algorithm: 'ECDSA',
|
|
57
|
+
risk: 'critical',
|
|
58
|
+
query: METHOD_CALL_QUERY,
|
|
59
|
+
requiredImports: [
|
|
60
|
+
{ module: 'Crypto.PublicKey', symbol: 'ECC', allowAlias: true },
|
|
61
|
+
],
|
|
62
|
+
methodNames: ['generate'],
|
|
63
|
+
description: "ECC key generation (PyCryptodome) is vulnerable to quantum attacks",
|
|
64
|
+
migration: 'Migrate to ML-DSA (FIPS 204) for signatures',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'python-ed25519',
|
|
68
|
+
language: 'python',
|
|
69
|
+
category: 'digital-signature',
|
|
70
|
+
algorithm: 'Ed25519',
|
|
71
|
+
risk: 'critical',
|
|
72
|
+
query: METHOD_CALL_QUERY,
|
|
73
|
+
requiredImports: [
|
|
74
|
+
{ module: 'cryptography.hazmat.primitives.asymmetric.ed25519', symbol: 'Ed25519PrivateKey', allowAlias: true },
|
|
75
|
+
],
|
|
76
|
+
methodNames: ['generate'],
|
|
77
|
+
description: "Ed25519 is vulnerable to quantum attacks via Shor's algorithm",
|
|
78
|
+
migration: 'Migrate to ML-DSA (FIPS 204) for signatures',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'python-x25519',
|
|
82
|
+
language: 'python',
|
|
83
|
+
category: 'key-exchange',
|
|
84
|
+
algorithm: 'X25519',
|
|
85
|
+
risk: 'critical',
|
|
86
|
+
query: METHOD_CALL_QUERY,
|
|
87
|
+
requiredImports: [
|
|
88
|
+
{ module: 'cryptography.hazmat.primitives.asymmetric.x25519', symbol: 'X25519PrivateKey', allowAlias: true },
|
|
89
|
+
],
|
|
90
|
+
methodNames: ['generate'],
|
|
91
|
+
description: "X25519 key exchange is vulnerable to quantum attacks via Shor's algorithm",
|
|
92
|
+
migration: 'Migrate to ML-KEM (FIPS 203) for key exchange',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'python-dsa-keygen',
|
|
96
|
+
language: 'python',
|
|
97
|
+
category: 'digital-signature',
|
|
98
|
+
algorithm: 'DSA',
|
|
99
|
+
risk: 'critical',
|
|
100
|
+
query: METHOD_CALL_QUERY,
|
|
101
|
+
requiredImports: [
|
|
102
|
+
{ module: 'cryptography.hazmat.primitives.asymmetric', symbol: 'dsa', allowAlias: true },
|
|
103
|
+
],
|
|
104
|
+
methodNames: ['generate_private_key'],
|
|
105
|
+
description: "DSA key generation is vulnerable to quantum attacks via Shor's algorithm",
|
|
106
|
+
migration: 'Migrate to ML-DSA (FIPS 204) for signatures',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'python-dh-keygen',
|
|
110
|
+
language: 'python',
|
|
111
|
+
category: 'key-exchange',
|
|
112
|
+
algorithm: 'DH',
|
|
113
|
+
risk: 'critical',
|
|
114
|
+
query: METHOD_CALL_QUERY,
|
|
115
|
+
requiredImports: [
|
|
116
|
+
{ module: 'cryptography.hazmat.primitives.asymmetric', symbol: 'dh', allowAlias: true },
|
|
117
|
+
],
|
|
118
|
+
methodNames: ['generate_parameters'],
|
|
119
|
+
description: "Diffie-Hellman key exchange is vulnerable to quantum attacks via Shor's algorithm",
|
|
120
|
+
migration: 'Migrate to ML-KEM (FIPS 203) for key exchange',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 'python-md5',
|
|
124
|
+
language: 'python',
|
|
125
|
+
category: 'weak-hash',
|
|
126
|
+
algorithm: 'MD5',
|
|
127
|
+
risk: 'critical',
|
|
128
|
+
query: METHOD_CALL_QUERY,
|
|
129
|
+
requiredImports: [
|
|
130
|
+
{ module: 'hashlib', allowAlias: true },
|
|
131
|
+
],
|
|
132
|
+
methodNames: ['md5'],
|
|
133
|
+
description: 'MD5 is cryptographically broken and unsuitable for any security use',
|
|
134
|
+
migration: 'Migrate to SHA-256 or SHA-3 for hashing',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: 'python-sha1',
|
|
138
|
+
language: 'python',
|
|
139
|
+
category: 'weak-hash',
|
|
140
|
+
algorithm: 'SHA-1',
|
|
141
|
+
risk: 'critical',
|
|
142
|
+
query: METHOD_CALL_QUERY,
|
|
143
|
+
requiredImports: [
|
|
144
|
+
{ module: 'hashlib', allowAlias: true },
|
|
145
|
+
],
|
|
146
|
+
methodNames: ['sha1'],
|
|
147
|
+
description: 'SHA-1 is cryptographically broken with practical collision attacks',
|
|
148
|
+
migration: 'Migrate to SHA-256 or SHA-3 for hashing',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'python-sha256',
|
|
152
|
+
language: 'python',
|
|
153
|
+
category: 'safe-hash',
|
|
154
|
+
algorithm: 'SHA-256',
|
|
155
|
+
risk: 'moderate',
|
|
156
|
+
query: METHOD_CALL_QUERY,
|
|
157
|
+
requiredImports: [
|
|
158
|
+
{ module: 'hashlib', allowAlias: true },
|
|
159
|
+
],
|
|
160
|
+
methodNames: ['sha256'],
|
|
161
|
+
description: "SHA-256 has reduced security margin under Grover's algorithm (128-bit effective)",
|
|
162
|
+
migration: 'Consider SHA-384 or SHA-512 for larger post-quantum security margin',
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../../../src/scanner/code/ast/patterns/python.ts"],"names":[],"mappings":"AAEA,mDAAmD;AACnD,MAAM,iBAAiB,GAAG;;;;;;CAMzB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAiB;IAC7C;QACE,EAAE,EAAE,mBAAmB;QACvB,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,uBAAuB;QAC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AE,UAAU,EAAE,IAAI,EAAE;SACxC;QACD,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,WAAW,EAAE,kFAAkF;QAC/F,SAAS,EAAE,qEAAqE;KACjF;CACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Language, CryptoCategory, RiskLevel } from '../../../../types/index.js';
|
|
2
|
+
export interface ImportConstraint {
|
|
3
|
+
module: string;
|
|
4
|
+
symbol?: string;
|
|
5
|
+
allowAlias: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ASTPattern {
|
|
8
|
+
id: string;
|
|
9
|
+
language: Language;
|
|
10
|
+
category: CryptoCategory;
|
|
11
|
+
algorithm: string;
|
|
12
|
+
risk: RiskLevel;
|
|
13
|
+
query: string;
|
|
14
|
+
/** If set, the analyzer checks that @obj resolves to one of these imports */
|
|
15
|
+
requiredImports?: ImportConstraint[];
|
|
16
|
+
/** Method names to match against @method capture (case-sensitive) */
|
|
17
|
+
methodNames?: string[];
|
|
18
|
+
/** If set, the first argument text must match this regex (for disambiguation) */
|
|
19
|
+
firstArgPattern?: RegExp;
|
|
20
|
+
description: string;
|
|
21
|
+
migration: string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/scanner/code/ast/patterns/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEtF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,eAAe,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACrC,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/scanner/code/ast/patterns/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Tree } from 'web-tree-sitter';
|
|
2
|
+
import type { ScopeInfo } from '../../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Detect the enclosing scope for a given line number in the AST.
|
|
5
|
+
* Line is 1-indexed to match CodeFinding.line.
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectScope(tree: Tree, line: number, language: 'python' | 'javascript'): ScopeInfo;
|
|
8
|
+
//# sourceMappingURL=scope-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-detector.d.ts","sourceRoot":"","sources":["../../../../src/scanner/code/ast/scope-detector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAChC,SAAS,CAgCX"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect the enclosing scope for a given line number in the AST.
|
|
3
|
+
* Line is 1-indexed to match CodeFinding.line.
|
|
4
|
+
*/
|
|
5
|
+
export function detectScope(tree, line, language) {
|
|
6
|
+
const row = line - 1; // tree-sitter uses 0-indexed rows
|
|
7
|
+
const node = tree.rootNode.descendantForPosition({ row, column: 0 });
|
|
8
|
+
let functionName;
|
|
9
|
+
let className;
|
|
10
|
+
let isTestCode = false;
|
|
11
|
+
let isConditionalPath = false;
|
|
12
|
+
let current = node;
|
|
13
|
+
while (current) {
|
|
14
|
+
if (language === 'python') {
|
|
15
|
+
checkPythonScope(current, {
|
|
16
|
+
setFunction: (name) => { if (!functionName)
|
|
17
|
+
functionName = name; },
|
|
18
|
+
setClass: (name) => { if (!className)
|
|
19
|
+
className = name; },
|
|
20
|
+
setTest: () => { isTestCode = true; },
|
|
21
|
+
setConditional: () => { isConditionalPath = true; },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
checkJavaScriptScope(current, {
|
|
26
|
+
setFunction: (name) => { if (!functionName)
|
|
27
|
+
functionName = name; },
|
|
28
|
+
setClass: (name) => { if (!className)
|
|
29
|
+
className = name; },
|
|
30
|
+
setTest: () => { isTestCode = true; },
|
|
31
|
+
setConditional: () => { isConditionalPath = true; },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
current = current.parent;
|
|
35
|
+
}
|
|
36
|
+
return { functionName, className, isTestCode, isConditionalPath };
|
|
37
|
+
}
|
|
38
|
+
function checkPythonScope(node, cb) {
|
|
39
|
+
if (node.type === 'function_definition') {
|
|
40
|
+
const nameNode = node.childForFieldName('name');
|
|
41
|
+
if (nameNode) {
|
|
42
|
+
cb.setFunction(nameNode.text);
|
|
43
|
+
if (nameNode.text.startsWith('test_') || nameNode.text.startsWith('test')) {
|
|
44
|
+
cb.setTest();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Check for pytest decorators on parent decorated_definition
|
|
48
|
+
const parent = node.parent;
|
|
49
|
+
if (parent?.type === 'decorated_definition') {
|
|
50
|
+
for (let i = 0; i < parent.namedChildCount; i++) {
|
|
51
|
+
const child = parent.namedChild(i);
|
|
52
|
+
if (child.type === 'decorator' && /pytest\.(fixture|mark)/.test(child.text)) {
|
|
53
|
+
cb.setTest();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (node.type === 'class_definition') {
|
|
59
|
+
const nameNode = node.childForFieldName('name');
|
|
60
|
+
if (nameNode) {
|
|
61
|
+
cb.setClass(nameNode.text);
|
|
62
|
+
if (nameNode.text.startsWith('Test')) {
|
|
63
|
+
cb.setTest();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (node.type === 'try_statement') {
|
|
68
|
+
cb.setConditional();
|
|
69
|
+
}
|
|
70
|
+
if (node.type === 'if_statement' || node.type === 'elif_clause' || node.type === 'else_clause') {
|
|
71
|
+
cb.setConditional();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function checkJavaScriptScope(node, cb) {
|
|
75
|
+
// function declarations
|
|
76
|
+
if (node.type === 'function_declaration') {
|
|
77
|
+
const nameNode = node.childForFieldName('name');
|
|
78
|
+
if (nameNode)
|
|
79
|
+
cb.setFunction(nameNode.text);
|
|
80
|
+
}
|
|
81
|
+
// arrow functions assigned to variables: const X = () => { ... }
|
|
82
|
+
if (node.type === 'variable_declarator') {
|
|
83
|
+
const nameNode = node.childForFieldName('name');
|
|
84
|
+
const valueNode = node.childForFieldName('value');
|
|
85
|
+
if (nameNode && valueNode?.type === 'arrow_function') {
|
|
86
|
+
cb.setFunction(nameNode.text);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// method definitions in classes
|
|
90
|
+
if (node.type === 'method_definition') {
|
|
91
|
+
const nameNode = node.childForFieldName('name');
|
|
92
|
+
if (nameNode)
|
|
93
|
+
cb.setFunction(nameNode.text);
|
|
94
|
+
}
|
|
95
|
+
// class declarations
|
|
96
|
+
if (node.type === 'class_declaration') {
|
|
97
|
+
const nameNode = node.childForFieldName('name');
|
|
98
|
+
if (nameNode)
|
|
99
|
+
cb.setClass(nameNode.text);
|
|
100
|
+
}
|
|
101
|
+
// describe/it/test blocks
|
|
102
|
+
if (node.type === 'call_expression') {
|
|
103
|
+
const funcNode = node.childForFieldName('function');
|
|
104
|
+
if (funcNode && /^(describe|it|test|beforeEach|afterEach|beforeAll|afterAll)$/.test(funcNode.text)) {
|
|
105
|
+
cb.setTest();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// try/catch
|
|
109
|
+
if (node.type === 'try_statement') {
|
|
110
|
+
cb.setConditional();
|
|
111
|
+
}
|
|
112
|
+
if (node.type === 'if_statement') {
|
|
113
|
+
cb.setConditional();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=scope-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-detector.js","sourceRoot":"","sources":["../../../../src/scanner/code/ast/scope-detector.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,IAAU,EACV,IAAY,EACZ,QAAiC;IAEjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,kCAAkC;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAErE,IAAI,YAAgC,CAAC;IACrC,IAAI,SAA6B,CAAC;IAClC,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAE9B,IAAI,OAAO,GAAgB,IAAI,CAAC;IAEhC,OAAO,OAAO,EAAE,CAAC;QACf,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC1B,gBAAgB,CAAC,OAAO,EAAE;gBACxB,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,YAAY;oBAAE,YAA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AAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,QAAQ,IAAI,8DAA8D,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACnG,EAAE,CAAC,OAAO,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED,YAAY;IACZ,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAClC,EAAE,CAAC,cAAc,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QACjC,EAAE,CAAC,cAAc,EAAE,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Tree } from 'web-tree-sitter';
|
|
2
|
+
export interface VariableMap {
|
|
3
|
+
/** Get latest string value of a variable */
|
|
4
|
+
getString(name: string): string | undefined;
|
|
5
|
+
/** Get latest number value of a variable */
|
|
6
|
+
getNumber(name: string): number | undefined;
|
|
7
|
+
/** Get string value of a variable as it was at a specific line */
|
|
8
|
+
getStringAtLine(name: string, line: number): string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveVariables(tree: Tree, language: 'python' | 'javascript'): VariableMap;
|
|
11
|
+
//# sourceMappingURL=variable-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-resolver.d.ts","sourceRoot":"","sources":["../../../../src/scanner/code/ast/variable-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,iBAAiB,CAAC;AAOlD,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,4CAA4C;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,kEAAkE;IAClE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACjE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,WAAW,CAiC3F"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export function resolveVariables(tree, language) {
|
|
2
|
+
const entries = new Map();
|
|
3
|
+
function record(name, value, line) {
|
|
4
|
+
if (!entries.has(name))
|
|
5
|
+
entries.set(name, []);
|
|
6
|
+
entries.get(name).push({ value, line });
|
|
7
|
+
}
|
|
8
|
+
walkAssignments(tree.rootNode, language, record);
|
|
9
|
+
return {
|
|
10
|
+
getString(name) {
|
|
11
|
+
const list = entries.get(name);
|
|
12
|
+
if (!list || list.length === 0)
|
|
13
|
+
return undefined;
|
|
14
|
+
const last = list[list.length - 1];
|
|
15
|
+
return typeof last.value === 'string' ? last.value : undefined;
|
|
16
|
+
},
|
|
17
|
+
getNumber(name) {
|
|
18
|
+
const list = entries.get(name);
|
|
19
|
+
if (!list || list.length === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
const last = list[list.length - 1];
|
|
22
|
+
return typeof last.value === 'number' ? last.value : undefined;
|
|
23
|
+
},
|
|
24
|
+
getStringAtLine(name, line) {
|
|
25
|
+
const list = entries.get(name);
|
|
26
|
+
if (!list)
|
|
27
|
+
return undefined;
|
|
28
|
+
let best;
|
|
29
|
+
for (const entry of list) {
|
|
30
|
+
if (entry.line <= line)
|
|
31
|
+
best = entry;
|
|
32
|
+
}
|
|
33
|
+
return best && typeof best.value === 'string' ? best.value : undefined;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function walkAssignments(node, language, record) {
|
|
38
|
+
if (language === 'python') {
|
|
39
|
+
walkPythonAssignments(node, record);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
walkJavaScriptAssignments(node, record);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function walkPythonAssignments(node, record) {
|
|
46
|
+
if (node.type === 'assignment') {
|
|
47
|
+
const left = node.childForFieldName('left');
|
|
48
|
+
const right = node.childForFieldName('right');
|
|
49
|
+
if (left?.type === 'identifier' && right) {
|
|
50
|
+
const val = extractLiteral(right);
|
|
51
|
+
if (val !== undefined) {
|
|
52
|
+
record(left.text, val, left.startPosition.row + 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
57
|
+
walkPythonAssignments(node.child(i), record);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function walkJavaScriptAssignments(node, record) {
|
|
61
|
+
// variable_declarator: const/let/var name = value
|
|
62
|
+
if (node.type === 'variable_declarator') {
|
|
63
|
+
const nameNode = node.childForFieldName('name');
|
|
64
|
+
const valueNode = node.childForFieldName('value');
|
|
65
|
+
if (nameNode?.type === 'identifier' && valueNode) {
|
|
66
|
+
const val = extractLiteral(valueNode);
|
|
67
|
+
if (val !== undefined) {
|
|
68
|
+
record(nameNode.text, val, nameNode.startPosition.row + 1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// assignment_expression: name = value
|
|
73
|
+
if (node.type === 'assignment_expression') {
|
|
74
|
+
const left = node.childForFieldName('left');
|
|
75
|
+
const right = node.childForFieldName('right');
|
|
76
|
+
if (left?.type === 'identifier' && right) {
|
|
77
|
+
const val = extractLiteral(right);
|
|
78
|
+
if (val !== undefined) {
|
|
79
|
+
record(left.text, val, left.startPosition.row + 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
84
|
+
walkJavaScriptAssignments(node.child(i), record);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function extractLiteral(node) {
|
|
88
|
+
// Python: string has string_content child; JS: string has string_fragment child
|
|
89
|
+
if (node.type === 'string') {
|
|
90
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
91
|
+
const child = node.namedChild(i);
|
|
92
|
+
if (child.type === 'string_content' || child.type === 'string_fragment') {
|
|
93
|
+
return child.text;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Fallback: strip quotes
|
|
97
|
+
const text = node.text;
|
|
98
|
+
if ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'"))) {
|
|
99
|
+
return text.slice(1, -1);
|
|
100
|
+
}
|
|
101
|
+
return text;
|
|
102
|
+
}
|
|
103
|
+
// Python integer
|
|
104
|
+
if (node.type === 'integer') {
|
|
105
|
+
const num = parseInt(node.text, 10);
|
|
106
|
+
return isNaN(num) ? undefined : num;
|
|
107
|
+
}
|
|
108
|
+
// JS number
|
|
109
|
+
if (node.type === 'number') {
|
|
110
|
+
const num = parseInt(node.text, 10);
|
|
111
|
+
return isNaN(num) ? undefined : num;
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=variable-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-resolver.js","sourceRoot":"","sources":["../../../../src/scanner/code/ast/variable-resolver.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,gBAAgB,CAAC,IAAU,EAAE,QAAiC;IAC5E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE9C,SAAS,MAAM,CAAC,IAAY,EAAE,KAAsB,EAAE,IAAY;QAChE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,E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+1,6 @@
|
|
|
1
1
|
import type { Language, DiscoveredFile } from '../../types/index.js';
|
|
2
|
+
/** Extension → Language mapping. TypeScript maps to 'javascript'. */
|
|
3
|
+
export declare const EXTENSION_MAP: Record<string, Language>;
|
|
2
4
|
export interface DiscoverOptions {
|
|
3
5
|
/** Glob patterns to exclude */
|
|
4
6
|
ignore?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/scanner/code/discovery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/scanner/code/discovery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAErE,qEAAqE;AACrE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAqBlD,CAAC;AAsBF,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,EAAE,CAAC,CAoC3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdir, readFile } from 'node:fs/promises';
|
|
2
2
|
import { join, extname, basename } from 'node:path';
|
|
3
3
|
/** Extension → Language mapping. TypeScript maps to 'javascript'. */
|
|
4
|
-
const EXTENSION_MAP = {
|
|
4
|
+
export const EXTENSION_MAP = {
|
|
5
5
|
'.py': 'python',
|
|
6
6
|
'.pyw': 'python',
|
|
7
7
|
'.pyi': 'python',
|