Skip to content

Commit b2a40ca

Browse files
Copilothotlong
andcommitted
Document expression parser limitations and usage guidelines
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 164fab1 commit b2a40ca

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

SECURITY_FIX_SUMMARY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ Implemented a custom expression parser that:
3131
- Literals: `true`, `false`, `null`, numbers, strings
3232
- Escape sequences in strings
3333

34+
**Known Limitations** (acceptable for validation use cases):
35+
- Single comparison operator per expression (no chaining like `a > b > c`)
36+
- Simple escape sequence handling (doesn't handle escaped backslashes)
37+
- Field names in bracket notation cannot contain escaped quotes
38+
- These limitations don't affect typical validation expressions and can be addressed if needed
39+
40+
**Note**: For more complex expression requirements, the implementation can be extended or replaced with a dedicated library like JSONLogic or filtrex.
41+
3442
### 3. Code Quality Improvements
3543
- Added escape sequence handling for string literals
3644
- Separated strict (`===`) and loose (`==`) equality for backward compatibility

packages/core/src/validation/validators/object-validation-engine.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface ValidationExpressionEvaluator {
7878
}
7979

8080
/**
81-
* Safe expression evaluator using a simple parser (no dynamic code execution)
81+
* Simple expression evaluator using a simple parser (no dynamic code execution)
8282
*
8383
* SECURITY: This implementation parses expressions into an AST and evaluates them
8484
* without using eval() or new Function(). It supports:
@@ -87,9 +87,16 @@ export interface ValidationExpressionEvaluator {
8787
* - Property access: record.field, record['field']
8888
* - Literals: true, false, null, numbers, strings
8989
*
90+
* LIMITATIONS:
91+
* - Single comparison operator per expression (no chaining like a > b > c)
92+
* - Simple escape sequence handling (doesn't handle escaped backslashes)
93+
* - Field names in bracket notation cannot contain escaped quotes
94+
*
9095
* For more complex expressions, integrate a dedicated library like:
9196
* - JSONLogic (jsonlogic.com)
9297
* - filtrex
98+
*
99+
* @see https://github.com/objectstack-ai/objectui/blob/main/SECURITY_FIX_SUMMARY.md
93100
*/
94101
class SimpleExpressionEvaluator implements ValidationExpressionEvaluator {
95102
evaluate(expression: string, context: Record<string, any>): any {

0 commit comments

Comments
 (0)