redos-detector
Version:
A CLI and library which tests helps score how vulnerable a regex pattern is to ReDoS attacks. Supported in the browser, Node and Deno.
48 lines (47 loc) • 2.23 kB
TypeScript
import { ZeroWidthEntry } from './character-reader-level-1';
import { Reader } from '../reader';
import { CharacterClass, CharacterClassEscape, Dot, UnicodePropertyEscape, Value } from 'regjsparser';
import { CharacterReaderValueSplitSubType, StackEntry } from './character-reader-level-0';
import { Groups, LookaheadStack } from '../nodes/group';
import { MyRootNode } from '../parse';
import { CharacterGroups } from '../character-groups';
import { NodeExtra } from '../node-extra';
import { StackReferenceEntry } from '../nodes/reference';
export declare const characterReaderLevel2TypeSplit: unique symbol;
export declare const characterReaderLevel2TypeEntry: unique symbol;
export type CharacterReaderLevel2StackEntry = StackEntry | StackReferenceEntry;
export type CharacterReaderLevel2Stack = readonly CharacterReaderLevel2StackEntry[];
export type CharacterReaderLevel2ValueSplit = Readonly<{
reader: () => CharacterReaderLevel2;
subType: CharacterReaderValueSplitSubType;
type: typeof characterReaderLevel2TypeSplit;
}>;
export type CharacterReaderLevel2ValueEntry = Readonly<{
characterGroups: CharacterGroups;
groups: Groups;
lookaheadStack: LookaheadStack;
node: CharacterClass | CharacterClassEscape | Dot | UnicodePropertyEscape | Value;
precedingZeroWidthEntries: readonly ZeroWidthEntry[];
stack: CharacterReaderLevel2Stack;
type: typeof characterReaderLevel2TypeEntry;
}>;
export type CharacterReaderLevel2Value = CharacterReaderLevel2ValueEntry | CharacterReaderLevel2ValueSplit;
export type CharacterReaderLevel2ReturnValue = Readonly<{
bounded: boolean;
precedingZeroWidthEntries: readonly ZeroWidthEntry[];
type: 'end';
} | {
type: 'abort';
}>;
export type CharacterReaderLevel2 = Reader<CharacterReaderLevel2Value, CharacterReaderLevel2ReturnValue>;
/**
* Returns a `CharacterReaderLevel2` which builds on top of
* `CharacterReaderLevel1` but replaces references with their
* contents and includes the backreference stack.
*/
export declare function buildCharacterReaderLevel2({ caseInsensitive, dotAll, node, nodeExtra, }: {
caseInsensitive: boolean;
dotAll: boolean;
node: MyRootNode;
nodeExtra: NodeExtra;
}): CharacterReaderLevel2;