@pipeline-builder/api-core 7.2.0 → 7.2.2
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/contracts/pipeline.d.ts +71 -0
- package/lib/contracts/pipeline.js +76 -1
- package/lib/contracts/platform.d.ts +11 -0
- package/lib/contracts/platform.js +19 -1
- package/lib/contracts/plugin.d.ts +70 -0
- package/lib/contracts/plugin.js +57 -1
- package/lib/types/ecosystem-notifications.d.ts +36 -1
- package/lib/types/ecosystem-notifications.js +16 -2
- package/lib/types/error-codes.d.ts +10 -0
- package/lib/types/error-codes.js +14 -1
- package/lib/types/feature-flags.js +5 -4
- package/lib/types/index.d.ts +3 -1
- package/lib/types/index.js +5 -1
- package/lib/types/plugin-remediation.d.ts +605 -0
- package/lib/types/plugin-remediation.js +778 -0
- package/lib/types/plugin-scan.d.ts +35 -0
- package/lib/types/plugin-scan.js +5 -16
- package/lib/types/plugin-wire.d.ts +24 -0
- package/lib/types/plugin-wire.js +1 -1
- package/lib/types/remote-audit-actions.d.ts +1 -1
- package/lib/types/remote-audit-actions.js +50 -1
- package/lib/types/toolchain-remediation.d.ts +204 -0
- package/lib/types/toolchain-remediation.js +91 -0
- package/lib/utils/identity.d.ts +15 -0
- package/lib/utils/identity.js +16 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/lib/utils/plugin-remediation-hash.d.ts +8 -0
- package/lib/utils/plugin-remediation-hash.js +14 -0
- package/lib/validation/index.d.ts +1 -0
- package/lib/validation/index.js +2 -1
- package/lib/validation/pipeline-schemas.d.ts +12 -0
- package/lib/validation/pipeline-schemas.js +30 -1
- package/lib/validation/plugin-remediation-schemas.d.ts +74 -0
- package/lib/validation/plugin-remediation-schemas.js +41 -0
- package/package.json +1 -1
|
@@ -0,0 +1,605 @@
|
|
|
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
|
+
import type { PluginScanFinding, PluginScanFindingLocation } from './plugin-scan.js';
|
|
19
|
+
/**
|
|
20
|
+
* The grype package types remediation knows how to reason about, plus `other`
|
|
21
|
+
* for anything grype reports that is not in this list (no patcher, no overlay:
|
|
22
|
+
* it always goes to the owner request).
|
|
23
|
+
*/
|
|
24
|
+
export declare const GRYPE_PACKAGE_TYPES: readonly ['deb', 'apk', 'rpm', 'npm', 'python', 'go-module', 'java-archive', 'gem', 'rust-crate', 'dotnet', 'binary', 'other'];
|
|
25
|
+
export type GrypePackageType = typeof GRYPE_PACKAGE_TYPES[number];
|
|
26
|
+
/** How a source patch is possible for a package type. */
|
|
27
|
+
export type SourcePatchSupport =
|
|
28
|
+
/** Edit a manifest / lockfile / Dockerfile install line in the kept build context. */
|
|
29
|
+
'yes'
|
|
30
|
+
/** Only when the Dockerfile pins the tool's version with a recognised ARG. */
|
|
31
|
+
| 'pinned-arg' | 'no';
|
|
32
|
+
/** What the patchers need to know about one package type. */
|
|
33
|
+
export interface GrypePackageTypeSpec {
|
|
34
|
+
label: string;
|
|
35
|
+
/** A distro package: the upgrade level applies to the upstream version, a revision bump is a patch, an epoch change a major. */
|
|
36
|
+
osPackage: boolean;
|
|
37
|
+
/** Compiled into a binary: a fix needs a source rebuild; no overlay. */
|
|
38
|
+
compiled: boolean;
|
|
39
|
+
sourcePatch: SourcePatchSupport;
|
|
40
|
+
/** An overlay layer (`FROM <digest>` + one RUN upgrading the package in place) can fix it. */
|
|
41
|
+
overlay: boolean;
|
|
42
|
+
/** What the source patch does (docs / owner request copy). */
|
|
43
|
+
sourcePatchHow: string | null;
|
|
44
|
+
/** What the overlay RUN does, with `pkg` / `<fixed>` placeholders; null when no overlay is possible. */
|
|
45
|
+
overlayHow: string | null;
|
|
46
|
+
/** Shipped in the first patcher wave (deb, apk, npm, python). */
|
|
47
|
+
firstWave: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare const GRYPE_PACKAGE_TYPE_CATALOG: Readonly<Record<GrypePackageType, GrypePackageTypeSpec>>;
|
|
50
|
+
export declare function isGrypePackageType(value: unknown): value is GrypePackageType;
|
|
51
|
+
/** grype's raw `artifact.type` as a {@link GrypePackageType} (anything uncatalogued is `other`). */
|
|
52
|
+
export declare function toGrypePackageType(raw: string | null | undefined): GrypePackageType;
|
|
53
|
+
export declare const PLUGIN_REMEDIATION_STAGES: readonly ['queued', 'rebuild', 'libraries', 'awaiting_approval', 'published', 'rolling_out', 'done', 'needs_owner', 'needs_review', 'failed'];
|
|
54
|
+
export type PluginRemediationStage = typeof PLUGIN_REMEDIATION_STAGES[number];
|
|
55
|
+
/** Building, waiting or rolling out: at most one row per (plugin_id, findings_hash) in these (unique index). */
|
|
56
|
+
export declare const LIVE_REMEDIATION_STAGES: readonly ["queued", "rebuild", "libraries", "awaiting_approval", "published", "rolling_out", "needs_review"];
|
|
57
|
+
/** Before publish: at most ONE row per plugin version in these (unique index) — a version is never remediated twice at once. */
|
|
58
|
+
export declare const ACTIVE_BUILD_REMEDIATION_STAGES: readonly ["queued", "rebuild", "libraries", "awaiting_approval"];
|
|
59
|
+
/** Finished: nothing more happens unless someone retries. */
|
|
60
|
+
export declare const TERMINAL_REMEDIATION_STAGES: readonly ["done", "needs_owner", "failed"];
|
|
61
|
+
export declare const PLUGIN_REMEDIATION_STAGE_LABELS: Readonly<Record<PluginRemediationStage, string>>;
|
|
62
|
+
export declare function isPluginRemediationStage(value: unknown): value is PluginRemediationStage;
|
|
63
|
+
/** Why a remediation ended where it did (the `outcome` column and the metric label). */
|
|
64
|
+
export declare const PLUGIN_REMEDIATION_OUTCOMES: readonly [
|
|
65
|
+
/** Every targeted finding cleared. */
|
|
66
|
+
'cleared',
|
|
67
|
+
/** A fix was published, some findings went to the owner request. */
|
|
68
|
+
'partial',
|
|
69
|
+
/** Nothing could be fixed automatically; the owner request lists every finding. */
|
|
70
|
+
'owner_request',
|
|
71
|
+
/** A propose-mode fix was rejected by a plugins:write approver. */
|
|
72
|
+
'rejected',
|
|
73
|
+
/** Cancelled: the version was deleted, or the name deleted. */
|
|
74
|
+
'cancelled',
|
|
75
|
+
/** The owner uploaded a newer clean version; Stage 3 rolls that one out instead. */
|
|
76
|
+
'superseded',
|
|
77
|
+
/** The job itself failed (checksum mismatch, build infrastructure, internal error). */
|
|
78
|
+
'error'];
|
|
79
|
+
export type PluginRemediationOutcome = typeof PLUGIN_REMEDIATION_OUTCOMES[number];
|
|
80
|
+
/** How a finding was cleared. */
|
|
81
|
+
export declare const REMEDIATION_FIX_METHODS: readonly ['rebuild', 'source_patch', 'overlay', 'ask_agent'];
|
|
82
|
+
export type RemediationFixMethod = typeof REMEDIATION_FIX_METHODS[number];
|
|
83
|
+
/** Why a finding is left for the owner (each `remaining` entry carries one). */
|
|
84
|
+
export declare const REMEDIATION_REMAINING_REASONS: readonly [
|
|
85
|
+
/** grype reports no fixed version. */
|
|
86
|
+
'no_fix',
|
|
87
|
+
/** The fix needs a bigger library jump than the effective upgrade level allows (`requiredLevel` names it). */
|
|
88
|
+
'beyond_upgrade_level',
|
|
89
|
+
/** A Go module's fix is a new major (`/vN` module path): always the owner's change. */
|
|
90
|
+
'go_module_major',
|
|
91
|
+
/** Compiled into a binary and the version has no kept source to rebuild. */
|
|
92
|
+
'compiled_binary',
|
|
93
|
+
/** No kept source and no overlay possible for this package type. */
|
|
94
|
+
'no_source',
|
|
95
|
+
/** No patcher fits the package type or the build layout (and the ask-agent draft did not help). */
|
|
96
|
+
'no_patcher',
|
|
97
|
+
/** The patched build failed the contract check, the smokeTest, or changed user / entrypoint / commands. */
|
|
98
|
+
'patch_broke_plugin',
|
|
99
|
+
/** The patch touched more than the named packages' lines or one overlay layer. */
|
|
100
|
+
'patch_out_of_scope',
|
|
101
|
+
/** The patched image has a Critical/High the original version did not. */
|
|
102
|
+
'new_findings',
|
|
103
|
+
/** The patch applied and built, but the rescan still reports the finding. */
|
|
104
|
+
'still_present',
|
|
105
|
+
/** The rebuild / patched build failed. */
|
|
106
|
+
'build_failed',
|
|
107
|
+
/** A listed third-party plugin: the platform sends the publisher a fix request instead. */
|
|
108
|
+
'third_party_listing',
|
|
109
|
+
/** A waiver or OpenVEX statement already covers it (never targeted). */
|
|
110
|
+
'waived',
|
|
111
|
+
/** The remediation was cancelled before the finding was handled. */
|
|
112
|
+
'cancelled'];
|
|
113
|
+
export type RemediationRemainingReason = typeof REMEDIATION_REMAINING_REASONS[number];
|
|
114
|
+
export declare const REMEDIATION_REMAINING_REASON_LABELS: Readonly<Record<RemediationRemainingReason, string>>;
|
|
115
|
+
/** Why a fix is held for approval even under `mode = apply`. */
|
|
116
|
+
export declare const REMEDIATION_PROPOSE_REASONS: readonly [
|
|
117
|
+
/** The org's pluginRemediation.mode is `propose`. */
|
|
118
|
+
'org_mode',
|
|
119
|
+
/** A library crosses a major version (major upgrades are propose-only). */
|
|
120
|
+
'major_upgrade',
|
|
121
|
+
/** The plugin declares no smokeTest. */
|
|
122
|
+
'no_smoke_test',
|
|
123
|
+
/** The patch was drafted by the ask agent. */
|
|
124
|
+
'ask_agent_patch'];
|
|
125
|
+
export type RemediationProposeReason = typeof REMEDIATION_PROPOSE_REASONS[number];
|
|
126
|
+
/** A finding the remediation cleared. */
|
|
127
|
+
export interface RemediationClearedFinding {
|
|
128
|
+
id: string;
|
|
129
|
+
purl: string;
|
|
130
|
+
packageName: string;
|
|
131
|
+
packageType: GrypePackageType;
|
|
132
|
+
fromVersion: string;
|
|
133
|
+
/** The library version now installed; null when a rebuild removed the package. */
|
|
134
|
+
toVersion: string | null;
|
|
135
|
+
method: RemediationFixMethod;
|
|
136
|
+
}
|
|
137
|
+
/** A finding left for the owner, with why. */
|
|
138
|
+
export interface RemediationRemainingFinding {
|
|
139
|
+
id: string;
|
|
140
|
+
severity: 'critical' | 'high';
|
|
141
|
+
purl: string;
|
|
142
|
+
packageName: string;
|
|
143
|
+
packageType: GrypePackageType;
|
|
144
|
+
packageVersion: string;
|
|
145
|
+
fixedIn: string[];
|
|
146
|
+
kev?: boolean;
|
|
147
|
+
reason: RemediationRemainingReason;
|
|
148
|
+
/** For `beyond_upgrade_level`: the level the fix would need. */
|
|
149
|
+
requiredLevel?: LibraryUpgradeRequirement;
|
|
150
|
+
/** Short operator-facing detail (a build error CODE, the failing check). Never log text, source or secrets. */
|
|
151
|
+
detail?: string;
|
|
152
|
+
}
|
|
153
|
+
export declare const LIBRARY_UPGRADE_LEVELS: readonly ['patch', 'minor', 'major'];
|
|
154
|
+
export type LibraryUpgradeLevel = typeof LIBRARY_UPGRADE_LEVELS[number];
|
|
155
|
+
/** What a move needs: a level, or `owner` when no level allows it (a Go /vN module path). */
|
|
156
|
+
export type LibraryUpgradeRequirement = LibraryUpgradeLevel | 'owner';
|
|
157
|
+
export declare const DEFAULT_LIBRARY_UPGRADE_LEVEL: LibraryUpgradeLevel;
|
|
158
|
+
export declare function isLibraryUpgradeLevel(value: unknown): value is LibraryUpgradeLevel;
|
|
159
|
+
/** The strictest of the given levels (absent ones ignored); `fallback` when none is given. */
|
|
160
|
+
export declare function strictestUpgradeLevel(levels: ReadonlyArray<LibraryUpgradeLevel | null | undefined>, fallback?: LibraryUpgradeLevel): LibraryUpgradeLevel;
|
|
161
|
+
/**
|
|
162
|
+
* The level that applies to one library of one plugin: the strictest of the
|
|
163
|
+
* org level, the org's per-package-type level and the plugin's own level.
|
|
164
|
+
*/
|
|
165
|
+
export declare function effectiveLibraryUpgradeLevel(settings: Pick<PluginRemediationSettings, 'libraryUpgradeLevel' | 'libraryUpgradeLevelByType' | 'libraryUpgradeLevelByPlugin'>, packageType: GrypePackageType, pluginName: string): LibraryUpgradeLevel;
|
|
166
|
+
/**
|
|
167
|
+
* Order two versions of the same package: negative when `a` is lower.
|
|
168
|
+
* OS packages compare epoch, then upstream, then revision (dpkg order); others
|
|
169
|
+
* use SemVer precedence when both parse, else the dpkg order of the strings.
|
|
170
|
+
*/
|
|
171
|
+
export declare function comparePackageVersions(a: string, b: string, packageType: GrypePackageType): number;
|
|
172
|
+
/**
|
|
173
|
+
* The upgrade level moving a library from `installed` to `candidate` needs:
|
|
174
|
+
*
|
|
175
|
+
* - OS packages (deb, apk, rpm): the level applies to the UPSTREAM version; a
|
|
176
|
+
* distro revision of the same upstream (`1.1.1n-0+deb11u5` → `…u6`) is a
|
|
177
|
+
* patch, and an epoch change is a major.
|
|
178
|
+
* - 0.x: a minor bump counts as major (semver: 0.x minors may break).
|
|
179
|
+
* - Go modules: a new major of v2 or above is a different module path (`/vN`),
|
|
180
|
+
* so it is always the owner's change (`owner`), whatever the level.
|
|
181
|
+
* - Non-semver versions (dates, four-part numbers): the first three numeric
|
|
182
|
+
* parts; a version that can't be parsed counts as a major upgrade.
|
|
183
|
+
* - A candidate that is not above `installed` moves nothing: `patch`.
|
|
184
|
+
*/
|
|
185
|
+
export declare function libraryUpgradeRequirement(installed: string, candidate: string, packageType: GrypePackageType): LibraryUpgradeRequirement;
|
|
186
|
+
/** Whether `level` allows moving a library from `installed` to `candidate`. */
|
|
187
|
+
export declare function libraryUpgradeAllowed(installed: string, candidate: string, level: LibraryUpgradeLevel, packageType: GrypePackageType): boolean;
|
|
188
|
+
/** One package (purl) and the single version that clears all of its fixable findings. */
|
|
189
|
+
export interface PackageFixChoice {
|
|
190
|
+
purl: string;
|
|
191
|
+
packageName: string;
|
|
192
|
+
packageType: GrypePackageType;
|
|
193
|
+
installedVersion: string;
|
|
194
|
+
/** The highest of the lowest fixed versions across its CVEs; null when none of them has a fix. */
|
|
195
|
+
fixVersion: string | null;
|
|
196
|
+
/** Findings `fixVersion` clears (sorted). */
|
|
197
|
+
findingIds: string[];
|
|
198
|
+
/** Findings with no fixed version (sorted). */
|
|
199
|
+
noFixIds: string[];
|
|
200
|
+
kev: boolean;
|
|
201
|
+
locations: PluginScanFindingLocation[];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Group findings by package (purl) and pick, per package, the highest of the
|
|
205
|
+
* lowest fixed versions across its CVEs — one upgrade that clears all of them.
|
|
206
|
+
* Waived / VEX-covered findings must be filtered out by the caller. Sorted by purl.
|
|
207
|
+
*/
|
|
208
|
+
export declare function chooseFixVersion(findings: readonly PluginScanFinding[]): PackageFixChoice[];
|
|
209
|
+
/**
|
|
210
|
+
* The canonical text of a targeted findings set, for `findings_hash`
|
|
211
|
+
* (sha256 of this, see `remediationFindingsHash` in the root barrel). It
|
|
212
|
+
* includes each finding's fixed versions, so a vulnerability-DB update that
|
|
213
|
+
* adds a fix changes the hash and lets a failed set be retried.
|
|
214
|
+
*/
|
|
215
|
+
export declare function remediationFindingsKey(findings: ReadonlyArray<Pick<PluginScanFinding, 'id' | 'purl' | 'packageVersion' | 'fixedIn'>>): string;
|
|
216
|
+
/** How the plugin version moves: patch and minor library upgrades → next patch; a major library upgrade → next minor. */
|
|
217
|
+
export type RemediationVersionBump = 'patch' | 'minor';
|
|
218
|
+
export declare function remediationVersionBump(choices: ReadonlyArray<{
|
|
219
|
+
requirement: LibraryUpgradeRequirement;
|
|
220
|
+
}>): RemediationVersionBump;
|
|
221
|
+
/**
|
|
222
|
+
* The next FREE version after `fromVersion` (its prerelease/build ignored):
|
|
223
|
+
* `patch` → the smallest `M.m.(p+k)` not taken (1.4.3, or 1.4.4 when 1.4.3 is
|
|
224
|
+
* taken); `minor` → the smallest `M.(m+k).0` not taken. Never crosses the
|
|
225
|
+
* major. `taken` should include soft-deleted versions (the name/version is
|
|
226
|
+
* still reserved by their rows). Null when `fromVersion` is not semver.
|
|
227
|
+
*/
|
|
228
|
+
export declare function nextRemediationVersion(fromVersion: string, taken: Iterable<string>, bump: RemediationVersionBump): string | null;
|
|
229
|
+
/** pluginRemediation.mode — building and publishing fixes. */
|
|
230
|
+
export declare const PLUGIN_REMEDIATION_MODES: readonly ['off', 'propose', 'apply'];
|
|
231
|
+
export type PluginRemediationMode = typeof PLUGIN_REMEDIATION_MODES[number];
|
|
232
|
+
/** pluginRemediation.rollout on a ROOT org. */
|
|
233
|
+
export declare const PLUGIN_REMEDIATION_ROLLOUTS: readonly ['off', 'propose', 'apply'];
|
|
234
|
+
export type PluginRemediationRollout = typeof PLUGIN_REMEDIATION_ROLLOUTS[number];
|
|
235
|
+
/** pluginRemediation.rollout on a TEAM (sub-organization); `inherit` = the root org's. */
|
|
236
|
+
export declare const TEAM_REMEDIATION_ROLLOUTS: readonly ['inherit', 'off', 'propose', 'apply'];
|
|
237
|
+
export type TeamRemediationRollout = typeof TEAM_REMEDIATION_ROLLOUTS[number];
|
|
238
|
+
/** pipelines.remediation_upgrades — a pipeline's election. */
|
|
239
|
+
export declare const PIPELINE_REMEDIATION_ELECTIONS: readonly ['inherit', 'off', 'propose', 'apply'];
|
|
240
|
+
export type PipelineRemediationElection = typeof PIPELINE_REMEDIATION_ELECTIONS[number];
|
|
241
|
+
export declare const DEFAULT_PLUGIN_REMEDIATION_MODE: PluginRemediationMode;
|
|
242
|
+
export declare const DEFAULT_ROOT_REMEDIATION_ROLLOUT: PluginRemediationRollout;
|
|
243
|
+
export declare const DEFAULT_TEAM_REMEDIATION_ROLLOUT: TeamRemediationRollout;
|
|
244
|
+
export declare const DEFAULT_PIPELINE_REMEDIATION_ELECTION: PipelineRemediationElection;
|
|
245
|
+
export declare const isPluginRemediationMode: (v: unknown) => v is PluginRemediationMode;
|
|
246
|
+
export declare const isTeamRemediationRollout: (v: unknown) => v is TeamRemediationRollout;
|
|
247
|
+
export declare const isPipelineRemediationElection: (v: unknown) => v is PipelineRemediationElection;
|
|
248
|
+
/**
|
|
249
|
+
* An org's pluginRemediation settings, as every service reads them
|
|
250
|
+
* (`plugin_remediation_settings`, one row per org; absent = the defaults).
|
|
251
|
+
*/
|
|
252
|
+
export interface PluginRemediationSettings {
|
|
253
|
+
mode: PluginRemediationMode;
|
|
254
|
+
libraryUpgradeLevel: LibraryUpgradeLevel;
|
|
255
|
+
/** Per package type; the strictest of this, the org level and the plugin's own level applies. */
|
|
256
|
+
libraryUpgradeLevelByType: Partial<Record<GrypePackageType, LibraryUpgradeLevel>>;
|
|
257
|
+
/** Per plugin NAME (set from the plugin's settings with plugins:write); absent = "Follow organization". */
|
|
258
|
+
libraryUpgradeLevelByPlugin: Record<string, LibraryUpgradeLevel>;
|
|
259
|
+
/** Root org: off | propose | apply (never inherit). Team: inherit (default) | off | propose | apply. */
|
|
260
|
+
rollout: TeamRemediationRollout;
|
|
261
|
+
/** Root org only: whether a pipeline may elect `apply` when its org default is propose or off. */
|
|
262
|
+
allowPipelineApply: boolean;
|
|
263
|
+
}
|
|
264
|
+
export declare const DEFAULT_PLUGIN_REMEDIATION_SETTINGS: Readonly<PluginRemediationSettings>;
|
|
265
|
+
/** The stored row's fields (drizzle camelCase); every field optional, `rollout` NULL = the default for the org kind. */
|
|
266
|
+
export interface PluginRemediationSettingsRowLike {
|
|
267
|
+
mode?: unknown;
|
|
268
|
+
libraryUpgradeLevel?: unknown;
|
|
269
|
+
libraryUpgradeLevelByType?: unknown;
|
|
270
|
+
libraryUpgradeLevelByPlugin?: unknown;
|
|
271
|
+
rollout?: unknown;
|
|
272
|
+
allowPipelineApply?: unknown;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The effective settings of one org from its row (null = no row). Tolerant: an
|
|
276
|
+
* unknown stored value falls back to its default. A root org's `inherit` (or
|
|
277
|
+
* NULL) rollout reads as `propose`; a team's NULL reads as `inherit`.
|
|
278
|
+
*/
|
|
279
|
+
export declare function normalizePluginRemediationSettings(row: PluginRemediationSettingsRowLike | null | undefined, opts: {
|
|
280
|
+
isTeam: boolean;
|
|
281
|
+
}): PluginRemediationSettings;
|
|
282
|
+
/**
|
|
283
|
+
* Whether a fix is published automatically (`apply`) or held for a
|
|
284
|
+
* plugins:write approval with step-up (`propose`), and why it is held.
|
|
285
|
+
* `off` builds nothing.
|
|
286
|
+
*/
|
|
287
|
+
export declare function remediationPublishMode(orgMode: PluginRemediationMode, facts: {
|
|
288
|
+
majorUpgrade: boolean;
|
|
289
|
+
hasSmokeTest: boolean;
|
|
290
|
+
askAgentPatch: boolean;
|
|
291
|
+
}): {
|
|
292
|
+
mode: PluginRemediationMode;
|
|
293
|
+
proposeReasons: RemediationProposeReason[];
|
|
294
|
+
};
|
|
295
|
+
/** Where a pipeline's effective rollout mode came from. */
|
|
296
|
+
export type RemediationRolloutSource = 'pipeline' | 'team' | 'root';
|
|
297
|
+
export interface ResolvedRemediationRollout {
|
|
298
|
+
mode: PluginRemediationRollout;
|
|
299
|
+
source: RemediationRolloutSource;
|
|
300
|
+
/** The org default the pipeline inherits (team's own, else the root's). */
|
|
301
|
+
orgDefault: PluginRemediationRollout;
|
|
302
|
+
/** The pipeline elected `apply` but its root org disallows it under this default: resolved to `propose`. */
|
|
303
|
+
applyRefused: boolean;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* A pipeline's effective Stage 3 mode. The most specific setting wins:
|
|
307
|
+
* pipeline, then its own org when that is a team, then the root org. `off` on
|
|
308
|
+
* the pipeline always wins (opting out is always allowed). A pipeline `apply`
|
|
309
|
+
* is honoured only when the org default is `apply` or the root allows pipeline
|
|
310
|
+
* apply; otherwise it resolves to `propose` (`applyRefused`). Re-run before
|
|
311
|
+
* every wave AND just before moving each pipeline.
|
|
312
|
+
*/
|
|
313
|
+
export declare function resolveRemediationRollout(input: {
|
|
314
|
+
pipeline: PipelineRemediationElection;
|
|
315
|
+
/** The pipeline's org setting when that org is a TEAM; null/undefined for a root org's pipeline. */
|
|
316
|
+
team?: TeamRemediationRollout | null;
|
|
317
|
+
root: PluginRemediationRollout;
|
|
318
|
+
allowPipelineApply: boolean;
|
|
319
|
+
}): ResolvedRemediationRollout;
|
|
320
|
+
/** Whether a pipeline may store `election` (the pipeline update route's check; 403 PIPELINE_REMEDIATION_APPLY_NOT_ALLOWED otherwise). */
|
|
321
|
+
export declare function pipelineElectionAllowed(election: PipelineRemediationElection, orgDefault: PluginRemediationRollout, allowPipelineApply: boolean): boolean;
|
|
322
|
+
export declare const REMEDIATION_ROLLOUT_STATUSES: readonly ['pending', 'canary', 'batches', 'done', 'paused', 'cancelled'];
|
|
323
|
+
export type RemediationRolloutStatus = typeof REMEDIATION_ROLLOUT_STATUSES[number];
|
|
324
|
+
export declare const REMEDIATION_ROLLOUT_PAUSE_REASONS: readonly ['canary_failed', 'rollbacks', 'rollback_target_deleted'];
|
|
325
|
+
export type RemediationRolloutPauseReason = typeof REMEDIATION_ROLLOUT_PAUSE_REASONS[number];
|
|
326
|
+
/** Per-pipeline state of a rollout (`pipeline_remediation_upgrades.state`). */
|
|
327
|
+
export declare const PIPELINE_REMEDIATION_UPGRADE_STATES: readonly [
|
|
328
|
+
/** propose: an upgrade proposal is open on the pipeline page. */
|
|
329
|
+
'proposed',
|
|
330
|
+
/** Approval-gated install (plugin_installs:manage): a change request instead of a move. */
|
|
331
|
+
'change_requested',
|
|
332
|
+
/** apply: waiting for its wave. */
|
|
333
|
+
'queued',
|
|
334
|
+
/** Moved to the fix version (and redeployed). */
|
|
335
|
+
'moved',
|
|
336
|
+
/** The move failed (validation, compliance, concurrent edit). */
|
|
337
|
+
'failed',
|
|
338
|
+
/** Moved back after a failed run on a step using the new version. */
|
|
339
|
+
'rolled_back',
|
|
340
|
+
/** A rollback was needed but the previous version is no longer live (or is KEV-flagged without an acceptance): paused, owners told. */
|
|
341
|
+
'rollback_blocked',
|
|
342
|
+
/** The pipeline elected off. */
|
|
343
|
+
'skipped_opt_out',
|
|
344
|
+
/** The org's runner was unhealthy; retried in a later wave. */
|
|
345
|
+
'skipped_runner',
|
|
346
|
+
/** The owner dismissed the proposal. */
|
|
347
|
+
'dismissed',
|
|
348
|
+
/** A newer fix (or the owner's own version) replaced this one. */
|
|
349
|
+
'superseded'];
|
|
350
|
+
export type PipelineRemediationUpgradeState = typeof PIPELINE_REMEDIATION_UPGRADE_STATES[number];
|
|
351
|
+
export interface RemediationRolloutWave {
|
|
352
|
+
index: number;
|
|
353
|
+
kind: 'canary' | 'batch';
|
|
354
|
+
pipelineIds: string[];
|
|
355
|
+
startedAt: string;
|
|
356
|
+
finishedAt: string | null;
|
|
357
|
+
outcome: 'running' | 'succeeded' | 'failed';
|
|
358
|
+
}
|
|
359
|
+
/** `plugin_remediations.rollout`, written by the plugin service from the pipeline service's reports. */
|
|
360
|
+
export interface RemediationRolloutSummary {
|
|
361
|
+
status: RemediationRolloutStatus;
|
|
362
|
+
toVersion: string;
|
|
363
|
+
waves: RemediationRolloutWave[];
|
|
364
|
+
counts: {
|
|
365
|
+
eligible: number;
|
|
366
|
+
proposed: number;
|
|
367
|
+
changeRequested: number;
|
|
368
|
+
moved: number;
|
|
369
|
+
failed: number;
|
|
370
|
+
rolledBack: number;
|
|
371
|
+
skippedOptOut: number;
|
|
372
|
+
skippedRunner: number;
|
|
373
|
+
};
|
|
374
|
+
pausedReason?: RemediationRolloutPauseReason;
|
|
375
|
+
updatedAt: string;
|
|
376
|
+
}
|
|
377
|
+
/** Up to this many pipelines in the canary wave, preferring ones that ran successfully in the last {@link REMEDIATION_CANARY_RECENT_DAYS} days. */
|
|
378
|
+
export declare const REMEDIATION_CANARY_SIZE = 5;
|
|
379
|
+
export declare const REMEDIATION_CANARY_RECENT_DAYS = 7;
|
|
380
|
+
/** Batch size after the canary (the apply route's limit). */
|
|
381
|
+
export declare const REMEDIATION_BATCH_SIZE = 50;
|
|
382
|
+
/** A failed run on a step using the new version within this window rolls the pipeline back. */
|
|
383
|
+
export declare const REMEDIATION_ROLLBACK_WINDOW_MS: number;
|
|
384
|
+
/** Rollbacks in one rollout that pause it and mark the remediation needs_review. */
|
|
385
|
+
export declare const REMEDIATION_MAX_ROLLBACKS = 2;
|
|
386
|
+
/** The BullMQ job name, on the org's plugin build tier queue. */
|
|
387
|
+
export declare const PLUGIN_REMEDIATION_JOB_NAME = "plugin-remediation";
|
|
388
|
+
/** The job payload. Everything else is read from the `plugin_remediations` row. */
|
|
389
|
+
export interface PluginRemediationJobData {
|
|
390
|
+
kind: 'plugin-remediation';
|
|
391
|
+
remediationId: string;
|
|
392
|
+
orgId: string;
|
|
393
|
+
pluginId: string;
|
|
394
|
+
pluginName: string;
|
|
395
|
+
fromVersion: string;
|
|
396
|
+
}
|
|
397
|
+
/** Job id = idempotency key: one job per remediation row. */
|
|
398
|
+
export declare function pluginRemediationJobId(remediationId: string): string;
|
|
399
|
+
export interface RemediationPriorityInput {
|
|
400
|
+
kev: boolean;
|
|
401
|
+
/** Highest EPSS (0–1) among the targeted findings; 0 when unknown. */
|
|
402
|
+
maxEpss: number;
|
|
403
|
+
/** Pipelines using the version. */
|
|
404
|
+
pipelineCount: number;
|
|
405
|
+
}
|
|
406
|
+
/** KEV first, then EPSS, then the number of pipelines using the version. Negative when `a` runs first. */
|
|
407
|
+
export declare function compareRemediationPriority(a: RemediationPriorityInput, b: RemediationPriorityInput): number;
|
|
408
|
+
/**
|
|
409
|
+
* The BullMQ `priority` of a remediation job (lower runs first; always >= 1,
|
|
410
|
+
* so un-prioritised user builds run before every remediation).
|
|
411
|
+
*/
|
|
412
|
+
export declare function remediationQueuePriority(p: RemediationPriorityInput): number;
|
|
413
|
+
/** The severities remediation may target (PLUGIN_REMEDIATION_SEVERITIES). */
|
|
414
|
+
export declare const REMEDIATION_SEVERITIES: readonly ['critical', 'high'];
|
|
415
|
+
export type RemediationSeverity = typeof REMEDIATION_SEVERITIES[number];
|
|
416
|
+
export declare const DEFAULT_REMEDIATION_SEVERITIES: readonly RemediationSeverity[];
|
|
417
|
+
/**
|
|
418
|
+
* PLUGIN_REMEDIATION_SEVERITIES: a comma list of `critical` / `high`
|
|
419
|
+
* (case-insensitive, whitespace and duplicates ignored), in catalog order.
|
|
420
|
+
* Unset or blank → the default (both). Any unknown entry, or a list with no
|
|
421
|
+
* valid entry, → the default plus ONE `warn` call naming the value.
|
|
422
|
+
*/
|
|
423
|
+
export declare function parseRemediationSeverities(raw: string | undefined | null, warn?: (message: string) => void): RemediationSeverity[];
|
|
424
|
+
/** PLUGIN_REMEDIATION_ENABLED: on unless the value is exactly `false` (trimmed, case-insensitive). */
|
|
425
|
+
export declare function parseRemediationEnabled(raw: string | undefined | null): boolean;
|
|
426
|
+
/**
|
|
427
|
+
* Whether remediation targets a finding: it has a fixed version and its
|
|
428
|
+
* severity is in `severities` — or it is KEV-listed, which is always targeted
|
|
429
|
+
* (a KEV finding with no fix still goes to the owner request with `no_fix`).
|
|
430
|
+
*/
|
|
431
|
+
export declare function isRemediationTarget(f: Pick<PluginScanFinding, 'severity' | 'fixedIn' | 'kev'>, severities: readonly RemediationSeverity[]): boolean;
|
|
432
|
+
/**
|
|
433
|
+
* The plugin service's config object (api/plugin/src/config.ts) carries these
|
|
434
|
+
* as `remediation.enabled` and `remediation.severities`.
|
|
435
|
+
*/
|
|
436
|
+
export interface PluginRemediationConfig {
|
|
437
|
+
enabled: boolean;
|
|
438
|
+
severities: RemediationSeverity[];
|
|
439
|
+
}
|
|
440
|
+
/** Env names and defaults (read with literal `envInt` / `envBool` / `envStr` calls in the services). */
|
|
441
|
+
export declare const PLUGIN_REMEDIATION_ENV: {
|
|
442
|
+
/** Only the literal `false` disables: no jobs queued or run, nothing published or rolled out. */
|
|
443
|
+
readonly enabled: {
|
|
444
|
+
readonly name: 'PLUGIN_REMEDIATION_ENABLED';
|
|
445
|
+
readonly default: true;
|
|
446
|
+
};
|
|
447
|
+
/** Comma list of critical, high; KEV-listed findings are always targeted. */
|
|
448
|
+
readonly severities: {
|
|
449
|
+
readonly name: 'PLUGIN_REMEDIATION_SEVERITIES';
|
|
450
|
+
readonly default: 'critical,high';
|
|
451
|
+
};
|
|
452
|
+
readonly concurrency: {
|
|
453
|
+
readonly name: 'PLUGIN_REMEDIATION_CONCURRENCY';
|
|
454
|
+
readonly default: 2;
|
|
455
|
+
};
|
|
456
|
+
readonly baseConcurrency: {
|
|
457
|
+
readonly name: 'PLUGIN_REMEDIATION_BASE_CONCURRENCY';
|
|
458
|
+
readonly default: 4;
|
|
459
|
+
};
|
|
460
|
+
readonly maxPerOrgPerDay: {
|
|
461
|
+
readonly name: 'PLUGIN_REMEDIATION_MAX_PER_ORG_PER_DAY';
|
|
462
|
+
readonly default: 20;
|
|
463
|
+
};
|
|
464
|
+
/** propose | off: a flagged managed toolchain release gets a verified release candidate (never published automatically), or the owner request. */
|
|
465
|
+
readonly toolchains: {
|
|
466
|
+
readonly name: 'PLUGIN_REMEDIATION_TOOLCHAINS';
|
|
467
|
+
readonly default: 'propose';
|
|
468
|
+
};
|
|
469
|
+
readonly sourcesBucket: {
|
|
470
|
+
readonly name: 'PLUGIN_SOURCES_BUCKET';
|
|
471
|
+
readonly default: 'plugin-sources';
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
/** Metric names (labels: stage ∈ stages, outcome ∈ outcomes, type ∈ package types). */
|
|
475
|
+
export declare const PLUGIN_REMEDIATION_METRICS: {
|
|
476
|
+
/** {stage, outcome} — one per remediation reaching a stage end. */
|
|
477
|
+
readonly remediations: 'plugin_remediations_total';
|
|
478
|
+
/** {type} — findings cleared, by package type. */
|
|
479
|
+
readonly findingsCleared: 'plugin_remediation_findings_cleared_total';
|
|
480
|
+
/** {kind} (object | prefix | image) — a purge delete that failed and landed in plugin_source_orphans. */
|
|
481
|
+
readonly sourceDeleteFailures: 'plugin_source_delete_failures_total';
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* RustFS keys in the `plugin-sources` bucket ({@link PLUGIN_REMEDIATION_ENV}.sourcesBucket):
|
|
485
|
+
* <orgId>/<pluginId>/<version>/<sha256>.zip a version's kept build context
|
|
486
|
+
* <orgId>/<pluginId>/<version>/remediations/<remediationId>/patched-<sha256>.zip a remediation's patched context (copied to the fix version's own source key on publish)
|
|
487
|
+
* <orgId>/<pluginId>/<version>/remediations/<remediationId>/remediation.diff the patch diff (plugin_remediations.patch_key)
|
|
488
|
+
* <orgId>/<pluginId>/<version>/remediations/<remediationId>/export.diff Official only: the patch re-rooted at deploy/plugins/<name>/ for maintainers
|
|
489
|
+
* listings/<listingId>/<version>/<sha256>.zip a listed version's own copy (outlives the publisher org's row)
|
|
490
|
+
* Purging a version deletes its `<orgId>/<pluginId>/<version>/` prefix; the org purge deletes `<orgId>/`.
|
|
491
|
+
*/
|
|
492
|
+
export declare function pluginSourceVersionPrefix(orgId: string, pluginId: string, version: string): string;
|
|
493
|
+
export declare function pluginSourceKey(orgId: string, pluginId: string, version: string, sha256: string): string;
|
|
494
|
+
export declare function pluginSourceOrgPrefix(orgId: string): string;
|
|
495
|
+
export declare function remediationArtifactPrefix(orgId: string, pluginId: string, version: string, remediationId: string): string;
|
|
496
|
+
export declare function remediationPatchedSourceKey(orgId: string, pluginId: string, version: string, remediationId: string, sha256: string): string;
|
|
497
|
+
export declare function remediationDiffKey(orgId: string, pluginId: string, version: string, remediationId: string): string;
|
|
498
|
+
export declare function remediationExportKey(orgId: string, pluginId: string, version: string, remediationId: string): string;
|
|
499
|
+
export declare function listingSourceKey(listingId: string, version: string, sha256: string): string;
|
|
500
|
+
/** `plugins.source_kind` / `plugin_listing_versions.source_kind`. */
|
|
501
|
+
export declare const PLUGIN_SOURCE_KINDS: readonly ['zip', 'none'];
|
|
502
|
+
export type PluginSourceKind = typeof PLUGIN_SOURCE_KINDS[number];
|
|
503
|
+
/** `plugin_source_orphans.kind`. */
|
|
504
|
+
export declare const PLUGIN_SOURCE_ORPHAN_KINDS: readonly ['object', 'prefix', 'image'];
|
|
505
|
+
export type PluginSourceOrphanKind = typeof PLUGIN_SOURCE_ORPHAN_KINDS[number];
|
|
506
|
+
/** By-name delete, restore and purge share one bucket: 10 per org per hour. */
|
|
507
|
+
export declare const PLUGIN_BY_NAME_RATE_LIMIT: {
|
|
508
|
+
readonly name: 'plugin-by-name-destructive';
|
|
509
|
+
readonly max: 10;
|
|
510
|
+
readonly windowMs: 3600000;
|
|
511
|
+
};
|
|
512
|
+
/** How long a by-name delete waits for running builds / remediations of the name before cancelling them. */
|
|
513
|
+
export declare const PLUGIN_DELETE_INFLIGHT_WAIT_MS = 600000;
|
|
514
|
+
/** One remediation as `GET /plugins/remediations[/:id]` answers it. */
|
|
515
|
+
export interface PluginRemediationDto {
|
|
516
|
+
id: string;
|
|
517
|
+
pluginId: string;
|
|
518
|
+
pluginName: string;
|
|
519
|
+
fromVersion: string;
|
|
520
|
+
stage: PluginRemediationStage;
|
|
521
|
+
outcome: PluginRemediationOutcome | null;
|
|
522
|
+
toVersion: string | null;
|
|
523
|
+
toPluginId: string | null;
|
|
524
|
+
versionBump: RemediationVersionBump | null;
|
|
525
|
+
upgradeLevel: LibraryUpgradeLevel | null;
|
|
526
|
+
publishMode: 'propose' | 'apply' | null;
|
|
527
|
+
proposeReasons: RemediationProposeReason[];
|
|
528
|
+
fixMethods: RemediationFixMethod[];
|
|
529
|
+
targetedCount: number;
|
|
530
|
+
cleared: RemediationClearedFinding[];
|
|
531
|
+
remaining: RemediationRemainingFinding[];
|
|
532
|
+
/** A patch diff is stored (fetch it from GET /plugins/remediations/:id/patch). */
|
|
533
|
+
hasPatch: boolean;
|
|
534
|
+
/** Official only: an export for deploy/plugins/** is stored (GET /plugins/remediations/:id/export, system org). */
|
|
535
|
+
hasExport: boolean;
|
|
536
|
+
rollout: RemediationRolloutSummary | null;
|
|
537
|
+
/** Pipelines this remediation's rollout moved back (at most 1000; kept beside the rollout summary). */
|
|
538
|
+
rolledBackPipelineIds: string[];
|
|
539
|
+
/** A short error CODE (never raw log text). */
|
|
540
|
+
error: string | null;
|
|
541
|
+
attempt: number;
|
|
542
|
+
retryOf: string | null;
|
|
543
|
+
decidedBy: string | null;
|
|
544
|
+
decidedAt: string | null;
|
|
545
|
+
createdAt: string;
|
|
546
|
+
updatedAt: string;
|
|
547
|
+
publishedAt: string | null;
|
|
548
|
+
finishedAt: string | null;
|
|
549
|
+
}
|
|
550
|
+
export declare const PLUGIN_DELETE_SKIP_REASONS: readonly ['in_use', 'frozen', 'listed'];
|
|
551
|
+
export type PluginDeleteSkipReason = typeof PLUGIN_DELETE_SKIP_REASONS[number];
|
|
552
|
+
export interface PluginDeleteSkip {
|
|
553
|
+
id: string;
|
|
554
|
+
version: string;
|
|
555
|
+
reason: PluginDeleteSkipReason;
|
|
556
|
+
/** For in_use: the pipelines using it (at most 50). */
|
|
557
|
+
pipelines?: Array<{
|
|
558
|
+
id: string;
|
|
559
|
+
name: string | null;
|
|
560
|
+
}>;
|
|
561
|
+
}
|
|
562
|
+
/** `GET /plugins/by-name/:name/delete-preview` (and what DELETE would do). */
|
|
563
|
+
export interface PluginDeletePreview {
|
|
564
|
+
name: string;
|
|
565
|
+
/** The name comes from the root org (a team sees it but has nothing to delete). */
|
|
566
|
+
inheritedFromRoot: boolean;
|
|
567
|
+
/** The name is listed; the dialog offers an "unmaintained" / yank request. */
|
|
568
|
+
listing: {
|
|
569
|
+
id: string;
|
|
570
|
+
publisher: string;
|
|
571
|
+
} | null;
|
|
572
|
+
deletable: Array<{
|
|
573
|
+
id: string;
|
|
574
|
+
version: string;
|
|
575
|
+
sourceBytes: number | null;
|
|
576
|
+
}>;
|
|
577
|
+
skipped: PluginDeleteSkip[];
|
|
578
|
+
/** Queued / running builds and remediations of the name the delete would cancel. */
|
|
579
|
+
inFlight: {
|
|
580
|
+
builds: number;
|
|
581
|
+
remediations: number;
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/** `DELETE /plugins/by-name/:name`. */
|
|
585
|
+
export interface PluginDeleteAllResult {
|
|
586
|
+
batchId: string;
|
|
587
|
+
deleted: Array<{
|
|
588
|
+
id: string;
|
|
589
|
+
version: string;
|
|
590
|
+
}>;
|
|
591
|
+
skipped: PluginDeleteSkip[];
|
|
592
|
+
}
|
|
593
|
+
/** `POST /plugins/by-name/:name/restore` and `/purge` (`?batchId=` required). */
|
|
594
|
+
export interface PluginBatchActionResult {
|
|
595
|
+
batchId: string;
|
|
596
|
+
done: Array<{
|
|
597
|
+
id: string;
|
|
598
|
+
version: string;
|
|
599
|
+
}>;
|
|
600
|
+
skipped: Array<{
|
|
601
|
+
id: string;
|
|
602
|
+
version: string;
|
|
603
|
+
reason: string;
|
|
604
|
+
}>;
|
|
605
|
+
}
|