@pipeline-builder/api-core 7.2.2 → 7.2.4
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/lib/constants/ai-draft.d.ts +37 -0
- package/lib/constants/ai-draft.js +38 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +2 -1
- package/lib/contracts/pipeline.d.ts +2 -0
- package/lib/contracts/plugin.d.ts +2 -0
- package/lib/contracts/plugin.js +3 -1
- package/lib/services/ai-draft-store.d.ts +79 -0
- package/lib/services/ai-draft-store.js +147 -0
- package/lib/services/cache-service.d.ts +7 -0
- package/lib/services/cache-service.js +10 -1
- package/lib/services/index.d.ts +2 -1
- package/lib/services/index.js +3 -2
- package/lib/services/version-vuln-policy.js +4 -2
- package/lib/types/ecosystem-notifications.d.ts +2 -2
- package/lib/types/ecosystem-notifications.js +7 -2
- package/lib/types/error-codes.d.ts +9 -0
- package/lib/types/error-codes.js +13 -1
- package/lib/types/package-version-order.d.ts +45 -0
- package/lib/types/package-version-order.js +385 -0
- package/lib/types/plugin-remediation.d.ts +102 -26
- package/lib/types/plugin-remediation.js +120 -77
- package/lib/types/plugin-scan.d.ts +9 -0
- package/lib/types/plugin-scan.js +1 -1
- package/lib/types/plugin-secret-files.d.ts +37 -0
- package/lib/types/plugin-secret-files.js +127 -12
- package/lib/types/toolchain-remediation.d.ts +6 -1
- package/lib/types/toolchain-remediation.js +5 -2
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +2 -2
- package/lib/utils/secret-encryption.d.ts +46 -5
- package/lib/utils/secret-encryption.js +139 -32
- package/package.json +1 -1
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nightly plugin CVE remediation (docs/plugin-publishing.md "Scan gates"): the
|
|
3
|
-
* shared vocabulary of the remediation job (plugin service), the pipeline
|
|
4
|
-
* rollout (pipeline service), the settings and the dashboard.
|
|
5
|
-
*
|
|
6
|
-
* A remediation is one record per flagged plugin version (`plugin_remediations`)
|
|
7
|
-
* that moves through {@link PLUGIN_REMEDIATION_STAGES}: Stage 1 rebuilds the
|
|
8
|
-
* version on a freshly pulled base, Stage 2 upgrades the named Critical/High
|
|
9
|
-
* libraries by package type, the fix is published as the next free patch (or
|
|
10
|
-
* minor) version, and Stage 3 moves pipelines onto it.
|
|
11
|
-
*
|
|
12
|
-
* Dependency-free apart from the semver module, so the browser loads it through
|
|
13
|
-
* `@pipeline-builder/api-core/plugin-scan` (which re-exports this module).
|
|
14
|
-
* Nothing here reads the environment: the env NAMES and defaults are constants,
|
|
15
|
-
* and each service reads them with a literal envInt / envBool / envStr call (the env name spelled out) so the
|
|
16
|
-
* env-documented guard sees them.
|
|
17
|
-
*/
|
|
18
1
|
import type { PluginScanFinding, PluginScanFindingLocation } from './plugin-scan.js';
|
|
19
2
|
/**
|
|
20
3
|
* The grype package types remediation knows how to reason about, plus `other`
|
|
@@ -45,6 +28,12 @@ export interface GrypePackageTypeSpec {
|
|
|
45
28
|
overlayHow: string | null;
|
|
46
29
|
/** Shipped in the first patcher wave (deb, apk, npm, python). */
|
|
47
30
|
firstWave: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The ecosystem's version order (negative when `a` is lower; only the sign
|
|
33
|
+
* counts): dpkg for OS packages, PEP 440, Maven ComparableVersion, RubyGems,
|
|
34
|
+
* NuGet, else SemVer (falling back to the dpkg order of the strings).
|
|
35
|
+
*/
|
|
36
|
+
compare: (a: string, b: string) => number;
|
|
48
37
|
}
|
|
49
38
|
export declare const GRYPE_PACKAGE_TYPE_CATALOG: Readonly<Record<GrypePackageType, GrypePackageTypeSpec>>;
|
|
50
39
|
export declare function isGrypePackageType(value: unknown): value is GrypePackageType;
|
|
@@ -109,7 +98,9 @@ export declare const REMEDIATION_REMAINING_REASONS: readonly [
|
|
|
109
98
|
/** A waiver or OpenVEX statement already covers it (never targeted). */
|
|
110
99
|
'waived',
|
|
111
100
|
/** The remediation was cancelled before the finding was handled. */
|
|
112
|
-
'cancelled'
|
|
101
|
+
'cancelled',
|
|
102
|
+
/** grype reported it without a purl or locations (a CPE-only match): nothing to patch or trace to a layer. */
|
|
103
|
+
'no_package_details'];
|
|
113
104
|
export type RemediationRemainingReason = typeof REMEDIATION_REMAINING_REASONS[number];
|
|
114
105
|
export declare const REMEDIATION_REMAINING_REASON_LABELS: Readonly<Record<RemediationRemainingReason, string>>;
|
|
115
106
|
/** Why a fix is held for approval even under `mode = apply`. */
|
|
@@ -164,9 +155,10 @@ export declare function strictestUpgradeLevel(levels: ReadonlyArray<LibraryUpgra
|
|
|
164
155
|
*/
|
|
165
156
|
export declare function effectiveLibraryUpgradeLevel(settings: Pick<PluginRemediationSettings, 'libraryUpgradeLevel' | 'libraryUpgradeLevelByType' | 'libraryUpgradeLevelByPlugin'>, packageType: GrypePackageType, pluginName: string): LibraryUpgradeLevel;
|
|
166
157
|
/**
|
|
167
|
-
* Order two versions of the same package: negative when `a` is lower.
|
|
168
|
-
*
|
|
169
|
-
*
|
|
158
|
+
* Order two versions of the same package: negative when `a` is lower. Each
|
|
159
|
+
* package type's own order ({@link GrypePackageTypeSpec.compare}): dpkg for
|
|
160
|
+
* deb / apk / rpm, PEP 440 for python, Maven ComparableVersion for
|
|
161
|
+
* java-archive, RubyGems for gem, NuGet for dotnet, SemVer for the rest.
|
|
170
162
|
*/
|
|
171
163
|
export declare function comparePackageVersions(a: string, b: string, packageType: GrypePackageType): number;
|
|
172
164
|
/**
|
|
@@ -202,7 +194,8 @@ export interface PackageFixChoice {
|
|
|
202
194
|
}
|
|
203
195
|
/**
|
|
204
196
|
* Group findings by package (purl) and pick, per package, the highest of the
|
|
205
|
-
* lowest fixed versions
|
|
197
|
+
* lowest fixed versions (above the installed one, when any is) across its
|
|
198
|
+
* CVEs — one upgrade that clears all of them.
|
|
206
199
|
* Waived / VEX-covered findings must be filtered out by the caller. Sorted by purl.
|
|
207
200
|
*/
|
|
208
201
|
export declare function chooseFixVersion(findings: readonly PluginScanFinding[]): PackageFixChoice[];
|
|
@@ -219,7 +212,9 @@ export declare function remediationVersionBump(choices: ReadonlyArray<{
|
|
|
219
212
|
requirement: LibraryUpgradeRequirement;
|
|
220
213
|
}>): RemediationVersionBump;
|
|
221
214
|
/**
|
|
222
|
-
* The next FREE version after `fromVersion` (its prerelease/build ignored
|
|
215
|
+
* The next FREE version after `fromVersion` (its prerelease/build ignored;
|
|
216
|
+
* each `taken` version is read through the semver grammar, a leading `v` and
|
|
217
|
+
* build metadata dropped):
|
|
223
218
|
* `patch` → the smallest `M.m.(p+k)` not taken (1.4.3, or 1.4.4 when 1.4.3 is
|
|
224
219
|
* taken); `minor` → the smallest `M.(m+k).0` not taken. Never crosses the
|
|
225
220
|
* major. `taken` should include soft-deleted versions (the name/version is
|
|
@@ -346,7 +341,11 @@ export declare const PIPELINE_REMEDIATION_UPGRADE_STATES: readonly [
|
|
|
346
341
|
/** The owner dismissed the proposal. */
|
|
347
342
|
'dismissed',
|
|
348
343
|
/** A newer fix (or the owner's own version) replaced this one. */
|
|
349
|
-
'superseded'
|
|
344
|
+
'superseded',
|
|
345
|
+
/** apply: the install it moves has another change request pending; resumed once that request is decided. */
|
|
346
|
+
'waiting_change_request',
|
|
347
|
+
/** Moved, but its redeploy did not start (duplicate window, runner refusal): the worker retries it. */
|
|
348
|
+
'moved_pending_redeploy'];
|
|
350
349
|
export type PipelineRemediationUpgradeState = typeof PIPELINE_REMEDIATION_UPGRADE_STATES[number];
|
|
351
350
|
export interface RemediationRolloutWave {
|
|
352
351
|
index: number;
|
|
@@ -370,10 +369,39 @@ export interface RemediationRolloutSummary {
|
|
|
370
369
|
rolledBack: number;
|
|
371
370
|
skippedOptOut: number;
|
|
372
371
|
skippedRunner: number;
|
|
372
|
+
/** Waiting for another change request on their install to be decided. */
|
|
373
|
+
waitingChangeRequest?: number;
|
|
374
|
+
/** Moved, redeploy still being retried. */
|
|
375
|
+
movedPendingRedeploy?: number;
|
|
373
376
|
};
|
|
374
377
|
pausedReason?: RemediationRolloutPauseReason;
|
|
375
378
|
updatedAt: string;
|
|
376
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* `plugin_remediations.error` of a published TENANT fix whose rollout never
|
|
382
|
+
* started and is no longer retried: the pipeline service refused the start
|
|
383
|
+
* (a 4xx other than 408 / 429), or {@link REMEDIATION_ROLLOUT_START_MAX_ATTEMPTS}
|
|
384
|
+
* transient failures (5xx, 408, 429, unreachable) in a row. The row stays
|
|
385
|
+
* `published` (the version is live and choosable); POST …/retry starts it again.
|
|
386
|
+
*/
|
|
387
|
+
export declare const REMEDIATION_ROLLOUT_START_FAILED = "rollout_start_failed";
|
|
388
|
+
/** Start attempts of one tenant rollout, the publish's own included, before the nightly sweep gives up. */
|
|
389
|
+
export declare const REMEDIATION_ROLLOUT_START_MAX_ATTEMPTS = 5;
|
|
390
|
+
/** Why the sweep stopped starting a rollout (the `reason` label of the start-failures counter). */
|
|
391
|
+
export type RemediationRolloutStartGiveUp = 'permanent' | 'exhausted';
|
|
392
|
+
/**
|
|
393
|
+
* The start bookkeeping kept in the `rollout` jsonb of a `published` row
|
|
394
|
+
* (`startAttempts` / `lastStartStatus`, beside a summary once one exists).
|
|
395
|
+
* `lastStatus`: the pipeline service's HTTP status ('503'), or `unreachable`,
|
|
396
|
+
* `invalid_response`, `request_invalid` (refused before it was sent),
|
|
397
|
+
* `not_startable` (no fix version to start).
|
|
398
|
+
*/
|
|
399
|
+
export interface RemediationRolloutStart {
|
|
400
|
+
attempts: number;
|
|
401
|
+
lastStatus: string | null;
|
|
402
|
+
}
|
|
403
|
+
/** The last failed start as one phrase ("Rollout didn't start: <this>"), for the card and the N37 notice. */
|
|
404
|
+
export declare function rolloutStartFailureText(lastStatus: string | null | undefined): string;
|
|
377
405
|
/** Up to this many pipelines in the canary wave, preferring ones that ran successfully in the last {@link REMEDIATION_CANARY_RECENT_DAYS} days. */
|
|
378
406
|
export declare const REMEDIATION_CANARY_SIZE = 5;
|
|
379
407
|
export declare const REMEDIATION_CANARY_RECENT_DAYS = 7;
|
|
@@ -390,7 +418,8 @@ export interface PluginRemediationJobData {
|
|
|
390
418
|
kind: 'plugin-remediation';
|
|
391
419
|
remediationId: string;
|
|
392
420
|
orgId: string;
|
|
393
|
-
|
|
421
|
+
/** Informational (the job reads the row): NULL once the version it fixes was purged, and the job then ends the row. */
|
|
422
|
+
pluginId: string | null;
|
|
394
423
|
pluginName: string;
|
|
395
424
|
fromVersion: string;
|
|
396
425
|
}
|
|
@@ -479,6 +508,8 @@ export declare const PLUGIN_REMEDIATION_METRICS: {
|
|
|
479
508
|
readonly findingsCleared: 'plugin_remediation_findings_cleared_total';
|
|
480
509
|
/** {kind} (object | prefix | image) — a purge delete that failed and landed in plugin_source_orphans. */
|
|
481
510
|
readonly sourceDeleteFailures: 'plugin_source_delete_failures_total';
|
|
511
|
+
/** {reason} (permanent | exhausted) — a published tenant fix whose rollout start was given up. */
|
|
512
|
+
readonly rolloutStartFailures: 'plugin_remediation_rollout_start_failures_total';
|
|
482
513
|
};
|
|
483
514
|
/**
|
|
484
515
|
* RustFS keys in the `plugin-sources` bucket ({@link PLUGIN_REMEDIATION_ENV}.sourcesBucket):
|
|
@@ -514,7 +545,12 @@ export declare const PLUGIN_DELETE_INFLIGHT_WAIT_MS = 600000;
|
|
|
514
545
|
/** One remediation as `GET /plugins/remediations[/:id]` answers it. */
|
|
515
546
|
export interface PluginRemediationDto {
|
|
516
547
|
id: string;
|
|
517
|
-
|
|
548
|
+
/**
|
|
549
|
+
* The version it fixed; NULL once that version was purged (the record of a
|
|
550
|
+
* published fix outlives it: name, version and diff stay readable, but it is
|
|
551
|
+
* never re-run).
|
|
552
|
+
*/
|
|
553
|
+
pluginId: string | null;
|
|
518
554
|
pluginName: string;
|
|
519
555
|
fromVersion: string;
|
|
520
556
|
stage: PluginRemediationStage;
|
|
@@ -534,6 +570,12 @@ export interface PluginRemediationDto {
|
|
|
534
570
|
/** Official only: an export for deploy/plugins/** is stored (GET /plugins/remediations/:id/export, system org). */
|
|
535
571
|
hasExport: boolean;
|
|
536
572
|
rollout: RemediationRolloutSummary | null;
|
|
573
|
+
/**
|
|
574
|
+
* Start attempts of a tenant rollout that has not started yet (null when none
|
|
575
|
+
* failed). With `error` = {@link REMEDIATION_ROLLOUT_START_FAILED} on a
|
|
576
|
+
* `published` row the sweep gave up: Retry starts it again.
|
|
577
|
+
*/
|
|
578
|
+
rolloutStart: RemediationRolloutStart | null;
|
|
537
579
|
/** Pipelines this remediation's rollout moved back (at most 1000; kept beside the rollout summary). */
|
|
538
580
|
rolledBackPipelineIds: string[];
|
|
539
581
|
/** A short error CODE (never raw log text). */
|
|
@@ -590,6 +632,40 @@ export interface PluginDeleteAllResult {
|
|
|
590
632
|
}>;
|
|
591
633
|
skipped: PluginDeleteSkip[];
|
|
592
634
|
}
|
|
635
|
+
/**
|
|
636
|
+
* `DELETE /plugins/by-name/:name` answers 202 with this: the delete (name lock,
|
|
637
|
+
* cancel in-flight builds and remediations, wait for running ones, soft-delete)
|
|
638
|
+
* runs as a background job. `batchId` is the batch the versions are deleted
|
|
639
|
+
* under (Restore plugin / Purge plugin take it); poll `jobId` at
|
|
640
|
+
* `GET /plugins/by-name/:name/delete-jobs/:jobId`.
|
|
641
|
+
*/
|
|
642
|
+
export interface PluginDeleteJobAccepted {
|
|
643
|
+
batchId: string;
|
|
644
|
+
jobId: string;
|
|
645
|
+
}
|
|
646
|
+
export declare const PLUGIN_DELETE_JOB_STATES: readonly ['running', 'succeeded', 'failed'];
|
|
647
|
+
export type PluginDeleteJobState = typeof PLUGIN_DELETE_JOB_STATES[number];
|
|
648
|
+
/** `GET /plugins/by-name/:name/delete-jobs/:jobId` (`plugins:read`). Kept 24 hours. */
|
|
649
|
+
export interface PluginDeleteJobStatus {
|
|
650
|
+
jobId: string;
|
|
651
|
+
name: string;
|
|
652
|
+
batchId: string;
|
|
653
|
+
state: PluginDeleteJobState;
|
|
654
|
+
force: boolean;
|
|
655
|
+
startedAt: string;
|
|
656
|
+
finishedAt: string | null;
|
|
657
|
+
/** Filled once `state` is `succeeded`. */
|
|
658
|
+
deleted: Array<{
|
|
659
|
+
id: string;
|
|
660
|
+
version: string;
|
|
661
|
+
}>;
|
|
662
|
+
skipped: PluginDeleteSkip[];
|
|
663
|
+
/** Set when `state` is `failed`: the error code (when typed) and message. A job whose worker stopped reporting is failed with code null. */
|
|
664
|
+
error: {
|
|
665
|
+
code: string | null;
|
|
666
|
+
message: string;
|
|
667
|
+
} | null;
|
|
668
|
+
}
|
|
593
669
|
/** `POST /plugins/by-name/:name/restore` and `/purge` (`?batchId=` required). */
|
|
594
670
|
export interface PluginBatchActionResult {
|
|
595
671
|
batchId: string;
|