kangaroo-expression
Version:
Secure expression evaluator with AST-based execution - A fast, safe, and powerful JavaScript-like expression language
47 lines • 1.62 kB
TypeScript
import type { Node } from 'acorn';
import type { SecurityValidation, FunctionRegistry, SecurityRule, ExpressionContext } from '@/types';
export declare class SecurityValidator {
private functionRegistry;
private customRules;
private validationCache;
private cacheSize;
private readonly maxCacheSize;
private readonly blockedIdentifiers;
private readonly blockedProperties;
private readonly supportedNodeTypes;
private readonly blockedOperators;
private readonly dangerousPatterns;
constructor(functionRegistry: FunctionRegistry);
validate(node: Node, context?: ExpressionContext): SecurityValidation;
addRule(rule: SecurityRule): void;
removeRule(ruleId: string): void;
getRules(): SecurityRule[];
clearCache(): void;
getCacheStats(): {
size: number;
maxSize: number;
};
private validateNode;
private applyBuiltInValidation;
private applyCustomRules;
private validateIdentifier;
private validateMemberExpression;
private validateCallExpression;
private validateCallbackMethodCall;
private validateBinaryExpression;
private validateUnaryExpression;
private validateArrowFunction;
private validateLiteral;
private validateObjectExpression;
private validateChildren;
private isPrototypePollutionPattern;
private getPropertyChainDepth;
private getMethodName;
private getFullMethodName;
private getPosition;
private assessRiskLevel;
private getCacheKey;
private setCached;
private initializeBuiltInRules;
}
//# sourceMappingURL=validator.d.ts.map