@intentius/chant-lexicon-cedar 0.44.8

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 (265) hide show
  1. package/README.md +190 -0
  2. package/dist/avp/ambient.d.ts +54 -0
  3. package/dist/avp/ambient.d.ts.map +1 -0
  4. package/dist/avp/client.d.ts +127 -0
  5. package/dist/avp/client.d.ts.map +1 -0
  6. package/dist/avp/describe-resources.d.ts +42 -0
  7. package/dist/avp/describe-resources.d.ts.map +1 -0
  8. package/dist/avp/embed.d.ts +120 -0
  9. package/dist/avp/embed.d.ts.map +1 -0
  10. package/dist/avp/live-export.d.ts +94 -0
  11. package/dist/avp/live-export.d.ts.map +1 -0
  12. package/dist/avp/ownership.d.ts +97 -0
  13. package/dist/avp/ownership.d.ts.map +1 -0
  14. package/dist/avp/statement.d.ts +22 -0
  15. package/dist/avp/statement.d.ts.map +1 -0
  16. package/dist/avp/store.d.ts +82 -0
  17. package/dist/avp/store.d.ts.map +1 -0
  18. package/dist/avp/testdata/mock-transport.d.ts +55 -0
  19. package/dist/avp/testdata/mock-transport.d.ts.map +1 -0
  20. package/dist/codegen/docs-cli.d.ts +3 -0
  21. package/dist/codegen/docs-cli.d.ts.map +1 -0
  22. package/dist/codegen/docs.d.ts +26 -0
  23. package/dist/codegen/docs.d.ts.map +1 -0
  24. package/dist/codegen/emit.d.ts +85 -0
  25. package/dist/codegen/emit.d.ts.map +1 -0
  26. package/dist/codegen/generate-cli.d.ts +3 -0
  27. package/dist/codegen/generate-cli.d.ts.map +1 -0
  28. package/dist/codegen/generate.d.ts +37 -0
  29. package/dist/codegen/generate.d.ts.map +1 -0
  30. package/dist/codegen/naming.d.ts +48 -0
  31. package/dist/codegen/naming.d.ts.map +1 -0
  32. package/dist/codegen/package.d.ts +10 -0
  33. package/dist/codegen/package.d.ts.map +1 -0
  34. package/dist/composites/deny-by-default-set.d.ts +58 -0
  35. package/dist/composites/deny-by-default-set.d.ts.map +1 -0
  36. package/dist/composites/index.d.ts +12 -0
  37. package/dist/composites/index.d.ts.map +1 -0
  38. package/dist/composites/owner-can-manage.d.ts +48 -0
  39. package/dist/composites/owner-can-manage.d.ts.map +1 -0
  40. package/dist/config.d.ts +102 -0
  41. package/dist/config.d.ts.map +1 -0
  42. package/dist/coverage.d.ts +59 -0
  43. package/dist/coverage.d.ts.map +1 -0
  44. package/dist/detect.d.ts +18 -0
  45. package/dist/detect.d.ts.map +1 -0
  46. package/dist/generated/index.d.ts +251 -0
  47. package/dist/generated/index.d.ts.map +1 -0
  48. package/dist/generated/runtime.d.ts +2 -0
  49. package/dist/generated/runtime.d.ts.map +1 -0
  50. package/dist/import/adapter.d.ts +21 -0
  51. package/dist/import/adapter.d.ts.map +1 -0
  52. package/dist/import/clause-text.d.ts +38 -0
  53. package/dist/import/clause-text.d.ts.map +1 -0
  54. package/dist/import/generator.d.ts +53 -0
  55. package/dist/import/generator.d.ts.map +1 -0
  56. package/dist/import/parser.d.ts +57 -0
  57. package/dist/import/parser.d.ts.map +1 -0
  58. package/dist/index.d.ts +34 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/init-templates.d.ts +32 -0
  61. package/dist/init-templates.d.ts.map +1 -0
  62. package/dist/integrity.json +22 -0
  63. package/dist/lint/audit-catalog.d.ts +29 -0
  64. package/dist/lint/audit-catalog.d.ts.map +1 -0
  65. package/dist/lint/post-synth/cedar-helpers.d.ts +97 -0
  66. package/dist/lint/post-synth/cedar-helpers.d.ts.map +1 -0
  67. package/dist/lint/post-synth/cedc010.d.ts +17 -0
  68. package/dist/lint/post-synth/cedc010.d.ts.map +1 -0
  69. package/dist/lint/post-synth/cedc011.d.ts +17 -0
  70. package/dist/lint/post-synth/cedc011.d.ts.map +1 -0
  71. package/dist/lint/post-synth/cedc012.d.ts +21 -0
  72. package/dist/lint/post-synth/cedc012.d.ts.map +1 -0
  73. package/dist/lint/post-synth/cedc013.d.ts +20 -0
  74. package/dist/lint/post-synth/cedc013.d.ts.map +1 -0
  75. package/dist/lint/post-synth/cedc014.d.ts +19 -0
  76. package/dist/lint/post-synth/cedc014.d.ts.map +1 -0
  77. package/dist/lint/post-synth/cede010.d.ts +34 -0
  78. package/dist/lint/post-synth/cede010.d.ts.map +1 -0
  79. package/dist/lint/post-synth/cede011.d.ts +22 -0
  80. package/dist/lint/post-synth/cede011.d.ts.map +1 -0
  81. package/dist/lint/post-synth/ceds010.d.ts +24 -0
  82. package/dist/lint/post-synth/ceds010.d.ts.map +1 -0
  83. package/dist/lint/post-synth/ceds011.d.ts +19 -0
  84. package/dist/lint/post-synth/ceds011.d.ts.map +1 -0
  85. package/dist/lint/post-synth/ceds012.d.ts +17 -0
  86. package/dist/lint/post-synth/ceds012.d.ts.map +1 -0
  87. package/dist/lint/post-synth/index.d.ts +3 -0
  88. package/dist/lint/post-synth/index.d.ts.map +1 -0
  89. package/dist/lint/post-synth/wasm-helpers.d.ts +108 -0
  90. package/dist/lint/post-synth/wasm-helpers.d.ts.map +1 -0
  91. package/dist/lint/rules/index.d.ts +10 -0
  92. package/dist/lint/rules/index.d.ts.map +1 -0
  93. package/dist/lint/rules/policy-shape.d.ts +31 -0
  94. package/dist/lint/rules/policy-shape.d.ts.map +1 -0
  95. package/dist/lsp/completions.d.ts +24 -0
  96. package/dist/lsp/completions.d.ts.map +1 -0
  97. package/dist/lsp/hover.d.ts +11 -0
  98. package/dist/lsp/hover.d.ts.map +1 -0
  99. package/dist/lsp/registry.d.ts +45 -0
  100. package/dist/lsp/registry.d.ts.map +1 -0
  101. package/dist/manifest.json +8 -0
  102. package/dist/mcp/index.d.ts +34 -0
  103. package/dist/mcp/index.d.ts.map +1 -0
  104. package/dist/mcp/policy-coverage.d.ts +81 -0
  105. package/dist/mcp/policy-coverage.d.ts.map +1 -0
  106. package/dist/meta.json +699 -0
  107. package/dist/okf/index.md +37 -0
  108. package/dist/okf/rules/CEDC001.md +11 -0
  109. package/dist/okf/rules/CEDC010.md +11 -0
  110. package/dist/okf/rules/CEDC011.md +15 -0
  111. package/dist/okf/rules/CEDC012.md +11 -0
  112. package/dist/okf/rules/CEDC013.md +15 -0
  113. package/dist/okf/rules/CEDC014.md +15 -0
  114. package/dist/okf/rules/CEDE010.md +15 -0
  115. package/dist/okf/rules/CEDE011.md +15 -0
  116. package/dist/okf/rules/CEDS010.md +15 -0
  117. package/dist/okf/rules/CEDS011.md +11 -0
  118. package/dist/okf/rules/CEDS012.md +15 -0
  119. package/dist/okf/types/AdminAction.md +14 -0
  120. package/dist/okf/types/Application.md +14 -0
  121. package/dist/okf/types/ApproveAction.md +13 -0
  122. package/dist/okf/types/CommentAction.md +14 -0
  123. package/dist/okf/types/CreateAction.md +14 -0
  124. package/dist/okf/types/DeleteAction.md +14 -0
  125. package/dist/okf/types/Document.md +18 -0
  126. package/dist/okf/types/Folder.md +15 -0
  127. package/dist/okf/types/Group.md +14 -0
  128. package/dist/okf/types/ListAction.md +14 -0
  129. package/dist/okf/types/Policy.md +29 -0
  130. package/dist/okf/types/ReadAction.md +14 -0
  131. package/dist/okf/types/ServiceAccount.md +15 -0
  132. package/dist/okf/types/ShareAction.md +14 -0
  133. package/dist/okf/types/Team.md +14 -0
  134. package/dist/okf/types/User.md +18 -0
  135. package/dist/okf/types/WriteAction.md +14 -0
  136. package/dist/package-cli.d.ts +3 -0
  137. package/dist/package-cli.d.ts.map +1 -0
  138. package/dist/plugin.d.ts +8 -0
  139. package/dist/plugin.d.ts.map +1 -0
  140. package/dist/rules/cedar-helpers.ts +209 -0
  141. package/dist/rules/cedc010.ts +80 -0
  142. package/dist/rules/cedc011.ts +47 -0
  143. package/dist/rules/cedc012.ts +64 -0
  144. package/dist/rules/cedc013.ts +68 -0
  145. package/dist/rules/cedc014.ts +73 -0
  146. package/dist/rules/cede010.ts +89 -0
  147. package/dist/rules/cede011.ts +58 -0
  148. package/dist/rules/ceds010.ts +57 -0
  149. package/dist/rules/ceds011.ts +42 -0
  150. package/dist/rules/ceds012.ts +50 -0
  151. package/dist/rules/policy-shape.ts +148 -0
  152. package/dist/rules/wasm-helpers.ts +315 -0
  153. package/dist/serializer.d.ts +138 -0
  154. package/dist/serializer.d.ts.map +1 -0
  155. package/dist/spec/fetch.d.ts +71 -0
  156. package/dist/spec/fetch.d.ts.map +1 -0
  157. package/dist/spec/parse.d.ts +113 -0
  158. package/dist/spec/parse.d.ts.map +1 -0
  159. package/dist/spec/pin.d.ts +116 -0
  160. package/dist/spec/pin.d.ts.map +1 -0
  161. package/dist/spec/pinned-names.json +18 -0
  162. package/dist/spec/wasm.d.ts +143 -0
  163. package/dist/spec/wasm.d.ts.map +1 -0
  164. package/dist/types/index.d.ts +219 -0
  165. package/dist/validate-cli.d.ts +3 -0
  166. package/dist/validate-cli.d.ts.map +1 -0
  167. package/dist/validate.d.ts +25 -0
  168. package/dist/validate.d.ts.map +1 -0
  169. package/package.json +75 -0
  170. package/src/avp/OWNERSHIP.md +125 -0
  171. package/src/avp/ambient.test.ts +113 -0
  172. package/src/avp/ambient.ts +124 -0
  173. package/src/avp/client.ts +310 -0
  174. package/src/avp/describe-resources.test.ts +316 -0
  175. package/src/avp/describe-resources.ts +215 -0
  176. package/src/avp/embed.test.ts +114 -0
  177. package/src/avp/embed.ts +190 -0
  178. package/src/avp/live-export.test.ts +232 -0
  179. package/src/avp/live-export.ts +185 -0
  180. package/src/avp/ownership.test.ts +101 -0
  181. package/src/avp/ownership.ts +170 -0
  182. package/src/avp/statement.ts +50 -0
  183. package/src/avp/store.ts +152 -0
  184. package/src/avp/testdata/mock-transport.ts +147 -0
  185. package/src/codegen/docs-cli.ts +7 -0
  186. package/src/codegen/docs.ts +873 -0
  187. package/src/codegen/emit.ts +496 -0
  188. package/src/codegen/generate-cli.ts +18 -0
  189. package/src/codegen/generate.test.ts +128 -0
  190. package/src/codegen/generate.ts +123 -0
  191. package/src/codegen/naming.ts +101 -0
  192. package/src/codegen/package.ts +52 -0
  193. package/src/composites/composites.test.ts +206 -0
  194. package/src/composites/deny-by-default-set.ts +98 -0
  195. package/src/composites/index.ts +13 -0
  196. package/src/composites/owner-can-manage.ts +80 -0
  197. package/src/config-namespace.test.ts +44 -0
  198. package/src/config.test.ts +82 -0
  199. package/src/config.ts +119 -0
  200. package/src/coverage.test.ts +61 -0
  201. package/src/coverage.ts +166 -0
  202. package/src/detect.test.ts +64 -0
  203. package/src/detect.ts +59 -0
  204. package/src/generated/index.d.ts +219 -0
  205. package/src/generated/index.ts +279 -0
  206. package/src/generated/lexicon-cedar.json +699 -0
  207. package/src/generated/runtime.ts +2 -0
  208. package/src/import/adapter.ts +63 -0
  209. package/src/import/clause-text.ts +178 -0
  210. package/src/import/generator.test.ts +133 -0
  211. package/src/import/generator.ts +219 -0
  212. package/src/import/parser.test.ts +265 -0
  213. package/src/import/parser.ts +352 -0
  214. package/src/import/roundtrip.test.ts +127 -0
  215. package/src/import/testdata/full.cedar +36 -0
  216. package/src/import/testdata/full.cedar.json +238 -0
  217. package/src/import/testdata/realistic.cedar +35 -0
  218. package/src/import/testdata/simple.cedar +6 -0
  219. package/src/index.ts +94 -0
  220. package/src/init-templates.test.ts +158 -0
  221. package/src/init-templates.ts +358 -0
  222. package/src/lint/audit-catalog.ts +130 -0
  223. package/src/lint/post-synth/cedar-helpers.ts +209 -0
  224. package/src/lint/post-synth/cedc010.ts +80 -0
  225. package/src/lint/post-synth/cedc011.ts +47 -0
  226. package/src/lint/post-synth/cedc012.ts +64 -0
  227. package/src/lint/post-synth/cedc013.ts +68 -0
  228. package/src/lint/post-synth/cedc014.ts +73 -0
  229. package/src/lint/post-synth/cede010.ts +89 -0
  230. package/src/lint/post-synth/cede011.ts +58 -0
  231. package/src/lint/post-synth/ceds010.ts +57 -0
  232. package/src/lint/post-synth/ceds011.ts +42 -0
  233. package/src/lint/post-synth/ceds012.ts +50 -0
  234. package/src/lint/post-synth/index.ts +25 -0
  235. package/src/lint/post-synth/post-synth.test.ts +474 -0
  236. package/src/lint/post-synth/wasm-helpers.ts +315 -0
  237. package/src/lint/rules/index.ts +12 -0
  238. package/src/lint/rules/policy-shape.test.ts +90 -0
  239. package/src/lint/rules/policy-shape.ts +148 -0
  240. package/src/lsp/completions.test.ts +111 -0
  241. package/src/lsp/completions.ts +55 -0
  242. package/src/lsp/hover.test.ts +82 -0
  243. package/src/lsp/hover.ts +75 -0
  244. package/src/lsp/registry.ts +74 -0
  245. package/src/mcp/index.ts +103 -0
  246. package/src/mcp/policy-coverage.test.ts +176 -0
  247. package/src/mcp/policy-coverage.ts +205 -0
  248. package/src/package-cli.ts +22 -0
  249. package/src/plugin.test.ts +115 -0
  250. package/src/plugin.ts +312 -0
  251. package/src/serializer.test.ts +502 -0
  252. package/src/serializer.ts +335 -0
  253. package/src/skills/chant-cedar-authoring.md +180 -0
  254. package/src/skills/chant-cedar-avp-embedding.md +125 -0
  255. package/src/skills/chant-cedar-meta-policy.md +119 -0
  256. package/src/spec/default-schema.cedarschema +108 -0
  257. package/src/spec/fetch.ts +107 -0
  258. package/src/spec/parse.test.ts +123 -0
  259. package/src/spec/parse.ts +253 -0
  260. package/src/spec/pin.test.ts +88 -0
  261. package/src/spec/pin.ts +243 -0
  262. package/src/spec/pinned-names.json +18 -0
  263. package/src/spec/wasm.ts +283 -0
  264. package/src/validate-cli.ts +8 -0
  265. package/src/validate.ts +85 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * CEDE011: surface the Cedar validator's warnings
