@ploaness/governance 1.0.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.
Files changed (222) hide show
  1. package/dist/a11y-hit-target.d.ts +35 -0
  2. package/dist/a11y-hit-target.d.ts.map +1 -0
  3. package/dist/a11y-hit-target.js +82 -0
  4. package/dist/a11y-hit-target.js.map +1 -0
  5. package/dist/a11y-incomplete.d.ts +18 -0
  6. package/dist/a11y-incomplete.d.ts.map +1 -0
  7. package/dist/a11y-incomplete.js +65 -0
  8. package/dist/a11y-incomplete.js.map +1 -0
  9. package/dist/access-boundary.d.ts +62 -6
  10. package/dist/access-boundary.d.ts.map +1 -1
  11. package/dist/access-boundary.js +201 -6
  12. package/dist/access-boundary.js.map +1 -1
  13. package/dist/admin-view-coverage.d.ts +25 -0
  14. package/dist/admin-view-coverage.d.ts.map +1 -0
  15. package/dist/admin-view-coverage.js +74 -0
  16. package/dist/admin-view-coverage.js.map +1 -0
  17. package/dist/asset-policy.d.ts.map +1 -1
  18. package/dist/asset-policy.js +1 -23
  19. package/dist/asset-policy.js.map +1 -1
  20. package/dist/axe-coverage.d.ts +40 -0
  21. package/dist/axe-coverage.d.ts.map +1 -0
  22. package/dist/axe-coverage.js +62 -0
  23. package/dist/axe-coverage.js.map +1 -0
  24. package/dist/banned-typography.d.ts.map +1 -1
  25. package/dist/banned-typography.js +26 -0
  26. package/dist/banned-typography.js.map +1 -1
  27. package/dist/blocklist-entries.d.ts +36 -0
  28. package/dist/blocklist-entries.d.ts.map +1 -0
  29. package/dist/blocklist-entries.js +338 -0
  30. package/dist/blocklist-entries.js.map +1 -0
  31. package/dist/blocklist.d.ts +91 -0
  32. package/dist/blocklist.d.ts.map +1 -0
  33. package/dist/blocklist.js +187 -0
  34. package/dist/blocklist.js.map +1 -0
  35. package/dist/build-diagnosis.d.ts +10 -0
  36. package/dist/build-diagnosis.d.ts.map +1 -0
  37. package/dist/build-diagnosis.js +38 -0
  38. package/dist/build-diagnosis.js.map +1 -0
  39. package/dist/container-failure.d.ts.map +1 -1
  40. package/dist/container-failure.js +1 -18
  41. package/dist/container-failure.js.map +1 -1
  42. package/dist/container-files.d.ts +16 -0
  43. package/dist/container-files.d.ts.map +1 -1
  44. package/dist/container-files.js +23 -8
  45. package/dist/container-files.js.map +1 -1
  46. package/dist/container-images.d.ts +43 -0
  47. package/dist/container-images.d.ts.map +1 -0
  48. package/dist/container-images.js +157 -0
  49. package/dist/container-images.js.map +1 -0
  50. package/dist/dependency-freshness.d.ts +8 -0
  51. package/dist/dependency-freshness.d.ts.map +1 -1
  52. package/dist/dependency-freshness.js +2 -18
  53. package/dist/dependency-freshness.js.map +1 -1
  54. package/dist/doc-blocks.d.ts.map +1 -1
  55. package/dist/doc-blocks.js +1 -13
  56. package/dist/doc-blocks.js.map +1 -1
  57. package/dist/document-references.d.ts.map +1 -1
  58. package/dist/document-references.js +7 -1
  59. package/dist/document-references.js.map +1 -1
  60. package/dist/editorconfig-policy.d.ts +7 -0
  61. package/dist/editorconfig-policy.d.ts.map +1 -1
  62. package/dist/editorconfig-policy.js +19 -12
  63. package/dist/editorconfig-policy.js.map +1 -1
  64. package/dist/environment-coherence.d.ts +87 -0
  65. package/dist/environment-coherence.d.ts.map +1 -0
  66. package/dist/environment-coherence.js +128 -0
  67. package/dist/environment-coherence.js.map +1 -0
  68. package/dist/environment-files.d.ts.map +1 -1
  69. package/dist/environment-files.js +1 -19
  70. package/dist/environment-files.js.map +1 -1
  71. package/dist/file-roles.d.ts +7 -2
  72. package/dist/file-roles.d.ts.map +1 -1
  73. package/dist/file-roles.js +10 -9
  74. package/dist/file-roles.js.map +1 -1
  75. package/dist/freshness-repair.d.ts +82 -0
  76. package/dist/freshness-repair.d.ts.map +1 -0
  77. package/dist/freshness-repair.js +91 -0
  78. package/dist/freshness-repair.js.map +1 -0
  79. package/dist/generated-denial.d.ts.map +1 -1
  80. package/dist/generated-denial.js +1 -9
  81. package/dist/generated-denial.js.map +1 -1
  82. package/dist/generated-drift.d.ts +18 -0
  83. package/dist/generated-drift.d.ts.map +1 -0
  84. package/dist/generated-drift.js +24 -0
  85. package/dist/generated-drift.js.map +1 -0
  86. package/dist/harness-package.d.ts +13 -0
  87. package/dist/harness-package.d.ts.map +1 -0
  88. package/dist/harness-package.js +20 -0
  89. package/dist/harness-package.js.map +1 -0
  90. package/dist/history-policy.d.ts.map +1 -1
  91. package/dist/history-policy.js +1 -7
  92. package/dist/history-policy.js.map +1 -1
  93. package/dist/image-assets.d.ts.map +1 -1
  94. package/dist/image-assets.js +1 -10
  95. package/dist/image-assets.js.map +1 -1
  96. package/dist/index.d.ts +22 -1
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +22 -1
  99. package/dist/index.js.map +1 -1
  100. package/dist/install-policy.d.ts +21 -0
  101. package/dist/install-policy.d.ts.map +1 -1
  102. package/dist/install-policy.js +53 -1
  103. package/dist/install-policy.js.map +1 -1
  104. package/dist/jsx-accessibility-scope.d.ts +17 -0
  105. package/dist/jsx-accessibility-scope.d.ts.map +1 -0
  106. package/dist/jsx-accessibility-scope.js +36 -0
  107. package/dist/jsx-accessibility-scope.js.map +1 -0
  108. package/dist/jsx-accessibility.d.ts +13 -0
  109. package/dist/jsx-accessibility.d.ts.map +1 -0
  110. package/dist/jsx-accessibility.js +188 -0
  111. package/dist/jsx-accessibility.js.map +1 -0
  112. package/dist/network-policy.d.ts.map +1 -1
  113. package/dist/network-policy.js +1 -12
  114. package/dist/network-policy.js.map +1 -1
  115. package/dist/oxlint-policy.d.ts +16 -0
  116. package/dist/oxlint-policy.d.ts.map +1 -0
  117. package/dist/oxlint-policy.js +28 -0
  118. package/dist/oxlint-policy.js.map +1 -0
  119. package/dist/oxlint-report.d.ts +29 -0
  120. package/dist/oxlint-report.d.ts.map +1 -0
  121. package/dist/oxlint-report.js +84 -0
  122. package/dist/oxlint-report.js.map +1 -0
  123. package/dist/oxlint-scope.d.ts +13 -0
  124. package/dist/oxlint-scope.d.ts.map +1 -0
  125. package/dist/oxlint-scope.js +46 -0
  126. package/dist/oxlint-scope.js.map +1 -0
  127. package/dist/oxlint-suppressions.d.ts +17 -0
  128. package/dist/oxlint-suppressions.d.ts.map +1 -0
  129. package/dist/oxlint-suppressions.js +72 -0
  130. package/dist/oxlint-suppressions.js.map +1 -0
  131. package/dist/paired-assets.d.ts.map +1 -1
  132. package/dist/paired-assets.js.map +1 -1
  133. package/dist/payload-access.d.ts +6 -0
  134. package/dist/payload-access.d.ts.map +1 -1
  135. package/dist/payload-access.js +188 -57
  136. package/dist/payload-access.js.map +1 -1
  137. package/dist/payload-configs.d.ts +23 -0
  138. package/dist/payload-configs.d.ts.map +1 -0
  139. package/dist/payload-configs.js +96 -0
  140. package/dist/payload-configs.js.map +1 -0
  141. package/dist/payload-defaults.d.ts +128 -0
  142. package/dist/payload-defaults.d.ts.map +1 -0
  143. package/dist/payload-defaults.js +295 -0
  144. package/dist/payload-defaults.js.map +1 -0
  145. package/dist/payload-field-access.d.ts +4 -0
  146. package/dist/payload-field-access.d.ts.map +1 -0
  147. package/dist/payload-field-access.js +51 -0
  148. package/dist/payload-field-access.js.map +1 -0
  149. package/dist/payload-policy.d.ts +13 -0
  150. package/dist/payload-policy.d.ts.map +1 -1
  151. package/dist/payload-policy.js +171 -32
  152. package/dist/payload-policy.js.map +1 -1
  153. package/dist/payload-source.js +2 -2
  154. package/dist/payload-source.js.map +1 -1
  155. package/dist/relationship-cleanup.d.ts +18 -0
  156. package/dist/relationship-cleanup.d.ts.map +1 -0
  157. package/dist/relationship-cleanup.js +96 -0
  158. package/dist/relationship-cleanup.js.map +1 -0
  159. package/dist/release-age.d.ts.map +1 -1
  160. package/dist/release-age.js +1 -16
  161. package/dist/release-age.js.map +1 -1
  162. package/dist/request-limits.d.ts.map +1 -1
  163. package/dist/request-limits.js +1 -11
  164. package/dist/request-limits.js.map +1 -1
  165. package/dist/route-coverage.d.ts +27 -0
  166. package/dist/route-coverage.d.ts.map +1 -0
  167. package/dist/route-coverage.js +57 -0
  168. package/dist/route-coverage.js.map +1 -0
  169. package/dist/route-map.d.ts +65 -0
  170. package/dist/route-map.d.ts.map +1 -0
  171. package/dist/route-map.js +168 -0
  172. package/dist/route-map.js.map +1 -0
  173. package/dist/run-plan.d.ts.map +1 -1
  174. package/dist/run-plan.js +1 -19
  175. package/dist/run-plan.js.map +1 -1
  176. package/dist/secret-policy.d.ts.map +1 -1
  177. package/dist/secret-policy.js +5 -15
  178. package/dist/secret-policy.js.map +1 -1
  179. package/dist/settings-layering.d.ts +8 -30
  180. package/dist/settings-layering.d.ts.map +1 -1
  181. package/dist/settings-layering.js +19 -48
  182. package/dist/settings-layering.js.map +1 -1
  183. package/dist/settings.d.ts +19 -2
  184. package/dist/settings.d.ts.map +1 -1
  185. package/dist/settings.js +5 -1
  186. package/dist/settings.js.map +1 -1
  187. package/dist/source-security.d.ts +4 -0
  188. package/dist/source-security.d.ts.map +1 -0
  189. package/dist/source-security.js +56 -0
  190. package/dist/source-security.js.map +1 -0
  191. package/dist/source-text.d.ts +16 -0
  192. package/dist/source-text.d.ts.map +1 -1
  193. package/dist/source-text.js +46 -16
  194. package/dist/source-text.js.map +1 -1
  195. package/dist/toolchain-pins.d.ts.map +1 -1
  196. package/dist/toolchain-pins.js +2 -19
  197. package/dist/toolchain-pins.js.map +1 -1
  198. package/dist/version-policy.d.ts +7 -8
  199. package/dist/version-policy.d.ts.map +1 -1
  200. package/dist/version-policy.js +46 -26
  201. package/dist/version-policy.js.map +1 -1
  202. package/dist/vulnerability-policy.d.ts.map +1 -1
  203. package/dist/vulnerability-policy.js +1 -11
  204. package/dist/vulnerability-policy.js.map +1 -1
  205. package/dist/wiring-policy.d.ts.map +1 -1
  206. package/dist/wiring-policy.js +4 -1
  207. package/dist/wiring-policy.js.map +1 -1
  208. package/dist/wiring-violation.d.ts.map +1 -1
  209. package/dist/wiring-violation.js +1 -6
  210. package/dist/wiring-violation.js.map +1 -1
  211. package/dist/workspace-policy.d.ts.map +1 -1
  212. package/dist/workspace-policy.js +3 -9
  213. package/dist/workspace-policy.js.map +1 -1
  214. package/dist/yaml-blocks.d.ts +10 -0
  215. package/dist/yaml-blocks.d.ts.map +1 -1
  216. package/dist/yaml-blocks.js +20 -0
  217. package/dist/yaml-blocks.js.map +1 -1
  218. package/package.json +2 -2
  219. package/dist/url-safety.d.ts +0 -12
  220. package/dist/url-safety.d.ts.map +0 -1
  221. package/dist/url-safety.js +0 -58
  222. package/dist/url-safety.js.map +0 -1
