Skip to content

Commit 50aeb83

Browse files
committed
docs: note that parser and decoder input size is not limited
Callers processing untrusted source or source maps should enforce their own limits, such as a maximum input size and a sandboxed, time-bound parse or decode. Signed-off-by: Lilit Darbinyan <ldarbinyan@bloomberg.net>
1 parent f0327e7 commit 50aeb83

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ decoder.decode("barilla.js", 0, 4); // orzo
178178
decoder.decode("barilla.js", 0, 25); // penne
179179
```
180180

181+
## Untrusted input
182+
183+
The parser and decoder do not limit the size of their input, so very large or
184+
deeply nested input can use a lot of CPU and memory. If you process untrusted
185+
source or source maps, enforce your own limits, such as a maximum input size and
186+
a sandboxed, time-bound parse or decode.
187+
181188
## Development
182189

183190
- Clone this repository

‎src/decoder.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class SourceMapDecoder {
2929
private [_functionDescs]: Map<string, FunctionDesc[]>;
3030

3131
/**
32-
* Initializes the `SourceMapDecoder`
32+
* Initializes the `SourceMapDecoder`.
33+
* Input size is not limited; see the README if decoding untrusted source maps.
3334
* @param sourceMap - a PASTA enriched source map
3435
*
3536
* @throws if the input source map is invalid

‎src/parser.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import * as ts from "typescript";
2323
* Parse a source file and return descriptions of all functions present in the
2424
* source file. Each description includes the name of the function, and start and
2525
* end coordinates. For anonymous functions the name is "<anonymous>".
26+
* Input size is not limited; see the README if parsing untrusted source.
2627
*
2728
* @param source - the contents of a source file
2829
* @param filetype - the type of the source file (e.g. ECMAScript or TypeScript)

0 commit comments

Comments
 (0)