hackmyagent 0.16.5 → 0.16.7
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/.integrity-manifest.json +1 -1
- package/dist/arp/crypto/hybrid-signing.d.ts +107 -0
- package/dist/arp/crypto/hybrid-signing.d.ts.map +1 -0
- package/dist/arp/crypto/hybrid-signing.js +321 -0
- package/dist/arp/crypto/hybrid-signing.js.map +1 -0
- package/dist/arp/crypto/index.d.ts +13 -0
- package/dist/arp/crypto/index.d.ts.map +1 -0
- package/dist/arp/crypto/index.js +33 -0
- package/dist/arp/crypto/index.js.map +1 -0
- package/dist/arp/crypto/manifest-loader.d.ts +117 -0
- package/dist/arp/crypto/manifest-loader.d.ts.map +1 -0
- package/dist/arp/crypto/manifest-loader.js +361 -0
- package/dist/arp/crypto/manifest-loader.js.map +1 -0
- package/dist/arp/crypto/types.d.ts +69 -0
- package/dist/arp/crypto/types.d.ts.map +1 -0
- package/dist/arp/crypto/types.js +11 -0
- package/dist/arp/crypto/types.js.map +1 -0
- package/dist/arp/index.d.ts +27 -0
- package/dist/arp/index.d.ts.map +1 -1
- package/dist/arp/index.js +94 -1
- package/dist/arp/index.js.map +1 -1
- package/dist/arp/intelligence/behavioral-risk-server.d.ts +82 -0
- package/dist/arp/intelligence/behavioral-risk-server.d.ts.map +1 -0
- package/dist/arp/intelligence/behavioral-risk-server.js +258 -0
- package/dist/arp/intelligence/behavioral-risk-server.js.map +1 -0
- package/dist/arp/intelligence/behavioral-risk.d.ts +217 -0
- package/dist/arp/intelligence/behavioral-risk.d.ts.map +1 -0
- package/dist/arp/intelligence/behavioral-risk.js +429 -0
- package/dist/arp/intelligence/behavioral-risk.js.map +1 -0
- package/dist/arp/intelligence/coordinator.d.ts +93 -2
- package/dist/arp/intelligence/coordinator.d.ts.map +1 -1
- package/dist/arp/intelligence/coordinator.js +281 -1
- package/dist/arp/intelligence/coordinator.js.map +1 -1
- package/dist/arp/intelligence/guard-anomaly.d.ts +349 -0
- package/dist/arp/intelligence/guard-anomaly.d.ts.map +1 -0
- package/dist/arp/intelligence/guard-anomaly.js +399 -0
- package/dist/arp/intelligence/guard-anomaly.js.map +1 -0
- package/dist/arp/intelligence/nanomind-l1.d.ts +37 -0
- package/dist/arp/intelligence/nanomind-l1.d.ts.map +1 -1
- package/dist/arp/intelligence/nanomind-l1.js +78 -0
- package/dist/arp/intelligence/nanomind-l1.js.map +1 -1
- package/dist/arp/intelligence/verify-classification.d.ts +124 -0
- package/dist/arp/intelligence/verify-classification.d.ts.map +1 -0
- package/dist/arp/intelligence/verify-classification.js +329 -0
- package/dist/arp/intelligence/verify-classification.js.map +1 -0
- package/dist/arp/proxy/server.d.ts +38 -8
- package/dist/arp/proxy/server.d.ts.map +1 -1
- package/dist/arp/proxy/server.js +89 -0
- package/dist/arp/proxy/server.js.map +1 -1
- package/dist/arp/types.d.ts +228 -1
- package/dist/arp/types.d.ts.map +1 -1
- package/dist/cli.js +85 -18
- package/dist/cli.js.map +1 -1
- package/dist/nanomind-core/compiler/semantic-compiler.d.ts.map +1 -1
- package/dist/nanomind-core/compiler/semantic-compiler.js +170 -10
- package/dist/nanomind-core/compiler/semantic-compiler.js.map +1 -1
- package/dist/nanomind-core/compiler/source-code-preprocessor.d.ts +64 -0
- package/dist/nanomind-core/compiler/source-code-preprocessor.d.ts.map +1 -0
- package/dist/nanomind-core/compiler/source-code-preprocessor.js +656 -0
- package/dist/nanomind-core/compiler/source-code-preprocessor.js.map +1 -0
- package/dist/nanomind-core/ingestion/artifact-parser.d.ts.map +1 -1
- package/dist/nanomind-core/ingestion/artifact-parser.js +15 -6
- package/dist/nanomind-core/ingestion/artifact-parser.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guard anomaly detector (AIComply P1, distribution drift layer).
|
|
3
|
+
*
|
|
4
|
+
* This module complements the per-event behavioral risk channel
|
|
5
|
+
* (`behavioral-risk.ts`) with a statistical layer that watches the
|
|
6
|
+
* CLASSIFICATION DISTRIBUTION over a sliding window and flags drift
|
|
7
|
+
* from a reference baseline. The two layers are additive and catch
|
|
8
|
+
* different attacks:
|
|
9
|
+
*
|
|
10
|
+
* - Behavioral risk scores a single event against the agent's
|
|
11
|
+
* behavioral baseline: "does THIS action look anomalous?" It
|
|
12
|
+
* catches individual outliers.
|
|
13
|
+
* - Guard anomaly scores the recent class mix against a reference
|
|
14
|
+
* distribution: "has the TYPE of events drifted from what the
|
|
15
|
+
* Guard was trained on?" It catches regime shifts.
|
|
16
|
+
*
|
|
17
|
+
* A slow attacker whose individual events stay below the per-event
|
|
18
|
+
* risk threshold but whose actions collectively shift the class
|
|
19
|
+
* distribution (for example a sustained 5x over-rate of a
|
|
20
|
+
* sensitive-class label relative to the training baseline) is
|
|
21
|
+
* invisible to the per-event layer and obvious to the drift
|
|
22
|
+
* detector.
|
|
23
|
+
*
|
|
24
|
+
* ## Design decisions
|
|
25
|
+
*
|
|
26
|
+
* ### 1. Sliding ring buffer over reservoir sample
|
|
27
|
+
*
|
|
28
|
+
* A ring buffer of the most recent `windowSize` classification labels
|
|
29
|
+
* gives exact recency with bounded memory. A reservoir sample would
|
|
30
|
+
* preserve uniformly-drawn history and let stale events dilute the
|
|
31
|
+
* current drift signal, which is the opposite of what drift detection
|
|
32
|
+
* wants: the question is whether the CURRENT distribution matches
|
|
33
|
+
* the baseline, not whether history mixed with the present does.
|
|
34
|
+
*
|
|
35
|
+
* ### 2. Chi-square goodness-of-fit over z-score or KL divergence
|
|
36
|
+
*
|
|
37
|
+
* Chi-square is the principled test for a multi-class observed
|
|
38
|
+
* distribution against a reference. It operates on raw count vectors,
|
|
39
|
+
* produces a single scalar statistic, and has a well-understood null
|
|
40
|
+
* distribution (chi-squared with K-1 degrees of freedom) that gives
|
|
41
|
+
* caller-interpretable thresholds.
|
|
42
|
+
*
|
|
43
|
+
* Z-score is wrong for a multi-class comparison because it measures
|
|
44
|
+
* deviation of a single scalar from its own baseline; it cannot
|
|
45
|
+
* capture joint drift across the class vector. KL divergence is a
|
|
46
|
+
* reasonable alternative but lacks a principled threshold tied to a
|
|
47
|
+
* null distribution, which matters when the caller needs to reason
|
|
48
|
+
* about false-positive rates in a security context.
|
|
49
|
+
*
|
|
50
|
+
* ### 3. Injected baseline with Laplace smoothing
|
|
51
|
+
*
|
|
52
|
+
* The baseline class distribution is a dependency of this detector,
|
|
53
|
+
* not a concern of this module. The caller is responsible for
|
|
54
|
+
* providing it from the authoritative source. Two shipping paths are
|
|
55
|
+
* supported by callers of this module:
|
|
56
|
+
*
|
|
57
|
+
* - Registry-exported training distribution. The NanoMind-Guard
|
|
58
|
+
* training pipeline computes the class distribution over the
|
|
59
|
+
* training corpus and ships it out-of-band through the Registry.
|
|
60
|
+
* The runtime fetches it at startup and passes it here. This is
|
|
61
|
+
* the target deployment state.
|
|
62
|
+
*
|
|
63
|
+
* - Observation-based bootstrap. In pre-Registry deployments a
|
|
64
|
+
* caller can collect observations over a "learning" period and
|
|
65
|
+
* build a baseline from them via `buildBaselineFromObservations`.
|
|
66
|
+
* This is intentionally a weaker source: the baseline is only as
|
|
67
|
+
* trustworthy as the period it was collected over.
|
|
68
|
+
*
|
|
69
|
+
* Laplace smoothing handles zero-count classes on both sides without
|
|
70
|
+
* special casing. The smoothed baseline probability for class c with
|
|
71
|
+
* K total classes is `(p(c) + alpha) / (1 + alpha * K)`, which
|
|
72
|
+
* preserves sum-to-one and guarantees strictly positive expected
|
|
73
|
+
* counts so the chi-square denominator never underflows. The default
|
|
74
|
+
* alpha of 0.01 is intentionally small so that a window which mirrors
|
|
75
|
+
* the baseline scores a chi-square near zero; larger alpha values
|
|
76
|
+
* pull the smoothed baseline toward uniform and bias the null-case
|
|
77
|
+
* statistic upward.
|
|
78
|
+
*
|
|
79
|
+
* ### 4. Bounded memory contract
|
|
80
|
+
*
|
|
81
|
+
* A ring buffer of at most `windowSize` label strings plus a count
|
|
82
|
+
* map whose size is bounded by the number of distinct classes seen in
|
|
83
|
+
* the window (in practice <20 for current AIComply label sets, hard
|
|
84
|
+
* bounded by `windowSize`). A per-label length cap of
|
|
85
|
+
* `MAX_CLASSIFICATION_LENGTH` characters guards against an adversary
|
|
86
|
+
* passing pathologically long labels to exhaust memory; longer labels
|
|
87
|
+
* are rejected as a record-time no-op so the window remains
|
|
88
|
+
* O(windowSize * MAX_CLASSIFICATION_LENGTH) bytes in the worst case.
|
|
89
|
+
* `windowSize` itself is clamped to `MAX_GUARD_ANOMALY_WINDOW` so a
|
|
90
|
+
* misconfigured caller cannot blow up memory either.
|
|
91
|
+
*
|
|
92
|
+
* ### 5. Alarm surfacing
|
|
93
|
+
*
|
|
94
|
+
* Parallel to the session 28 behavioral risk channel, the coordinator
|
|
95
|
+
* records the `GuardAnomalyStatus` on `event.data.guardAnomaly` for
|
|
96
|
+
* every classified event. On the `drift` branch the coordinator
|
|
97
|
+
* raises category to `anomaly` and severity to `medium`; on
|
|
98
|
+
* `baseline-pending` and `normal` the record is written without
|
|
99
|
+
* mutation. This is the record-and-lift policy: observation is
|
|
100
|
+
* always recorded so downstream audit can see the drift state at the
|
|
101
|
+
* time of each event, and enforcement kicks in only when the
|
|
102
|
+
* chi-square statistic crosses the configured threshold.
|
|
103
|
+
*
|
|
104
|
+
* ## Parse-to-deny (CR-001)
|
|
105
|
+
*
|
|
106
|
+
* The detector never throws. `record()` rejects non-string or empty
|
|
107
|
+
* classifications as a no-op that returns the current status without
|
|
108
|
+
* mutating internal state. `installBaseline` silently drops invalid
|
|
109
|
+
* entries; if the baseline is empty after installation, the detector
|
|
110
|
+
* reports `baseline-pending` forever rather than inventing a default.
|
|
111
|
+
* Callers must treat `drift` as authoritative and must not use the
|
|
112
|
+
* statistic itself to make per-event decisions beyond the threshold
|
|
113
|
+
* comparison already encoded here.
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* Baseline class distribution. Keys are classification labels; values
|
|
117
|
+
* are either probabilities that sum to ~1 or raw counts. The detector
|
|
118
|
+
* normalizes internally, so either form works. Entries with invalid
|
|
119
|
+
* keys or non-finite or negative values are silently dropped.
|
|
120
|
+
*/
|
|
121
|
+
export type ClassDistribution = Record<string, number>;
|
|
122
|
+
/**
|
|
123
|
+
* One entry in the top-K deviation list on a drift status: a class
|
|
124
|
+
* name and how far its observed count deviated from its smoothed
|
|
125
|
+
* expected count. Positive deviation means the class was
|
|
126
|
+
* over-represented in the window, negative means under-represented.
|
|
127
|
+
*/
|
|
128
|
+
export interface ClassDeviation {
|
|
129
|
+
className: string;
|
|
130
|
+
observed: number;
|
|
131
|
+
expected: number;
|
|
132
|
+
deviation: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Discriminated union returned by `record()`. Callers route on
|
|
136
|
+
* `status`:
|
|
137
|
+
*
|
|
138
|
+
* - `baseline-pending` when the observation window contains fewer
|
|
139
|
+
* than `minObservations`, or when the installed baseline is
|
|
140
|
+
* empty. Record-only on the coordinator side: no severity raise.
|
|
141
|
+
*
|
|
142
|
+
* - `normal` when the chi-square statistic is under threshold.
|
|
143
|
+
* Record-only.
|
|
144
|
+
*
|
|
145
|
+
* - `drift` when the chi-square statistic is at or above threshold.
|
|
146
|
+
* Carries the top-K most-deviated classes so downstream audit can
|
|
147
|
+
* see which classes drove the alarm without re-running the chi-
|
|
148
|
+
* square computation.
|
|
149
|
+
*/
|
|
150
|
+
export type GuardAnomalyStatus = {
|
|
151
|
+
status: 'baseline-pending';
|
|
152
|
+
/** How many valid observations are currently in the window. */
|
|
153
|
+
observed: number;
|
|
154
|
+
/** Minimum observations required before drift scoring activates. */
|
|
155
|
+
required: number;
|
|
156
|
+
/** Reason the detector is pending: not enough data, or empty baseline. */
|
|
157
|
+
reason: 'insufficient-observations' | 'empty-baseline';
|
|
158
|
+
} | {
|
|
159
|
+
status: 'normal';
|
|
160
|
+
statistic: number;
|
|
161
|
+
threshold: number;
|
|
162
|
+
windowSize: number;
|
|
163
|
+
source: string;
|
|
164
|
+
} | {
|
|
165
|
+
status: 'drift';
|
|
166
|
+
statistic: number;
|
|
167
|
+
threshold: number;
|
|
168
|
+
topDeviations: ClassDeviation[];
|
|
169
|
+
windowSize: number;
|
|
170
|
+
source: string;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Construction config. Only `baseline` is required; sensible defaults
|
|
174
|
+
* are provided for every other knob.
|
|
175
|
+
*/
|
|
176
|
+
export interface GuardAnomalyConfig {
|
|
177
|
+
/** Baseline class distribution (counts or probabilities). */
|
|
178
|
+
baseline: ClassDistribution;
|
|
179
|
+
/**
|
|
180
|
+
* Maximum sliding window size. Default: 200. Clamped to
|
|
181
|
+
* [1, MAX_GUARD_ANOMALY_WINDOW] by the constructor so a misconfigured
|
|
182
|
+
* caller cannot allocate unbounded memory.
|
|
183
|
+
*/
|
|
184
|
+
windowSize?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Chi-square statistic threshold that triggers a drift alarm.
|
|
187
|
+
* Default: 21.666 (~chi^2_{0.01} for df=9, a reasonable value for
|
|
188
|
+
* ~10-class distributions at 99% confidence). Callers with larger
|
|
189
|
+
* K should increase this; callers with smaller K should decrease it.
|
|
190
|
+
*/
|
|
191
|
+
alarmThreshold?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Laplace smoothing alpha. Default: 0.01. Larger alpha pulls the
|
|
194
|
+
* smoothed baseline toward uniform, reducing sensitivity to rare
|
|
195
|
+
* classes AND biasing a null-case (observed matches baseline)
|
|
196
|
+
* statistic upward; smaller alpha reduces smoothing at the cost of
|
|
197
|
+
* instability on zero-count classes. The default is tuned so that
|
|
198
|
+
* a baseline-matching window over a ~100 event window scores under
|
|
199
|
+
* 0.5 and never crosses the default alarm threshold.
|
|
200
|
+
*/
|
|
201
|
+
smoothing?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Minimum observations before drift scoring activates. Default:
|
|
204
|
+
* max(30, floor(windowSize / 4)). Below this, `record()` returns
|
|
205
|
+
* `baseline-pending`.
|
|
206
|
+
*/
|
|
207
|
+
minObservations?: number;
|
|
208
|
+
/** Audit source tag surfaced on the status object. Default: 'guard-anomaly'. */
|
|
209
|
+
sourceName?: string;
|
|
210
|
+
/**
|
|
211
|
+
* How many top deviations to include in a drift status. Default: 3.
|
|
212
|
+
* The full sorted list is truncated to this count.
|
|
213
|
+
*/
|
|
214
|
+
topKDeviations?: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Minimal interface the coordinator holds. The concrete detector
|
|
218
|
+
* implements this; tests that want to inject bespoke behavior can
|
|
219
|
+
* stub it directly without instantiating a full detector.
|
|
220
|
+
*/
|
|
221
|
+
export interface GuardAnomalySource {
|
|
222
|
+
/**
|
|
223
|
+
* Record a classification observation and return the current drift
|
|
224
|
+
* status. Must never throw. An empty, non-string, or over-long
|
|
225
|
+
* classification is a no-op that returns the current status.
|
|
226
|
+
*/
|
|
227
|
+
record(classification: string): GuardAnomalyStatus;
|
|
228
|
+
}
|
|
229
|
+
/** Default sliding-window size if the caller does not override. */
|
|
230
|
+
export declare const DEFAULT_GUARD_ANOMALY_WINDOW = 200;
|
|
231
|
+
/**
|
|
232
|
+
* Hard cap on the sliding-window size. Bounds worst-case memory to
|
|
233
|
+
* `MAX_GUARD_ANOMALY_WINDOW * MAX_CLASSIFICATION_LENGTH` bytes of
|
|
234
|
+
* label storage.
|
|
235
|
+
*/
|
|
236
|
+
export declare const MAX_GUARD_ANOMALY_WINDOW = 10000;
|
|
237
|
+
/**
|
|
238
|
+
* Default chi-square alarm threshold. Approximately the critical
|
|
239
|
+
* value for chi-squared with 9 degrees of freedom at p=0.01, which
|
|
240
|
+
* is a reasonable default for distributions with about 10 classes
|
|
241
|
+
* and a 1% tolerable false-positive rate.
|
|
242
|
+
*/
|
|
243
|
+
export declare const DEFAULT_GUARD_ANOMALY_THRESHOLD = 21.666;
|
|
244
|
+
/**
|
|
245
|
+
* Default Laplace smoothing constant. Tuned small so a null-case
|
|
246
|
+
* window (observed matches baseline) scores near zero. See the
|
|
247
|
+
* module header for the rationale on why 0.01 was chosen over the
|
|
248
|
+
* textbook 0.5.
|
|
249
|
+
*/
|
|
250
|
+
export declare const DEFAULT_GUARD_ANOMALY_SMOOTHING = 0.01;
|
|
251
|
+
/** Default top-K deviation count surfaced on a drift status. */
|
|
252
|
+
export declare const DEFAULT_GUARD_ANOMALY_TOP_K = 3;
|
|
253
|
+
/** Absolute floor on minObservations regardless of windowSize. */
|
|
254
|
+
export declare const DEFAULT_GUARD_ANOMALY_MIN_OBS = 30;
|
|
255
|
+
/**
|
|
256
|
+
* Maximum accepted classification label length. Labels longer than
|
|
257
|
+
* this are rejected at `record()` as a no-op so a malicious producer
|
|
258
|
+
* cannot inflate memory by writing pathologically long labels into
|
|
259
|
+
* the window.
|
|
260
|
+
*/
|
|
261
|
+
export declare const MAX_CLASSIFICATION_LENGTH = 256;
|
|
262
|
+
/**
|
|
263
|
+
* Statistical drift detector over a sliding window of classification
|
|
264
|
+
* labels. Thread-unsafe by construction; callers are expected to
|
|
265
|
+
* serialize calls through the coordinator's analyze() loop.
|
|
266
|
+
*/
|
|
267
|
+
export declare class GuardAnomalyDetector implements GuardAnomalySource {
|
|
268
|
+
private readonly windowSize;
|
|
269
|
+
private readonly alarmThreshold;
|
|
270
|
+
private readonly smoothing;
|
|
271
|
+
private readonly minObservations;
|
|
272
|
+
private readonly sourceName;
|
|
273
|
+
private readonly topKDeviations;
|
|
274
|
+
/** Normalized baseline probabilities (sum to 1 when non-empty). */
|
|
275
|
+
private baselineNorm;
|
|
276
|
+
/** Ring buffer of label strings; indices in [0, windowSize). */
|
|
277
|
+
private readonly window;
|
|
278
|
+
/** Next write index. Wraps at windowSize. */
|
|
279
|
+
private head;
|
|
280
|
+
/** True once the ring has wrapped at least once. */
|
|
281
|
+
private filled;
|
|
282
|
+
/** Running count of each class currently in the window. */
|
|
283
|
+
private readonly counts;
|
|
284
|
+
constructor(config: GuardAnomalyConfig);
|
|
285
|
+
/**
|
|
286
|
+
* Record a classification observation and return the current drift
|
|
287
|
+
* status. Never throws. Returns the current status (without
|
|
288
|
+
* recording) when the classification is empty, not a string, or
|
|
289
|
+
* exceeds `MAX_CLASSIFICATION_LENGTH`.
|
|
290
|
+
*/
|
|
291
|
+
record(classification: string): GuardAnomalyStatus;
|
|
292
|
+
/** Current number of observations in the sliding window. */
|
|
293
|
+
getWindowObservations(): number;
|
|
294
|
+
/** Configured window capacity. */
|
|
295
|
+
getWindowCapacity(): number;
|
|
296
|
+
/**
|
|
297
|
+
* Snapshot of the current observed class counts. Returns a new
|
|
298
|
+
* object; safe to mutate without affecting the detector.
|
|
299
|
+
*/
|
|
300
|
+
getObserved(): ClassDistribution;
|
|
301
|
+
/**
|
|
302
|
+
* Snapshot of the installed (normalized) baseline. Returns a new
|
|
303
|
+
* object.
|
|
304
|
+
*/
|
|
305
|
+
getBaseline(): ClassDistribution;
|
|
306
|
+
/**
|
|
307
|
+
* Replace the baseline without tearing down the detector. Used by
|
|
308
|
+
* a caller that rotates the Guard's training distribution in
|
|
309
|
+
* place. The observation window is preserved so drift detection
|
|
310
|
+
* continues without a re-learning period.
|
|
311
|
+
*/
|
|
312
|
+
setBaseline(baseline: ClassDistribution): void;
|
|
313
|
+
/**
|
|
314
|
+
* Clear the observation window. Baseline is untouched. Intended
|
|
315
|
+
* for callers that want to reset state after a confirmed drift
|
|
316
|
+
* resolution or a configuration change.
|
|
317
|
+
*/
|
|
318
|
+
reset(): void;
|
|
319
|
+
private installBaseline;
|
|
320
|
+
private computeStatus;
|
|
321
|
+
/**
|
|
322
|
+
* Compute the Laplace-smoothed chi-square goodness-of-fit statistic
|
|
323
|
+
* of the current window against the installed baseline, and the
|
|
324
|
+
* full per-class deviation list sorted by absolute deviation.
|
|
325
|
+
*
|
|
326
|
+
* Smoothed baseline:
|
|
327
|
+
* smoothed_p(c) = (p(c) + alpha) / (1 + alpha * K)
|
|
328
|
+
* where K = |universe|, the union of baseline classes and observed
|
|
329
|
+
* classes. This preserves sum-to-one and yields strictly positive
|
|
330
|
+
* expected counts for every c in the universe, so the chi-square
|
|
331
|
+
* denominator never underflows.
|
|
332
|
+
*/
|
|
333
|
+
private computeChiSquare;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Build a baseline `ClassDistribution` from an array of observation
|
|
337
|
+
* labels. Intended for the observation-based bootstrap path where no
|
|
338
|
+
* Registry-exported baseline is yet available. The returned object
|
|
339
|
+
* is a count map; the detector normalizes it internally.
|
|
340
|
+
*
|
|
341
|
+
* Callers should collect at least several hundred observations over
|
|
342
|
+
* a trusted "learning" period before calling this. A baseline built
|
|
343
|
+
* from fewer observations is noise, and a baseline built from a
|
|
344
|
+
* compromised period bakes the attack into the reference.
|
|
345
|
+
*
|
|
346
|
+
* Entries that are not non-empty strings are silently skipped.
|
|
347
|
+
*/
|
|
348
|
+
export declare function buildBaselineFromObservations(samples: ReadonlyArray<string>): ClassDistribution;
|
|
349
|
+
//# sourceMappingURL=guard-anomaly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard-anomaly.d.ts","sourceRoot":"","sources":["../../../src/arp/intelligence/guard-anomaly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiHG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,MAAM,EAAE,kBAAkB,CAAC;IAC3B,+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