3
+ *
4
+ * `validate()` returns two arrays, and the second one is the interesting one
5
+ * for a policy nobody has noticed is dead. The validator's warnings are the
6
+ * findings that do not make the set invalid but do mean it is not doing what it
7
+ * says: "policy is impossible: the policy expression evaluates to false for all
8
+ * valid requests" is the one that matters most — a guard whose attribute
9
+ * comparison can never hold, so the grant it wraps never fires and the access
10
+ * it was written to give quietly does not exist.
11
+ *
12
+ * Split from CEDE010 rather than folded into it because the two mean different
13
+ * things: an error is a policy no evaluator will accept, a warning is a policy
14
+ * that will be accepted and will not work. They deserve different severities
15
+ * and, in a report, different lines.
16
+ *
17
+ * Same two traps as CEDE010 — findings live under `type: "success"`, and their
18
+ * order is not stable, so `validatePolicySet` sorts before returning.
19
+ */
20
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
21
+ import { parsedPolicySets } from "./cedar-helpers";
22
+ import { findSchema, loadWasm, normalizePolicySet, validatePolicySet } from "./wasm-helpers";
23
+
24
+ export const cede011: PostSynthCheck = {
25
+ id: "CEDE011",
26
+ description: "Cedar validation warnings (impossible policies, shadowed conditions) on an emitted policy set",
27
+
28
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
29
+ const diagnostics: PostSynthDiagnostic[] = [];
30
+ const sets = parsedPolicySets(ctx);
31
+ if (sets.length === 0) return diagnostics;
32
+
33
+ // Both "no validator" and "no schema" are already reported once by
34
+ // CEDC010/CEDE010; repeating them here would triple the same line.
35
+ const wasm = loadWasm();
36
+ if (!wasm) return diagnostics;
37
+ const schema = findSchema(ctx);
38
+ if (!schema) return diagnostics;
39
+
40
+ for (const set of sets) {
41
+ const { policySet } = normalizePolicySet(wasm, set);
42
+ const outcome = validatePolicySet(wasm, policySet, schema.schema);
43
+ if (outcome.failure) continue; // CEDE010 reports the failed call
44
+
45
+ for (const finding of outcome.warnings) {
46
+ diagnostics.push({
47
+ checkId: "CEDE011",
48
+ severity: "warning",
49
+ message: `Policy "${finding.policyId}" validates but Cedar warns about it: ${finding.message}`,
50
+ entity: finding.policyId,
51
+ lexicon: set.lexicon,
52
+ });
53
+ }
54
+ }
55
+
56
+ return diagnostics;
57
+ },
58
+ };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * CEDS010: a bare `permit(principal, action, resource);` is a standing grant
3
+ *
4
+ * The one policy that permits everything to everyone on everything. It is
5
+ * valid Cedar, it is what a scaffolded policy looks like before anyone has
6
+ * written the real one, and the Cedar validator says nothing about it — checked
7
+ * directly against 4.12.0 (chant #1648): a schema-clean run over exactly this
8
+ * policy returns zero errors, zero warnings, zero other warnings. There is no
9
+ * upstream tool that will catch it, which is why the epic names this wall as a
10
+ * definition-of-done item and why it lives here.
11
+ *
12
+ * The shape is unambiguous in the JSON: all three scopes unconstrained
13
+ * (`op: "All"`) and no `when`/`unless` clause to narrow it. Anything with even
14
+ * one constraint or one guard is somebody's deliberate decision and is not this
15
+ * check's business (an unconstrained *action* alone is CEDS012).
16
+ *
17
+ * Severity is env-gated on the same `ctx.env` seam the k8s org-policy example
18
+ * and the aws tier checks use: a production build fails, everything else warns,
19
+ * so the scaffold-and-iterate loop stays workable while the thing that ships
20
+ * cannot carry it.
21
+ */
22
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
23
+ import { conditionsOf, effectOf, isProdLikeEnv, parsedPolicySets, scopeIsAll } from "./cedar-helpers";
24
+
25
+ export const ceds010: PostSynthCheck = {
26
+ id: "CEDS010",
27
+ description: "A bare permit(principal, action, resource) with no scope constraints and no conditions grants everything",
28
+
29
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
30
+ const diagnostics: PostSynthDiagnostic[] = [];
31
+ const prod = isProdLikeEnv(ctx.env);
32
+ const severity = prod ? "error" : "warning";
33
+
34
+ for (const set of parsedPolicySets(ctx)) {
35
+ for (const entry of set.entries) {
36
+ if (effectOf(entry.policy) !== "permit") continue;
37
+ const policy = entry.policy;
38
+ const bare =
39
+ scopeIsAll(policy.principal) &&
40
+ scopeIsAll(policy.action) &&
41
+ scopeIsAll(policy.resource) &&
42
+ conditionsOf(policy).length === 0;
43
+ if (!bare) continue;
44
+
45
+ diagnostics.push({
46
+ checkId: "CEDS010",
47
+ severity,
48
+ message: `Policy "${entry.key}" is a bare permit(principal, action, resource) — every principal may take every action on every resource.${prod ? "" : " This is an error in a production build."} Constrain a scope or add a when/unless guard.`,
49
+ entity: entry.key,
50
+ lexicon: set.lexicon,
51
+ });
52
+ }
53
+ }
54
+
55
+ return diagnostics;
56
+ },
57
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * CEDS011: a policy set with no `forbid` has no floor
3
+ *
4
+ * Cedar's evaluation order is fixed and is the reason `forbid` exists: a
5
+ * `forbid` that matches beats every `permit`, no matter how the permits are
6
+ * written or in what order. That makes a `forbid` the only construct in the
7
+ * language that states an invariant — "never outside the corporate network",
8
+ * "never on a resource marked frozen" — which no later grant can widen.
9
+ *
10
+ * A set built only from permits has none. Every future policy is additive, and
11
+ * the blast radius of a careless one is bounded by nothing. This is a
12
+ * convention rather than a bug, so it warns; the fix is one `forbid` carrying
13
+ * whatever the set's real invariant is.
14
+ *
15
+ * Reported once per policy set, not once per permit.
16
+ */
17
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
18
+ import { effectOf, parsedPolicySets } from "./cedar-helpers";
19
+
20
+ export const ceds011: PostSynthCheck = {
21
+ id: "CEDS011",
22
+ description: "A policy set built entirely from permits carries no forbid to bound them",
23
+
24
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
25
+ const diagnostics: PostSynthDiagnostic[] = [];
26
+
27
+ for (const set of parsedPolicySets(ctx)) {
28
+ if (set.entries.length === 0) continue;
29
+ if (set.entries.some((entry) => effectOf(entry.policy) === "forbid")) continue;
30
+
31
+ diagnostics.push({
32
+ checkId: "CEDS011",
33
+ severity: "warning",
34
+ message: `Cedar policy set "${set.source}" has ${set.entries.length} policy/policies and no forbid. A forbid beats every permit regardless of order, so it is the only way to state an invariant a later grant cannot widen — add one for whatever this set must never allow.`,
35
+ entity: set.source,
36
+ lexicon: set.lexicon,
37
+ });
38
+ }
39
+
40
+ return diagnostics;
41
+ },
42
+ };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * CEDS012: a `permit` over every action is IAM's `"Action": "*"`
3
+ *
4
+ * A permit that names a principal or a resource but leaves `action`
5
+ * unconstrained grants every action Cedar's schema defines on that target —
6
+ * including the ones added next quarter, which is what makes it different from
7
+ * a wide-but-enumerated grant. The author almost always meant a specific verb
8
+ * or a group (`action in [Action::"read", Action::"list"]`).
9
+ *
10
+ * Scoped deliberately narrow so it does not double-report: a policy with *no*
11
+ * constraint anywhere and no guard is a bare permit, which is CEDS010's
12
+ * finding and a more serious one. This check speaks only to a policy that
13
+ * constrained something and then left the verb open.
14
+ */
15
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
16
+ import { conditionsOf, effectOf, parsedPolicySets, scopeIsAll } from "./cedar-helpers";
17
+
18
+ export const ceds012: PostSynthCheck = {
19
+ id: "CEDS012",
20
+ description: "A permit that leaves the action scope unconstrained grants every action, including future ones",
21
+
22
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
23
+ const diagnostics: PostSynthDiagnostic[] = [];
24
+
25
+ for (const set of parsedPolicySets(ctx)) {
26
+ for (const entry of set.entries) {
27
+ const policy = entry.policy;
28
+ if (effectOf(policy) !== "permit") continue;
29
+ if (!scopeIsAll(policy.action)) continue;
30
+
31
+ // The everything-permit belongs to CEDS010.
32
+ const narrowedElsewhere =
33
+ !scopeIsAll(policy.principal) ||
34
+ !scopeIsAll(policy.resource) ||
35
+ conditionsOf(policy).length > 0;
36
+ if (!narrowedElsewhere) continue;
37
+
38
+ diagnostics.push({
39
+ checkId: "CEDS012",
40
+ severity: "warning",
41
+ message: `Policy "${entry.key}" permits every action — the action scope is unconstrained, so the grant widens on its own as the schema gains actions. Name the actions it needs (action == Action::"read", or action in [ … ]).`,
42
+ entity: entry.key,
43
+ lexicon: set.lexicon,
44
+ });
45
+ }
46
+ }
47
+
48
+ return diagnostics;
49
+ },
50
+ };
@@ -0,0 +1,25 @@
1
+ // Code generated by chant generate. DO NOT EDIT.
2
+ import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
3
+ import { cedc010 } from "./cedc010";
4
+ import { cedc011 } from "./cedc011";
5
+ import { cedc012 } from "./cedc012";
6
+ import { cedc013 } from "./cedc013";
7
+ import { cedc014 } from "./cedc014";
8
+ import { cede010 } from "./cede010";
9
+ import { cede011 } from "./cede011";
10
+ import { ceds010 } from "./ceds010";
11
+ import { ceds011 } from "./ceds011";
12
+ import { ceds012 } from "./ceds012";
13
+
14
+ export const postSynthChecks: PostSynthCheck[] = [
15
+ cedc010,
16
+ cedc011,
17
+ cedc012,
18
+ cedc013,
19
+ cedc014,
20
+ cede010,
21
+ cede011,
22
+ ceds010,
23
+ ceds011,
24
+ ceds012,
25
+ ];