@opentide/opentide 0.0.0-stage → 1.0.0-rc.3

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/index.d.ts ADDED
@@ -0,0 +1,457 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
12
+ /**
13
+ * Cancels a connection's operations: the one running rejects with the code
14
+ * `interrupted`, and so does every later one.
15
+ */
16
+ export declare class Canceller {
17
+ /** Cancels. */
18
+ cancel(): void
19
+ /** Whether `cancel` was called. */
20
+ get isCancelled(): boolean
21
+ }
22
+
23
+ /**
24
+ * One tenant's client, built from that tenant's own settings (TLS, CA
25
+ * bundle, proxy, timeout, credentials). Secrets never reach a message.
26
+ *
27
+ * `query`, `validateQuery` and `deploy` return promises: each operation
28
+ * runs off Node's thread, so one connection serves many at once.
29
+ */
30
+ export declare class Connection {
31
+ /**
32
+ * Connects to `tenant`: resolves its credentials and builds its client.
33
+ * Nothing is sent until an operation runs. Throws `credential_unset`
34
+ * (naming the variable), `tenant_setup_invalid`,
35
+ * `operation_unsupported` (a platform without a connector) or
36
+ * `usage_invalid_value` (a timeout that is not a number of seconds).
37
+ */
38
+ static open(tenant: TenantConfig, options?: ConnectOptions | undefined | null): Connection
39
+ /** The platform's identifier. */
40
+ get platform(): string
41
+ /** The tenant's name. */
42
+ get tenant(): string
43
+ /** What this tenant's connector can do. */
44
+ get capabilities(): Capabilities
45
+ /**
46
+ * A handle that cancels this connection's operations from elsewhere (a
47
+ * signal handler, a timer).
48
+ */
49
+ canceller(): Canceller
50
+ /**
51
+ * Runs `text` on the tenant (`opentide query`) and resolves to at most
52
+ * `limit` rows. Nothing is saved on the tenant. Rejects with
53
+ * `tenant_refused` (the vendor's words in `detail`), `query_timed_out`,
54
+ * `tenant_unreachable`, `authentication_failed`, `interrupted`,
55
+ * `operation_unsupported`, ...
56
+ */
57
+ query(text: string, options?: QueryOptions | undefined | null): Promise<QueryResult>
58
+ /**
59
+ * Checks `text` on the tenant (`opentide validate query --live`): by
60
+ * default a search for one row over the minute before now. Resolves for
61
+ * a query the tenant accepts; rejects with `tenant_refused` for one it
62
+ * refuses, and with `operation_unsupported` on a platform that cannot
63
+ * check a query live (CrowdStrike, HarfangLab, Sysdig).
64
+ */
65
+ validateQuery(text: string, options?: QueryOptions | undefined | null): Promise<LiveCheck>
66
+ /**
67
+ * Applies `operation` to the rule `ruleId` on the tenant, sending `body`
68
+ * (the request `opentide deploy` compiles for this tenant) as its
69
+ * bytes, and resolves to the platform's identifier of the rule. Rejects
70
+ * with `tenant_refused` and the other codes of `query`. A `delete`
71
+ * takes no body (`null`), but on HarfangLab, whose body names the
72
+ * rule's kind (`{"kind": "Sigma"}`); the
73
+ * other operations reject without one (`usage_invalid_value`).
74
+ * `options.signal` aborts it.
75
+ */
76
+ deploy(ruleId: string, operation: 'create' | 'update' | 'disable' | 'delete', body?: string | Uint8Array | undefined | null, options?: DeployOptions | undefined | null): Promise<DeployOutcome>
77
+ }
78
+
79
+ /**
80
+ * A tenant as the workspace configures it (`Workspace.tenants`), or as code
81
+ * configures it: its platform, its name and its `setup`, whose `$NAME`
82
+ * credentials are read when it connects. Its setup's values never leave it.
83
+ */
84
+ export declare class TenantConfig {
85
+ /**
86
+ * The tenant `name` of `platform` with its `setup`: each key and its
87
+ * value, a `$NAME` value read from the environment when it connects
88
+ * (`{ url: 'https://s1.example', api_token: '$S1_API_TOKEN' }`).
89
+ */
90
+ constructor(platform: string, name: string, setup: Record<string, string>)
91
+ /** The platform's identifier (`splunk`, `sentinel_one`). */
92
+ get platform(): string
93
+ /** The tenant's name. */
94
+ get name(): string
95
+ /** The keys of its `setup`, in name order; never their values. */
96
+ get setupKeys(): Array<string>
97
+ }
98
+
99
+ /**
100
+ * A Tide workspace: its configuration, resolved once, and every object file,
101
+ * read and parsed once into one index. Each method reads that index.
102
+ */
103
+ export declare class Workspace {
104
+ /**
105
+ * Opens the workspace at `path` on disk: a repository holding
106
+ * `.opentide/` or `objects/`, or a folder inside one. The files are read
107
+ * and indexed off Node's event loop; the promise resolves to the
108
+ * workspace.
109
+ */
110
+ static open(path: string, options?: OpenOptions | undefined | null): Promise<Workspace>
111
+ /**
112
+ * Opens a workspace held in memory, rooted at `root`: each key of
113
+ * `files` is a path (relative to `root`, or absolute), each value its
114
+ * text. Nothing is read from or written to the disk.
115
+ */
116
+ static fromFiles(root: string, files: Record<string, string>): Workspace
117
+ /** The workspace folder: the one that holds `.opentide/` and `objects/`. */
118
+ get root(): string
119
+ /**
120
+ * Runs every check of `opentide validate`: `checks`, `report` and
121
+ * `summary` as `validate --json` writes them, whether the run fails, and
122
+ * its exit code.
123
+ */
124
+ validate(options?: ValidateOptions | undefined | null): { checks: Record<string, { check: string; status: string }>; report: any; summary: any; failed: boolean; warned: boolean; exitCode: number }
125
+ /**
126
+ * Runs `opentide lint` (its `lint.toml`, or the checks `options` names)
127
+ * without fixing anything: `findings` and `summary` as `lint --json`
128
+ * writes them, the status, the message and the exit code.
129
+ */
130
+ lint(options?: LintOptions | undefined | null): { path: string; checks: string[]; findings: any[]; status: 'completed' | 'issues' | 'failed'; message: string; exitCode: number; failureCode: string | null; summary: any | null; outcome: string | null; unmatched: string[]; warnings: string[]; nextActions: Array<{ command: string; reason: string }> }
131
+ /**
132
+ * What `opentide info` reports: the object counts, the files that did
133
+ * not load and each platform with its tenants (the environment
134
+ * variables each reads and whether each is set, never their values).
135
+ * `environment` is where the variables are looked up, as
136
+ * `Connection.open`'s names the one a connection reads; omitted: the
137
+ * process's.
138
+ */
139
+ info(environment?: Record<string, string> | undefined | null): any
140
+ /**
141
+ * The catalogue (`opentide info catalog`): every object with its
142
+ * techniques and platforms, every edge, the signals and the ATT&CK
143
+ * matrix.
144
+ */
145
+ catalog(): any
146
+ /**
147
+ * The detection rules: their rows of the catalogue (`uuid`, `type`,
148
+ * `schema`, `name`, `path`, `techniques`, ...), in index order.
149
+ */
150
+ rules(): any[]
151
+ /** The detection objectives: their rows of the catalogue. */
152
+ objectives(): any[]
153
+ /** The threat vectors: their rows of the catalogue. */
154
+ threats(): any[]
155
+ /**
156
+ * The rules that cover the ATT&CK `technique` (`opentide info coverage
157
+ * --technique`), their own techniques or inherited ones.
158
+ */
159
+ coverage(technique: string): { technique: string; rules: string[]; count: number; own: string[]; inherited: string[]; matched_techniques: string[] }
160
+ /**
161
+ * The deploy plan: what `opentide deploy --dry-run` would send, computed
162
+ * locally. Nothing is sent and nothing is written. `document` is
163
+ * `deploy --dry-run --json`'s `result`. The rules are compiled off
164
+ * Node's event loop.
165
+ */
166
+ deployPlan(options?: DeployPlanOptions | undefined | null): Promise<{ document: any; summary: any | null; ok: boolean }>
167
+ /**
168
+ * The tenants the workspace configures for `platform` (the
169
+ * `[[tenants]]` of `.opentide/configurations/platforms/<platform>.toml`),
170
+ * in file order; empty when it configures none. Open one with
171
+ * `Connection.open`. Throws `usage_invalid_choice` for a `platform`
172
+ * that is neither built in nor a loaded plugin's.
173
+ */
174
+ tenants(platform: string): Array<TenantConfig>
175
+ }
176
+
177
+ /**
178
+ * What the connector of `platform` can do; `null` for a platform without
179
+ * one.
180
+ */
181
+ export declare function capabilities(platform: string): Capabilities | null
182
+
183
+ /**
184
+ * What a platform's connector can do: `Connection.deploy`,
185
+ * `Connection.validateQuery` (`validate query --live`) and
186
+ * `Connection.query` (`opentide query`).
187
+ */
188
+ export interface Capabilities {
189
+ /** `Connection.deploy`. */
190
+ deploy: boolean
191
+ /** `Connection.validateQuery`. */
192
+ liveValidation: boolean
193
+ /** `Connection.query`. */
194
+ query: boolean
195
+ }
196
+
197
+ /** How `Connection.open` reaches a tenant. */
198
+ export interface ConnectOptions {
199
+ /**
200
+ * Replaces the process's environment for the tenant's `$NAME`
201
+ * credentials, its CA bundles (`SSL_CERT_FILE`, ...) and its proxies
202
+ * (`HTTPS_PROXY`, `NO_PROXY`, ...).
203
+ */
204
+ environment?: Record<string, string>
205
+ /** The proxy every request goes through, before the environment's. */
206
+ proxy?: string
207
+ /**
208
+ * How long, in seconds, the tenant may take to answer a read (Elastic,
209
+ * Splunk, Carbon Black Cloud, Sentinel, Google SecOps); default 120. A
210
+ * deploy waits as long as `opentide deploy` does, whatever this is.
211
+ */
212
+ timeout?: number
213
+ }
214
+
215
+ /** Something a deploy did: the event's name and its fields, in order. */
216
+ export interface DeployEvent {
217
+ /** The event's name, as `opentide deploy` logs it (`sysdig_rule_created`). */
218
+ name: string
219
+ /** Its fields, in order, as `[key, value]` pairs. */
220
+ fields: Array<[string, string]>
221
+ }
222
+
223
+ /**
224
+ * `deploy`'s options: the signal that aborts it, and a Sysdig rule's
225
+ * runtime policies.
226
+ */
227
+ export interface DeployOptions {
228
+ /**
229
+ * Aborts this deploy alone, as `QueryOptions.signal` does a query. A
230
+ * deploy aborted after the tenant received it may have been applied.
231
+ */
232
+ signal?: AbortSignal
233
+ /**
234
+ * A Sysdig rule's runtime policies (a plan entry's `policies`); unset,
235
+ * the tenant's, as `opentide deploy` takes them.
236
+ */
237
+ policies?: Array<string>
238
+ }
239
+
240
+ /** What `deploy` resolves to. */
241
+ export interface DeployOutcome {
242
+ /**
243
+ * The platform's identifier of the rule, which a deploy keeps in its
244
+ * deployment state.
245
+ */
246
+ remoteId: string | null
247
+ /** What was done. */
248
+ operation: 'create' | 'update' | 'disable' | 'delete'
249
+ /**
250
+ * What the deploy raised without failing: the rule is deployed, and
251
+ * these say what to check, as `opentide deploy` warns of them.
252
+ */
253
+ warnings: Array<DeployWarning>
254
+ /**
255
+ * What the deploy did, as the events `opentide deploy` logs at info
256
+ * level (`sysdig_rule_created`): nothing to act on.
257
+ */
258
+ events: Array<DeployEvent>
259
+ }
260
+
261
+ /** What `Workspace.deployPlan` plans: `opentide deploy --dry-run`'s options. */
262
+ export interface DeployPlanOptions {
263
+ /** `--strategy` (repeatable); default `['RELEASE']`. */
264
+ strategies?: Array<'PREVIEW' | 'RELEASE'>
265
+ /** `--uuid`: objects by UUID. */
266
+ uuids?: Array<string>
267
+ /** `--file`: object files. */
268
+ files?: Array<string>
269
+ /** `--platform`: one platform. */
270
+ platform?: string
271
+ /**
272
+ * `--keep-deprecated` (`true`) or `--no-keep-deprecated` (`false`);
273
+ * unset: the configuration's.
274
+ */
275
+ keepDeprecated?: boolean
276
+ /**
277
+ * Where the tenants' `$NAME` credentials are looked up, to say which are
278
+ * unset, as `Connection.open`'s `environment` names the one a connection
279
+ * reads; unset: the process's.
280
+ */
281
+ environment?: Record<string, string>
282
+ }
283
+
284
+ /** A warning a deploy raised: the rule is deployed, with something to check. */
285
+ export interface DeployWarning {
286
+ /** The event `opentide deploy` logs it as (`sysdig_rule_recreated`). */
287
+ code: string
288
+ /** What happened. */
289
+ message: string
290
+ /**
291
+ * Whether it raises the run's warnings, as `opentide deploy` ends with
292
+ * its warnings exit code; `false` for one that only says what was done
293
+ * (`splunk_alert_deleted`).
294
+ */
295
+ raised: boolean
296
+ }
297
+
298
+ /**
299
+ * What `Workspace.lint` runs: `opentide lint`'s options, without `--fix`
300
+ * and `--changed` (the command line's).
301
+ */
302
+ export interface LintOptions {
303
+ /** `--check`; empty runs the checks `lint.toml` enables. */
304
+ checks?: Array<'filenames' | 'metadata' | 'recommended' | 'placeholders' | 'queries'>
305
+ /** `--strict`: any finding fails the run. */
306
+ strict?: boolean
307
+ /** `--file`: object files, by path or by name. */
308
+ files?: Array<string>
309
+ }
310
+
311
+ /** What `validateQuery` resolves to, for a query the tenant accepted. */
312
+ export interface LiveCheck {
313
+ /** The search's answer, when the check ran one. */
314
+ result: QueryResult | null
315
+ /** Why validation still fails the query (Defender's required columns). */
316
+ errors: Array<string>
317
+ /** The tenant's reservations about the verdict. */
318
+ warnings: Array<string>
319
+ }
320
+
321
+ /**
322
+ * Runs `opentide` with `argv` (without the program name) in this process,
323
+ * on its environment, working directory and standard streams, and returns
324
+ * the exit code. The package's `opentide` bin exits with it.
325
+ *
326
+ * Ctrl-C stops the run, which then returns 130 (`error: interrupted`); a
327
+ * second Ctrl-C ends the process at once, as the PyPI CLI does.
328
+ *
329
+ * The promise resolves to the exit code; the run happens off Node's event
330
+ * loop, which keeps serving timers and I/O meanwhile.
331
+ */
332
+ export declare function main(argv: Array<string>): Promise<number>
333
+
334
+ /** How `Workspace.open` opens a workspace. */
335
+ export interface OpenOptions {
336
+ /**
337
+ * The folder paths in findings are shown from (default: the
338
+ * workspace's own folder).
339
+ */
340
+ cwd?: string
341
+ }
342
+
343
+ /** The platforms with a connector, in the order opentide lists them. */
344
+ export declare function platforms(): Array<string>
345
+
346
+ /** A column of a query's rows. */
347
+ export interface QueryColumn {
348
+ /** Its name (`process.name`). */
349
+ name: string
350
+ /** The vendor's type name; `null` when the platform names none. */
351
+ type: string | null
352
+ }
353
+
354
+ /**
355
+ * What `query` and `validateQuery` run: `opentide query`'s options, and
356
+ * the signal that aborts the one operation.
357
+ */
358
+ export interface QueryOptions {
359
+ /**
360
+ * The query's language (`kql`, `esql`, `s1ql`); empty or unset takes the
361
+ * platform's first.
362
+ */
363
+ language?: string
364
+ /**
365
+ * Where the search starts: a `Date` or an RFC 3339 instant
366
+ * (`2026-11-12T09:00:00Z`). Default: 24 hours before `end` for `query`,
367
+ * the minute before `end` for `validateQuery`.
368
+ */
369
+ start?: Date | string
370
+ /** Where the search ends: a `Date` or an RFC 3339 instant. Default: now. */
371
+ end?: Date | string
372
+ /**
373
+ * The most rows to return, 1 to 5000 (default 100); `truncated` says
374
+ * there were more. Anything else rejects with `usage_invalid_value`.
375
+ */
376
+ limit?: number
377
+ /**
378
+ * The Elastic indices, the HarfangLab telemetry source or the
379
+ * CrowdStrike repository.
380
+ */
381
+ index?: Array<string>
382
+ /** Elastic's data view. */
383
+ dataView?: string
384
+ /** How long, in seconds, an asynchronous search may run (default 120). */
385
+ timeout?: number
386
+ /**
387
+ * Aborts this operation alone: when it aborts, the promise rejects with
388
+ * the code `interrupted` and the search is stopped on the tenant where
389
+ * the API allows it; the connection's other operations run on. A signal
390
+ * already aborted rejects at once. (`Connection.canceller` cancels
391
+ * every operation of the connection.)
392
+ */
393
+ signal?: AbortSignal
394
+ }
395
+
396
+ /** What `query` resolves to. */
397
+ export interface QueryResult {
398
+ /** The columns, in order. */
399
+ columns: Array<QueryColumn>
400
+ /**
401
+ * The rows, at most the request's `limit`: each an object of its
402
+ * columns in the order they came.
403
+ */
404
+ rows: Array<Record<string, any>>
405
+ /** More rows matched than the limit let through. */
406
+ truncated: boolean
407
+ /** The platform stopped early and says the rows are incomplete. */
408
+ partial: boolean
409
+ /** The platform's reservations about the result. */
410
+ warnings: Array<string>
411
+ /** The platform's id of the search (CrowdStrike's job id). */
412
+ vendorQueryId: string | null
413
+ /**
414
+ * What was sent, when the connector changed the query (a limit it
415
+ * added).
416
+ */
417
+ sent: string | null
418
+ /** The language the connector used. */
419
+ language: string | null
420
+ }
421
+
422
+ /**
423
+ * Runs `opentide --json <argv>` in this process and returns its JSON
424
+ * document, keys in the command line's order: the envelope (`ok`,
425
+ * `command`, `result`, `failure`, ...) or, for `commands`, the command tree.
426
+ * A command that fails still returns its document, with `ok: false`.
427
+ *
428
+ * The promise rejects with an `Error` whose `code` is `no_json_document`
429
+ * when the command wrote no document (`--version`). The command runs off
430
+ * Node's event loop.
431
+ */
432
+ export declare function runJson(argv: Array<string>): Promise<any>
433
+
434
+ /** What `Workspace.validate` runs: `opentide validate`'s options. */
435
+ export interface ValidateOptions {
436
+ /** `--check`: one check, else the default ones. */
437
+ check?: 'id-uniqueness' | 'uuid-format' | 'schema' | 'cve' | 'sharing-config' | 'configuration' | 'queries'
438
+ /** `--file`: object files, by path or by name. */
439
+ files?: Array<string>
440
+ /** `--uuid`: objects by UUID. */
441
+ uuids?: Array<string>
442
+ /** `--type`: object families (`rule`, `threat`, `objective`). */
443
+ types?: Array<string>
444
+ /** `--strict`: a warning fails the run too. */
445
+ strict?: boolean
446
+ /**
447
+ * `--queries`: a query the engine rejects as an error (the default), a
448
+ * warning, or not checked.
449
+ */
450
+ queries?: 'error' | 'warn' | 'off'
451
+ }
452
+
453
+ /**
454
+ * The version the command line reports (`opentide --version`): the npm
455
+ * package's, which the build passes as `OPENTIDE_BUILD_VERSION`.
456
+ */
457
+ export declare const VERSION: string