@runhalo/engine 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Halo AST Rule Engine
3
+ *
4
+ * Takes a parsed tree-sitter AST + rule ID and returns an AST-based verdict
5
+ * that supplements the regex scanner. AST analysis can suppress false positives
6
+ * (e.g., a Schema that already has TTL) or confirm true positives with higher
7
+ * confidence.
8
+ *
9
+ * Sprint 8: 10 rule analyzers for JS/TS.
10
+ * HARD SCOPE: Single-file only (via DataFlowTracer).
11
+ */
12
+ import Parser from 'tree-sitter';
13
+ export type ASTVerdict = 'confirmed' | 'suppressed' | 'regex_only';
14
+ export interface ASTResult {
15
+ /** Whether the violation is confirmed, suppressed, or not analyzable by AST */
16
+ verdict: ASTVerdict;
17
+ /** Confidence in the verdict: 0.0 to 1.0 */
18
+ confidence: number;
19
+ /** Human-readable reason for the verdict */
20
+ reason?: string;
21
+ }
22
+ /** Minimal violation info needed for AST analysis */
23
+ export interface ViolationInfo {
24
+ ruleId: string;
25
+ line: number;
26
+ column: number;
27
+ codeSnippet: string;
28
+ }
29
+ export declare class ASTRuleEngine {
30
+ private scopeAnalyzer;
31
+ constructor();
32
+ /**
33
+ * Analyze a regex-detected violation using AST context.
34
+ *
35
+ * @param ruleId - The COPPA/ethical rule ID
36
+ * @param content - Full file content
37
+ * @param violation - The violation from the regex scanner
38
+ * @param tree - Parsed tree-sitter AST
39
+ * @returns ASTResult with verdict, confidence, and reason
40
+ */
41
+ analyzeViolation(ruleId: string, content: string, violation: ViolationInfo, tree: Parser.Tree): ASTResult;
42
+ /**
43
+ * Analyze a violation with a known file path (used from scanFileWithAST integration).
44
+ * This version passes the real file path for scope analysis.
45
+ */
46
+ analyzeViolationWithPath(ruleId: string, filePath: string, content: string, violation: ViolationInfo, tree: Parser.Tree): ASTResult;
47
+ private getAnalyzer;
48
+ private analyzeTracking003;
49
+ private analyzeRetention005;
50
+ private analyzeExtLinks017;
51
+ private analyzeXSS015;
52
+ private analyzeAuth001;
53
+ private analyzeUI008;
54
+ private checkPrivacyInContent;
55
+ private analyzeUGC014;
56
+ private analyzeFlow009;
57
+ private analyzeCookies016;
58
+ private analyzeInfiniteScroll001;
59
+ }
60
+ export default ASTRuleEngine;