@@ -2,8 +2,14 @@ import { type PayloadViolation } from './payload-source.js';
2
2
  export declare const findUndeclaredAccess: (source: string) => readonly PayloadViolation[];
3
3
  /** Report an auth collection that leaves the login-attempt cap and lock time to Payload's defaults. */
4
4
  export declare const findUnhardenedAuth: (source: string) => readonly PayloadViolation[];
5
+ /** Report an auth collection that leaves who may clear a lockout to Payload's default. */
6
+ export declare const findUnlockableAuth: (source: string) => readonly PayloadViolation[];
5
7
  /** Report a config whose drafts are readable by an unauthenticated client. */
6
8
  export declare const findAnonymousDraftReads: (source: string) => readonly PayloadViolation[];
9
+ /** Report a config that keeps versions and leaves who may read them to Payload's fall-through. */
10
+ export declare const findUndeclaredVersionReads: (source: string) => readonly PayloadViolation[];
7
11
  /** Report an upload collection that accepts whatever file type Payload's defaults allow. */
8
12
  export declare const findUnrestrictedUploads: (source: string) => readonly PayloadViolation[];
13
+ /** Report an upload collection that admits SVG, or may, without deciding the headers it is served with. */
14
+ export declare const findUndecidedSvgHeaders: (source: string) => readonly PayloadViolation[];
9
15
  //# sourceMappingURL=payload-access.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payload-access.d.ts","sourceRoot":"","sources":["../src/payload-access.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAA;AA4E5B,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAkB3E,CAAA;AAkCJ,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAG1E,CAAA;AA2CH,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAa/E,CAAA;AA6BH,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAG/E,CAAA"}
