@ploaness/governance 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y-hit-target.d.ts.map +1 -1
- package/dist/a11y-hit-target.js +1 -21
- package/dist/a11y-hit-target.js.map +1 -1
- package/dist/a11y-incomplete.d.ts.map +1 -1
- package/dist/a11y-incomplete.js +1 -18
- package/dist/a11y-incomplete.js.map +1 -1
- package/dist/access-boundary.d.ts +43 -1
- package/dist/access-boundary.d.ts.map +1 -1
- package/dist/access-boundary.js +146 -5
- package/dist/access-boundary.js.map +1 -1
- package/dist/admin-view-coverage.d.ts.map +1 -1
- package/dist/admin-view-coverage.js +1 -17
- package/dist/admin-view-coverage.js.map +1 -1
- package/dist/asset-policy.d.ts.map +1 -1
- package/dist/asset-policy.js +1 -23
- package/dist/asset-policy.js.map +1 -1
- package/dist/axe-coverage.d.ts +3 -4
- package/dist/axe-coverage.d.ts.map +1 -1
- package/dist/axe-coverage.js +18 -51
- package/dist/axe-coverage.js.map +1 -1
- package/dist/blocklist-entries.d.ts +36 -0
- package/dist/blocklist-entries.d.ts.map +1 -0
- package/dist/blocklist-entries.js +338 -0
- package/dist/blocklist-entries.js.map +1 -0
- package/dist/blocklist.d.ts +91 -0
- package/dist/blocklist.d.ts.map +1 -0
- package/dist/blocklist.js +187 -0
- package/dist/blocklist.js.map +1 -0
- package/dist/container-failure.d.ts.map +1 -1
- package/dist/container-failure.js +1 -18
- package/dist/container-failure.js.map +1 -1
- package/dist/container-files.d.ts +16 -0
- package/dist/container-files.d.ts.map +1 -1
- package/dist/container-files.js +23 -8
- package/dist/container-files.js.map +1 -1
- package/dist/container-images.d.ts +43 -0
- package/dist/container-images.d.ts.map +1 -0
- package/dist/container-images.js +157 -0
- package/dist/container-images.js.map +1 -0
- package/dist/dependency-freshness.d.ts +8 -0
- package/dist/dependency-freshness.d.ts.map +1 -1
- package/dist/dependency-freshness.js +2 -18
- package/dist/dependency-freshness.js.map +1 -1
- package/dist/doc-blocks.d.ts.map +1 -1
- package/dist/doc-blocks.js +1 -13
- package/dist/doc-blocks.js.map +1 -1
- package/dist/editorconfig-policy.d.ts +7 -0
- package/dist/editorconfig-policy.d.ts.map +1 -1
- package/dist/editorconfig-policy.js +19 -12
- package/dist/editorconfig-policy.js.map +1 -1
- package/dist/environment-coherence.d.ts.map +1 -1
- package/dist/environment-coherence.js +1 -23
- package/dist/environment-coherence.js.map +1 -1
- package/dist/environment-files.d.ts.map +1 -1
- package/dist/environment-files.js +1 -19
- package/dist/environment-files.js.map +1 -1
- package/dist/file-roles.d.ts +7 -2
- package/dist/file-roles.d.ts.map +1 -1
- package/dist/file-roles.js +10 -9
- package/dist/file-roles.js.map +1 -1
- package/dist/freshness-repair.d.ts +82 -0
- package/dist/freshness-repair.d.ts.map +1 -0
- package/dist/freshness-repair.js +91 -0
- package/dist/freshness-repair.js.map +1 -0
- package/dist/generated-denial.d.ts.map +1 -1
- package/dist/generated-denial.js +1 -9
- package/dist/generated-denial.js.map +1 -1
- package/dist/generated-drift.d.ts.map +1 -1
- package/dist/generated-drift.js +1 -12
- package/dist/generated-drift.js.map +1 -1
- package/dist/harness-package.d.ts +13 -0
- package/dist/harness-package.d.ts.map +1 -0
- package/dist/harness-package.js +20 -0
- package/dist/harness-package.js.map +1 -0
- package/dist/history-policy.d.ts.map +1 -1
- package/dist/history-policy.js +1 -7
- package/dist/history-policy.js.map +1 -1
- package/dist/image-assets.d.ts.map +1 -1
- package/dist/image-assets.js +1 -10
- package/dist/image-assets.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/install-policy.d.ts +21 -0
- package/dist/install-policy.d.ts.map +1 -1
- package/dist/install-policy.js +53 -1
- package/dist/install-policy.js.map +1 -1
- package/dist/jsx-accessibility-scope.d.ts +17 -0
- package/dist/jsx-accessibility-scope.d.ts.map +1 -0
- package/dist/jsx-accessibility-scope.js +36 -0
- package/dist/jsx-accessibility-scope.js.map +1 -0
- package/dist/jsx-accessibility.d.ts +13 -0
- package/dist/jsx-accessibility.d.ts.map +1 -0
- package/dist/jsx-accessibility.js +188 -0
- package/dist/jsx-accessibility.js.map +1 -0
- package/dist/network-policy.d.ts.map +1 -1
- package/dist/network-policy.js +1 -12
- package/dist/network-policy.js.map +1 -1
- package/dist/oxlint-policy.d.ts +16 -0
- package/dist/oxlint-policy.d.ts.map +1 -0
- package/dist/oxlint-policy.js +28 -0
- package/dist/oxlint-policy.js.map +1 -0
- package/dist/oxlint-report.d.ts +29 -0
- package/dist/oxlint-report.d.ts.map +1 -0
- package/dist/oxlint-report.js +84 -0
- package/dist/oxlint-report.js.map +1 -0
- package/dist/oxlint-scope.d.ts +13 -0
- package/dist/oxlint-scope.d.ts.map +1 -0
- package/dist/oxlint-scope.js +46 -0
- package/dist/oxlint-scope.js.map +1 -0
- package/dist/oxlint-suppressions.d.ts +17 -0
- package/dist/oxlint-suppressions.d.ts.map +1 -0
- package/dist/oxlint-suppressions.js +72 -0
- package/dist/oxlint-suppressions.js.map +1 -0
- package/dist/paired-assets.d.ts.map +1 -1
- package/dist/paired-assets.js.map +1 -1
- package/dist/payload-access.d.ts +6 -0
- package/dist/payload-access.d.ts.map +1 -1
- package/dist/payload-access.js +166 -9
- package/dist/payload-access.js.map +1 -1
- package/dist/payload-configs.d.ts +0 -1
- package/dist/payload-configs.d.ts.map +1 -1
- package/dist/payload-configs.js +36 -17
- package/dist/payload-configs.js.map +1 -1
- package/dist/payload-defaults.d.ts +128 -0
- package/dist/payload-defaults.d.ts.map +1 -0
- package/dist/payload-defaults.js +295 -0
- package/dist/payload-defaults.js.map +1 -0
- package/dist/payload-policy.d.ts +13 -0
- package/dist/payload-policy.d.ts.map +1 -1
- package/dist/payload-policy.js +81 -40
- package/dist/payload-policy.js.map +1 -1
- package/dist/relationship-cleanup.d.ts.map +1 -1
- package/dist/relationship-cleanup.js +16 -16
- package/dist/relationship-cleanup.js.map +1 -1
- package/dist/release-age.d.ts.map +1 -1
- package/dist/release-age.js +1 -16
- package/dist/release-age.js.map +1 -1
- package/dist/request-limits.d.ts.map +1 -1
- package/dist/request-limits.js +1 -11
- package/dist/request-limits.js.map +1 -1
- package/dist/route-map.d.ts.map +1 -1
- package/dist/route-map.js +1 -16
- package/dist/route-map.js.map +1 -1
- package/dist/run-plan.d.ts.map +1 -1
- package/dist/run-plan.js +1 -19
- package/dist/run-plan.js.map +1 -1
- package/dist/secret-policy.d.ts.map +1 -1
- package/dist/secret-policy.js +1 -11
- package/dist/secret-policy.js.map +1 -1
- package/dist/settings-layering.d.ts +8 -30
- package/dist/settings-layering.d.ts.map +1 -1
- package/dist/settings-layering.js +19 -48
- package/dist/settings-layering.js.map +1 -1
- package/dist/settings.d.ts +9 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/source-text.d.ts +2 -0
- package/dist/source-text.d.ts.map +1 -1
- package/dist/source-text.js +7 -16
- package/dist/source-text.js.map +1 -1
- package/dist/toolchain-pins.d.ts.map +1 -1
- package/dist/toolchain-pins.js +2 -19
- package/dist/toolchain-pins.js.map +1 -1
- package/dist/version-policy.d.ts +7 -8
- package/dist/version-policy.d.ts.map +1 -1
- package/dist/version-policy.js +15 -26
- package/dist/version-policy.js.map +1 -1
- package/dist/vulnerability-policy.d.ts.map +1 -1
- package/dist/vulnerability-policy.js +1 -11
- package/dist/vulnerability-policy.js.map +1 -1
- package/dist/wiring-policy.d.ts.map +1 -1
- package/dist/wiring-policy.js +4 -1
- package/dist/wiring-policy.js.map +1 -1
- package/dist/wiring-violation.d.ts.map +1 -1
- package/dist/wiring-violation.js +1 -6
- package/dist/wiring-violation.js.map +1 -1
- package/dist/workspace-policy.d.ts.map +1 -1
- package/dist/workspace-policy.js +3 -9
- package/dist/workspace-policy.js.map +1 -1
- package/dist/yaml-blocks.d.ts +10 -0
- package/dist/yaml-blocks.d.ts.map +1 -1
- package/dist/yaml-blocks.js +20 -0
- package/dist/yaml-blocks.js.map +1 -1
- package/package.json +2 -2
package/dist/payload-access.js
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
// make on the project's behalf if the project does not make it first.
|
|
8
8
|
import { payloadConfigsIn, } from './payload-configs.js';
|
|
9
9
|
import { configBody, depthOneBlockKeys, depthOneValue, } from './payload-source.js';
|
|
10
|
-
import { NOT_FOUND, topLevelKeys } from './source-text.js';
|
|
10
|
+
import { balancedArguments, NOT_FOUND, scanDelimited, topLevelKeys, } from './source-text.js';
|
|
11
11
|
const eachConfig = (source, judge) => payloadConfigsIn(source).flatMap((found) => judge(found.kind, found));
|
|
12
12
|
// Payload fills the missing operations in during sanitisation, so a partial access block is invisible
|
|
13
|
-
// the moment the app boots - and its default
|
|
14
|
-
// the word `access` appears somewhere in the file, which is what this rule used to do, accepted a
|
|
15
|
-
// that declared one operation out of four.
|
|
13
|
+
// the moment the app boots - and its default admits every signed-in user to every operation. Checking
|
|
14
|
+
// that the word `access` appears somewhere in the file, which is what this rule used to do, accepted a
|
|
15
|
+
// block that declared one operation out of four.
|
|
16
16
|
export const findUndeclaredAccess = (source) => eachConfig(source, (kind, found) => {
|
|
17
17
|
const declared = depthOneBlockKeys(found.body, 'access');
|
|
18
18
|
const missing = kind.operations.filter((operation) => !declared.includes(operation));
|
|
@@ -23,8 +23,8 @@ export const findUndeclaredAccess = (source) => eachConfig(source, (kind, found)
|
|
|
23
23
|
line: found.line,
|
|
24
24
|
rule: 'require-complete-access',
|
|
25
25
|
reason: `a ${kind.label} must declare access for ${kind.operations.join(', ')}; ` +
|
|
26
|
-
`${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} left to
|
|
27
|
-
'
|
|
26
|
+
`${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} left to Payload's ` +
|
|
27
|
+
'default, which admits every signed-in user',
|
|
28
28
|
},
|
|
29
29
|
];
|
|
30
30
|
});
|
|
@@ -65,6 +65,32 @@ const unhardenedAuthIn = (found) => {
|
|
|
65
65
|
};
|
|
66
66
|
/** Report an auth collection that leaves the login-attempt cap and lock time to Payload's defaults. */
|
|
67
67
|
export const findUnhardenedAuth = (source) => eachConfig(source, (kind, found) => kind.label === COLLECTION ? unhardenedAuthIn(found) : []);
|
|
68
|
+
// The cap above, undone from inside. `unlock` is one of the operations Payload fills the access block
|
|
69
|
+
// with during sanitisation, so a collection that decides create, read, update and delete has still said
|
|
70
|
+
// nothing about who may clear a locked account - and the default admits every signed-in user. One
|
|
71
|
+
// ordinary account can therefore lift the lockout on another as fast as the attempts accrue, which
|
|
72
|
+
// leaves the attempt cap and lock time enforced by the rule above protecting nothing. Advisory
|
|
73
|
+
// GHSA-jg8r-5jh2-v2xj is this default, reported against Payload itself.
|
|
74
|
+
const UNLOCK_OPERATION = 'unlock';
|
|
75
|
+
const unlockableAuthIn = (found) => {
|
|
76
|
+
if (depthOneValue(found.body, 'auth') === undefined) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
const declared = depthOneBlockKeys(found.body, 'access');
|
|
80
|
+
return declared.includes(UNLOCK_OPERATION)
|
|
81
|
+
? []
|
|
82
|
+
: [
|
|
83
|
+
{
|
|
84
|
+
line: found.line,
|
|
85
|
+
rule: 'require-unlock-access',
|
|
86
|
+
reason: `an auth collection must declare access for ${UNLOCK_OPERATION}; Payload fills it with ` +
|
|
87
|
+
'a default that admits every signed-in user, so one account can clear the lockout on ' +
|
|
88
|
+
'another and undo the attempt cap',
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
};
|
|
92
|
+
/** Report an auth collection that leaves who may clear a lockout to Payload's default. */
|
|
93
|
+
export const findUnlockableAuth = (source) => eachConfig(source, (kind, found) => kind.label === COLLECTION ? unlockableAuthIn(found) : []);
|
|
68
94
|
// A draft is unpublished content. With versions.drafts enabled, `?draft=true` serves it to whoever the
|
|
69
95
|
// read rule admits - so a read that is unconditionally true publishes every draft to anyone.
|
|
70
96
|
const DRAFTS_ENABLED = /drafts\s*:\s*(?:true|\{)/;
|
|
@@ -87,9 +113,14 @@ const blockEnd = (access, open) => {
|
|
|
87
113
|
// collection itself were open to anyone.
|
|
88
114
|
//
|
|
89
115
|
// Only the inline form is decidable here, and the lint pass forbids that form in a config file, so a
|
|
90
|
-
// conforming project writes `read: anyone` and this rule stays silent on it.
|
|
91
|
-
//
|
|
92
|
-
//
|
|
116
|
+
// conforming project writes `read: anyone` and this rule stays silent on it. This rule therefore
|
|
117
|
+
// reaches only a config declared outside the linted directories.
|
|
118
|
+
//
|
|
119
|
+
// What covers the conforming case is `findUnconstrainedDraftReads` in payload-defaults.ts, which asks
|
|
120
|
+
// the built configuration's own read rule what it answers a stranger and reads the constraint it hands
|
|
121
|
+
// back. The anonymous sweep does NOT cover it: the sweep separates a grant carrying a query constraint
|
|
122
|
+
// from one that does not, and never opens the constraint, so a read filtered by audience and not by
|
|
123
|
+
// status passed it. That gap was open for as long as this comment claimed the sweep closed it.
|
|
93
124
|
const isDraftExposed = (body) => {
|
|
94
125
|
const versions = depthOneValue(body, 'versions');
|
|
95
126
|
if (versions === undefined || !DRAFTS_ENABLED.test(versions)) {
|
|
@@ -113,6 +144,32 @@ export const findAnonymousDraftReads = (source) => eachConfig(source, (kind, fou
|
|
|
113
144
|
},
|
|
114
145
|
]
|
|
115
146
|
: []);
|
|
147
|
+
// The read rule, bypassed by asking a different question. A version carries the whole document, and
|
|
148
|
+
// `readVersions` is the one access operation Payload never fills in - for a collection or a global - so
|
|
149
|
+
// an undeclared rule is not absent but open: `executeAccess` falls through to "any signed-in user" when
|
|
150
|
+
// it is handed nothing. A read narrowed to an audience by a `Where` filter therefore still hands every
|
|
151
|
+
// stored version of every document to anyone signed in. This is asked wherever versions are kept rather
|
|
152
|
+
// than only where drafts are, because the versions route exists either way.
|
|
153
|
+
const VERSIONS_DISABLED = /^\s*false\s*(?=[,}])/;
|
|
154
|
+
const READ_VERSIONS_OPERATION = 'readVersions';
|
|
155
|
+
const carriesVersions = (body) => {
|
|
156
|
+
const versions = depthOneValue(body, 'versions');
|
|
157
|
+
return versions !== undefined && !VERSIONS_DISABLED.test(versions);
|
|
158
|
+
};
|
|
159
|
+
/** Report a config that keeps versions and leaves who may read them to Payload's fall-through. */
|
|
160
|
+
export const findUndeclaredVersionReads = (source) => eachConfig(source, (kind, found) => carriesVersions(found.body) &&
|
|
161
|
+
!depthOneBlockKeys(found.body, 'access').includes(READ_VERSIONS_OPERATION)
|
|
162
|
+
? [
|
|
163
|
+
{
|
|
164
|
+
line: found.line,
|
|
165
|
+
rule: 'require-version-read-access',
|
|
166
|
+
reason: `a ${kind.label} that keeps versions must declare access for ` +
|
|
167
|
+
`${READ_VERSIONS_OPERATION}; Payload leaves it undeclared and then admits every ` +
|
|
168
|
+
'signed-in user, so a scoped read is bypassed by asking for a version of a document ' +
|
|
169
|
+
'instead of the document',
|
|
170
|
+
},
|
|
171
|
+
]
|
|
172
|
+
: []);
|
|
116
173
|
// `mimeTypes` defaults to undefined, so an upload collection takes whatever a client sends until the
|
|
117
174
|
// project says otherwise. Served from the application's own origin, an uploaded SVG is script that runs
|
|
118
175
|
// as the site, which is why the restriction is required rather than advised. No size cap is asked for
|
|
@@ -139,4 +196,104 @@ const unrestrictedUploadIn = (found) => {
|
|
|
139
196
|
};
|
|
140
197
|
/** Report an upload collection that accepts whatever file type Payload's defaults allow. */
|
|
141
198
|
export const findUnrestrictedUploads = (source) => eachConfig(source, (kind, found) => kind.label === COLLECTION ? unrestrictedUploadIn(found) : []);
|
|
199
|
+
// An upload collection that admits SVG and has not decided how the file is served.
|
|
200
|
+
//
|
|
201
|
+
// Payload adds `Content-Security-Policy: script-src 'none'` to an SVG file response, and refuses an SVG
|
|
202
|
+
// whose text carries a script - but only on the branch where content detection found nothing and fell
|
|
203
|
+
// back to the extension. An SVG that opens with an XML declaration is detected as XML, retyped as SVG,
|
|
204
|
+
// and skips that check entirely. So a collection that admits SVG must decide the headers itself, through
|
|
205
|
+
// `modifyResponseHeaders`, or through a `handlers` entry, which answers before the headers hook runs and
|
|
206
|
+
// is therefore the same decision. Admission is read the way Payload reads it in `validateMimeType`: an
|
|
207
|
+
// entry loses its first `*` and must be a prefix of the file's type, and an empty list admits everything.
|
|
208
|
+
//
|
|
209
|
+
// A list this reader cannot see - an imported constant, a spread, a call, a template with a
|
|
210
|
+
// substitution - is treated as admitting SVG, because a rule whose silence means "safe" cannot be silent
|
|
211
|
+
// where it cannot read. The repair is cheap either way: write the list inline, or declare the headers,
|
|
212
|
+
// which cost an image nothing.
|
|
213
|
+
const SVG_MIME_TYPE = 'image/svg+xml';
|
|
214
|
+
const RESPONSE_HEADER_KEYS = ['modifyResponseHeaders', 'handlers'];
|
|
215
|
+
const ARRAY_OPEN = '[';
|
|
216
|
+
const EMPTY_LIST = '[]';
|
|
217
|
+
// A quoted string with nothing that could be a substitution inside it; a MIME type carries no quote.
|
|
218
|
+
const STRING_LITERAL = /^(['"`])([^'"`$]*)\1$/;
|
|
219
|
+
// The upload block alone, cut where its own braces close. `depthOneValue` runs to the end of the
|
|
220
|
+
// collection literal, so a depth-one key looked for in that slice would also be found in the NEXT
|
|
221
|
+
// block: `admin: { mimeTypes: ... }` would answer for `upload`.
|
|
222
|
+
const uploadBlockOf = (found) => {
|
|
223
|
+
const value = depthOneValue(found.body, 'upload');
|
|
224
|
+
if (value === undefined) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const open = value.indexOf('{');
|
|
228
|
+
return value.trimStart().startsWith('{') ? value.slice(open, blockEnd(value, open)) : undefined;
|
|
229
|
+
};
|
|
230
|
+
const coversSvg = (entry) => SVG_MIME_TYPE.startsWith(entry.replace('*', ''));
|
|
231
|
+
// The depth-zero elements of an array's inner text. `topLevelSlice` cannot serve here: the scanner
|
|
232
|
+
// jumps a string literal whole, so that slice drops exactly the characters this rule reads.
|
|
233
|
+
const arrayElements = (inner) => {
|
|
234
|
+
const commas = scanDelimited(inner, 0, (found, step) => step.character === ',' && step.depth === 0
|
|
235
|
+
? { state: [...found, step.index], stop: false }
|
|
236
|
+
: { state: found, stop: false }, []);
|
|
237
|
+
const bounds = [-1, ...commas, inner.length];
|
|
238
|
+
return bounds
|
|
239
|
+
.slice(0, -1)
|
|
240
|
+
.map((start, position) => inner.slice(start + 1, bounds[position + 1] ?? inner.length).trim())
|
|
241
|
+
.filter((element) => element.length > 0);
|
|
242
|
+
};
|
|
243
|
+
const literalOf = (element) => STRING_LITERAL.exec(element)?.[2];
|
|
244
|
+
// A provable admission outranks an unreadable neighbour, so `[...IMAGE_TYPES, 'image/svg+xml']` is
|
|
245
|
+
// reported for the entry that can be named rather than for the spread that cannot.
|
|
246
|
+
const svgAdmissionOf = (raw) => {
|
|
247
|
+
if (!raw.trimStart().startsWith(ARRAY_OPEN)) {
|
|
248
|
+
return { verdict: 'unreadable' };
|
|
249
|
+
}
|
|
250
|
+
const inner = balancedArguments(raw, raw.indexOf(ARRAY_OPEN));
|
|
251
|
+
if (inner === undefined) {
|
|
252
|
+
return { verdict: 'unreadable' };
|
|
253
|
+
}
|
|
254
|
+
const elements = arrayElements(inner);
|
|
255
|
+
if (elements.length === 0) {
|
|
256
|
+
return { verdict: 'admitted', entry: EMPTY_LIST };
|
|
257
|
+
}
|
|
258
|
+
const literals = elements.map((element) => literalOf(element));
|
|
259
|
+
const admitting = literals.find((literal) => literal !== undefined && coversSvg(literal));
|
|
260
|
+
if (admitting !== undefined) {
|
|
261
|
+
return { verdict: 'admitted', entry: admitting };
|
|
262
|
+
}
|
|
263
|
+
return literals.every((literal) => literal !== undefined)
|
|
264
|
+
? { verdict: 'excluded' }
|
|
265
|
+
: { verdict: 'unreadable' };
|
|
266
|
+
};
|
|
267
|
+
const SVG_REPAIR = 'set Content-Disposition: attachment and Content-Security-Policy: sandbox in modifyResponseHeaders';
|
|
268
|
+
const SVG_HAZARD = 'an SVG served from this origin is script that runs as the site';
|
|
269
|
+
const svgReason = (admission) => {
|
|
270
|
+
const preamble = `an upload collection admitting SVG must declare ${RESPONSE_HEADER_KEYS.join(' or ')}; `;
|
|
271
|
+
if (admission.verdict === 'unreadable') {
|
|
272
|
+
return (`${preamble}mimeTypes here is not an inline list of string literals, so whether it admits ` +
|
|
273
|
+
`${SVG_MIME_TYPE} cannot be read from this file, and ${SVG_HAZARD}; write the list inline, or ${SVG_REPAIR}`);
|
|
274
|
+
}
|
|
275
|
+
const admits = admission.entry === EMPTY_LIST
|
|
276
|
+
? `the empty mimeTypes list admits every type, ${SVG_MIME_TYPE} included`
|
|
277
|
+
: `the mimeTypes entry '${admission.entry}' admits ${SVG_MIME_TYPE}`;
|
|
278
|
+
return (`${preamble}${admits}, ${SVG_HAZARD}, and Payload's own scripted-SVG check skips a file that ` +
|
|
279
|
+
`opens with an XML declaration; ${SVG_REPAIR}, or drop the entry`);
|
|
280
|
+
};
|
|
281
|
+
const undecidedSvgHeadersIn = (found) => {
|
|
282
|
+
const block = uploadBlockOf(found);
|
|
283
|
+
if (block === undefined) {
|
|
284
|
+
return [];
|
|
285
|
+
}
|
|
286
|
+
const keys = topLevelKeys(block, 0);
|
|
287
|
+
// An absent list is the restriction rule's finding, so one collection never carries both.
|
|
288
|
+
if (!keys.includes(UPLOAD_RESTRICTION) ||
|
|
289
|
+
RESPONSE_HEADER_KEYS.some((key) => keys.includes(key))) {
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
292
|
+
const admission = svgAdmissionOf(depthOneValue(block, UPLOAD_RESTRICTION) ?? '');
|
|
293
|
+
return admission.verdict === 'excluded'
|
|
294
|
+
? []
|
|
295
|
+
: [{ line: found.line, rule: 'require-svg-response-headers', reason: svgReason(admission) }];
|
|
296
|
+
};
|
|
297
|
+
/** Report an upload collection that admits SVG, or may, without deciding the headers it is served with. */
|
|
298
|
+
export const findUndecidedSvgHeaders = (source) => eachConfig(source, (kind, found) => kind.label === COLLECTION ? undecidedSvgHeadersIn(found) : []);
|
|
142
299
|
//# sourceMappingURL=payload-access.js.map
|
|
@@ -1 +1 @@
|
|
|
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vF,MAAM,KAAK,GAAuB,aAAa,CAAC,KAAK,CAAC,CAAA;IACtD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,IAAI,GAAsB,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtD,0FAA0F;IAC1F,IACE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAClC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAAW,EAAW,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EACvE,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,SAAS,GAAiB,cAAc,CAAC,aAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9F,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU;QACrC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAChG,CAAC,CAAA;AAED,2GAA2G;AAC3G,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAA+B,EAAE,CACrF,UAAU,CACR,MAAM,EACN,CAAC,IAAuB,EAAE,KAAyB,EAA+B,EAAE,CAClF,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAChE,CAAA"}
|
|
@@ -7,7 +7,6 @@ export interface PayloadConfigKind {
|
|
|
7
7
|
/** One Payload configuration literal, with the source position its body begins at. */
|
|
8
8
|
export interface FoundPayloadConfig {
|
|
9
9
|
readonly kind: PayloadConfigKind;
|
|
10
|
-
readonly marker: number;
|
|
11
10
|
readonly body: string;
|
|
12
11
|
readonly bodyStart: number;
|
|
13
12
|
readonly line: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-configs.d.ts","sourceRoot":"","sources":["../src/payload-configs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payload-configs.d.ts","sourceRoot":"","sources":["../src/payload-configs.ts"],"names":[],"mappings":"AAaA,4EAA4E;AAC5E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAA;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CACvC;AAED,sFAAsF;AACtF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,qFAAqF;AACrF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AA0ED,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,SAAS,kBAAkB,EAI1E,CAAA;AAwCH,2EAA2E;AAC3E,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EACd,QAAQ,kBAAkB,KACzB,SAAS,iBAAiB,EAkB5B,CAAA"}
|
package/dist/payload-configs.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
// Access policy and field policy ask different questions of the same object: whether a collection or
|
|
4
|
-
// global has declared its operation boundary, and whether a privilege-bearing field has declared its
|
|
5
|
-
// own. The declaration forms must therefore have one owner. A second regex beside the access rule was
|
|
6
|
-
// how generic annotations and `satisfies` configurations previously escaped every Payload check.
|
|
1
|
+
// Share the vocabulary of Payload configuration literals across source-policy checks.
|
|
2
|
+
import { COLLECTION_OPERATIONS, GLOBAL_OPERATIONS } from './payload-defaults.js';
|
|
7
3
|
import { configBody, depthOneValue } from './payload-source.js';
|
|
8
4
|
import { balancedArguments, lineOf, NOT_FOUND, scanDelimited, } from './source-text.js';
|
|
9
5
|
const declarationPattern = (typeName) => new RegExp(String.raw `(:|satisfies)\s*${typeName}(?=[<=,)\s]|$)`, 'g');
|
|
@@ -12,27 +8,50 @@ const CONFIG_KINDS = [
|
|
|
12
8
|
kind: 'collection',
|
|
13
9
|
label: 'CollectionConfig',
|
|
14
10
|
declaration: declarationPattern('CollectionConfig'),
|
|
15
|
-
operations:
|
|
11
|
+
operations: COLLECTION_OPERATIONS,
|
|
16
12
|
},
|
|
17
13
|
{
|
|
18
14
|
kind: 'global',
|
|
19
15
|
label: 'GlobalConfig',
|
|
20
16
|
declaration: declarationPattern('GlobalConfig'),
|
|
21
|
-
operations:
|
|
17
|
+
operations: GLOBAL_OPERATIONS,
|
|
22
18
|
},
|
|
23
19
|
];
|
|
24
20
|
const SATISFIES = 'satisfies';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
// What may stand between a leading type reference and the literal it types. Every form a config is
|
|
22
|
+
// really written in puts one of four things there: `= {`, a generic argument and then `= {`, `=> ({`,
|
|
23
|
+
// or the opening brace of a function body. Taking "the next brace anywhere after the type name"
|
|
24
|
+
// instead crossed statement boundaries and read an unrelated literal further down the file as the
|
|
25
|
+
// configuration. A call argument (`= jobsAccess({ ... })`), a parameter annotation
|
|
26
|
+
// (`(config: CollectionConfig): void => { ... }`), an interface member and a type-alias member each
|
|
27
|
+
// put an identifier, a `)` or a `}` in this gap, and each was judged as though it were a collection -
|
|
28
|
+
// so the very code a project writes to GIVE a generated collection its access block was reported as a
|
|
29
|
+
// collection with none.
|
|
30
|
+
const GOVERNED_BODY = /^\s*(?:<[^;{}]*>\s*)?(?:=>?\s*(?:\(\s*)?)?\{/;
|
|
31
|
+
/** The literal a leading annotation governs, or nothing when the annotation types something else. */
|
|
32
|
+
const governedLiteral = (source, afterType) => {
|
|
33
|
+
const gap = GOVERNED_BODY.exec(source.slice(afterType));
|
|
34
|
+
if (gap === null) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const bodyStart = afterType + gap[0].length - 1;
|
|
38
|
+
const inner = balancedArguments(source, bodyStart);
|
|
39
|
+
return inner === undefined ? undefined : { body: `{${inner}}`, bodyStart };
|
|
40
|
+
};
|
|
41
|
+
/** The literal a trailing `satisfies` types: the one that closed just before it. */
|
|
42
|
+
const precedingLiteral = (source, marker) => {
|
|
43
|
+
const body = configBody(source, marker, true);
|
|
29
44
|
if (body === undefined) {
|
|
30
|
-
return
|
|
45
|
+
return undefined;
|
|
31
46
|
}
|
|
32
|
-
const bodyStart =
|
|
33
|
-
return bodyStart === NOT_FOUND
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
const bodyStart = source.lastIndexOf(body, marker);
|
|
48
|
+
return bodyStart === NOT_FOUND ? undefined : { body, bodyStart };
|
|
49
|
+
};
|
|
50
|
+
const configsOfKind = (source, kind) => [...source.matchAll(kind.declaration)].flatMap((match) => {
|
|
51
|
+
const literal = match[1] === SATISFIES
|
|
52
|
+
? precedingLiteral(source, match.index)
|
|
53
|
+
: governedLiteral(source, match.index + match[0].length);
|
|
54
|
+
return literal === undefined ? [] : [{ kind, ...literal, line: lineOf(source, match.index) }];
|
|
36
55
|
});
|
|
37
56
|
/** Every collection and global configuration literal the source declares. */
|
|
38
57
|
export const payloadConfigsIn = (source) => CONFIG_KINDS.flatMap((kind) => configsOfKind(source, kind));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-configs.js","sourceRoot":"","sources":["../src/payload-configs.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"payload-configs.js","sourceRoot":"","sources":["../src/payload-configs.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E,IAAI,CAAC,IAAI,CAAC,CAAA;QACrE,OAAO,IAAI,KAAK,SAAS;YACvB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5E,CAAC,CACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** The operations a collection must decide; the static rule holds a written config to the same list. */
|
|
2
|
+
export declare const COLLECTION_OPERATIONS: readonly string[];
|
|
3
|
+
/** The operations a global must decide. */
|
|
4
|
+
export declare const GLOBAL_OPERATIONS: readonly string[];
|
|
5
|
+
/** The operation an auth collection decides on top of the four: who may clear a locked account. */
|
|
6
|
+
export declare const UNLOCK_OPERATION: string;
|
|
7
|
+
/** The operation a versioned collection or global decides: who may read a stored version. */
|
|
8
|
+
export declare const READ_VERSIONS_OPERATION: string;
|
|
9
|
+
/** What an entity of the built configuration is, as far as the operations it owes depend on it. */
|
|
10
|
+
export interface PayloadSubjectTraits {
|
|
11
|
+
readonly kind: PayloadSubjectKind;
|
|
12
|
+
readonly hasAuth: boolean;
|
|
13
|
+
readonly hasVersions: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The access operations one entity owes a decision on. Two of them are conditional, and neither may be
|
|
17
|
+
* added to the lists above: Payload writes `unlock` onto EVERY collection during sanitisation, auth or
|
|
18
|
+
* not, so demanding it unconditionally would report the whole configuration, and `readVersions` means
|
|
19
|
+
* nothing on an entity that keeps no versions.
|
|
20
|
+
* @param traits what the entity is: its kind, and whether it authenticates or keeps versions.
|
|
21
|
+
* @returns the operations that entity must decide, in the order they are reported.
|
|
22
|
+
*/
|
|
23
|
+
export declare const accessOperationsFor: (traits: PayloadSubjectTraits) => readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* The prefix the probe prints its report behind. A plugin may log on import, and a line the parser can
|
|
26
|
+
* name is what separates the report from that chatter.
|
|
27
|
+
*/
|
|
28
|
+
export declare const INHERITED_ACCESS_REPORT_MARKER: string;
|
|
29
|
+
/** One entity of the built configuration and the operations it left to Payload's default. */
|
|
30
|
+
export interface InheritedAccessEntry {
|
|
31
|
+
readonly slug: string;
|
|
32
|
+
readonly inherited: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* What a read rule answered an anonymous caller, as the probe observed it. `filtered` carries the
|
|
36
|
+
* query constraint the rule returned, which is the half `/api/access` reports and the anonymous sweep
|
|
37
|
+
* never opens; `undecidable` is a rule that threw when asked, which is reported rather than assumed
|
|
38
|
+
* safe.
|
|
39
|
+
*/
|
|
40
|
+
export type AnonymousRead = {
|
|
41
|
+
readonly kind: 'denied';
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: 'filtered';
|
|
44
|
+
readonly where: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: 'open';
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'undecidable';
|
|
49
|
+
readonly reason: string;
|
|
50
|
+
};
|
|
51
|
+
/** One entity that keeps drafts, and what its read rule answers a caller with no credentials. */
|
|
52
|
+
export interface DraftReadEntry {
|
|
53
|
+
readonly kind: PayloadSubjectKind;
|
|
54
|
+
readonly slug: string;
|
|
55
|
+
readonly anonymousRead: AnonymousRead;
|
|
56
|
+
}
|
|
57
|
+
/** What the probe reports: every collection and every global, decided ones included. */
|
|
58
|
+
export interface InheritedAccessReport {
|
|
59
|
+
readonly collections: readonly InheritedAccessEntry[];
|
|
60
|
+
readonly draftReads: readonly DraftReadEntry[];
|
|
61
|
+
readonly globals: readonly InheritedAccessEntry[];
|
|
62
|
+
}
|
|
63
|
+
/** The two kinds of entity a Payload configuration holds. */
|
|
64
|
+
export type PayloadSubjectKind = 'collection' | 'global';
|
|
65
|
+
/** One entity Payload builds for its own bookkeeping, which keeps the default access by design. */
|
|
66
|
+
export interface ExemptPayloadSubject {
|
|
67
|
+
readonly kind: PayloadSubjectKind;
|
|
68
|
+
readonly slug: string;
|
|
69
|
+
readonly reason: string;
|
|
70
|
+
}
|
|
71
|
+
/** The entities exempt from the rule, each with the reason. Nothing a project declares extends this. */
|
|
72
|
+
export declare const EXEMPT_PAYLOAD_SUBJECTS: readonly ExemptPayloadSubject[];
|
|
73
|
+
/**
|
|
74
|
+
* The saved-filter collection Payload builds behind `enableQueryPresets`.
|
|
75
|
+
*
|
|
76
|
+
* It is named here because the probe has to read its access from somewhere other than the collection.
|
|
77
|
+
* `getAccess` wraps EVERY operation of this one collection in a closure that calls the project's rule
|
|
78
|
+
* where there is one and Payload's own default where there is not, so the built collection carries four
|
|
79
|
+
* functions that match neither the default by reference nor its source text. Read there, a project that
|
|
80
|
+
* decided nothing is indistinguishable from one that decided everything - and undecided means an
|
|
81
|
+
* unconstrained `create` for any signed-in user, and a preset shared as `everyone` readable by every
|
|
82
|
+
* role that can log in, the ones a project keeps outside its editorial staff included.
|
|
83
|
+
*/
|
|
84
|
+
export declare const QUERY_PRESETS_SLUG: string;
|
|
85
|
+
/**
|
|
86
|
+
* Every entity of the built configuration that still carries Payload's default access on a judged
|
|
87
|
+
* operation, in configuration order, each naming where the project decides it.
|
|
88
|
+
* @param report what the probe read from the built configuration.
|
|
89
|
+
* @returns one finding per entity, or nothing when every entity decides its access.
|
|
90
|
+
*/
|
|
91
|
+
export declare const findInheritedAccess: (report: InheritedAccessReport) => readonly string[];
|
|
92
|
+
/**
|
|
93
|
+
* Whether a read filter admits published documents alone.
|
|
94
|
+
*
|
|
95
|
+
* A clause under `and` is enough on its own, because every conjunct holds. A clause under `or` counts
|
|
96
|
+
* only when EVERY branch carries one, because a single branch without it is a way in - which is the
|
|
97
|
+
* shape of the defect this rule exists for.
|
|
98
|
+
* @param where the query constraint the read rule returned.
|
|
99
|
+
* @returns whether every document the filter admits is a published one.
|
|
100
|
+
*/
|
|
101
|
+
export declare const requiresPublishedStatus: (where: unknown) => boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Every entity that keeps drafts and lets a stranger read something that was never approved, in
|
|
104
|
+
* configuration order.
|
|
105
|
+
* @param report what the probe read from the built configuration.
|
|
106
|
+
* @returns one finding per entity, or nothing when no drafts read admits an unapproved document.
|
|
107
|
+
*/
|
|
108
|
+
export declare const findUnconstrainedDraftReads: (report: InheritedAccessReport) => readonly string[];
|
|
109
|
+
/**
|
|
110
|
+
* Read the probe's report out of everything the probe wrote to standard output.
|
|
111
|
+
*
|
|
112
|
+
* The LAST marker line is the report, so a plugin that logs during import cannot hide it, and a report
|
|
113
|
+
* that fails to parse or has the wrong shape is undefined rather than empty: a probe that printed a
|
|
114
|
+
* stack trace must fail the gate, never pass it as "no findings".
|
|
115
|
+
* @param text the probe's standard output.
|
|
116
|
+
* @returns the report, or undefined when no well-formed report was printed.
|
|
117
|
+
*/
|
|
118
|
+
export declare const parseInheritedAccessReport: (text: string) => InheritedAccessReport | undefined;
|
|
119
|
+
/** Where a Payload member keeps its configuration when its tsconfig says nothing else. */
|
|
120
|
+
export declare const DEFAULT_PAYLOAD_CONFIG_PATH: string;
|
|
121
|
+
/**
|
|
122
|
+
* The path of the Payload configuration a member's tsconfig aliases as `@payload-config`, which is the
|
|
123
|
+
* alias `ploaness init` writes and Payload's own CLI resolves through.
|
|
124
|
+
* @param tsconfig the parsed tsconfig, or anything when it could not be read.
|
|
125
|
+
* @returns the configured path relative to the member root, or the default path.
|
|
126
|
+
*/
|
|
127
|
+
export declare const payloadConfigPathOf: (tsconfig: unknown) => string;
|
|
128
|
+
//# sourceMappingURL=payload-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-defaults.d.ts","sourceRoot":"","sources":["../src/payload-defaults.ts"],"names":[],"mappings":"AAgBA,wGAAwG;AACxG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA2C,CAAA;AAE9F,2CAA2C;AAC3C,eAAO,MAAM,iBAA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