@aws/cloudformation-validate 1.5.1-beta → 1.7.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,31 +1,46 @@
1
- # CloudFormation Validate WASM Bindings
1
+ # CloudFormation Validate for Node.js
2
2
 
3
- WASM bindings for [`cloudformation-validate`](https://github.com/aws-cloudformation/cloudformation-validate). Compiles
4
- the full validation pipeline
5
- template parser, schema validator, Rego engine, and CEL engine — into a single `.wasm` module for Node.js.
3
+ Validate AWS CloudFormation templates from JavaScript or TypeScript and catch schema violations, security risks, and
4
+ best-practice findings before deployment in your editor, build, or CI.
6
5
 
7
- All WASM objects must be explicitly freed via `.free()` to release memory.
6
+ - **Offline** all rules and resource schemas are bundled.
7
+ - **Fast** — sub-second validation per template.
8
8
 
9
- For a complete, runnable example, see
10
- [examples](https://github.com/aws-cloudformation/cloudformation-validate/tree/main/src/bindings-wasm/examples).
9
+ ## Installation
11
10
 
12
- ## Engine
11
+ Available on [npm](https://www.npmjs.com/package/@aws/cloudformation-validate) as `@aws/cloudformation-validate`.
13
12
 
14
- `RegoEngine` and `CelEngine` both implement the `Engine` interface. They are interchangeable — both produce identical
15
- diagnostics for the same template and config.
13
+ ```bash
14
+ npm install @aws/cloudformation-validate
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ Engines, models, and validators hold off-heap memory — call `.free()` when done with each object:
16
20
 
17
21
  ```typescript
18
- import { RegoEngine, CelEngine, TemplateFile } from "@aws/cloudformation-validate";
22
+ import { RegoEngine, TemplateFile } from "@aws/cloudformation-validate";
19
23
 
20
24
  const engine = new RegoEngine();
21
- const report = engine.validateStandard(new TemplateFile("template.yaml"));
22
-
23
- for (const d of report.diagnostics) {
24
- console.log(`[${d.severity}] ${d.ruleId}: ${d.message}`);
25
+ try {
26
+ const report = engine.validateStandard(new TemplateFile("template.yaml"));
27
+ for (const d of report.diagnostics) {
28
+ console.log(`[${d.severity}] ${d.ruleId}: ${d.message}`);
29
+ }
30
+ } finally {
31
+ engine.free();
25
32
  }
26
- engine.free();
27
33
  ```
28
34
 
35
+ Each diagnostic identifies the rule, severity, affected resource and property, and source location — see
36
+ [StandardDiagnostic](#standarddiagnostic). A complete, runnable project is in
37
+ [examples](https://github.com/aws-cloudformation/cloudformation-validate/tree/main/src/bindings-wasm/examples).
38
+
39
+ ## Engine
40
+
41
+ `RegoEngine` and `CelEngine` both implement the `Engine` interface and are interchangeable — they produce identical
42
+ diagnostics for the same template and config.
43
+
29
44
  ### `Engine` interface
30
45
 
31
46
  | Method | Returns | Description |
@@ -34,22 +49,62 @@ engine.free();
34
49
  | `validateDetailed(template, config?)` | `DetailedReport` | Validates and returns diagnostics with documentation URLs, rule descriptions, phase tags, and `ViolationContext` |
35
50
  | `listRules()` | `RuleInfo[]` | Returns metadata for every built-in and loaded custom rule |
36
51
  | `engineName()` | `string` | `"rego"` or `"cel"` |
37
- | `free()` | `void` | Releases WASM memory |
52
+ | `free()` | `void` | Releases the engine's off-heap memory |
38
53
 
39
54
  ### `EngineConfig`
40
55
 
41
- Passed to the constructor. All fields optional, default to empty arrays.
56
+ Passed to the constructor. All fields are optional; omitted rule arrays are empty and an omitted
57
+ `schemaValidatorConfig` uses only the bundled schemas.
42
58
 
43
59
  ```typescript
44
60
  interface EngineConfig {
45
- customRules?: ExternalRuleSource[]; // engine-native rules (Rego for RegoEngine, CEL for CelEngine)
46
- guardRules?: ExternalRuleSource[]; // CloudFormation Guard DSL rules — translated internally by each engine
61
+ customRules?: RuleSource[]; // engine-native rules (Rego for RegoEngine, CEL for CelEngine)
62
+ guardRules?: RuleSource[]; // CloudFormation Guard DSL rules — translated internally
63
+ schemaValidatorConfig?: SchemaValidatorConfig; // schema validation and overlay configuration
64
+ }
65
+
66
+ interface SchemaValidatorConfig {
67
+ additionalSchemas?: SchemaSource[]; // resource provider schemas merged over the bundled schemas
68
+ }
69
+
70
+ type RuleSource = ExternalRuleSource | RuleFile;
71
+ type SchemaSource = AdditionalSchemaSource | SchemaFile;
72
+
73
+ class RuleFile {
74
+ constructor(path: string); // rule file read from disk; the path becomes the rule source name
75
+ }
76
+
77
+ class SchemaFile {
78
+ constructor(path: string, typeName?: string); // schema file; typeName defaults to the value inside the JSON
47
79
  }
48
80
 
49
81
  interface ExternalRuleSource {
50
82
  name: string; // identifier shown in diagnostics (e.g. file path)
51
83
  content: string; // full rule source text
52
84
  }
85
+
86
+ interface AdditionalSchemaSource {
87
+ typeName?: string; // omit to use the typeName inside the schema JSON
88
+ schema: string; // complete resource provider schema JSON
89
+ }
90
+ ```
91
+
92
+ Pass a `RuleFile` to load a rule from disk — the same pattern as `TemplateFile` for templates — or an
93
+ `ExternalRuleSource` when you already have the rule text in memory. `SchemaFile` does the same for an additional
94
+ resource provider schema. Its optional constructor `typeName` may be omitted when the schema JSON contains its own
95
+ `typeName`.
96
+
97
+ The generated `AdditionalSchemaSource` record exposes `typeName` as an optional field. Omit it (or leave the
98
+ `SchemaFile` constructor argument unset) for an in-memory schema whose JSON already contains its own `typeName`.
99
+
100
+ ```typescript
101
+ const engine = new CelEngine({
102
+ customRules: [new RuleFile("rules/s3_encryption.json")],
103
+ guardRules: [new RuleFile("rules/compliance.guard")],
104
+ schemaValidatorConfig: {
105
+ additionalSchemas: [new SchemaFile("schemas/aws-lambda-function.json")],
106
+ },
107
+ });
53
108
  ```
54
109
 
55
110
  ## ValidateConfig
@@ -90,13 +145,15 @@ interface RuleFilterConfig {
90
145
  idRanges?: IdRange[]; // numeric ranges, e.g. { prefix: "E", start: 3000, end: 3099 }
91
146
  idPatterns?: string[]; // regex patterns matched against rule IDs
92
147
  resourceIds?: ResourceIdFilter[]; // a rule (or every rule) on a logical resource ID
148
+ logicalIds?: LogicalIdFilter[]; // a rule (or every rule) on a named template entity
93
149
  resourceTypes?: ResourceTypeFilter[]; // a rule (or every rule) on a resource type
94
150
  services?: ServiceFilter[]; // a rule (or every rule) on a service, e.g. "AWS::AutoScaling"
95
151
  }
96
152
 
97
- // resourceIds / resourceTypes / services each carry an optional ruleId:
153
+ // resourceIds / logicalIds / resourceTypes / services each carry an optional ruleId:
98
154
  // set it to scope the filter to one rule, or omit it for every rule on the target.
99
155
  interface ResourceIdFilter { ruleId?: string; resourceId: string; }
156
+ interface LogicalIdFilter { ruleId?: string; logicalId: string; entityType?: EntityType; }
100
157
  interface ResourceTypeFilter { ruleId?: string; resourceType: string; }
101
158
  interface ServiceFilter { ruleId?: string; service: string; }
102
159
  ```
@@ -104,6 +161,11 @@ interface ServiceFilter { ruleId?: string; service: string; }
104
161
  The `service` is matched verbatim against the `service-provider::service-name` prefix of the resource type — its first
105
162
  two `::`-delimited segments (e.g. `AWS::AutoScaling` in `AWS::AutoScaling::LaunchConfiguration`).
106
163
 
164
+ The `resourceIds` dimension matches only diagnostics attributed to a resource; `logicalIds` additionally matches
165
+ diagnostics on parameters, outputs, mappings, conditions, and template rules (for resource diagnostics the two carry
166
+ the same value). An optional `entityType` scopes a `LogicalIdFilter` to entities of one type, so `MyThing` as a
167
+ `"Parameter"` is matched without touching a same-named entity of another type.
168
+
107
169
  ### PseudoParameterOverrides
108
170
 
109
171
  Override CloudFormation pseudo-parameters used during intrinsic function resolution. All fields optional — when
@@ -185,7 +247,7 @@ interface StandardReport {
185
247
  ```
186
248
 
187
249
  `DetailedReport` has the same structure but its diagnostics include additional fields: `documentationUrl`,
188
- `ruleDescription`, `phase` (`PARSE` | `SCHEMA` | `LINT`), `section`, and `context` (`ViolationContext` with
250
+ `ruleDescription`, `phase` (`PARSE` | `SCHEMA` | `LINT`), and `context` (`ViolationContext` with
189
251
  `actualValue`, `expectedConstraint`, `resolutionSource`, etc.).
190
252
 
191
253
  ### StandardDiagnostic
@@ -196,9 +258,8 @@ interface StandardDiagnostic {
196
258
  severity: Severity; // "FATAL" | "ERROR" | "WARN" | "INFO" | "DEBUG"
197
259
  message: string;
198
260
  source: RuleOrigin; // "SCHEMA" | "CFN_LINT" | "ENGINE" | "CUSTOM" | "GUARD"
199
- resourceId?: string; // logical resource ID
200
- resourceType?: string; // e.g. "AWS::S3::Bucket"
201
- propertyPath?: string; // e.g. "Properties/BucketName"
261
+ entity?: Entity; // the named template entity the finding targets, if any
262
+ propertyPath?: string; // e.g. "Properties.BucketName", or section-absolute like "Parameters/MyParam/Type"
202
263
  suggestedFix?: string;
203
264
  category?: string;
204
265
  startLine?: number;
@@ -208,4 +269,15 @@ interface StandardDiagnostic {
208
269
  relatedResources?: RelatedResource[];
209
270
  conditionScenario?: Record<string, boolean>; // condition truth assignment that triggers this diagnostic
210
271
  }
272
+
273
+ // The named template entity a diagnostic is attributed to. The entity type is the
274
+ // singular form of the top-level template section the entity is declared in.
275
+ interface Entity {
276
+ logicalId: string; // logical ID as declared in the template
277
+ entityType: EntityType;
278
+ resourceType?: string; // CloudFormation type, when the entity is a resource whose type is known
279
+ }
280
+
281
+ type EntityType = "Resource" | "Parameter" | "Output" | "Mapping" | "Metadata"
282
+ | "Rule" | "Condition" | "Transform" | "FormatVersion" | "Description";
211
283
  ```
@@ -84,7 +84,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84
84
  ******************************
85
85
 
86
86
  anyhow
87
- 1.0.103 <https://github.com/dtolnay/anyhow>
87
+ 1.0.104 <https://github.com/dtolnay/anyhow>
88
88
  Apache License
89
89
  Version 2.0, January 2004
90
90
  http://www.apache.org/licenses/
@@ -3445,7 +3445,7 @@ the following restrictions:
3445
3445
  ******************************
3446
3446
 
3447
3447
  futures-core
3448
- 0.3.32 <https://github.com/rust-lang/futures-rs>
3448
+ 0.3.33 <https://github.com/rust-lang/futures-rs>
3449
3449
  Apache License
3450
3450
  Version 2.0, January 2004
3451
3451
  http://www.apache.org/licenses/
@@ -3653,7 +3653,7 @@ limitations under the License.
3653
3653
  ******************************
3654
3654
 
3655
3655
  futures-task
3656
- 0.3.32 <https://github.com/rust-lang/futures-rs>
3656
+ 0.3.33 <https://github.com/rust-lang/futures-rs>
3657
3657
  Apache License
3658
3658
  Version 2.0, January 2004
3659
3659
  http://www.apache.org/licenses/
@@ -3861,7 +3861,7 @@ limitations under the License.
3861
3861
  ******************************
3862
3862
 
3863
3863
  futures-util
3864
- 0.3.32 <https://github.com/rust-lang/futures-rs>
3864
+ 0.3.33 <https://github.com/rust-lang/futures-rs>
3865
3865
  Apache License
3866
3866
  Version 2.0, January 2004
3867
3867
  http://www.apache.org/licenses/
@@ -6789,7 +6789,7 @@ limitations under the License.
6789
6789
  ******************************
6790
6790
 
6791
6791
  memchr
6792
- 2.8.2 <https://github.com/BurntSushi/memchr>
6792
+ 2.8.3 <https://github.com/BurntSushi/memchr>
6793
6793
  The MIT License (MIT)
6794
6794
 
6795
6795
  Copyright (c) 2015 Andrew Gallant
@@ -7361,7 +7361,7 @@ SOFTWARE.
7361
7361
  ******************************
7362
7362
 
7363
7363
  num-bigint
7364
- 0.4.7 <https://github.com/rust-num/num-bigint>
7364
+ 0.4.8 <https://github.com/rust-num/num-bigint>
7365
7365
  Apache License
7366
7366
  Version 2.0, January 2004
7367
7367
  http://www.apache.org/licenses/
@@ -8968,7 +8968,7 @@ limitations under the License.
8968
8968
  ******************************
8969
8969
 
8970
8970
  proc-macro2
8971
- 1.0.106 <https://github.com/dtolnay/proc-macro2>
8971
+ 1.0.107 <https://github.com/dtolnay/proc-macro2>
8972
8972
  Apache License
8973
8973
  Version 2.0, January 2004
8974
8974
  http://www.apache.org/licenses/
@@ -9047,7 +9047,7 @@ limitations under the License.
9047
9047
  ******************************
9048
9048
 
9049
9049
  quote
9050
- 1.0.46 <https://github.com/dtolnay/quote>
9050
+ 1.0.47 <https://github.com/dtolnay/quote>
9051
9051
  Apache License
9052
9052
  Version 2.0, January 2004
9053
9053
  http://www.apache.org/licenses/
@@ -9126,7 +9126,7 @@ limitations under the License.
9126
9126
  ******************************
9127
9127
 
9128
9128
  rand
9129
- 0.9.4 <https://github.com/rust-random/rand>
9129
+ 0.9.5 <https://github.com/rust-random/rand>
9130
9130
  Apache License
9131
9131
  Version 2.0, January 2004
9132
9132
  http://www.apache.org/licenses/
@@ -9477,7 +9477,7 @@ APPENDIX: How to apply the Apache License to your work.
9477
9477
  ******************************
9478
9478
 
9479
9479
  regex
9480
- 1.12.4 <https://github.com/rust-lang/regex>
9480
+ 1.13.1 <https://github.com/rust-lang/regex>
9481
9481
  Apache License
9482
9482
  Version 2.0, January 2004
9483
9483
  http://www.apache.org/licenses/
@@ -9684,7 +9684,7 @@ limitations under the License.
9684
9684
  ******************************
9685
9685
 
9686
9686
  regex-automata
9687
- 0.4.14 <https://github.com/rust-lang/regex>
9687
+ 0.4.16 <https://github.com/rust-lang/regex>
9688
9688
  Apache License
9689
9689
  Version 2.0, January 2004
9690
9690
  http://www.apache.org/licenses/
@@ -10752,7 +10752,7 @@ limitations under the License.
10752
10752
  ******************************
10753
10753
 
10754
10754
  serde
10755
- 1.0.228 <https://github.com/serde-rs/serde>
10755
+ 1.0.229 <https://github.com/serde-rs/serde>
10756
10756
  Apache License
10757
10757
  Version 2.0, January 2004
10758
10758
  http://www.apache.org/licenses/
@@ -10858,7 +10858,7 @@ SOFTWARE.
10858
10858
  ******************************
10859
10859
 
10860
10860
  serde_core
10861
- 1.0.228 <https://github.com/serde-rs/serde>
10861
+ 1.0.229 <https://github.com/serde-rs/serde>
10862
10862
  Apache License
10863
10863
  Version 2.0, January 2004
10864
10864
  http://www.apache.org/licenses/
@@ -10937,7 +10937,7 @@ limitations under the License.
10937
10937
  ******************************
10938
10938
 
10939
10939
  serde_derive
10940
- 1.0.228 <https://github.com/serde-rs/serde>
10940
+ 1.0.229 <https://github.com/serde-rs/serde>
10941
10941
  Apache License
10942
10942
  Version 2.0, January 2004
10943
10943
  http://www.apache.org/licenses/
@@ -11095,7 +11095,7 @@ limitations under the License.
11095
11095
  ******************************
11096
11096
 
11097
11097
  serde_json
11098
- 1.0.150 <https://github.com/serde-rs/json>
11098
+ 1.0.151 <https://github.com/serde-rs/json>
11099
11099
  Apache License
11100
11100
  Version 2.0, January 2004
11101
11101
  http://www.apache.org/licenses/
@@ -11491,7 +11491,7 @@ limitations under the License.
11491
11491
  ******************************
11492
11492
 
11493
11493
  spin
11494
- 0.9.8 <https://github.com/mvdnes/spin-rs.git>
11494
+ 0.9.9 <https://github.com/mvdnes/spin-rs.git>
11495
11495
  The MIT License (MIT)
11496
11496
 
11497
11497
  Copyright (c) 2014 Mathijs van de Nes
@@ -11517,7 +11517,86 @@ SOFTWARE.
11517
11517
  ******************************
11518
11518
 
11519
11519
  syn
11520
- 2.0.118 <https://github.com/dtolnay/syn>
11520
+ 2.0.119 <https://github.com/dtolnay/syn>
11521
+ Apache License
11522
+ Version 2.0, January 2004
11523
+ http://www.apache.org/licenses/
11524
+
11525
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11526
+
11527
+ 1. Definitions.
11528
+
11529
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
11530
+
11531
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
11532
+
11533
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
11534
+
11535
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
11536
+
11537
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
11538
+
11539
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
11540
+
11541
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
11542
+
11543
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
11544
+
11545
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
11546
+
11547
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
11548
+
11549
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
11550
+
11551
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
11552
+
11553
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
11554
+
11555
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
11556
+
11557
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
11558
+
11559
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
11560
+
11561
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
11562
+
11563
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
11564
+
11565
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
11566
+
11567
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
11568
+
11569
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
11570
+
11571
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
11572
+
11573
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
11574
+
11575
+ END OF TERMS AND CONDITIONS
11576
+
11577
+ APPENDIX: How to apply the Apache License to your work.
11578
+
11579
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
11580
+
11581
+ Copyright [yyyy] [name of copyright owner]
11582
+
11583
+ Licensed under the Apache License, Version 2.0 (the "License");
11584
+ you may not use this file except in compliance with the License.
11585
+ You may obtain a copy of the License at
11586
+
11587
+ http://www.apache.org/licenses/LICENSE-2.0
11588
+
11589
+ Unless required by applicable law or agreed to in writing, software
11590
+ distributed under the License is distributed on an "AS IS" BASIS,
11591
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11592
+ See the License for the specific language governing permissions and
11593
+ limitations under the License.
11594
+
11595
+
11596
+ ******************************
11597
+
11598
+ syn
11599
+ 3.0.3 <https://github.com/dtolnay/syn>
11521
11600
  Apache License
11522
11601
  Version 2.0, January 2004
11523
11602
  http://www.apache.org/licenses/
@@ -11675,7 +11754,7 @@ limitations under the License.
11675
11754
  ******************************
11676
11755
 
11677
11756
  thiserror
11678
- 2.0.18 <https://github.com/dtolnay/thiserror>
11757
+ 2.0.19 <https://github.com/dtolnay/thiserror>
11679
11758
  Apache License
11680
11759
  Version 2.0, January 2004
11681
11760
  http://www.apache.org/licenses/
@@ -11833,7 +11912,7 @@ limitations under the License.
11833
11912
  ******************************
11834
11913
 
11835
11914
  thiserror-impl
11836
- 2.0.18 <https://github.com/dtolnay/thiserror>
11915
+ 2.0.19 <https://github.com/dtolnay/thiserror>
11837
11916
  Apache License
11838
11917
  Version 2.0, January 2004
11839
11918
  http://www.apache.org/licenses/
@@ -12276,7 +12355,7 @@ THE SOFTWARE.
12276
12355
  ******************************
12277
12356
 
12278
12357
  uuid
12279
- 1.23.4 <https://github.com/uuid-rs/uuid>
12358
+ 1.24.0 <https://github.com/uuid-rs/uuid>
12280
12359
  Apache License
12281
12360
  Version 2.0, January 2004
12282
12361
  http://www.apache.org/licenses/
@@ -13923,7 +14002,7 @@ END OF TERMS AND CONDITIONS
13923
14002
  ******************************
13924
14003
 
13925
14004
  zerocopy
13926
- 0.8.52 <https://github.com/google/zerocopy>
14005
+ 0.8.55 <https://github.com/google/zerocopy>
13927
14006
  Apache License
13928
14007
  Version 2.0, January 2004
13929
14008
  http://www.apache.org/licenses/
@@ -14131,7 +14210,7 @@ zerocopy
14131
14210
  ******************************
14132
14211
 
14133
14212
  zmij
14134
- 1.0.21 <https://github.com/dtolnay/zmij>
14213
+ 1.0.23 <https://github.com/dtolnay/zmij>
14135
14214
  Permission is hereby granted, free of charge, to any
14136
14215
  person obtaining a copy of this software and associated
14137
14216
  documentation files (the "Software"), to deal in the
@@ -191,6 +191,18 @@ export interface DiagnosticResource {
191
191
  * Property paths containing ${...} text that is not an Fn::Sub variable and is left as a literal.
192
192
  */
193
193
  unsubstitutedVariables: PathVariable[];
194
+ /**
195
+ * Fn::Sub map keys not referenced in the template string, each with its path and the unused key name.
196
+ */
197
+ unusedSubKeys: PathVariable[];
198
+ /**
199
+ * Property values that are a raw pseudo-parameter string instead of using Ref, each with its path and the pseudo-parameter name.
200
+ */
201
+ rawPseudoParams: PathVariable[];
202
+ /**
203
+ * Property paths containing a {{resolve:secretsmanager:...}} dynamic reference.
204
+ */
205
+ secretsmanagerRefPaths: string[];
194
206
  /**
195
207
  * References whose target does not resolve to any resource or parameter, each with its path and unresolved target.
196
208
  */
@@ -235,6 +247,7 @@ export interface RuleFilterConfig {
235
247
  */
236
248
  idPatterns?: string[];
237
249
  resourceIds?: ResourceIdFilter[];
250
+ logicalIds?: LogicalIdFilter[];
238
251
  resourceTypes?: ResourceTypeFilter[];
239
252
  services?: ServiceFilter[];
240
253
  }
@@ -257,6 +270,31 @@ export interface DiagnosticCondition {
257
270
  mutexWith?: string[];
258
271
  }
259
272
 
273
+ /**
274
+ * A single additional CloudFormation resource provider schema to overlay on top
275
+ * of the bundled schemas.
276
+ *
277
+ * `type_name` identifies the resource type (e.g., `\"AWS::Lambda::Function\"`).
278
+ * When absent (`None`), the `typeName` field inside the schema JSON is used
279
+ * instead. When both are present they must agree.
280
+ *
281
+ * `schema` is the complete resource provider schema as a JSON string, in the
282
+ * standard CloudFormation registry format.
283
+ */
284
+ export interface AdditionalSchemaSource {
285
+ /**
286
+ * The resource type name (e.g., `\"AWS::Lambda::Function\"`). When absent, the
287
+ * `typeName` field of the schema JSON is used instead. When both are
288
+ * present they must agree.
289
+ */
290
+ typeName?: string;
291
+ /**
292
+ * The complete resource provider schema as a JSON string, in the standard
293
+ * CloudFormation registry format.
294
+ */
295
+ schema: string;
296
+ }
297
+
260
298
  /**
261
299
  * A single assertion within a template rule.
262
300
  */
@@ -386,6 +424,25 @@ export interface ResolvedResource {
386
424
  diagnostics: ResourceDiagnostics;
387
425
  }
388
426
 
427
+ /**
428
+ * A top-level CloudFormation template section, as documented in the template
429
+ * anatomy (<https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html>).
430
+ *
431
+ * This is the canonical, single definition of the section names — section
432
+ * constants in other crates derive from it.
433
+ */
434
+ export type TopLevelSection =
435
+ | 'Resources'
436
+ | 'Parameters'
437
+ | 'Outputs'
438
+ | 'Mappings'
439
+ | 'Metadata'
440
+ | 'Rules'
441
+ | 'Conditions'
442
+ | 'Transform'
443
+ | 'FormatVersion'
444
+ | 'Description';
445
+
389
446
  /**
390
447
  * Advanced introspection view of a parsed CloudFormation template: its reference graph,
391
448
  * conditions, and resolved resources and outputs.
@@ -547,6 +604,19 @@ export interface RelatedResource {
547
604
  message: string;
548
605
  }
549
606
 
607
+ /**
608
+ * Configuration for constructing a [`SchemaValidator`] with optional overlay
609
+ * schemas. Bindings and the CLI use this to build the validator separately from
610
+ * the rule engine.
611
+ */
612
+ export interface SchemaValidatorConfig {
613
+ /**
614
+ * Additional CloudFormation resource provider schemas to merge on top of the
615
+ * bundled schemas before schema validation.
616
+ */
617
+ additionalSchemas?: AdditionalSchemaSource[];
618
+ }
619
+
550
620
  /**
551
621
  * Controls the level of detail in validation output.
552
622
  */
@@ -661,6 +731,18 @@ export interface ResourceDiagnostics {
661
731
  * Occurrences of ${...} placeholders outside an Fn::Sub that will not be substituted; each pairs the property path with the placeholder text.
662
732
  */
663
733
  unsubstitutedVariables: PathValuePair[];
734
+ /**
735
+ * Fn::Sub map keys not referenced in the template string; each pairs the property path with the unused key name.
736
+ */
737
+ unusedSubKeys: PathValuePair[];
738
+ /**
739
+ * Property values that are a raw pseudo-parameter string (e.g. \"AWS::Region\") instead of using Ref.
740
+ */
741
+ rawPseudoParams: PathValuePair[];
742
+ /**
743
+ * Property paths containing a {{resolve:secretsmanager:...}} dynamic reference.
744
+ */
745
+ secretsmanagerRefPaths: string[];
664
746
  /**
665
747
  * References whose target is not a defined resource, parameter, or pseudo parameter; each pairs the property path with the missing target name.
666
748
  */
@@ -705,6 +787,19 @@ export interface ResourceIdFilter {
705
787
  resourceId: string;
706
788
  }
707
789
 
790
+ /**
791
+ * Suppress a rule for a specific named template entity — a resource,
792
+ * parameter, output, mapping, condition, or template rule — identified by its
793
+ * logical ID. An absent `rule_id` scopes the filter to every rule on that
794
+ * entity; an absent `entity_type` scopes it to entities of every type with
795
+ * that logical ID.
796
+ */
797
+ export interface LogicalIdFilter {
798
+ ruleId?: string;
799
+ logicalId: string;
800
+ entityType?: EntityType;
801
+ }
802
+
708
803
  /**
709
804
  * Suppress a rule for a specific resource type. An absent `rule_id` scopes the
710
805
  * filter to every rule on that type.
@@ -729,6 +824,43 @@ export interface ServiceFilter {
729
824
  service: string;
730
825
  }
731
826
 
827
+ /**
828
+ * The kind of template entity a diagnostic targets — the singular form of the
829
+ * top-level section the entity is declared in. Every documented section has a
830
+ * variant; the ones whose children are addressable by logical ID (resources,
831
+ * parameters, outputs, mappings, conditions, rules, and metadata keys) are
832
+ * the ones diagnostics attribute findings to today.
833
+ */
834
+ export type EntityType =
835
+ | 'Resource'
836
+ | 'Parameter'
837
+ | 'Output'
838
+ | 'Mapping'
839
+ | 'Metadata'
840
+ | 'Rule'
841
+ | 'Condition'
842
+ | 'Transform'
843
+ | 'FormatVersion'
844
+ | 'Description';
845
+
846
+ /**
847
+ * The named template entity a diagnostic is attributed to, when it targets
848
+ * one. The entity type is the singular form of the top-level template
849
+ * section the entity is declared in.
850
+ */
851
+ export interface Entity {
852
+ /**
853
+ * Logical ID of the entity as declared in the template.
854
+ */
855
+ logicalId: string;
856
+ entityType: EntityType;
857
+ /**
858
+ * CloudFormation resource type, when the entity is a resource whose type
859
+ * is known.
860
+ */
861
+ resourceType?: string;
862
+ }
863
+
732
864
  /**
733
865
  * The template resource a diagnostic is attributed to, when it targets one.
734
866
  */
@@ -810,7 +942,7 @@ export interface PseudoParameterOverrides {
810
942
  export type RuleOrigin = 'SCHEMA' | 'CFN_LINT' | 'ENGINE' | 'CUSTOM' | 'GUARD';
811
943
 
812
944
  /**
813
- *r" A single validation finding with its resource and source location flattened into individual fields.
945
+ *r" A single validation finding with its source location flattened into individual fields.
814
946
  */
815
947
  export interface StandardDiagnostic {
816
948
  /**
@@ -824,10 +956,9 @@ export interface StandardDiagnostic {
824
956
  */
825
957
  source: RuleOrigin;
826
958
  /**
827
- * Logical ID of the resource this finding targets, if any.
959
+ * The named template entity this finding targets — a resource, parameter, output, mapping, condition, or template rule — if any.
828
960
  */
829
- resourceId?: string;
830
- resourceType?: string;
961
+ entity?: Entity;
831
962
  /**
832
963
  * Path to the offending property within the resource, such as \'Properties.Name\'.
833
964
  */
@@ -863,10 +994,9 @@ export interface DetailedDiagnostic {
863
994
  */
864
995
  source: RuleOrigin;
865
996
  /**
866
- * Logical ID of the resource this finding targets, if any.
997
+ * The named template entity this finding targets — a resource, parameter, output, mapping, condition, or template rule — if any.
867
998
  */
868
- resourceId?: string;
869
- resourceType?: string;
999
+ entity?: Entity;
870
1000
  /**
871
1001
  * Path to the offending property within the resource, such as \'Properties.Name\'.
872
1002
  */
@@ -888,10 +1018,6 @@ export interface DetailedDiagnostic {
888
1018
  documentationUrl?: string;
889
1019
  ruleDescription?: string;
890
1020
  phase?: Phase;
891
- /**
892
- *r" Top-level template section the finding falls under, such as 'Resources' or 'Parameters'.
893
- */
894
- section?: string;
895
1021
  context?: ViolationContext;
896
1022
  }
897
1023
 
@@ -904,6 +1030,13 @@ export interface EngineConfig {
904
1030
  * Guard DSL rules as raw source text, usable regardless of the selected engine.
905
1031
  */
906
1032
  guardRules?: ExternalRuleSource[];
1033
+ /**
1034
+ * Optional schema validator configuration. A standalone engine derives its
1035
+ * schema-aware rule metadata from this config. Language APIs also use it to
1036
+ * construct the schema validator bundled with the engine, so both components
1037
+ * observe the same additional schemas.
1038
+ */
1039
+ schemaValidatorConfig?: SchemaValidatorConfig;
907
1040
  }
908
1041
 
909
1042
  export interface MapEntry {
@@ -984,7 +1117,7 @@ export class WasmSchemaValidator {
984
1117
  free(): void;
985
1118
  [Symbol.dispose](): void;
986
1119
  listRules(): any;
987
- constructor();
1120
+ constructor(config: SchemaValidatorConfig);
988
1121
  schemaCount(): number;
989
1122
  validate(model: WasmSemanticModel, region?: string | null): any;
990
1123
  }
package/bindings_wasm.js CHANGED
@@ -193,9 +193,15 @@ class WasmSchemaValidator {
193
193
  }
194
194
  return takeFromExternrefTable0(ret[0]);
195
195
  }
196
- constructor() {
197
- const ret = wasm.wasmschemavalidator_new();
198
- this.__wbg_ptr = ret;
196
+ /**
197
+ * @param {SchemaValidatorConfig} config
198
+ */
199
+ constructor(config) {
200
+ const ret = wasm.wasmschemavalidator_new(config);
201
+ if (ret[2]) {
202
+ throw takeFromExternrefTable0(ret[1]);
203
+ }
204
+ this.__wbg_ptr = ret[0];
199
205
  WasmSchemaValidatorFinalization.register(this, this.__wbg_ptr, this);
200
206
  return this;
201
207
  }
Binary file
@@ -46,7 +46,7 @@ export const wasmregoengine_validateStandard: (
46
46
  f: number,
47
47
  ) => [number, number, number];
48
48
  export const wasmschemavalidator_listRules: (a: number) => [number, number, number];
49
- export const wasmschemavalidator_new: () => number;
49
+ export const wasmschemavalidator_new: (a: any) => [number, number, number];
50
50
  export const wasmschemavalidator_schemaCount: (a: number) => number;
51
51
  export const wasmschemavalidator_validate: (a: number, b: number, c: number, d: number) => [number, number, number];
52
52
  export const wasmsemanticmodel_conditions: (a: number) => [number, number, number];
package/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type {
2
2
  DetailedReport,
3
3
  DiagnosticModel,
4
- EngineConfig,
4
+ AdditionalSchemaSource,
5
+ ExternalRuleSource,
5
6
  ParameterInfo,
6
7
  ResolvedOutput,
7
8
  ResolvedResource,
@@ -17,11 +18,14 @@ export type {
17
18
  RuleOrigin,
18
19
  IdRange,
19
20
  ResourceIdFilter,
21
+ LogicalIdFilter,
20
22
  ResourceTypeFilter,
21
23
  ServiceFilter,
22
24
  RuleFilterConfig,
23
25
  RuleInfo,
24
26
  SourceSpan,
27
+ Entity,
28
+ EntityType,
25
29
  ResourceRef,
26
30
  RelatedResource,
27
31
  ViolationContext,
@@ -34,9 +38,9 @@ export type {
34
38
  StandardReport,
35
39
  DetailedReport,
36
40
  PseudoParameterOverrides,
37
- EngineConfig,
38
41
  ValidateConfig,
39
42
  ExternalRuleSource,
43
+ AdditionalSchemaSource,
40
44
  ResolvedValue,
41
45
  RefKind,
42
46
  ParameterInfo,
@@ -87,6 +91,46 @@ export declare class TemplateFile {
87
91
  constructor(path: string);
88
92
  readBytes(): Uint8Array;
89
93
  }
94
+ export declare class RuleFile {
95
+ readonly path: string;
96
+ constructor(path: string);
97
+ readContent(): string;
98
+ }
99
+ export type RuleSource = ExternalRuleSource | RuleFile;
100
+ /**
101
+ * A CloudFormation resource provider schema loaded from a file, for use as an
102
+ * overlay. `typeName` may be omitted to use the `typeName` inside the file.
103
+ */
104
+ export declare class SchemaFile {
105
+ readonly path: string;
106
+ readonly typeName?: string | undefined;
107
+ constructor(path: string, typeName?: string | undefined);
108
+ readContent(): string;
109
+ }
110
+ export type SchemaSource = AdditionalSchemaSource | SchemaFile;
111
+ export interface EngineConfig {
112
+ /** Engine-native rules (Rego for RegoEngine, CEL for CelEngine). */
113
+ customRules?: RuleSource[];
114
+ /** CloudFormation Guard DSL rules, usable with either engine. */
115
+ guardRules?: RuleSource[];
116
+ /**
117
+ * Optional schema validator configuration. When present, the engine derives
118
+ * overlay-aware metadata from the configured additional schemas.
119
+ */
120
+ schemaValidatorConfig?: SchemaValidatorConfig;
121
+ }
122
+ /**
123
+ * Configuration for the schema validator. Additional schemas are merged on top
124
+ * of the bundled CloudFormation provider schemas before schema validation.
125
+ */
126
+ export interface SchemaValidatorConfig {
127
+ /**
128
+ * Additional CloudFormation resource provider schemas to merge on top of the
129
+ * bundled schemas. Each overlay extends or overrides the bundled schema for
130
+ * its resource type.
131
+ */
132
+ additionalSchemas?: SchemaSource[];
133
+ }
90
134
  export declare class TemplateModel {
91
135
  private readonly inner;
92
136
  constructor(template: TemplateFile);
@@ -103,6 +147,7 @@ export declare class TemplateModel {
103
147
  }
104
148
  export declare class SchemaValidator {
105
149
  private readonly inner;
150
+ constructor(config?: SchemaValidatorConfig);
106
151
  listRules(): RuleInfo[];
107
152
  schemaCount(): number;
108
153
  validate(template: TemplateFile, region?: string): StandardDiagnostic[];
package/index.js CHANGED
@@ -4,6 +4,8 @@ exports.CelEngine =
4
4
  exports.RegoEngine =
5
5
  exports.SchemaValidator =
6
6
  exports.TemplateModel =
7
+ exports.SchemaFile =
8
+ exports.RuleFile =
7
9
  exports.TemplateFile =
8
10
  void 0;
9
11
  exports.version = version;
@@ -18,6 +20,53 @@ class TemplateFile {
18
20
  }
19
21
  }
20
22
  exports.TemplateFile = TemplateFile;
23
+ class RuleFile {
24
+ constructor(path) {
25
+ this.path = path;
26
+ }
27
+ readContent() {
28
+ return (0, fs_1.readFileSync)(this.path, 'utf8');
29
+ }
30
+ }
31
+ exports.RuleFile = RuleFile;
32
+ /**
33
+ * A CloudFormation resource provider schema loaded from a file, for use as an
34
+ * overlay. `typeName` may be omitted to use the `typeName` inside the file.
35
+ */
36
+ class SchemaFile {
37
+ constructor(path, typeName) {
38
+ this.path = path;
39
+ this.typeName = typeName;
40
+ }
41
+ readContent() {
42
+ return (0, fs_1.readFileSync)(this.path, 'utf8');
43
+ }
44
+ }
45
+ exports.SchemaFile = SchemaFile;
46
+ function toExternalRuleSources(sources) {
47
+ return (sources ?? []).map((source) =>
48
+ source instanceof RuleFile ? { name: source.path, content: source.readContent() } : source,
49
+ );
50
+ }
51
+ function toAdditionalSchemas(sources) {
52
+ return (sources ?? []).map((source) =>
53
+ source instanceof SchemaFile ? { typeName: source.typeName, schema: source.readContent() } : source,
54
+ );
55
+ }
56
+ function toWasmEngineConfig(config) {
57
+ return {
58
+ customRules: toExternalRuleSources(config?.customRules),
59
+ guardRules: toExternalRuleSources(config?.guardRules),
60
+ schemaValidatorConfig: config?.schemaValidatorConfig
61
+ ? toWasmSchemaValidatorConfig(config.schemaValidatorConfig)
62
+ : undefined,
63
+ };
64
+ }
65
+ function toWasmSchemaValidatorConfig(config) {
66
+ return {
67
+ additionalSchemas: toAdditionalSchemas(config?.additionalSchemas),
68
+ };
69
+ }
21
70
  class TemplateModel {
22
71
  constructor(template) {
23
72
  this.inner = bridge.WasmSemanticModel.parse(template.readBytes());
@@ -55,8 +104,8 @@ class TemplateModel {
55
104
  }
56
105
  exports.TemplateModel = TemplateModel;
57
106
  class SchemaValidator {
58
- constructor() {
59
- this.inner = new bridge.WasmSchemaValidator();
107
+ constructor(config) {
108
+ this.inner = new bridge.WasmSchemaValidator(toWasmSchemaValidatorConfig(config));
60
109
  }
61
110
  listRules() {
62
111
  return this.inner.listRules();
@@ -80,7 +129,7 @@ exports.SchemaValidator = SchemaValidator;
80
129
  function createEngineClass(WasmClass) {
81
130
  return class {
82
131
  constructor(config) {
83
- this.inner = new WasmClass(config ?? {});
132
+ this.inner = new WasmClass(toWasmEngineConfig(config));
84
133
  }
85
134
  validateStandard(template, config) {
86
135
  return this.inner.validateStandard(template.readBytes(), config ?? {}, template.path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/cloudformation-validate",
3
- "version": "1.5.1-beta",
3
+ "version": "1.7.0-beta",
4
4
  "description": "AWS CloudFormation Validate",
5
5
  "keywords": [
6
6
  "aws",