1
+ {"version":3,"file":"payload-access.d.ts","sourceRoot":"","sources":["../src/payload-access.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAA;AAsB5B,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAqB5E,CAAA;AA8CH,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAK1E,CAAA;AA6BH,0FAA0F;AAC1F,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAK1E,CAAA;AAgDH,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAe/E,CAAA;AAiBH,kGAAkG;AAClG,eAAO,MAAM,0BAA0B,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAkBlF,CAAA;AA6BH,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAK/E,CAAA;AAsIH,2GAA2G;AAC3G,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,SAAS,gBAAgB,EAK/E,CAAA"}
@@ -5,49 +5,14 @@
5
5
  // question the others do not ask - "which object literal IS this config" - and because together the two
6
6
  // halves passed the file size cap. Every one of them is a security decision that Payload will silently
7
7
  // make on the project's behalf if the project does not make it first.
8
+ import { payloadConfigsIn, } from './payload-configs.js';
8
9
  import { configBody, depthOneBlockKeys, depthOneValue, } from './payload-source.js';
9
- import { lineOf, NOT_FOUND, topLevelKeys } from './source-text.js';
10
- // The three ways a Payload config is declared, all of them idiomatic:
11
- //
12
- // const Users: CollectionConfig = { ... } the annotation
13
- // const Users: CollectionConfig<'users'> = { ... } the annotation, with the slug as a type argument
14
- // const Users = { ... } satisfies CollectionConfig the inferred form
15
- //
16
- // Only the first was matched for a long time, because the lookahead that stopped `CollectionConfigs`
17
- // from matching also excluded `<`, and nothing looked for `satisfies` at all. A collection written
18
- // either of the other two ways passed every rule below without one of them ever reading it - which is
19
- // the worst failure a gate can have, because it is indistinguishable from a pass.
20
- const declarationPattern = (typeName) => new RegExp(String.raw `(:|satisfies)\s*${typeName}(?=[<=,)\s]|$)`, 'g');
21
- /** The operations a collection must decide for itself rather than inherit. */
22
- const COLLECTION_OPERATIONS = ['create', 'read', 'update', 'delete'];
23
- /** A global has no create or delete: it exists from the moment it is configured. */
24
- const GLOBAL_OPERATIONS = ['read', 'update'];
25
- const CONFIG_KINDS = [
26
- {
27
- label: 'CollectionConfig',
28
- declaration: declarationPattern('CollectionConfig'),
29
- operations: COLLECTION_OPERATIONS,
30
- },
31
- {
32
- label: 'GlobalConfig',
33
- declaration: declarationPattern('GlobalConfig'),
34
- operations: GLOBAL_OPERATIONS,
35
- },
36
- ];
37
- const SATISFIES = 'satisfies';
38
- // EVERY config in the file, not the first. `search` returned one offset, so a module exporting two
39
- // collections - or a collection beside a global - had its second config judged by nothing at all. The
40
- // Local API rules already iterated their matches; these did not, and the asymmetry was invisible
41
- // because a file with one config, which is most of them, behaves identically either way.
42
- const findConfigs = (source, kind) => [...source.matchAll(kind.declaration)].flatMap((match) => {
43
- const body = configBody(source, match.index, match[1] === SATISFIES);
44
- return body === undefined ? [] : [{ marker: match.index, body }];
45
- });
46
- const eachConfig = (source, judge) => CONFIG_KINDS.flatMap((kind) => findConfigs(source, kind).flatMap((found) => judge(kind, found)));
10
+ import { balancedArguments, NOT_FOUND, scanDelimited, topLevelKeys, } from './source-text.js';
11
+ const eachConfig = (source, judge) => payloadConfigsIn(source).flatMap((found) => judge(found.kind, found));
47
12
  // Payload fills the missing operations in during sanitisation, so a partial access block is invisible
48
- // the moment the app boots - and its default for a non-auth collection is public read. Checking that
49
- // the word `access` appears somewhere in the file, which is what this rule used to do, accepted a block
50
- // 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.
51
16
  export const findUndeclaredAccess = (source) => eachConfig(source, (kind, found) => {
52
17
  const declared = depthOneBlockKeys(found.body, 'access');
53
18
  const missing = kind.operations.filter((operation) => !declared.includes(operation));
@@ -55,11 +20,11 @@ export const findUndeclaredAccess = (source) => eachConfig(source, (kind, found)
55
20
  ? []
56
21
  : [
57
22
  {
58
- line: lineOf(source, found.marker),
23
+ line: found.line,
59
24
  rule: 'require-complete-access',
60
25
  reason: `a ${kind.label} must declare access for ${kind.operations.join(', ')}; ` +
61
- `${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} left to the Payload ` +
62
- 'defaults, which allow public read',
26
+ `${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} left to Payload's ` +
27
+ 'default, which admits every signed-in user',
63
28
  },
64
29
  ];
65
30
  });
@@ -68,7 +33,11 @@ export const findUndeclaredAccess = (source) => eachConfig(source, (kind, found)
68
33
  // the case this rule most needs to catch.
69
34
  const AUTH_HARDENING_KEYS = ['maxLoginAttempts', 'lockTime'];
70
35
  const COLLECTION = 'CollectionConfig';
71
- const unhardenedAuthIn = (source, found) => {
36
+ const leadingNumber = (value) => {
37
+ const match = /^\s*(-?\d[\d_]*(?:\.\d[\d_]*)?)\s*(?=[,}])/.exec(value ?? '');
38
+ return match === null ? undefined : Number((match[1] ?? '').replaceAll('_', ''));
39
+ };
40
+ const unhardenedAuthIn = (found) => {
72
41
  const value = depthOneValue(found.body, 'auth');
73
42
  if (value === undefined) {
74
43
  return [];
@@ -77,20 +46,51 @@ const unhardenedAuthIn = (source, found) => {
77
46
  ? topLevelKeys(value, 0)
78
47
  : [];
79
48
  const missing = AUTH_HARDENING_KEYS.filter((key) => !declared.includes(key));
80
- return missing.length === 0
49
+ const disabled = AUTH_HARDENING_KEYS.filter((key) => {
50
+ const numeric = leadingNumber(depthOneValue(value, key));
51
+ return numeric !== undefined && numeric <= 0;
52
+ });
53
+ return missing.length === 0 && disabled.length === 0
81
54
  ? []
82
55
  : [
83
56
  {
84
- line: lineOf(source, found.marker),
57
+ line: found.line,
85
58
  rule: 'require-auth-hardening',
86
59
  reason: `an auth collection must declare ${AUTH_HARDENING_KEYS.join(' and ')}; ` +
87
- `${missing.join(' and ')} left to the Payload defaults means a login attempt is never ` +
88
- 'capped and an account is never locked',
60
+ (missing.length === 0 ? '' : `${missing.join(' and ')} is missing; `) +
61
+ (disabled.length === 0 ? '' : `${disabled.join(' and ')} is not positive; `) +
62
+ 'without a positive attempt cap and lock time, login guesses are not bounded',
89
63
  },
90
64
  ];
91
65
  };
92
66
  /** Report an auth collection that leaves the login-attempt cap and lock time to Payload's defaults. */
93
- export const findUnhardenedAuth = (source) => eachConfig(source, (kind, found) => kind.label === COLLECTION ? unhardenedAuthIn(source, found) : []);
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) : []);
94
94
  // A draft is unpublished content. With versions.drafts enabled, `?draft=true` serves it to whoever the
95
95
  // read rule admits - so a read that is unconditionally true publishes every draft to anyone.
96
96
  const DRAFTS_ENABLED = /drafts\s*:\s*(?:true|\{)/;
@@ -113,9 +113,14 @@ const blockEnd = (access, open) => {
113
113
  // collection itself were open to anyone.
114
114
  //
115
115
  // Only the inline form is decidable here, and the lint pass forbids that form in a config file, so a
116
- // conforming project writes `read: anyone` and this rule stays silent on it. What covers the conforming
117
- // case is the managed access-boundary sweep, which asks the running application what it grants rather
118
- // than reading the source. This rule reaches a config declared outside the linted directories.
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.
119
124
  const isDraftExposed = (body) => {
120
125
  const versions = depthOneValue(body, 'versions');
121
126
  if (versions === undefined || !DRAFTS_ENABLED.test(versions)) {
@@ -132,19 +137,45 @@ const isDraftExposed = (body) => {
132
137
  export const findAnonymousDraftReads = (source) => eachConfig(source, (kind, found) => isDraftExposed(found.body)
133
138
  ? [
134
139
  {
135
- line: lineOf(source, found.marker),
140
+ line: found.line,
136
141
  rule: 'no-anonymous-draft-reads',
137
142
  reason: `a ${kind.label} with drafts enabled must not grant an unconditionally true read; ` +
138
143
  'an unauthenticated client would fetch unpublished drafts through ?draft=true',
139
144
  },
140
145
  ]
141
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
+ : []);
142
173
  // `mimeTypes` defaults to undefined, so an upload collection takes whatever a client sends until the
143
174
  // project says otherwise. Served from the application's own origin, an uploaded SVG is script that runs
144
175
  // as the site, which is why the restriction is required rather than advised. No size cap is asked for
145
176
  // here: Payload takes that at the config root rather than on the collection.
146
177
  const UPLOAD_RESTRICTION = 'mimeTypes';
147
- const unrestrictedUploadIn = (source, found) => {
178
+ const unrestrictedUploadIn = (found) => {
148
179
  const value = depthOneValue(found.body, 'upload');
149
180
  if (value === undefined) {
150
181
  return [];
@@ -156,7 +187,7 @@ const unrestrictedUploadIn = (source, found) => {
156
187
  ? []
157
188
  : [
158
189
  {
159
- line: lineOf(source, found.marker),
190
+ line: found.line,
160
191
  rule: 'require-upload-restrictions',
161
192
  reason: `an upload collection must declare ${UPLOAD_RESTRICTION}; left undeclared it accepts ` +
162
193
  'any file, and an SVG served from this origin is script that runs as the site',
@@ -164,5 +195,105 @@ const unrestrictedUploadIn = (source, found) => {
164
195
  ];
165
196
  };
166
197
  /** Report an upload collection that accepts whatever file type Payload's defaults allow. */
167
- export const findUnrestrictedUploads = (source) => eachConfig(source, (kind, found) => kind.label === COLLECTION ? unrestrictedUploadIn(source, found) : []);
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) : []);
168
299
  //# sourceMappingURL=payload-access.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payload-access.js","sourceRoot":"","sources":["../src/payload-access.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,sCAAsC;AACtC,EAAE;AACF,iGAAiG;AACjG,wGAAwG;AACxG,uGAAuG;AACvG,sEAAsE;AACtE,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,aAAa,GAEd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAElE,sEAAsE;AACtE,EAAE;AACF,oEAAoE;AACpE,sGAAsG;AACtG,uEAAuE;AACvE,EAAE;AACF,qGAAqG;AACrG,mGAAmG;AACnG,sGAAsG;AACtG,kFAAkF;AAClF,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAU,EAAE,CACtD,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,mBAAmB,QAAQ,gBAAgB,EAAE,GAAG,CAAC,CAAA;AAExE,8EAA8E;AAC9E,MAAM,qBAAqB,GAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAEvF,oFAAoF;AACpF,MAAM,iBAAiB,GAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAS/D,MAAM,YAAY,GAA0B;IAC1C;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,kBAAkB,CAAC,kBAAkB,CAAC;QACnD,UAAU,EAAE,qBAAqB;KAClC;IACD;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,kBAAkB,CAAC,cAAc,CAAC;QAC/C,UAAU,EAAE,iBAAiB;KAC9B;CACF,CAAA;AAQD,MAAM,SAAS,GAAW,WAAW,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,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"}
@@ -0,0 +1,23 @@
1
+ /** The operations one Payload configuration kind must decide explicitly. */
2
+ export interface PayloadConfigKind {
3
+ readonly kind: 'collection' | 'global';
4
+ readonly label: string;
5
+ readonly operations: readonly string[];
6
+ }
7
+ /** One Payload configuration literal, with the source position its body begins at. */
8
+ export interface FoundPayloadConfig {
9
+ readonly kind: PayloadConfigKind;
10
+ readonly body: string;
11
+ readonly bodyStart: number;
12
+ readonly line: number;
13
+ }
14
+ /** One object written directly as an element of a configuration's `fields` array. */
15
+ export interface FoundFieldLiteral {
16
+ readonly body: string;
17
+ readonly line: number;
18
+ }
19
+ /** Every collection and global configuration literal the source declares. */
20
+ export declare const payloadConfigsIn: (source: string) => readonly FoundPayloadConfig[];
21
+ /** The field literals directly visible in one collection/global config. */
22
+ export declare const directFieldsIn: (source: string, config: FoundPayloadConfig) => readonly FoundFieldLiteral[];
23
+ //# sourceMappingURL=payload-configs.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,96 @@
1
+ // Share the vocabulary of Payload configuration literals across source-policy checks.
2
+ import { COLLECTION_OPERATIONS, GLOBAL_OPERATIONS } from './payload-defaults.js';
3
+ import { configBody, depthOneValue } from './payload-source.js';
4
+ import { balancedArguments, lineOf, NOT_FOUND, scanDelimited, } from './source-text.js';
5
+ const declarationPattern = (typeName) => new RegExp(String.raw `(:|satisfies)\s*${typeName}(?=[<=,)\s]|$)`, 'g');
6
+ const CONFIG_KINDS = [
7
+ {
8
+ kind: 'collection',
9
+ label: 'CollectionConfig',
10
+ declaration: declarationPattern('CollectionConfig'),
11
+ operations: COLLECTION_OPERATIONS,
12
+ },
13
+ {
14
+ kind: 'global',
15
+ label: 'GlobalConfig',
16
+ declaration: declarationPattern('GlobalConfig'),
17
+ operations: GLOBAL_OPERATIONS,
18
+ },
19
+ ];
20
+ const SATISFIES = 'satisfies';
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);
44
+ if (body === undefined) {
45
+ return undefined;
46
+ }
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) }];
55
+ });
56
+ /** Every collection and global configuration literal the source declares. */
57
+ export const payloadConfigsIn = (source) => CONFIG_KINDS.flatMap((kind) => configsOfKind(source, kind));
58
+ const DIRECT_FIELD_DEPTH = 2;
59
+ const closeLastSpan = (spans, close) => {
60
+ const last = spans.at(-1);
61
+ return last?.close === NOT_FOUND ? [...spans.slice(0, -1), { open: last.open, close }] : spans;
62
+ };
63
+ const opensDirectField = (step) => step.character === '{' && step.depth === DIRECT_FIELD_DEPTH;
64
+ const endsDirectField = (step) => step.character === '}' && step.depth === 1;
65
+ const endsFieldArray = (step) => step.character === ']' && step.depth === 0;
66
+ const afterFieldDelimiter = (spans, step) => {
67
+ if (opensDirectField(step)) {
68
+ return { state: [...spans, { open: step.index, close: NOT_FOUND }], stop: false };
69
+ }
70
+ if (endsDirectField(step)) {
71
+ return { state: closeLastSpan(spans, step.index), stop: false };
72
+ }
73
+ return { state: spans, stop: endsFieldArray(step) };
74
+ };
75
+ // Starting on the array opener puts its direct object elements at depth two. A nested object opens at
76
+ // depth three or more and is part of the field rather than another field beside it.
77
+ const directObjectSpans = (source, open) => scanDelimited(source, open, afterFieldDelimiter, []);
78
+ /** The field literals directly visible in one collection/global config. */
79
+ export const directFieldsIn = (source, config) => {
80
+ const fields = depthOneValue(config.body, 'fields');
81
+ if (fields === undefined) {
82
+ return [];
83
+ }
84
+ const open = fields.indexOf('[');
85
+ if (open === NOT_FOUND) {
86
+ return [];
87
+ }
88
+ const fieldsStart = config.bodyStart + config.body.length - fields.length;
89
+ return directObjectSpans(fields, open).flatMap((span) => {
90
+ const body = balancedArguments(fields, span.open);
91
+ return body === undefined
92
+ ? []
93
+ : [{ body: `{${body}}`, line: lineOf(source, fieldsStart + span.open) }];
94
+ });
95
+ };
96
+ //# sourceMappingURL=payload-configs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload-configs.js","sourceRoot":"","sources":["../src/payload-configs.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE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