/** Called from the exact scan-time stat that caused a file to be excluded. */ export type OversizedFileObserver = (path: string, bytes: number) => void; /** * Run `fn` over every path with at most `concurrency` calls in flight, returning results in * INPUT order — a drop-in replacement for `Promise.all(paths.map(fn))` that does not scale its * peak memory with `paths.length`. * * Rejection behaves as `Promise.all` does: the returned promise rejects with the first error. * Every caller in this codebase catches per file and returns an empty result instead, so a * single unreadable file never aborts a scan. */ export declare function mapFilesBounded(paths: readonly string[], fn: (path: string, index: number) => Promise, concurrency?: number): Promise; /** * Is a file of this many bytes too large for a repository-wide source scan? * * Exported so the predicate exists exactly once: the scan applies it to a `stat` result, and * `analyze` applies it to the sizes the walker already recorded in order to DISCLOSE the * exclusions. Two spellings of the same threshold would let those two surfaces disagree about * the same repository. */ export declare function isOversizedForScan(bytes: number, maxBytes?: number): boolean; /** * The union of the file extensions the enrichment extractors read — UI components, schemas, * routes, middleware, and environment variables. * * Used ONLY to scope the oversized-file disclosure. A repository can hold a 6 MB image or data * blob that no extractor would ever have opened; reporting it as "excluded from the scan" is a * true statement that tells the operator nothing and trains them to ignore the warning. So the * disclosure is narrowed to files an extractor would actually have read. * * Errs WIDE on purpose. An extension listed here that some individual extractor ignores costs at * most one over-reported file; an extension missing here would silently hide a genuinely dropped * component, route, or environment variable — the exact failure the disclosure exists to prevent. */ export declare const SCANNED_SOURCE_EXTENSIONS: ReadonlySet; /** * Environment-declaration files the env scan reads. Lives here, beside the extension set, because * these files are the reason an extension test alone is NOT a sufficient description of what the * enrichment scans open: `extname('.env')` is `''`, `extname('.env.local')` is `'.local'`, and * `extname('.env.production')` is `'.production'` — none of which is a source extension. A * disclosure predicate built only from extensions therefore drops an oversized `.env` silently, * which is precisely the failure this module claims to prevent. */ export declare const ENV_DECLARATION_FILES: ReadonlySet; /** * Would an enrichment scan have opened this file at all? * * The single predicate behind the oversized-file disclosure. It exists so that "what the scans * read" and "what we tell the operator we skipped" cannot drift apart: a file this returns `false` * for was never going to contribute, so reporting it as excluded is noise; a file it returns * `true` for and that exceeds the cap MUST be reported. */ export declare function isScannedByEnrichment(filePath: string): boolean; /** * Read a source file as UTF-8, or return `null` if it is unreadable or exceeds the scan's * per-file size cap. * * The size is measured BEFORE the read, which is the whole point: reading first and measuring * after would already have materialized the buffer and the string that the cap exists to prevent. * * Two things are required to make that actually true, and it is worth being precise about which * does what, because getting one of them is easy to mistake for getting both: * * - The measurement and the read go through ONE open file handle, never a `stat(path)` followed * by a `readFile(path)`. Those are two independent resolutions of the same NAME, so a path * that was replaced or re-symlinked in between would be read at a size belonging to a * different file. * - The read is bounded to the size that was checked. This is the part a single handle does NOT * give you: `handle.readFile()` reads to CURRENT end-of-file, so a file appended to after the * `stat` is read in full — measured, a 1 KB file that grew to 20 MB during the await window * came back as 20 MB through a 4 MB cap. Reading exactly `size` bytes into a buffer allocated * at `size` bounds the allocation by construction, whatever the file does afterwards. * * For a tool that analyzes untrusted repositories — and that re-analyzes while a watcher is * rewriting files — this is a real boundary, not a theoretical one. * * A file that GREW is therefore truncated to the prefix that was measured. That costs nothing in * practice: for a file nobody is writing (every real scan) `size` IS the whole file, so the read * is exact and no character can be split. * * `null` deliberately does not distinguish "too large" from "unreadable" — a scan callback can * do nothing different about either. Callers that render user-facing disclosure pass * `onOversized`; it fires from the exact open-handle stat that enforced the cap, so the warning * does not depend on the repository walker's earlier size snapshot. */ export declare function readSourceCapped(path: string, maxBytes?: number, onOversized?: OversizedFileObserver): Promise; //# sourceMappingURL=bounded-file-scan.d.ts.map