fix: make expression evaluation in active effects more secure

This commit is contained in:
Johannes Loher 2022-10-31 22:58:04 +01:00
parent 19ba312a44
commit 20ea70d96a
8 changed files with 1222 additions and 1 deletions

View file

@ -0,0 +1,61 @@
// SPDX-FileCopyrightText: 2022 Johannes Loher
//
// SPDX-License-Identifier: MIT
export type Token = TokenWithSymbol | TokenWithoutSymbol;
export interface TokenWithSymbol {
type: TypeWithSymbol;
symbol: string;
pos: number;
}
interface TokenWithoutSymbol {
type: TypeWithoutSymbol;
pos: number;
}
type TypeWithSymbol = "iden" | "number" | "string";
type TypeWithoutSymbol =
| "+"
| "-"
| "*"
| "**"
| "/"
| "%"
| "==="
| "!=="
| "=="
| "!="
| "<"
| "<="
| ">"
| ">="
| "&&"
| "||"
| "&"
| "|"
| "~"
| "^"
| "<<"
| ">>"
| ">>>"
| "."
| "?."
| "??"
| "!"
| "?"
| ":"
| "("
| ")"
| "["
| "]"
| ","
| "{"
| "}"
| "invalid"
| "eof";
export const literals = ["true", "false", "null", "undefined"];
export const safeOperators = ["in", "instanceof", "typeof", "void"];