-
Notifications
You must be signed in to change notification settings - Fork 918
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Tinymath with math.js (#4492)
* Replace tinymath with math.js * Disable functions to make the expression parser less vulnerable whilst still supporting most functionality --------- Signed-off-by: Danila Gulderov <gulderov@ya.ru> Signed-off-by: Anan Zhuang <ananzh@amazon.com> Co-authored-by: Anan Zhuang <ananzh@amazon.com>
- Loading branch information
Showing
9 changed files
with
152 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/evaluate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { create, all } from 'mathjs'; | ||
|
||
const math = create(all); | ||
export const evaluate = math.evaluate; | ||
export const MATH_THROW_MSG = 'Math.js function is disabled'; | ||
|
||
math.import( | ||
{ | ||
import() { | ||
throw new Error(MATH_THROW_MSG); | ||
}, | ||
createUnit() { | ||
throw new Error(MATH_THROW_MSG); | ||
}, | ||
evaluate() { | ||
throw new Error(MATH_THROW_MSG); | ||
}, | ||
parse() { | ||
throw new Error(MATH_THROW_MSG); | ||
}, | ||
simplify() { | ||
throw new Error(MATH_THROW_MSG); | ||
}, | ||
derivative() { | ||
throw new Error(MATH_THROW_MSG); | ||
}, | ||
}, | ||
{ override: true } | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters