Files
Timmy-time-dashboard/tests
Kimi Agent 6bc1ce4723
Some checks failed
Tests / lint (pull_request) Successful in 3s
Tests / test (pull_request) Failing after 14s
fix: replace eval() with AST-walking safe evaluator in calculator (#52)
Replace eval() in the calculator tool with a safe AST-walking evaluator
that only allows arithmetic operations, math module functions, and a
whitelist of builtins (abs, round, min, max).

The new _safe_eval() function:
- Parses the expression into an AST tree
- Walks each node, only allowing:
  - Numeric literals (int, float, complex)
  - Binary ops (+, -, *, /, //, %, **)
  - Unary ops (+, -)
  - math.* attribute access
  - Whitelisted function calls
- Rejects: imports, attribute chains, subscripts, comparisons,
  lambdas, comprehensions, string operations, keyword args

No new dependencies — uses stdlib ast + operator modules.

Test coverage expanded from 18 to 33 tests, including security tests
for exec(), arbitrary attributes, lambdas, list comprehensions,
boolean ops, keyword args, and subscripts.
2026-03-14 15:54:11 -04:00
..
2026-03-11 16:55:27 -04:00
2026-03-11 16:55:27 -04:00
2026-03-11 12:23:35 -04:00
2026-03-11 12:23:35 -04:00
2026-03-11 12:23:35 -04:00