@xano/cli 1.3.1-beta.1 → 1.3.1
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/README.md +1 -269
- package/dist/base-command.d.ts +1 -12
- package/dist/base-command.js +22 -36
- package/dist/commands/branch/set_live/index.d.ts +0 -22
- package/dist/commands/branch/set_live/index.js +1 -60
- package/dist/commands/ephemeral/push/index.js +1 -6
- package/dist/commands/function/create/index.d.ts +0 -15
- package/dist/commands/function/create/index.js +0 -40
- package/dist/commands/function/edit/index.d.ts +0 -15
- package/dist/commands/function/edit/index.js +0 -40
- package/dist/commands/release/create/index.js +0 -7
- package/dist/commands/release/deploy/index.d.ts +0 -28
- package/dist/commands/release/deploy/index.js +6 -90
- package/dist/commands/release/import/index.js +1 -5
- package/dist/commands/release/list/index.d.ts +0 -7
- package/dist/commands/release/list/index.js +10 -54
- package/dist/commands/release/push/index.js +1 -19
- package/dist/commands/sandbox/push/index.js +1 -6
- package/dist/commands/tenant/create/index.d.ts +0 -3
- package/dist/commands/tenant/create/index.js +0 -21
- package/dist/commands/tenant/deploy_release/index.d.ts +0 -40
- package/dist/commands/tenant/deploy_release/index.js +4 -186
- package/dist/commands/tenant/edit/index.d.ts +0 -2
- package/dist/commands/tenant/edit/index.js +4 -39
- package/dist/commands/workspace/pull/index.d.ts +0 -10
- package/dist/commands/workspace/pull/index.js +7 -70
- package/dist/commands/workspace/push/index.d.ts +0 -19
- package/dist/commands/workspace/push/index.js +5 -124
- package/dist/utils/document-parser.d.ts +0 -10
- package/dist/utils/document-parser.js +0 -21
- package/dist/utils/multidoc-push.d.ts +2 -55
- package/dist/utils/multidoc-push.js +27 -103
- package/oclif.manifest.json +3142 -6141
- package/package.json +1 -7
- package/dist/commands/policy/catalogue/index.d.ts +0 -15
- package/dist/commands/policy/catalogue/index.js +0 -29
- package/dist/commands/policy/create/index.d.ts +0 -18
- package/dist/commands/policy/create/index.js +0 -39
- package/dist/commands/policy/delete/index.d.ts +0 -19
- package/dist/commands/policy/delete/index.js +0 -61
- package/dist/commands/policy/evaluate/index.d.ts +0 -32
- package/dist/commands/policy/evaluate/index.js +0 -71
- package/dist/commands/policy/list/index.d.ts +0 -14
- package/dist/commands/policy/list/index.js +0 -21
- package/dist/commands/policy/parse/index.d.ts +0 -19
- package/dist/commands/policy/parse/index.js +0 -18
- package/dist/commands/policy/publish/index.d.ts +0 -20
- package/dist/commands/policy/publish/index.js +0 -38
- package/dist/commands/policy/runs/index.d.ts +0 -54
- package/dist/commands/policy/runs/index.js +0 -273
- package/dist/commands/policy/status/index.d.ts +0 -21
- package/dist/commands/policy/status/index.js +0 -54
- package/dist/commands/skills/pull/index.d.ts +0 -30
- package/dist/commands/skills/pull/index.js +0 -118
- package/dist/commands/tenant_deploy_request/bypass/index.d.ts +0 -31
- package/dist/commands/tenant_deploy_request/bypass/index.js +0 -109
- package/dist/commands/tenant_deploy_request/create/index.d.ts +0 -21
- package/dist/commands/tenant_deploy_request/create/index.js +0 -108
- package/dist/commands/tenant_deploy_request/edit/index.d.ts +0 -22
- package/dist/commands/tenant_deploy_request/edit/index.js +0 -103
- package/dist/commands/tenant_deploy_request/get/index.d.ts +0 -25
- package/dist/commands/tenant_deploy_request/get/index.js +0 -116
- package/dist/commands/tenant_deploy_request/list/index.d.ts +0 -20
- package/dist/commands/tenant_deploy_request/list/index.js +0 -122
- package/dist/commands/tenant_deploy_request/revision/index.d.ts +0 -21
- package/dist/commands/tenant_deploy_request/revision/index.js +0 -83
- package/dist/commands/tenant_deploy_request/set_status/index.d.ts +0 -38
- package/dist/commands/tenant_deploy_request/set_status/index.js +0 -159
- package/dist/policy-command.d.ts +0 -90
- package/dist/policy-command.js +0 -94
- package/dist/utils/policy/catalogue.d.ts +0 -7
- package/dist/utils/policy/catalogue.js +0 -72
- package/dist/utils/policy/errors.d.ts +0 -12
- package/dist/utils/policy/errors.js +0 -61
- package/dist/utils/policy/feedback.d.ts +0 -68
- package/dist/utils/policy/feedback.js +0 -165
- package/dist/utils/policy/findings.d.ts +0 -23
- package/dist/utils/policy/findings.js +0 -65
- package/dist/utils/policy/gate.d.ts +0 -161
- package/dist/utils/policy/gate.js +0 -201
- package/dist/utils/policy/goal.d.ts +0 -46
- package/dist/utils/policy/goal.js +0 -95
- package/dist/utils/policy/permission.d.ts +0 -23
- package/dist/utils/policy/permission.js +0 -84
- package/dist/utils/policy/push-gate.d.ts +0 -5
- package/dist/utils/policy/push-gate.js +0 -29
- package/dist/utils/policy/release.d.ts +0 -85
- package/dist/utils/policy/release.js +0 -115
- package/dist/utils/policy/request.d.ts +0 -55
- package/dist/utils/policy/request.js +0 -115
- package/dist/utils/policy/runs.d.ts +0 -30
- package/dist/utils/policy/runs.js +0 -101
- package/dist/utils/policy/status.d.ts +0 -47
- package/dist/utils/policy/status.js +0 -117
- package/dist/utils/policy/types.d.ts +0 -185
- package/dist/utils/policy/types.js +0 -1
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { findingLine, hasNoObjects, policyResultSummary, policyRuleName, ruleKey, snapshotRules } from './findings.js';
|
|
2
|
-
const RUN_COLUMNS = [6, 8, 14, 12, 9, 0];
|
|
3
|
-
const runRow = (cells) => cells.map((cell, index) => cell.padEnd(RUN_COLUMNS[index])).join('').trimEnd();
|
|
4
|
-
/** The retained runs, as the run list summarises them, in a table, header first. */
|
|
5
|
-
export function policyRunTable(runs) {
|
|
6
|
-
return [
|
|
7
|
-
runRow(['Run', 'Status', 'Findings', 'Checked', 'Trigger', 'Started']),
|
|
8
|
-
...runs.map((run) => runRow([
|
|
9
|
-
String(run.id),
|
|
10
|
-
run.status,
|
|
11
|
-
`${run.counts.findings} findings`,
|
|
12
|
-
`${run.objects_checked} objects`,
|
|
13
|
-
run.trigger ?? '',
|
|
14
|
-
run.started_at ?? '',
|
|
15
|
-
])),
|
|
16
|
-
];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* One stored run. A run records its findings, results and the enforcement each policy had;
|
|
20
|
-
* `policy_check.blocking` is the gate's verdict at the time and is not stored. With `page`, the
|
|
21
|
-
* run's findings are one page of them (`GET run/{id}/findings`) and its counts are the summary's.
|
|
22
|
-
*/
|
|
23
|
-
export function policyRunSummary(run, page) {
|
|
24
|
-
const when = [run.started_at, run.finished_at].filter(Boolean).join(' → ');
|
|
25
|
-
const checked = typeof run.objects_checked === 'number' ? ` ${run.objects_checked} objects checked` : '';
|
|
26
|
-
const lines = [`Run ${run.id ?? '?'} ${run.status ?? 'unknown'}${run.trigger ? ` ${run.trigger}` : ''}${when ? ` ${when}` : ''}${checked}`];
|
|
27
|
-
const rules = snapshotRules(run.policies ?? []);
|
|
28
|
-
const findings = run.findings ?? [];
|
|
29
|
-
if (page)
|
|
30
|
-
lines.push(...pageLines(run, page));
|
|
31
|
-
else if (findings.length > 0)
|
|
32
|
-
lines.push(`Findings (${findings.length}):`, ...findings.map(finding => findingLine(finding, rules)));
|
|
33
|
-
else
|
|
34
|
-
lines.push('No findings.');
|
|
35
|
-
lines.push(...policyResultSummary(run.results));
|
|
36
|
-
return lines;
|
|
37
|
-
}
|
|
38
|
-
/** The run's counts, then one page of its findings and how to read the next. */
|
|
39
|
-
function pageLines(run, page) {
|
|
40
|
-
const rules = snapshotRules(run.policies ?? []);
|
|
41
|
-
const findings = run.findings ?? [];
|
|
42
|
-
const { counts } = run;
|
|
43
|
-
const lines = counts && counts.findings > 0
|
|
44
|
-
? [`Findings: ${counts.findings} (${counts.blocking} blocking, ${counts.advisory ?? counts.findings - counts.blocking} advisory)`]
|
|
45
|
-
: [];
|
|
46
|
-
if (findings.length === 0) {
|
|
47
|
-
lines.push(page.total > 0 ? `No findings from offset ${page.offset}: ${page.total} ${page.filtered ? 'match' : 'in all'}.`
|
|
48
|
-
: (page.filtered ? 'No findings match.' : 'No findings.'));
|
|
49
|
-
return lines;
|
|
50
|
-
}
|
|
51
|
-
const next = page.offset + findings.length;
|
|
52
|
-
// A page that is not every finding says so, and how to read the rest.
|
|
53
|
-
const partial = page.offset > 0 || next < page.total;
|
|
54
|
-
lines.push(`Findings ${page.offset + 1}-${next} of ${page.total}${page.filtered ? ' matching' : ''}${partial ? ' (one page)' : ''}:`, ...findings.map(finding => findingLine(finding, rules)));
|
|
55
|
-
if (next < page.total) {
|
|
56
|
-
lines.push(`Next page: \`${page.next ?? `xano policy runs ${run.id}`} --offset ${next}\`, or --all for all ${page.total}${page.filtered ? ', with the same filters' : ''}.`);
|
|
57
|
-
}
|
|
58
|
-
return lines;
|
|
59
|
-
}
|
|
60
|
-
function settingValue(value) {
|
|
61
|
-
if (Array.isArray(value))
|
|
62
|
-
return `[${value.map(item => settingValue(item)).join(', ')}]`;
|
|
63
|
-
if (value !== null && typeof value === 'object')
|
|
64
|
-
return JSON.stringify(value);
|
|
65
|
-
return String(value);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The resolved settings a check ran with, as `settings: name=value, …`, sorted by name so output
|
|
69
|
-
* is stable. Values that resolved to nothing are already omitted by the platform.
|
|
70
|
-
*/
|
|
71
|
-
export function policySettings(params) {
|
|
72
|
-
if (!params || typeof params !== 'object' || Array.isArray(params))
|
|
73
|
-
return '';
|
|
74
|
-
const entries = Object.entries(params).sort(([a], [b]) => a.localeCompare(b));
|
|
75
|
-
return entries.length === 0 ? '' : `settings: ${entries.map(([name, value]) => `${name}=${settingValue(value)}`).join(', ')}`;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* What a stored run recorded about the policies it evaluated: each policy's description as written
|
|
79
|
-
* then, and each rule's name, settings and how many objects it inspected. Empty for a run that
|
|
80
|
-
* evaluated no policy.
|
|
81
|
-
*/
|
|
82
|
-
export function policyRunDetail(run) {
|
|
83
|
-
const results = new Map((run?.results ?? []).map(result => [ruleKey(result.policy_key, result.check_id), result]));
|
|
84
|
-
const body = (run?.policies ?? []).flatMap(policy => {
|
|
85
|
-
const statement = policy.statement?.trim();
|
|
86
|
-
const rules = (policy.rules ?? []).map(rule => {
|
|
87
|
-
// The name falls back to the id, which the line already carries.
|
|
88
|
-
const name = policyRuleName(rule);
|
|
89
|
-
const result = results.get(ruleKey(policy.key, rule.id));
|
|
90
|
-
const inspected = result?.checked === undefined ? '' : (hasNoObjects(result) ? 'no objects checked' : `checked ${result.checked}`);
|
|
91
|
-
return ` ${[rule.id, name === rule.id ? '' : name, policySettings(rule.params) || 'settings: none', inspected]
|
|
92
|
-
.filter(Boolean).join(' ')}`;
|
|
93
|
-
});
|
|
94
|
-
return [` ${policy.key ?? 'policy'}${statement ? ` ${statement}` : ''}`, ...rules];
|
|
95
|
-
});
|
|
96
|
-
if (body.length === 0)
|
|
97
|
-
return [];
|
|
98
|
-
const provenance = [run?.trigger, run?.started_at].filter(Boolean).join(', ');
|
|
99
|
-
const heading = run?.id ? `Run ${run.id} as recorded` : 'This evaluation, which was not stored';
|
|
100
|
-
return [`${heading}${provenance ? ` (${provenance})` : ''}:`, ...body];
|
|
101
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Policy, PolicyRunHead } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Where a policy stands against the latest run. `stale` means the run evaluated a different
|
|
4
|
-
* version; `not_evaluated` that it has no result for every rule.
|
|
5
|
-
*/
|
|
6
|
-
export type PolicyStatus = 'error' | 'fail' | 'inactive' | 'no_checks' | 'no_objects_checked' | 'not_evaluated' | 'pass' | 'stale';
|
|
7
|
-
export interface PolicyStatusRow {
|
|
8
|
-
/** Whether the policy is active. */
|
|
9
|
-
active: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Whether the latest run's findings on this policy block a merge: the run evaluated it, in its
|
|
12
|
-
* current version, as active and mandatory (the platform's `latest_run.enforcement`), and found something.
|
|
13
|
-
*/
|
|
14
|
-
blocking: boolean;
|
|
15
|
-
checked: number;
|
|
16
|
-
/** Whether `findings` and `checked` come from the latest run: only for an active policy it evaluated in its current version. */
|
|
17
|
-
counted: boolean;
|
|
18
|
-
/** The policy's own enforcement (`mandatory` / `advisory`). */
|
|
19
|
-
enforcement: string;
|
|
20
|
-
findings: number;
|
|
21
|
-
key: string;
|
|
22
|
-
/** Completed rules that inspected no objects. */
|
|
23
|
-
rules_unchecked: number;
|
|
24
|
-
/** The platform's answer: the latest run evaluated a different version of this policy. */
|
|
25
|
-
stale: boolean;
|
|
26
|
-
status: PolicyStatus;
|
|
27
|
-
title?: string;
|
|
28
|
-
}
|
|
29
|
-
/** How a row's status reads in the summary table. */
|
|
30
|
-
export declare function statusLabel(row: PolicyStatusRow): string;
|
|
31
|
-
/** The policy's own enforcement, in Studio's words. Whether its findings block is `findingsLabel`'s to say. */
|
|
32
|
-
export declare function enforcementLabel(enforcement: string): string;
|
|
33
|
-
/** `3 findings`, marked blocking when they block; a dash where the row carries no current count. */
|
|
34
|
-
export declare function findingsLabel(row: PolicyStatusRow): string;
|
|
35
|
-
/**
|
|
36
|
-
* Combine the branch's policies with the latest stored run. Whether the run is still evidence for a
|
|
37
|
-
* policy is the platform's `latest_run` answer; only an active policy the run evaluated in its
|
|
38
|
-
* current version carries counts.
|
|
39
|
-
*/
|
|
40
|
-
export declare function computeStatusRows(policies: Policy[], run?: PolicyRunHead): PolicyStatusRow[];
|
|
41
|
-
/**
|
|
42
|
-
* `--fail-on-findings`: 2 for a current blocking finding, whatever else is true, as push and evaluate
|
|
43
|
-
* exit; otherwise 1 for stale, missing or errored evidence.
|
|
44
|
-
*/
|
|
45
|
-
export declare function statusExitCode(rows: PolicyStatusRow[]): number;
|
|
46
|
-
/** Why `--fail-on-findings` failed, in one line naming the policies, or `null` when it did not. */
|
|
47
|
-
export declare function statusExitReason(rows: PolicyStatusRow[]): null | string;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { hasNoObjects } from './findings.js';
|
|
2
|
-
/** How a row's status reads in the summary table. */
|
|
3
|
-
export function statusLabel(row) {
|
|
4
|
-
switch (row.status) {
|
|
5
|
-
case 'inactive': {
|
|
6
|
-
return 'inactive; not evaluated';
|
|
7
|
-
}
|
|
8
|
-
case 'pass': {
|
|
9
|
-
return row.rules_unchecked > 0
|
|
10
|
-
? `pass; ${row.rules_unchecked} rule${row.rules_unchecked === 1 ? '' : 's'} no objects checked`
|
|
11
|
-
: 'pass';
|
|
12
|
-
}
|
|
13
|
-
case 'stale': {
|
|
14
|
-
return 'outdated; evaluate again';
|
|
15
|
-
}
|
|
16
|
-
default: {
|
|
17
|
-
return row.status.replaceAll('_', ' ');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/** The policy's own enforcement, in Studio's words. Whether its findings block is `findingsLabel`'s to say. */
|
|
22
|
-
export function enforcementLabel(enforcement) {
|
|
23
|
-
if (enforcement === 'mandatory')
|
|
24
|
-
return 'Mandatory';
|
|
25
|
-
if (enforcement === 'advisory')
|
|
26
|
-
return 'Advisory';
|
|
27
|
-
return enforcement.trim() || '—';
|
|
28
|
-
}
|
|
29
|
-
/** `3 findings`, marked blocking when they block; a dash where the row carries no current count. */
|
|
30
|
-
export function findingsLabel(row) {
|
|
31
|
-
if (!row.counted)
|
|
32
|
-
return '— findings';
|
|
33
|
-
return `${row.findings} findings${row.blocking ? ' (blocking)' : ''}`;
|
|
34
|
-
}
|
|
35
|
-
/** Where an active policy stands, given its rule results in a run that is still evidence for it. */
|
|
36
|
-
function ruleStatus(results, ruleCount, checked) {
|
|
37
|
-
if (ruleCount === 0)
|
|
38
|
-
return 'no_checks';
|
|
39
|
-
if (results.length === 0)
|
|
40
|
-
return 'not_evaluated';
|
|
41
|
-
if (results.some((result) => !['fail', 'no_objects', 'pass'].includes(result.status ?? '')))
|
|
42
|
-
return 'error';
|
|
43
|
-
if (results.some((result) => result.status === 'fail'))
|
|
44
|
-
return 'fail';
|
|
45
|
-
if (results.length < ruleCount)
|
|
46
|
-
return 'not_evaluated';
|
|
47
|
-
return checked === 0 ? 'no_objects_checked' : 'pass';
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* A policy's finding count in a run: its verdict in the run summary, which counts them all without
|
|
51
|
-
* listing them, or, from a whole run, its findings counted.
|
|
52
|
-
*/
|
|
53
|
-
function findingCount(run, key) {
|
|
54
|
-
const verdict = (run?.policies ?? []).find((policy) => policy.key === key);
|
|
55
|
-
if (typeof verdict?.findings === 'number')
|
|
56
|
-
return verdict.findings;
|
|
57
|
-
return (run?.findings ?? []).filter((finding) => finding.policy_key === key).length;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Combine the branch's policies with the latest stored run. Whether the run is still evidence for a
|
|
61
|
-
* policy is the platform's `latest_run` answer; only an active policy the run evaluated in its
|
|
62
|
-
* current version carries counts.
|
|
63
|
-
*/
|
|
64
|
-
export function computeStatusRows(policies, run) {
|
|
65
|
-
return policies.map((policy) => {
|
|
66
|
-
const ids = new Set((policy.rules ?? []).map((rule) => rule.id));
|
|
67
|
-
const active = policy.active !== false;
|
|
68
|
-
const stale = policy.latest_run?.stale === true;
|
|
69
|
-
const counted = active && policy.latest_run?.included === true && !stale;
|
|
70
|
-
const results = counted
|
|
71
|
-
? (run?.results ?? []).filter((result) => result.policy_key === policy.key && ids.has(result.check_id ?? ''))
|
|
72
|
-
: [];
|
|
73
|
-
const checked = results.reduce((sum, result) => sum + (result.checked ?? 0), 0);
|
|
74
|
-
const findings = counted ? findingCount(run, policy.key) : 0;
|
|
75
|
-
let status = 'inactive';
|
|
76
|
-
if (active)
|
|
77
|
-
status = stale ? 'stale' : ruleStatus(results, ids.size, checked);
|
|
78
|
-
return {
|
|
79
|
-
active: policy.active,
|
|
80
|
-
blocking: counted && policy.latest_run?.enforcement === 'mandatory' && findings > 0,
|
|
81
|
-
checked,
|
|
82
|
-
counted,
|
|
83
|
-
enforcement: policy.enforcement,
|
|
84
|
-
findings,
|
|
85
|
-
key: policy.key,
|
|
86
|
-
rules_unchecked: status === 'pass' ? results.filter((result) => hasNoObjects(result)).length : 0,
|
|
87
|
-
stale,
|
|
88
|
-
status,
|
|
89
|
-
title: policy.title,
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/** The rows whose evidence cannot be relied on: stale, missing or errored. An inactive policy is never evaluated. */
|
|
94
|
-
function unreliableRows(rows) {
|
|
95
|
-
return rows.filter((row) => ['error', 'not_evaluated', 'stale'].includes(row.status));
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* `--fail-on-findings`: 2 for a current blocking finding, whatever else is true, as push and evaluate
|
|
99
|
-
* exit; otherwise 1 for stale, missing or errored evidence.
|
|
100
|
-
*/
|
|
101
|
-
export function statusExitCode(rows) {
|
|
102
|
-
if (rows.some((row) => row.blocking))
|
|
103
|
-
return 2;
|
|
104
|
-
return unreliableRows(rows).length > 0 ? 1 : 0;
|
|
105
|
-
}
|
|
106
|
-
/** Why `--fail-on-findings` failed, in one line naming the policies, or `null` when it did not. */
|
|
107
|
-
export function statusExitReason(rows) {
|
|
108
|
-
const unreliable = unreliableRows(rows);
|
|
109
|
-
const evidence = unreliable.map((row) => `${row.key} ${statusLabel(row)}`).join(', ');
|
|
110
|
-
const blocking = rows.filter((row) => row.blocking);
|
|
111
|
-
if (blocking.length === 0) {
|
|
112
|
-
return unreliable.length > 0 ? `Evaluation evidence is stale, missing or errored (${evidence}); exit 1.` : null;
|
|
113
|
-
}
|
|
114
|
-
const findings = blocking.reduce((sum, row) => sum + row.findings, 0);
|
|
115
|
-
// A prediction, not a verdict: the merge gate evaluates the branch again.
|
|
116
|
-
return `The latest run has ${findings} blocking finding${findings === 1 ? '' : 's'} (${blocking.map((row) => row.key).join(', ')}); the merge gate evaluates the branch again before a merge.${unreliable.length > 0 ? ` Evidence is also stale, missing or errored (${evidence}).` : ''}`;
|
|
117
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/** The shapes the policy routes answer with. Policy grammar belongs to the platform. */
|
|
2
|
-
export interface PolicyCatalogueEntry {
|
|
3
|
-
description?: string;
|
|
4
|
-
fix_hint?: string;
|
|
5
|
-
id: string;
|
|
6
|
-
/** The check's human name. */
|
|
7
|
-
label: string;
|
|
8
|
-
object_kinds?: string[];
|
|
9
|
-
params?: Record<string, {
|
|
10
|
-
required?: boolean;
|
|
11
|
-
type?: string;
|
|
12
|
-
}>;
|
|
13
|
-
/** Params of which a rule must set at least one. */
|
|
14
|
-
requires_one_of?: string[];
|
|
15
|
-
}
|
|
16
|
-
/** One rule as a run snapshot records it: the settings the check ran with, plus the check's label. */
|
|
17
|
-
export interface PolicySnapshotRule {
|
|
18
|
-
check?: string;
|
|
19
|
-
id?: string;
|
|
20
|
-
label?: string;
|
|
21
|
-
/** The resolved settings; PHP sends an empty map as `[]`. */
|
|
22
|
-
params?: unknown;
|
|
23
|
-
title?: string;
|
|
24
|
-
}
|
|
25
|
-
/** One policy as a run snapshot records it, including the description it carried at run time. */
|
|
26
|
-
export interface PolicySnapshotPolicy {
|
|
27
|
-
key?: string;
|
|
28
|
-
rules?: PolicySnapshotRule[];
|
|
29
|
-
/** The policy description as written at run time. */
|
|
30
|
-
statement?: string;
|
|
31
|
-
title?: string;
|
|
32
|
-
/** The Version History index this run evaluated. */
|
|
33
|
-
version?: number;
|
|
34
|
-
}
|
|
35
|
-
export interface PolicyRuleResult {
|
|
36
|
-
check_id?: string;
|
|
37
|
-
checked?: number;
|
|
38
|
-
message?: string;
|
|
39
|
-
policy_key?: string;
|
|
40
|
-
status?: string;
|
|
41
|
-
warnings?: string[];
|
|
42
|
-
}
|
|
43
|
-
export interface PolicyFinding {
|
|
44
|
-
/** Stable finding id, used to tell a blocking finding from an advisory one. */
|
|
45
|
-
id?: string;
|
|
46
|
-
message?: string;
|
|
47
|
-
object?: {
|
|
48
|
-
name?: string;
|
|
49
|
-
type?: string;
|
|
50
|
-
};
|
|
51
|
-
policy_key?: string;
|
|
52
|
-
policy_title?: string;
|
|
53
|
-
rule_id?: string;
|
|
54
|
-
rule_title?: string;
|
|
55
|
-
severity?: string;
|
|
56
|
-
}
|
|
57
|
-
/** The verdict every `policy_check` carries. */
|
|
58
|
-
export interface PolicyVerdict {
|
|
59
|
-
/** True when an active, mandatory policy failed; it decides the exit code whatever the status. */
|
|
60
|
-
blocking?: boolean;
|
|
61
|
-
/** The platform's verdict, including the names of rules that checked no objects. */
|
|
62
|
-
message?: string;
|
|
63
|
-
run_id?: number;
|
|
64
|
-
/**
|
|
65
|
-
* `pass`, `fail` or `error` (a check could not run) for an evaluation; `disabled`,
|
|
66
|
-
* `not_applicable`, `forbidden` or `unavailable` when nothing was evaluated.
|
|
67
|
-
*/
|
|
68
|
-
status?: string;
|
|
69
|
-
}
|
|
70
|
-
/** A run's finding counts: every finding, the blocking ones, and the rules that could not run. */
|
|
71
|
-
export interface PolicyCounts {
|
|
72
|
-
/** The findings that do not block; the run summary serves it, a push's feedback does not. */
|
|
73
|
-
advisory?: number;
|
|
74
|
-
blocking: number;
|
|
75
|
-
errors: number;
|
|
76
|
-
findings: number;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* A push's `policy_check`: the verdict with its findings and results, since a push answers no run.
|
|
80
|
-
* The lists hold the first 100 each, in the platform's order; the stored run (`run_id`) has them all.
|
|
81
|
-
*/
|
|
82
|
-
export interface PushPolicyCheck extends PolicyVerdict {
|
|
83
|
-
/** The first blocking findings. */
|
|
84
|
-
blocking_findings?: PolicyFinding[];
|
|
85
|
-
/** What the lists are out of. */
|
|
86
|
-
counts?: PolicyCounts;
|
|
87
|
-
/** The first findings, blocking first. */
|
|
88
|
-
findings?: PolicyFinding[];
|
|
89
|
-
results?: PolicyRuleResult[];
|
|
90
|
-
/** Every finding, listed or not. */
|
|
91
|
-
total?: number;
|
|
92
|
-
/** Whether either list was cut. */
|
|
93
|
-
truncated?: boolean;
|
|
94
|
-
}
|
|
95
|
-
/** A policy's place in its branch's newest run, as the platform serves it on every policy. */
|
|
96
|
-
export interface PolicyCoverage {
|
|
97
|
-
enforcement: null | string;
|
|
98
|
-
/** Whether the newest run evaluated this policy at all. */
|
|
99
|
-
included: boolean;
|
|
100
|
-
/** 0 when the branch has no run. */
|
|
101
|
-
run_id: number;
|
|
102
|
-
/** True only when the newest run evaluated a different version of this policy. */
|
|
103
|
-
stale: boolean;
|
|
104
|
-
version: null | number;
|
|
105
|
-
}
|
|
106
|
-
export interface Policy {
|
|
107
|
-
active: boolean;
|
|
108
|
-
enforcement: string;
|
|
109
|
-
id: number;
|
|
110
|
-
key: string;
|
|
111
|
-
latest_run?: PolicyCoverage;
|
|
112
|
-
rules?: Array<{
|
|
113
|
-
id: string;
|
|
114
|
-
}>;
|
|
115
|
-
title?: string;
|
|
116
|
-
/** When the policy was last written, as served; sent back as `last_updated_at` to refuse acting on a stale read. */
|
|
117
|
-
updated_at?: number | string;
|
|
118
|
-
/** The index of the policy's newest Version History entry; it moves only when the definition changes. */
|
|
119
|
-
version: number;
|
|
120
|
-
}
|
|
121
|
-
/** One stored run as the run list serves it: the verdict and counts, without findings or results. */
|
|
122
|
-
export interface PolicyRunSummary {
|
|
123
|
-
counts: {
|
|
124
|
-
blocking: number;
|
|
125
|
-
errors: number;
|
|
126
|
-
findings: number;
|
|
127
|
-
};
|
|
128
|
-
finished_at?: string;
|
|
129
|
-
id: number;
|
|
130
|
-
objects_checked: number;
|
|
131
|
-
started_at?: string;
|
|
132
|
-
status: string;
|
|
133
|
-
trigger?: string;
|
|
134
|
-
}
|
|
135
|
-
/** One run in full, as `GET run/{id}` serves it. */
|
|
136
|
-
export interface PolicyRun {
|
|
137
|
-
findings?: PolicyFinding[];
|
|
138
|
-
finished_at?: number | string;
|
|
139
|
-
/** 0 for an evaluation that was not stored. */
|
|
140
|
-
id?: number;
|
|
141
|
-
/** How many workspace objects the run inspected. */
|
|
142
|
-
objects_checked?: number;
|
|
143
|
-
/** The snapshot of the policies as they were when the run went out. */
|
|
144
|
-
policies?: PolicySnapshotPolicy[];
|
|
145
|
-
results?: PolicyRuleResult[];
|
|
146
|
-
started_at?: number | string;
|
|
147
|
-
status?: string;
|
|
148
|
-
trigger?: string;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* What `policy evaluate` answers: the run as `GET run/{id}` serves it, whether it was stored, and the verdict.
|
|
152
|
-
* With no active policy on the branch it is no run at all: `id` 0, `status` `not_applicable`, nothing evaluated.
|
|
153
|
-
*/
|
|
154
|
-
export interface PolicyEvaluation extends PolicyRun {
|
|
155
|
-
/** The summary answer's counts (`--summary`). */
|
|
156
|
-
counts?: PolicyCounts;
|
|
157
|
-
/** `blocking_total`: every blocking finding, beside the summary answer's listed ones. */
|
|
158
|
-
policy_check?: PolicyVerdict & {
|
|
159
|
-
blocking_finding_ids?: string[];
|
|
160
|
-
blocking_total?: number;
|
|
161
|
-
};
|
|
162
|
-
stored?: boolean;
|
|
163
|
-
/** The summary answer: every finding, and whether `findings` lists only the first. */
|
|
164
|
-
total?: number;
|
|
165
|
-
truncated?: boolean;
|
|
166
|
-
}
|
|
167
|
-
/** One run without its findings, as `GET run/{id}/summary` serves it. */
|
|
168
|
-
export interface PolicyRunHead extends PolicyRun {
|
|
169
|
-
counts?: PolicyCounts;
|
|
170
|
-
/** The snapshot, each policy with its verdict in this run. */
|
|
171
|
-
policies?: Array<PolicySnapshotPolicy & {
|
|
172
|
-
blocking?: boolean;
|
|
173
|
-
findings?: number;
|
|
174
|
-
objects_checked?: number;
|
|
175
|
-
status?: string;
|
|
176
|
-
}>;
|
|
177
|
-
}
|
|
178
|
-
/** One page of a run's findings, as `GET run/{id}/findings` serves it. */
|
|
179
|
-
export interface PolicyFindingsPage {
|
|
180
|
-
items: PolicyFinding[];
|
|
181
|
-
limit: number;
|
|
182
|
-
offset: number;
|
|
183
|
-
/** The findings that match the filters, listed or not. */
|
|
184
|
-
total: number;
|
|
185
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|