@oddessentials/odd-ai-reviewers 1.7.4 → 1.9.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.
- package/dist/agents/ai_semantic_review.d.ts.map +1 -1
- package/dist/agents/ai_semantic_review.js +7 -1
- package/dist/agents/ai_semantic_review.js.map +1 -1
- package/dist/agents/control_flow/safe-source-detector.d.ts +48 -0
- package/dist/agents/control_flow/safe-source-detector.d.ts.map +1 -0
- package/dist/agents/control_flow/safe-source-detector.js +434 -0
- package/dist/agents/control_flow/safe-source-detector.js.map +1 -0
- package/dist/agents/control_flow/safe-source-patterns.d.ts +61 -0
- package/dist/agents/control_flow/safe-source-patterns.d.ts.map +1 -0
- package/dist/agents/control_flow/safe-source-patterns.js +137 -0
- package/dist/agents/control_flow/safe-source-patterns.js.map +1 -0
- package/dist/agents/control_flow/scope-stack.d.ts +167 -0
- package/dist/agents/control_flow/scope-stack.d.ts.map +1 -0
- package/dist/agents/control_flow/scope-stack.js +448 -0
- package/dist/agents/control_flow/scope-stack.js.map +1 -0
- package/dist/agents/control_flow/vulnerability-detector.d.ts +13 -0
- package/dist/agents/control_flow/vulnerability-detector.d.ts.map +1 -1
- package/dist/agents/control_flow/vulnerability-detector.js +630 -35
- package/dist/agents/control_flow/vulnerability-detector.js.map +1 -1
- package/dist/agents/opencode.d.ts.map +1 -1
- package/dist/agents/opencode.js +7 -1
- package/dist/agents/opencode.js.map +1 -1
- package/dist/agents/pr_agent.d.ts.map +1 -1
- package/dist/agents/pr_agent.js +8 -2
- package/dist/agents/pr_agent.js.map +1 -1
- package/dist/agents/security.d.ts.map +1 -1
- package/dist/agents/security.js +1 -0
- package/dist/agents/security.js.map +1 -1
- package/dist/agents/types.d.ts +6 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/benchmark/adapter.d.ts +87 -0
- package/dist/benchmark/adapter.d.ts.map +1 -0
- package/dist/benchmark/adapter.js +298 -0
- package/dist/benchmark/adapter.js.map +1 -0
- package/dist/benchmark/scoring.d.ts +100 -0
- package/dist/benchmark/scoring.d.ts.map +1 -0
- package/dist/benchmark/scoring.js +195 -0
- package/dist/benchmark/scoring.js.map +1 -0
- package/dist/cli/dependencies/schemas.d.ts +3 -3
- package/dist/context-loader.d.ts +80 -0
- package/dist/context-loader.d.ts.map +1 -0
- package/dist/context-loader.js +202 -0
- package/dist/context-loader.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +131 -4
- package/dist/main.js.map +1 -1
- package/dist/phases/index.d.ts +1 -1
- package/dist/phases/index.d.ts.map +1 -1
- package/dist/phases/index.js +1 -1
- package/dist/phases/index.js.map +1 -1
- package/dist/phases/report.d.ts +8 -1
- package/dist/phases/report.d.ts.map +1 -1
- package/dist/phases/report.js +52 -5
- package/dist/phases/report.js.map +1 -1
- package/dist/report/ado.d.ts +2 -0
- package/dist/report/ado.d.ts.map +1 -1
- package/dist/report/ado.js +9 -23
- package/dist/report/ado.js.map +1 -1
- package/dist/report/finding-validator.d.ts +130 -0
- package/dist/report/finding-validator.d.ts.map +1 -0
- package/dist/report/finding-validator.js +347 -0
- package/dist/report/finding-validator.js.map +1 -0
- package/dist/report/framework-pattern-filter.d.ts +53 -0
- package/dist/report/framework-pattern-filter.d.ts.map +1 -0
- package/dist/report/framework-pattern-filter.js +189 -0
- package/dist/report/framework-pattern-filter.js.map +1 -0
- package/dist/report/github.d.ts +2 -0
- package/dist/report/github.d.ts.map +1 -1
- package/dist/report/github.js +9 -23
- package/dist/report/github.js.map +1 -1
- package/dist/trust.d.ts +6 -0
- package/dist/trust.d.ts.map +1 -1
- package/dist/trust.js +2 -0
- package/dist/trust.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe-Source Pattern Definitions
|
|
3
|
+
*
|
|
4
|
+
* Declarative registry of patterns for recognizing provably non-tainted data sources.
|
|
5
|
+
* Safe sources are excluded from taint tracking to prevent false positives.
|
|
6
|
+
*
|
|
7
|
+
* Per contract: safe-source-patterns.md v1.0
|
|
8
|
+
* Per FR-001 through FR-004: Each pattern matches a specific, provable AST shape.
|
|
9
|
+
*/
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Registry Constants
|
|
12
|
+
// =============================================================================
|
|
13
|
+
export const SAFE_SOURCE_REGISTRY_VERSION = '1.0';
|
|
14
|
+
export const EXPECTED_PATTERN_COUNT = 9;
|
|
15
|
+
/**
|
|
16
|
+
* All vulnerability types for patterns that prevent taint universally.
|
|
17
|
+
*/
|
|
18
|
+
export const ALL_VULN_TYPES = [
|
|
19
|
+
'injection',
|
|
20
|
+
'null_deref',
|
|
21
|
+
'auth_bypass',
|
|
22
|
+
'xss',
|
|
23
|
+
'path_traversal',
|
|
24
|
+
'prototype_pollution',
|
|
25
|
+
'ssrf',
|
|
26
|
+
];
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// Pattern Registry
|
|
29
|
+
// =============================================================================
|
|
30
|
+
export const SAFE_SOURCE_PATTERNS = [
|
|
31
|
+
// Pattern 1: Constant Literal Declarations (FR-001)
|
|
32
|
+
{
|
|
33
|
+
id: 'constant-literal-string',
|
|
34
|
+
name: 'Constant String Literal',
|
|
35
|
+
description: 'Module-scope const with string literal initializer',
|
|
36
|
+
preventsTaintFor: ALL_VULN_TYPES,
|
|
37
|
+
match: {
|
|
38
|
+
type: 'constant_declaration',
|
|
39
|
+
requireModuleScope: true,
|
|
40
|
+
requireLiteralInitializer: true,
|
|
41
|
+
},
|
|
42
|
+
confidence: 'high',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'constant-literal-number',
|
|
46
|
+
name: 'Constant Number Literal',
|
|
47
|
+
description: 'Module-scope const with numeric literal initializer',
|
|
48
|
+
preventsTaintFor: ALL_VULN_TYPES,
|
|
49
|
+
match: {
|
|
50
|
+
type: 'constant_declaration',
|
|
51
|
+
requireModuleScope: true,
|
|
52
|
+
requireLiteralInitializer: true,
|
|
53
|
+
},
|
|
54
|
+
confidence: 'high',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'constant-literal-array',
|
|
58
|
+
name: 'Constant Literal Array',
|
|
59
|
+
description: 'Module-scope const with array of literal values',
|
|
60
|
+
preventsTaintFor: ALL_VULN_TYPES,
|
|
61
|
+
match: {
|
|
62
|
+
type: 'constant_declaration',
|
|
63
|
+
requireModuleScope: true,
|
|
64
|
+
requireLiteralInitializer: true,
|
|
65
|
+
},
|
|
66
|
+
confidence: 'high',
|
|
67
|
+
},
|
|
68
|
+
// Pattern 2: Built-in Directory References (FR-002)
|
|
69
|
+
{
|
|
70
|
+
id: 'builtin-dirname',
|
|
71
|
+
name: 'Built-in __dirname',
|
|
72
|
+
description: 'Node.js __dirname built-in reference',
|
|
73
|
+
preventsTaintFor: ['path_traversal'],
|
|
74
|
+
match: {
|
|
75
|
+
type: 'builtin_reference',
|
|
76
|
+
identifiers: ['__dirname'],
|
|
77
|
+
},
|
|
78
|
+
confidence: 'high',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'builtin-filename',
|
|
82
|
+
name: 'Built-in __filename',
|
|
83
|
+
description: 'Node.js __filename built-in reference',
|
|
84
|
+
preventsTaintFor: ['path_traversal'],
|
|
85
|
+
match: {
|
|
86
|
+
type: 'builtin_reference',
|
|
87
|
+
identifiers: ['__filename'],
|
|
88
|
+
},
|
|
89
|
+
confidence: 'high',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'builtin-import-meta-dirname',
|
|
93
|
+
name: 'import.meta.dirname',
|
|
94
|
+
description: 'ESM import.meta.dirname reference',
|
|
95
|
+
preventsTaintFor: ['path_traversal'],
|
|
96
|
+
match: {
|
|
97
|
+
type: 'builtin_reference',
|
|
98
|
+
identifiers: ['import.meta.dirname'],
|
|
99
|
+
},
|
|
100
|
+
confidence: 'high',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'builtin-import-meta-url',
|
|
104
|
+
name: 'import.meta.url',
|
|
105
|
+
description: 'ESM import.meta.url reference',
|
|
106
|
+
preventsTaintFor: ['path_traversal'],
|
|
107
|
+
match: {
|
|
108
|
+
type: 'builtin_reference',
|
|
109
|
+
identifiers: ['import.meta.url'],
|
|
110
|
+
},
|
|
111
|
+
confidence: 'high',
|
|
112
|
+
},
|
|
113
|
+
// Pattern 3: Safe Directory Listing Returns (FR-003)
|
|
114
|
+
{
|
|
115
|
+
id: 'safe-readdir',
|
|
116
|
+
name: 'Safe Directory Listing',
|
|
117
|
+
description: 'fs.readdirSync/readdir with provably safe argument',
|
|
118
|
+
preventsTaintFor: ['path_traversal'],
|
|
119
|
+
match: {
|
|
120
|
+
type: 'safe_function_return',
|
|
121
|
+
callTargets: ['readdirSync', 'readdir'],
|
|
122
|
+
},
|
|
123
|
+
confidence: 'medium',
|
|
124
|
+
},
|
|
125
|
+
// Pattern 4: Constant Array Element Access (FR-004)
|
|
126
|
+
{
|
|
127
|
+
id: 'constant-element-access',
|
|
128
|
+
name: 'Constant Array Element Access',
|
|
129
|
+
description: 'Element access on a module-scope const literal array',
|
|
130
|
+
preventsTaintFor: ['injection', 'xss'],
|
|
131
|
+
match: {
|
|
132
|
+
type: 'constant_element_access',
|
|
133
|
+
},
|
|
134
|
+
confidence: 'high',
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
//# sourceMappingURL=safe-source-patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-source-patterns.js","sourceRoot":"","sources":["../../../src/agents/control_flow/safe-source-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwDH,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD,WAAW;IACX,YAAY;I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tracking for declaration-identity resolution.
|
|
3
|
+
*
|
|
4
|
+
* Provides a scope stack that maps variable names to their declaring AST nodes,
|
|
5
|
+
* enabling scope-aware variable resolution without a full TypeChecker.
|
|
6
|
+
*
|
|
7
|
+
* Used by safe-source-detector and vulnerability-detector to replace name-based
|
|
8
|
+
* tracking with declaration-identity tracking.
|
|
9
|
+
*/
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
/**
|
|
12
|
+
* Produce a deterministic identity string for an AST node.
|
|
13
|
+
* Format: `file:line:col` (1-based line, 0-based column).
|
|
14
|
+
*
|
|
15
|
+
* IMPORTANT: Never embed ts.Node references in serializable data structures.
|
|
16
|
+
* Use this helper to produce a stable key for maps, sets, and stored state.
|
|
17
|
+
*/
|
|
18
|
+
export declare function nodeIdentityKey(node: ts.Node, sourceFile: ts.SourceFile): string;
|
|
19
|
+
/**
|
|
20
|
+
* A variable name extracted from a destructuring assignment target
|
|
21
|
+
* (BinaryExpression LHS). This is the Expression-based counterpart to the
|
|
22
|
+
* simple `{ name, node }` returned by `extractBindingNames()` for
|
|
23
|
+
* BindingPattern nodes in VariableDeclarations.
|
|
24
|
+
*/
|
|
25
|
+
export interface DestructuringBinding {
|
|
26
|
+
/** Local binding name (after rename resolution) */
|
|
27
|
+
name: string;
|
|
28
|
+
/** AST node representing the binding */
|
|
29
|
+
node: ts.Node;
|
|
30
|
+
/** Position in array destructuring (for per-element taint) */
|
|
31
|
+
index?: number;
|
|
32
|
+
/**
|
|
33
|
+
* For nested bindings inside an array element container (e.g. `[{ a }]`),
|
|
34
|
+
* the position of the parent container in the enclosing array.
|
|
35
|
+
* Used by the vulnerability detector to look up the correct RHS element
|
|
36
|
+
* when `index` is not set on nested bindings.
|
|
37
|
+
*/
|
|
38
|
+
parentIndex?: number;
|
|
39
|
+
/** Original property key (for renamed destructuring, e.g. `{ orig: renamed }`) */
|
|
40
|
+
propertyKey?: string;
|
|
41
|
+
/**
|
|
42
|
+
* For nested bindings inside an object property (e.g. `{ a: { b } }`),
|
|
43
|
+
* the chain of property keys from the root to this binding's immediate container.
|
|
44
|
+
* Used by the vulnerability detector to traverse into nested RHS objects.
|
|
45
|
+
* Example: `{ a: { b: { c } } }` → binding `c` has outerKeys: ['a', 'b']
|
|
46
|
+
*/
|
|
47
|
+
outerKeys?: string[];
|
|
48
|
+
/** Whether this is a rest element (`...rest`) */
|
|
49
|
+
isRest: boolean;
|
|
50
|
+
/** Nesting depth (0 = top-level, max 10) */
|
|
51
|
+
depth: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Extract binding names from a destructuring assignment target.
|
|
55
|
+
*
|
|
56
|
+
* Handles `ArrayLiteralExpression` and `ObjectLiteralExpression` patterns
|
|
57
|
+
* used on the LHS of a `BinaryExpression` (assignment targets).
|
|
58
|
+
*
|
|
59
|
+
* This is the Expression-based counterpart to `extractBindingNames()` which
|
|
60
|
+
* handles `BindingPattern` nodes in `VariableDeclarations`.
|
|
61
|
+
*
|
|
62
|
+
* For simple identifiers: `x = 1` → [{ name: 'x', ... }]
|
|
63
|
+
* For array destructuring: `[a, b] = arr` → [{ name: 'a', index: 0 }, { name: 'b', index: 1 }]
|
|
64
|
+
* For object destructuring: `({ a, b: c } = obj)` → [{ name: 'a' }, { name: 'c', propertyKey: 'b' }]
|
|
65
|
+
* For rest elements: `[a, ...rest] = arr` → [{ name: 'a', index: 0 }, { name: 'rest', isRest: true }]
|
|
66
|
+
* For nested: `[{ a }] = arr` → [{ name: 'a', depth: 1 }]
|
|
67
|
+
*
|
|
68
|
+
* @param target - The LHS of a destructuring assignment
|
|
69
|
+
* @param maxDepth - Maximum recursion depth (default 10)
|
|
70
|
+
* @returns Array of extracted bindings with metadata
|
|
71
|
+
*/
|
|
72
|
+
export declare function extractBindingsFromAssignmentTarget(target: ts.Expression, maxDepth?: number): DestructuringBinding[];
|
|
73
|
+
/**
|
|
74
|
+
* Returns true if `node` introduces a new lexical scope.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isScopeNode(node: ts.Node): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Returns true if `node` introduces a function-level scope (not block-level).
|
|
79
|
+
* Used to determine the correct scope for `var` declarations, which are hoisted
|
|
80
|
+
* to the enclosing function (or source file) rather than the enclosing block.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isFunctionScopeNode(node: ts.Node): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Extract all binding identifiers from a BindingName (handles destructuring).
|
|
85
|
+
*
|
|
86
|
+
* For simple identifiers: `const x = 1` -> ['x']
|
|
87
|
+
* For object destructuring: `const { a, b: c } = obj` -> ['a', 'c']
|
|
88
|
+
* For array destructuring: `const [a, , b] = arr` -> ['a', 'b']
|
|
89
|
+
* For nested: `const { a: [b, c] } = obj` -> ['b', 'c']
|
|
90
|
+
*/
|
|
91
|
+
export declare function extractBindingNames(name: ts.BindingName): {
|
|
92
|
+
name: string;
|
|
93
|
+
node: ts.Node;
|
|
94
|
+
}[];
|
|
95
|
+
/**
|
|
96
|
+
* A lexical scope stack for resolving identifier names to declaration nodes.
|
|
97
|
+
*
|
|
98
|
+
* Usage:
|
|
99
|
+
* 1. Walk the AST. On entering a scope-creating node, call `enterScope(node)`.
|
|
100
|
+
* 2. For each variable/const/let declaration, call `addDeclaration(name, declNode)`.
|
|
101
|
+
* 3. To resolve an identifier, call `resolveDeclaration(name)` — returns the
|
|
102
|
+
* innermost declaration node for that name, or undefined if not found.
|
|
103
|
+
* 4. On leaving a scope-creating node, call `leaveScope()`.
|
|
104
|
+
*/
|
|
105
|
+
export declare class ScopeStack {
|
|
106
|
+
private stack;
|
|
107
|
+
/** Current nesting depth (0 when no scope is entered). */
|
|
108
|
+
get depth(): number;
|
|
109
|
+
/** Enter a new lexical scope. */
|
|
110
|
+
enterScope(node: ts.Node): void;
|
|
111
|
+
/** Leave the innermost scope. */
|
|
112
|
+
leaveScope(): void;
|
|
113
|
+
/** Register a declaration in the current (innermost) scope. */
|
|
114
|
+
addDeclaration(name: string, node: ts.Node): void;
|
|
115
|
+
/**
|
|
116
|
+
* Register a `var` declaration in the nearest function-level scope.
|
|
117
|
+
* `var` is hoisted to the enclosing function (or source file), not
|
|
118
|
+
* the enclosing block.
|
|
119
|
+
*/
|
|
120
|
+
addVarDeclaration(name: string, node: ts.Node): void;
|
|
121
|
+
/**
|
|
122
|
+
* Resolve a name to its declaring node by walking the stack from innermost
|
|
123
|
+
* scope outward. Returns the declaring node, or undefined if the name is
|
|
124
|
+
* not declared in any enclosing scope.
|
|
125
|
+
*/
|
|
126
|
+
resolveDeclaration(name: string): ts.Node | undefined;
|
|
127
|
+
/** Check whether a given declaration node is visible in the current scope chain. */
|
|
128
|
+
isInScope(declarationNode: ts.Node): boolean;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Register a variable declaration in the scope stack, handling:
|
|
132
|
+
* - Simple identifiers (`const x`)
|
|
133
|
+
* - Destructuring patterns (`const { a, b } = obj`, `const [a, b] = arr`)
|
|
134
|
+
* - `var` hoisting (registers in the nearest function scope, not block scope)
|
|
135
|
+
* - Catch clause variable binding
|
|
136
|
+
*/
|
|
137
|
+
export declare function registerDeclaration(node: ts.VariableDeclaration, scope: ScopeStack, sourceFile?: ts.SourceFile, declarationsByKey?: Map<string, ts.Node>): void;
|
|
138
|
+
/**
|
|
139
|
+
* Register all declaration types for a given node in the scope stack.
|
|
140
|
+
* This is the canonical helper used by all scope-walking code.
|
|
141
|
+
*/
|
|
142
|
+
export declare function registerNodeDeclarations(node: ts.Node, scope: ScopeStack, sourceFile?: ts.SourceFile, declarationsByKey?: Map<string, ts.Node>): void;
|
|
143
|
+
/**
|
|
144
|
+
* Build a ScopeStack that is populated with all declarations in `sourceFile`.
|
|
145
|
+
* This performs a full AST walk and registers every variable/const/let/var
|
|
146
|
+
* declaration, function parameter, catch variable, and function declaration name.
|
|
147
|
+
*
|
|
148
|
+
* Returns a Map from each AST node to the ScopeStack state at that point,
|
|
149
|
+
* keyed by node identity string. This is used for point-in-time resolution.
|
|
150
|
+
*
|
|
151
|
+
* For simpler use cases, use `walkWithScope()` instead.
|
|
152
|
+
*/
|
|
153
|
+
export declare function buildDeclarationMap(sourceFile: ts.SourceFile): Map<string, ts.Node>;
|
|
154
|
+
/**
|
|
155
|
+
* Walk an AST with scope tracking, invoking a callback for each node.
|
|
156
|
+
* The callback receives the current ScopeStack, which can be used to
|
|
157
|
+
* resolve identifiers at any point during the walk.
|
|
158
|
+
*
|
|
159
|
+
* Declarations are registered automatically for:
|
|
160
|
+
* - Variable declarations (`const x`, `let y`, `var z` with hoisting)
|
|
161
|
+
* - Destructuring patterns (`const { a } = obj`, `const [a] = arr`)
|
|
162
|
+
* - Function declaration names
|
|
163
|
+
* - Function/method/arrow parameters (including destructured)
|
|
164
|
+
* - Catch clause variables
|
|
165
|
+
*/
|
|
166
|
+
export declare function walkWithScope(sourceFile: ts.SourceFile, callback: (node: ts.Node, scope: ScopeStack, sourceFile: ts.SourceFile) => void): void;
|
|
167
|
+
//# sourceMappingURL=scope-stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-stack.d.ts","sourceRoot":"","sources":["../../../src/agents/control_flow/scope-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAM5B;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,CAGhF;AAMD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC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