@rigour-labs/core 3.0.5 → 4.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/dist/deep/fact-extractor.d.ts +80 -0
- package/dist/deep/fact-extractor.js +626 -0
- package/dist/deep/index.d.ts +14 -0
- package/dist/deep/index.js +12 -0
- package/dist/deep/prompts.d.ts +22 -0
- package/dist/deep/prompts.js +374 -0
- package/dist/deep/verifier.d.ts +16 -0
- package/dist/deep/verifier.js +388 -0
- package/dist/gates/deep-analysis.d.ts +28 -0
- package/dist/gates/deep-analysis.js +302 -0
- package/dist/gates/deprecated-apis-rules-lang.d.ts +21 -0
- package/dist/gates/deprecated-apis-rules-lang.js +311 -0
- package/dist/gates/deprecated-apis-rules-node.d.ts +19 -0
- package/dist/gates/deprecated-apis-rules-node.js +199 -0
- package/dist/gates/deprecated-apis-rules.d.ts +6 -0
- package/dist/gates/deprecated-apis-rules.js +6 -0
- package/dist/gates/deprecated-apis.js +1 -502
- package/dist/gates/hallucinated-imports-lang.d.ts +16 -0
- package/dist/gates/hallucinated-imports-lang.js +374 -0
- package/dist/gates/hallucinated-imports-stdlib.d.ts +12 -0
- package/dist/gates/hallucinated-imports-stdlib.js +228 -0
- package/dist/gates/hallucinated-imports.d.ts +0 -98
- package/dist/gates/hallucinated-imports.js +10 -678
- package/dist/gates/phantom-apis-data.d.ts +33 -0
- package/dist/gates/phantom-apis-data.js +398 -0
- package/dist/gates/phantom-apis.js +1 -393
- package/dist/gates/phantom-apis.test.js +52 -0
- package/dist/gates/promise-safety-helpers.d.ts +19 -0
- package/dist/gates/promise-safety-helpers.js +101 -0
- package/dist/gates/promise-safety-rules.d.ts +7 -0
- package/dist/gates/promise-safety-rules.js +19 -0
- package/dist/gates/promise-safety.d.ts +1 -21
- package/dist/gates/promise-safety.js +51 -257
- package/dist/gates/runner.d.ts +4 -2
- package/dist/gates/runner.js +46 -1
- package/dist/gates/test-quality-lang.d.ts +30 -0
- package/dist/gates/test-quality-lang.js +188 -0
- package/dist/gates/test-quality.d.ts +0 -14
- package/dist/gates/test-quality.js +13 -186
- package/dist/index.d.ts +10 -0
- package/dist/index.js +12 -2
- package/dist/inference/cloud-provider.d.ts +34 -0
- package/dist/inference/cloud-provider.js +126 -0
- package/dist/inference/index.d.ts +17 -0
- package/dist/inference/index.js +23 -0
- package/dist/inference/model-manager.d.ts +26 -0
- package/dist/inference/model-manager.js +106 -0
- package/dist/inference/sidecar-provider.d.ts +15 -0
- package/dist/inference/sidecar-provider.js +153 -0
- package/dist/inference/types.d.ts +77 -0
- package/dist/inference/types.js +19 -0
- package/dist/pattern-index/indexer-helpers.d.ts +38 -0
- package/dist/pattern-index/indexer-helpers.js +111 -0
- package/dist/pattern-index/indexer-lang.d.ts +13 -0
- package/dist/pattern-index/indexer-lang.js +244 -0
- package/dist/pattern-index/indexer-ts.d.ts +22 -0
- package/dist/pattern-index/indexer-ts.js +258 -0
- package/dist/pattern-index/indexer.d.ts +4 -106
- package/dist/pattern-index/indexer.js +58 -707
- package/dist/pattern-index/staleness-data.d.ts +6 -0
- package/dist/pattern-index/staleness-data.js +262 -0
- package/dist/pattern-index/staleness.js +1 -258
- package/dist/settings.d.ts +104 -0
- package/dist/settings.js +186 -0
- package/dist/storage/db.d.ts +16 -0
- package/dist/storage/db.js +132 -0
- package/dist/storage/findings.d.ts +14 -0
- package/dist/storage/findings.js +38 -0
- package/dist/storage/index.d.ts +9 -0
- package/dist/storage/index.js +8 -0
- package/dist/storage/patterns.d.ts +35 -0
- package/dist/storage/patterns.js +62 -0
- package/dist/storage/scans.d.ts +42 -0
- package/dist/storage/scans.js +55 -0
- package/dist/templates/index.d.ts +12 -16
- package/dist/templates/index.js +11 -527
- package/dist/templates/paradigms.d.ts +2 -0
- package/dist/templates/paradigms.js +46 -0
- package/dist/templates/presets.d.ts +14 -0
- package/dist/templates/presets.js +227 -0
- package/dist/templates/universal-config.d.ts +2 -0
- package/dist/templates/universal-config.js +190 -0
- package/dist/types/index.d.ts +438 -15
- package/dist/types/index.js +41 -1
- package/package.json +6 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data constants for phantom-apis gate.
|
|
3
|
+
* Language rule sets and stdlib method maps extracted to keep phantom-apis.ts under 500 lines.
|
|
4
|
+
*/
|
|
5
|
+
export interface PhantomRule {
|
|
6
|
+
pattern: RegExp;
|
|
7
|
+
module: string;
|
|
8
|
+
phantom: string;
|
|
9
|
+
suggestion: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Go commonly hallucinated APIs — AI mixes up Python/JS idioms with Go.
|
|
13
|
+
*/
|
|
14
|
+
export declare const GO_PHANTOM_RULES: PhantomRule[];
|
|
15
|
+
/**
|
|
16
|
+
* C# commonly hallucinated APIs — AI mixes up Java/Python idioms with .NET.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CSHARP_PHANTOM_RULES: PhantomRule[];
|
|
19
|
+
/**
|
|
20
|
+
* Java commonly hallucinated APIs — AI mixes up Python/JS/C# idioms with JDK.
|
|
21
|
+
*/
|
|
22
|
+
export declare const JAVA_PHANTOM_RULES: PhantomRule[];
|
|
23
|
+
/**
|
|
24
|
+
* Node.js 22.x stdlib method signatures.
|
|
25
|
+
* Only the most commonly hallucinated modules are covered.
|
|
26
|
+
* Each set contains ALL public methods/properties accessible on the module.
|
|
27
|
+
*/
|
|
28
|
+
export declare const NODE_STDLIB_METHODS: Record<string, Set<string>>;
|
|
29
|
+
/**
|
|
30
|
+
* Python 3.12+ stdlib method signatures.
|
|
31
|
+
* Covers the most commonly hallucinated modules.
|
|
32
|
+
*/
|
|
33
|
+
export declare const PYTHON_STDLIB_METHODS: Record<string, Set<string>>;
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data constants for phantom-apis gate.
|
|
3
|
+
* Language rule sets and stdlib method maps extracted to keep phantom-apis.ts under 500 lines.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Go commonly hallucinated APIs — AI mixes up Python/JS idioms with Go.
|
|
7
|
+
*/
|
|
8
|
+
export const GO_PHANTOM_RULES = [
|
|
9
|
+
{ pattern: /\bstrings\.includes\s*\(/, module: 'strings', phantom: 'includes', suggestion: "Use strings.Contains()" },
|
|
10
|
+
{ pattern: /\bstrings\.lower\s*\(/, module: 'strings', phantom: 'lower', suggestion: "Use strings.ToLower()" },
|
|
11
|
+
{ pattern: /\bstrings\.upper\s*\(/, module: 'strings', phantom: 'upper', suggestion: "Use strings.ToUpper()" },
|
|
12
|
+
{ pattern: /\bstrings\.strip\s*\(/, module: 'strings', phantom: 'strip', suggestion: "Use strings.TrimSpace()" },
|
|
13
|
+
{ pattern: /\bstrings\.find\s*\(/, module: 'strings', phantom: 'find', suggestion: "Use strings.Index()" },
|
|
14
|
+
{ pattern: /\bstrings\.startswith\s*\(/, module: 'strings', phantom: 'startswith', suggestion: "Use strings.HasPrefix()" },
|
|
15
|
+
{ pattern: /\bstrings\.endswith\s*\(/, module: 'strings', phantom: 'endswith', suggestion: "Use strings.HasSuffix()" },
|
|
16
|
+
// NOTE: os.ReadFile IS real (Go 1.16+). os.WriteFile IS real (Go 1.16+). Do NOT add them here.
|
|
17
|
+
{ pattern: /\bos\.Exists\s*\(/, module: 'os', phantom: 'Exists', suggestion: "Use os.Stat() and check os.IsNotExist(err)" },
|
|
18
|
+
{ pattern: /\bos\.isdir\s*\(/, module: 'os', phantom: 'isdir', suggestion: "Use os.Stat() then .IsDir()" },
|
|
19
|
+
{ pattern: /\bos\.listdir\s*\(/, module: 'os', phantom: 'listdir', suggestion: "Use os.ReadDir()" },
|
|
20
|
+
{ pattern: /\bfmt\.Format\s*\(/, module: 'fmt', phantom: 'Format', suggestion: "Use fmt.Sprintf()" },
|
|
21
|
+
// NOTE: fmt.Print, fmt.Println, fmt.Printf, fmt.Sprintf, fmt.Fprintf, fmt.Errorf are ALL real — do NOT add them here.
|
|
22
|
+
{ pattern: /\bhttp\.Get\s*\([^)]*\)\s*\.\s*Body/, module: 'http', phantom: 'Get().Body', suggestion: "http.Get() returns (*Response, error) — must check error first" },
|
|
23
|
+
{ pattern: /\bjson\.parse\s*\(/, module: 'json', phantom: 'parse', suggestion: "Use json.Unmarshal()" },
|
|
24
|
+
{ pattern: /\bjson\.stringify\s*\(/, module: 'json', phantom: 'stringify', suggestion: "Use json.Marshal()" },
|
|
25
|
+
{ pattern: /\bfilepath\.Combine\s*\(/, module: 'filepath', phantom: 'Combine', suggestion: "Use filepath.Join()" },
|
|
26
|
+
// NOTE: math.Max() IS real (float64 only). If you need int support, that's a type mismatch, not a phantom API.
|
|
27
|
+
{ pattern: /\bsort\.Sort\s*\(\s*\[\]/, module: 'sort', phantom: 'Sort([]T)', suggestion: "sort.Sort() requires sort.Interface — use slices.Sort() (Go 1.21+) or sort.Slice()" },
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* C# commonly hallucinated APIs — AI mixes up Java/Python idioms with .NET.
|
|
31
|
+
*/
|
|
32
|
+
export const CSHARP_PHANTOM_RULES = [
|
|
33
|
+
{ pattern: /\.length\b(?!\s*\()/, module: 'String', phantom: '.length', suggestion: "Use .Length (capital L) in C#" },
|
|
34
|
+
{ pattern: /\.equals\s*\(/, module: 'Object', phantom: '.equals()', suggestion: "Use .Equals() (capital E) in C#" },
|
|
35
|
+
{ pattern: /\.toString\s*\(/, module: 'Object', phantom: '.toString()', suggestion: "Use .ToString() (capital T) in C#" },
|
|
36
|
+
{ pattern: /\.hashCode\s*\(/, module: 'Object', phantom: '.hashCode()', suggestion: "Use .GetHashCode() in C#" },
|
|
37
|
+
{ pattern: /\.getClass\s*\(/, module: 'Object', phantom: '.getClass()', suggestion: "Use .GetType() in C#" },
|
|
38
|
+
{ pattern: /\.isEmpty\s*\(/, module: 'String', phantom: '.isEmpty()', suggestion: "Use string.IsNullOrEmpty() or .Length == 0 in C#" },
|
|
39
|
+
{ pattern: /\.charAt\s*\(/, module: 'String', phantom: '.charAt()', suggestion: "Use string[index] indexer in C#" },
|
|
40
|
+
{ pattern: /\.substring\s*\(/, module: 'String', phantom: '.substring()', suggestion: "Use .Substring() (capital S) in C#" },
|
|
41
|
+
{ pattern: /\.indexOf\s*\(/, module: 'String', phantom: '.indexOf()', suggestion: "Use .IndexOf() (capital I) in C#" },
|
|
42
|
+
{ pattern: /List<[^>]+>\s+\w+\s*=\s*new\s+ArrayList/, module: 'Collections', phantom: 'ArrayList', suggestion: "Use new List<T>() in C# — ArrayList is Java" },
|
|
43
|
+
{ pattern: /HashMap</, module: 'Collections', phantom: 'HashMap', suggestion: "Use Dictionary<TKey, TValue> in C#" },
|
|
44
|
+
{ pattern: /System\.out\.println/, module: 'System', phantom: 'System.out.println', suggestion: "Use Console.WriteLine() in C#" },
|
|
45
|
+
{ pattern: /\.stream\s*\(\)\s*\./, module: 'Collections', phantom: '.stream()', suggestion: "Use LINQ (.Select, .Where, etc.) in C# — .stream() is Java" },
|
|
46
|
+
{ pattern: /\.forEach\s*\(\s*\w+\s*->/, module: 'Collections', phantom: '.forEach(x ->)', suggestion: "Use .ForEach(x =>) or foreach loop in C#" },
|
|
47
|
+
{ pattern: /File\.readAllText\s*\(/, module: 'File', phantom: 'readAllText', suggestion: "Use File.ReadAllText() (capital R) in C#" },
|
|
48
|
+
{ pattern: /throws\s+\w+Exception/, module: 'method', phantom: 'throws', suggestion: "C# doesn't use checked exceptions — remove throws clause" },
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Java commonly hallucinated APIs — AI mixes up Python/JS/C# idioms with JDK.
|
|
52
|
+
*/
|
|
53
|
+
export const JAVA_PHANTOM_RULES = [
|
|
54
|
+
{ pattern: /\.len\s*\(/, module: 'Object', phantom: '.len()', suggestion: "Use .length() for String, .size() for Collection, .length for arrays in Java" },
|
|
55
|
+
{ pattern: /\bprint\s*\(\s*['"]/, module: 'IO', phantom: 'print()', suggestion: "Use System.out.println() in Java" },
|
|
56
|
+
// NOTE: .push() removed — Deque.push() and Stack.push() ARE valid Java. Cannot safely flag .push().
|
|
57
|
+
// NOTE: .append() removed — StringBuilder.append() IS valid Java. The lookahead was inverted (checked content
|
|
58
|
+
// after open paren, not variable before). Cannot safely distinguish list.append() from sb.append() via regex.
|
|
59
|
+
{ pattern: /\.include(?:s)?\s*\(/, module: 'Collection', phantom: '.includes()', suggestion: "Use .contains() in Java" },
|
|
60
|
+
{ pattern: /\.slice\s*\(/, module: 'List', phantom: '.slice()', suggestion: "Use .subList() for List in Java" },
|
|
61
|
+
{ pattern: /\.map\s*\(\s*\w+\s*=>/, module: 'Collection', phantom: '.map(x =>)', suggestion: "Use .stream().map(x ->) in Java — arrow is -> not =>" },
|
|
62
|
+
{ pattern: /\.filter\s*\(\s*\w+\s*=>/, module: 'Collection', phantom: '.filter(x =>)', suggestion: "Use .stream().filter(x ->) in Java — arrow is -> not =>" },
|
|
63
|
+
{ pattern: /Console\.(?:Write|Read)/, module: 'IO', phantom: 'Console', suggestion: "Console is C# — use System.out.println() or Scanner in Java" },
|
|
64
|
+
{ pattern: /\bvar\s+\w+\s*:\s*\w+\s*=/, module: 'syntax', phantom: 'var x: Type =', suggestion: "Java var doesn't use type annotation: use 'var x =' or 'Type x ='" },
|
|
65
|
+
// NOTE: .sorted() removed — stream().sorted() IS valid Java. Cannot distinguish from list.sorted().
|
|
66
|
+
// NOTE: .reversed() removed — List.reversed() and stream().reversed() are valid in Java 21+.
|
|
67
|
+
{ pattern: /String\.format\s*\(\s*\$"/, module: 'String', phantom: 'String.format($"...")', suggestion: "String interpolation $\"\" is C# — use String.format(\"%s\", ...) in Java" },
|
|
68
|
+
{ pattern: /\bnew\s+Map\s*[<(]/, module: 'Collections', phantom: 'new Map()', suggestion: "Use new HashMap<>() in Java — Map is an interface" },
|
|
69
|
+
{ pattern: /\bnew\s+List\s*[<(]/, module: 'Collections', phantom: 'new List()', suggestion: "Use new ArrayList<>() in Java — List is an interface" },
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Node.js 22.x stdlib method signatures.
|
|
73
|
+
* Only the most commonly hallucinated modules are covered.
|
|
74
|
+
* Each set contains ALL public methods/properties accessible on the module.
|
|
75
|
+
*/
|
|
76
|
+
export const NODE_STDLIB_METHODS = {
|
|
77
|
+
fs: new Set([
|
|
78
|
+
// Sync methods
|
|
79
|
+
'readFileSync', 'writeFileSync', 'appendFileSync', 'copyFileSync', 'renameSync',
|
|
80
|
+
'unlinkSync', 'mkdirSync', 'rmdirSync', 'rmSync', 'readdirSync', 'statSync',
|
|
81
|
+
'lstatSync', 'existsSync', 'accessSync', 'chmodSync', 'chownSync', 'closeSync',
|
|
82
|
+
'fchmodSync', 'fchownSync', 'fdatasyncSync', 'fstatSync', 'fsyncSync',
|
|
83
|
+
'ftruncateSync', 'futimesSync', 'linkSync', 'lutimesSync', 'mkdtempSync',
|
|
84
|
+
'openSync', 'opendirSync', 'readSync', 'readlinkSync', 'realpathSync',
|
|
85
|
+
'symlinkSync', 'truncateSync', 'utimesSync', 'writeSync', 'cpSync',
|
|
86
|
+
'statfsSync', 'globSync',
|
|
87
|
+
// Async callback methods
|
|
88
|
+
'readFile', 'writeFile', 'appendFile', 'copyFile', 'rename', 'unlink',
|
|
89
|
+
'mkdir', 'rmdir', 'rm', 'readdir', 'stat', 'lstat', 'access', 'chmod',
|
|
90
|
+
'chown', 'close', 'fchmod', 'fchown', 'fdatasync', 'fstat', 'fsync',
|
|
91
|
+
'ftruncate', 'futimes', 'link', 'lutimes', 'mkdtemp', 'open', 'opendir',
|
|
92
|
+
'read', 'readlink', 'realpath', 'symlink', 'truncate', 'utimes', 'write',
|
|
93
|
+
'cp', 'statfs', 'glob',
|
|
94
|
+
// Streams
|
|
95
|
+
'createReadStream', 'createWriteStream',
|
|
96
|
+
// Watch
|
|
97
|
+
'watch', 'watchFile', 'unwatchFile',
|
|
98
|
+
// Constants & promises
|
|
99
|
+
'constants', 'promises',
|
|
100
|
+
]),
|
|
101
|
+
path: new Set([
|
|
102
|
+
'basename', 'delimiter', 'dirname', 'extname', 'format', 'isAbsolute',
|
|
103
|
+
'join', 'normalize', 'parse', 'posix', 'relative', 'resolve', 'sep',
|
|
104
|
+
'toNamespacedPath', 'win32', 'matchesGlob',
|
|
105
|
+
]),
|
|
106
|
+
crypto: new Set([
|
|
107
|
+
'createHash', 'createHmac', 'createCipheriv', 'createDecipheriv',
|
|
108
|
+
'createSign', 'createVerify', 'createDiffieHellman', 'createDiffieHellmanGroup',
|
|
109
|
+
'createECDH', 'createSecretKey', 'createPublicKey', 'createPrivateKey',
|
|
110
|
+
'generateKey', 'generateKeyPair', 'generateKeyPairSync', 'generateKeySync',
|
|
111
|
+
'generatePrime', 'generatePrimeSync',
|
|
112
|
+
'getCiphers', 'getCurves', 'getDiffieHellman', 'getFips', 'getHashes',
|
|
113
|
+
'getRandomValues', 'hash',
|
|
114
|
+
'hkdf', 'hkdfSync',
|
|
115
|
+
'pbkdf2', 'pbkdf2Sync',
|
|
116
|
+
'privateDecrypt', 'privateEncrypt', 'publicDecrypt', 'publicEncrypt',
|
|
117
|
+
'randomBytes', 'randomFillSync', 'randomFill', 'randomInt', 'randomUUID',
|
|
118
|
+
'scrypt', 'scryptSync',
|
|
119
|
+
'setEngine', 'setFips',
|
|
120
|
+
'sign', 'verify',
|
|
121
|
+
'subtle', 'timingSafeEqual',
|
|
122
|
+
'constants', 'webcrypto', 'X509Certificate',
|
|
123
|
+
'checkPrime', 'checkPrimeSync',
|
|
124
|
+
'Certificate', 'Cipher', 'Decipher', 'DiffieHellman', 'DiffieHellmanGroup',
|
|
125
|
+
'ECDH', 'Hash', 'Hmac', 'KeyObject', 'Sign', 'Verify',
|
|
126
|
+
]),
|
|
127
|
+
os: new Set([
|
|
128
|
+
'arch', 'availableParallelism', 'constants', 'cpus', 'devNull',
|
|
129
|
+
'endianness', 'EOL', 'freemem', 'getPriority', 'homedir',
|
|
130
|
+
'hostname', 'loadavg', 'machine', 'networkInterfaces', 'platform',
|
|
131
|
+
'release', 'setPriority', 'tmpdir', 'totalmem', 'type',
|
|
132
|
+
'uptime', 'userInfo', 'version',
|
|
133
|
+
]),
|
|
134
|
+
child_process: new Set([
|
|
135
|
+
'exec', 'execFile', 'execFileSync', 'execSync',
|
|
136
|
+
'fork', 'spawn', 'spawnSync',
|
|
137
|
+
]),
|
|
138
|
+
http: new Set([
|
|
139
|
+
'createServer', 'get', 'globalAgent', 'request',
|
|
140
|
+
'Agent', 'ClientRequest', 'Server', 'ServerResponse', 'IncomingMessage',
|
|
141
|
+
'METHODS', 'STATUS_CODES', 'maxHeaderSize', 'validateHeaderName', 'validateHeaderValue',
|
|
142
|
+
'setMaxIdleHTTPParsers',
|
|
143
|
+
]),
|
|
144
|
+
https: new Set([
|
|
145
|
+
'createServer', 'get', 'globalAgent', 'request',
|
|
146
|
+
'Agent', 'Server',
|
|
147
|
+
]),
|
|
148
|
+
url: new Set([
|
|
149
|
+
'domainToASCII', 'domainToUnicode', 'fileURLToPath', 'format',
|
|
150
|
+
'pathToFileURL', 'resolve', 'URL', 'URLSearchParams',
|
|
151
|
+
// Deprecated but still exist
|
|
152
|
+
'parse', 'Url',
|
|
153
|
+
]),
|
|
154
|
+
util: new Set([
|
|
155
|
+
'callbackify', 'debuglog', 'deprecate', 'format', 'formatWithOptions',
|
|
156
|
+
'getSystemErrorName', 'getSystemErrorMap', 'inherits', 'inspect',
|
|
157
|
+
'isDeepStrictEqual', 'parseArgs', 'parseEnv', 'promisify',
|
|
158
|
+
'stripVTControlCharacters', 'styleText',
|
|
159
|
+
'TextDecoder', 'TextEncoder', 'MIMEType', 'MIMEParams',
|
|
160
|
+
'types', 'toUSVString', 'transferableAbortController', 'transferableAbortSignal',
|
|
161
|
+
'aborted',
|
|
162
|
+
]),
|
|
163
|
+
stream: new Set([
|
|
164
|
+
'Readable', 'Writable', 'Duplex', 'Transform', 'PassThrough',
|
|
165
|
+
'pipeline', 'finished', 'compose', 'addAbortSignal',
|
|
166
|
+
'getDefaultHighWaterMark', 'setDefaultHighWaterMark',
|
|
167
|
+
'promises', 'consumers',
|
|
168
|
+
]),
|
|
169
|
+
events: new Set([
|
|
170
|
+
'EventEmitter', 'once', 'on', 'getEventListeners',
|
|
171
|
+
'setMaxListeners', 'listenerCount', 'addAbortListener',
|
|
172
|
+
'getMaxListeners', 'EventEmitterAsyncResource',
|
|
173
|
+
]),
|
|
174
|
+
buffer: new Set([
|
|
175
|
+
'Buffer', 'SlowBuffer', 'transcode',
|
|
176
|
+
'constants', 'kMaxLength', 'kStringMaxLength',
|
|
177
|
+
'atob', 'btoa', 'isAscii', 'isUtf8', 'resolveObjectURL',
|
|
178
|
+
'Blob', 'File',
|
|
179
|
+
]),
|
|
180
|
+
querystring: new Set([
|
|
181
|
+
'decode', 'encode', 'escape', 'parse', 'stringify', 'unescape',
|
|
182
|
+
]),
|
|
183
|
+
net: new Set([
|
|
184
|
+
'createServer', 'createConnection', 'connect',
|
|
185
|
+
'isIP', 'isIPv4', 'isIPv6',
|
|
186
|
+
'Server', 'Socket', 'BlockList', 'SocketAddress',
|
|
187
|
+
'getDefaultAutoSelectFamily', 'setDefaultAutoSelectFamily',
|
|
188
|
+
'getDefaultAutoSelectFamilyAttemptTimeout', 'setDefaultAutoSelectFamilyAttemptTimeout',
|
|
189
|
+
]),
|
|
190
|
+
dns: new Set([
|
|
191
|
+
'lookup', 'lookupService', 'resolve', 'resolve4', 'resolve6',
|
|
192
|
+
'resolveAny', 'resolveCname', 'resolveCaa', 'resolveMx', 'resolveNaptr',
|
|
193
|
+
'resolveNs', 'resolvePtr', 'resolveSoa', 'resolveSrv', 'resolveTxt',
|
|
194
|
+
'reverse', 'setServers', 'getServers', 'setDefaultResultOrder',
|
|
195
|
+
'getDefaultResultOrder',
|
|
196
|
+
'promises', 'Resolver', 'ADDRCONFIG', 'V4MAPPED', 'ALL',
|
|
197
|
+
]),
|
|
198
|
+
tls: new Set([
|
|
199
|
+
'createServer', 'connect', 'createSecureContext', 'createSecurePair',
|
|
200
|
+
'getCiphers', 'rootCertificates', 'DEFAULT_ECDH_CURVE', 'DEFAULT_MAX_VERSION',
|
|
201
|
+
'DEFAULT_MIN_VERSION', 'DEFAULT_CIPHERS',
|
|
202
|
+
'Server', 'TLSSocket', 'SecureContext',
|
|
203
|
+
]),
|
|
204
|
+
zlib: new Set([
|
|
205
|
+
'createGzip', 'createGunzip', 'createDeflate', 'createInflate',
|
|
206
|
+
'createDeflateRaw', 'createInflateRaw', 'createBrotliCompress',
|
|
207
|
+
'createBrotliDecompress', 'createUnzip',
|
|
208
|
+
'gzip', 'gunzip', 'deflate', 'inflate', 'deflateRaw', 'inflateRaw',
|
|
209
|
+
'brotliCompress', 'brotliDecompress', 'unzip',
|
|
210
|
+
'gzipSync', 'gunzipSync', 'deflateSync', 'inflateSync',
|
|
211
|
+
'deflateRawSync', 'inflateRawSync', 'brotliCompressSync',
|
|
212
|
+
'brotliDecompressSync', 'unzipSync',
|
|
213
|
+
'constants',
|
|
214
|
+
]),
|
|
215
|
+
readline: new Set([
|
|
216
|
+
'createInterface', 'clearLine', 'clearScreenDown', 'cursorTo',
|
|
217
|
+
'moveCursor', 'emitKeypressEvents',
|
|
218
|
+
'Interface', 'InterfaceConstructor', 'promises',
|
|
219
|
+
]),
|
|
220
|
+
cluster: new Set([
|
|
221
|
+
'disconnect', 'fork', 'isMaster', 'isPrimary', 'isWorker',
|
|
222
|
+
'schedulingPolicy', 'settings', 'setupMaster', 'setupPrimary',
|
|
223
|
+
'worker', 'workers',
|
|
224
|
+
'Worker', 'SCHED_NONE', 'SCHED_RR',
|
|
225
|
+
]),
|
|
226
|
+
worker_threads: new Set([
|
|
227
|
+
'isMainThread', 'parentPort', 'resourceLimits', 'threadId',
|
|
228
|
+
'workerData', 'getEnvironmentData', 'setEnvironmentData',
|
|
229
|
+
'markAsUntransferable', 'moveMessagePortToContext', 'receiveMessageOnPort',
|
|
230
|
+
'BroadcastChannel', 'MessageChannel', 'MessagePort', 'Worker',
|
|
231
|
+
'SHARE_ENV',
|
|
232
|
+
]),
|
|
233
|
+
timers: new Set([
|
|
234
|
+
'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval',
|
|
235
|
+
'setImmediate', 'clearImmediate',
|
|
236
|
+
'promises',
|
|
237
|
+
]),
|
|
238
|
+
perf_hooks: new Set([
|
|
239
|
+
'performance', 'PerformanceObserver', 'PerformanceEntry',
|
|
240
|
+
'PerformanceMark', 'PerformanceMeasure', 'PerformanceNodeTiming',
|
|
241
|
+
'PerformanceResourceTiming', 'monitorEventLoopDelay',
|
|
242
|
+
'createHistogram',
|
|
243
|
+
]),
|
|
244
|
+
assert: new Set([
|
|
245
|
+
'ok', 'fail', 'equal', 'notEqual', 'deepEqual', 'notDeepEqual',
|
|
246
|
+
'deepStrictEqual', 'notDeepStrictEqual', 'strictEqual', 'notStrictEqual',
|
|
247
|
+
'throws', 'doesNotThrow', 'rejects', 'doesNotReject',
|
|
248
|
+
'ifError', 'match', 'doesNotMatch',
|
|
249
|
+
'strict', 'AssertionError', 'CallTracker',
|
|
250
|
+
]),
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Python 3.12+ stdlib method signatures.
|
|
254
|
+
* Covers the most commonly hallucinated modules.
|
|
255
|
+
*/
|
|
256
|
+
export const PYTHON_STDLIB_METHODS = {
|
|
257
|
+
os: new Set([
|
|
258
|
+
'getcwd', 'chdir', 'listdir', 'scandir', 'mkdir', 'makedirs',
|
|
259
|
+
'rmdir', 'removedirs', 'remove', 'unlink', 'rename', 'renames',
|
|
260
|
+
'replace', 'stat', 'lstat', 'fstat', 'chmod', 'chown', 'link',
|
|
261
|
+
'symlink', 'readlink', 'walk', 'fwalk', 'path', 'environ',
|
|
262
|
+
'getenv', 'putenv', 'unsetenv', 'getpid', 'getppid', 'getuid',
|
|
263
|
+
'getgid', 'system', 'popen', 'execv', 'execve', 'execvp',
|
|
264
|
+
'execvpe', '_exit', 'fork', 'kill', 'wait', 'waitpid',
|
|
265
|
+
'cpu_count', 'urandom', 'sep', 'linesep', 'devnull', 'curdir',
|
|
266
|
+
'pardir', 'extsep', 'altsep', 'pathsep', 'name', 'access',
|
|
267
|
+
'open', 'close', 'read', 'write', 'pipe', 'dup', 'dup2',
|
|
268
|
+
'ftruncate', 'isatty', 'lseek', 'terminal_size', 'get_terminal_size',
|
|
269
|
+
'get_blocking', 'set_blocking', 'add_dll_directory',
|
|
270
|
+
'get_exec_path', 'getlogin', 'strerror', 'umask',
|
|
271
|
+
'truncate', 'fchdir', 'fchmod', 'fchown',
|
|
272
|
+
]),
|
|
273
|
+
json: new Set([
|
|
274
|
+
'dump', 'dumps', 'load', 'loads',
|
|
275
|
+
'JSONDecoder', 'JSONEncoder', 'JSONDecodeError',
|
|
276
|
+
'tool',
|
|
277
|
+
]),
|
|
278
|
+
sys: new Set([
|
|
279
|
+
'argv', 'exit', 'path', 'modules', 'stdin', 'stdout', 'stderr',
|
|
280
|
+
'version', 'version_info', 'platform', 'executable', 'prefix',
|
|
281
|
+
'exec_prefix', 'maxsize', 'maxunicode', 'byteorder', 'builtin_module_names',
|
|
282
|
+
'flags', 'float_info', 'hash_info', 'implementation', 'int_info',
|
|
283
|
+
'getdefaultencoding', 'getfilesystemencoding', 'getrecursionlimit',
|
|
284
|
+
'getrefcount', 'getsizeof', 'gettrace', 'getprofile',
|
|
285
|
+
'setrecursionlimit', 'settrace', 'setprofile',
|
|
286
|
+
'exc_info', 'last_type', 'last_value', 'last_traceback',
|
|
287
|
+
'api_version', 'copyright', 'dont_write_bytecode',
|
|
288
|
+
'ps1', 'ps2', 'intern', 'is_finalizing',
|
|
289
|
+
'orig_argv', 'platlibdir', 'stdlib_module_names',
|
|
290
|
+
'thread_info', 'unraisablehook', 'winver',
|
|
291
|
+
'addaudithook', 'audit', 'breakpointhook',
|
|
292
|
+
'call_tracing', 'displayhook', 'excepthook',
|
|
293
|
+
'get_asyncgen_hooks', 'get_coroutine_origin_tracking_depth',
|
|
294
|
+
'getallocatedblocks', 'getwindowsversion',
|
|
295
|
+
'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth',
|
|
296
|
+
'set_int_max_str_digits', 'get_int_max_str_digits',
|
|
297
|
+
'activate_stack_trampoline', 'deactivate_stack_trampoline',
|
|
298
|
+
'is_stack_trampoline_active', 'last_exc',
|
|
299
|
+
'monitoring', 'exception',
|
|
300
|
+
]),
|
|
301
|
+
re: new Set([
|
|
302
|
+
'compile', 'search', 'match', 'fullmatch', 'split', 'findall',
|
|
303
|
+
'finditer', 'sub', 'subn', 'escape', 'purge', 'error',
|
|
304
|
+
'Pattern', 'Match',
|
|
305
|
+
'A', 'ASCII', 'DEBUG', 'DOTALL', 'I', 'IGNORECASE',
|
|
306
|
+
'L', 'LOCALE', 'M', 'MULTILINE', 'NOFLAG',
|
|
307
|
+
'S', 'U', 'UNICODE', 'VERBOSE', 'X',
|
|
308
|
+
]),
|
|
309
|
+
math: new Set([
|
|
310
|
+
'ceil', 'comb', 'copysign', 'fabs', 'factorial', 'floor',
|
|
311
|
+
'fmod', 'frexp', 'fsum', 'gcd', 'isclose', 'isfinite',
|
|
312
|
+
'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'log', 'log10',
|
|
313
|
+
'log1p', 'log2', 'modf', 'perm', 'pow', 'prod', 'remainder',
|
|
314
|
+
'trunc', 'ulp', 'nextafter', 'sumprod',
|
|
315
|
+
'exp', 'exp2', 'expm1', 'sqrt', 'cbrt',
|
|
316
|
+
'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh',
|
|
317
|
+
'cos', 'cosh', 'degrees', 'dist', 'hypot', 'radians',
|
|
318
|
+
'sin', 'sinh', 'tan', 'tanh',
|
|
319
|
+
'erf', 'erfc', 'gamma', 'lgamma',
|
|
320
|
+
'pi', 'e', 'tau', 'inf', 'nan',
|
|
321
|
+
]),
|
|
322
|
+
datetime: new Set([
|
|
323
|
+
'date', 'time', 'datetime', 'timedelta', 'timezone', 'tzinfo',
|
|
324
|
+
'MINYEAR', 'MAXYEAR', 'UTC',
|
|
325
|
+
]),
|
|
326
|
+
pathlib: new Set([
|
|
327
|
+
'Path', 'PurePath', 'PurePosixPath', 'PureWindowsPath',
|
|
328
|
+
'PosixPath', 'WindowsPath',
|
|
329
|
+
]),
|
|
330
|
+
subprocess: new Set([
|
|
331
|
+
'run', 'call', 'check_call', 'check_output', 'Popen',
|
|
332
|
+
'PIPE', 'STDOUT', 'DEVNULL', 'CompletedProcess',
|
|
333
|
+
'CalledProcessError', 'SubprocessError', 'TimeoutExpired',
|
|
334
|
+
'getoutput', 'getstatusoutput',
|
|
335
|
+
]),
|
|
336
|
+
shutil: new Set([
|
|
337
|
+
'copy', 'copy2', 'copyfile', 'copyfileobj', 'copymode', 'copystat',
|
|
338
|
+
'copytree', 'rmtree', 'move', 'disk_usage', 'chown', 'which',
|
|
339
|
+
'make_archive', 'get_archive_formats', 'register_archive_format',
|
|
340
|
+
'unregister_archive_format', 'unpack_archive', 'get_unpack_formats',
|
|
341
|
+
'register_unpack_format', 'unregister_unpack_format',
|
|
342
|
+
'get_terminal_size', 'SameFileError',
|
|
343
|
+
]),
|
|
344
|
+
collections: new Set([
|
|
345
|
+
'ChainMap', 'Counter', 'OrderedDict', 'UserDict', 'UserList',
|
|
346
|
+
'UserString', 'abc', 'defaultdict', 'deque', 'namedtuple',
|
|
347
|
+
]),
|
|
348
|
+
hashlib: new Set([
|
|
349
|
+
'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
|
|
350
|
+
'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
|
|
351
|
+
'blake2b', 'blake2s', 'shake_128', 'shake_256',
|
|
352
|
+
'new', 'algorithms_available', 'algorithms_guaranteed',
|
|
353
|
+
'pbkdf2_hmac', 'scrypt', 'file_digest',
|
|
354
|
+
]),
|
|
355
|
+
random: new Set([
|
|
356
|
+
'seed', 'getstate', 'setstate', 'getrandbits',
|
|
357
|
+
'randrange', 'randint', 'choice', 'choices', 'shuffle', 'sample',
|
|
358
|
+
'random', 'uniform', 'triangular', 'betavariate', 'expovariate',
|
|
359
|
+
'gammavariate', 'gauss', 'lognormvariate', 'normalvariate',
|
|
360
|
+
'vonmisesvariate', 'paretovariate', 'weibullvariate',
|
|
361
|
+
'Random', 'SystemRandom', 'randbytes',
|
|
362
|
+
]),
|
|
363
|
+
time: new Set([
|
|
364
|
+
'time', 'time_ns', 'clock_gettime', 'clock_gettime_ns',
|
|
365
|
+
'clock_settime', 'clock_settime_ns', 'clock_getres',
|
|
366
|
+
'gmtime', 'localtime', 'mktime', 'asctime', 'ctime',
|
|
367
|
+
'strftime', 'strptime', 'sleep', 'monotonic', 'monotonic_ns',
|
|
368
|
+
'perf_counter', 'perf_counter_ns', 'process_time', 'process_time_ns',
|
|
369
|
+
'thread_time', 'thread_time_ns', 'get_clock_info',
|
|
370
|
+
'struct_time', 'timezone', 'altzone', 'daylight', 'tzname',
|
|
371
|
+
'CLOCK_BOOTTIME', 'CLOCK_MONOTONIC', 'CLOCK_MONOTONIC_RAW',
|
|
372
|
+
'CLOCK_PROCESS_CPUTIME_ID', 'CLOCK_REALTIME',
|
|
373
|
+
'CLOCK_TAI', 'CLOCK_THREAD_CPUTIME_ID',
|
|
374
|
+
]),
|
|
375
|
+
csv: new Set([
|
|
376
|
+
'reader', 'writer', 'DictReader', 'DictWriter',
|
|
377
|
+
'Sniffer', 'register_dialect', 'unregister_dialect',
|
|
378
|
+
'get_dialect', 'list_dialects', 'field_size_limit',
|
|
379
|
+
'QUOTE_ALL', 'QUOTE_MINIMAL', 'QUOTE_NONNUMERIC', 'QUOTE_NONE',
|
|
380
|
+
'QUOTE_NOTNULL', 'QUOTE_STRINGS',
|
|
381
|
+
'Dialect', 'Error', 'excel', 'excel_tab', 'unix_dialect',
|
|
382
|
+
]),
|
|
383
|
+
logging: new Set([
|
|
384
|
+
'getLogger', 'basicConfig', 'shutdown', 'setLoggerClass',
|
|
385
|
+
'setLogRecordFactory', 'lastResort', 'captureWarnings',
|
|
386
|
+
'debug', 'info', 'warning', 'error', 'critical', 'exception',
|
|
387
|
+
'log', 'disable', 'addLevelName', 'getLevelName', 'getLevelNamesMapping',
|
|
388
|
+
'makeLogRecord', 'getHandlerByName', 'getHandlerNames',
|
|
389
|
+
'Logger', 'Handler', 'Formatter', 'Filter', 'LogRecord',
|
|
390
|
+
'StreamHandler', 'FileHandler', 'NullHandler',
|
|
391
|
+
'BufferingFormatter', 'LoggerAdapter', 'PercentStyle',
|
|
392
|
+
'StrFormatStyle', 'StringTemplateStyle',
|
|
393
|
+
'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL',
|
|
394
|
+
'FATAL', 'WARN', 'NOTSET',
|
|
395
|
+
'raiseExceptions', 'root',
|
|
396
|
+
'handlers', 'config',
|
|
397
|
+
]),
|
|
398
|
+
};
|