cdk-preflight 1.27.1 → 1.28.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.
@@ -27,7 +27,7 @@ cdk-preflight のルール追加パイプライン。AGENTS.md の設計原則
27
27
  - fail テンプレートはこのルール**だけ**に違反、pass テンプレートは完全クリーン
28
28
  - **数値・長さ・個数の制約は境界ちょうどで書く**。fail は「違反する値のうち限界に最も近いもの」、pass は「限界そのもの」— 20 文字下限なら fail=19 文字 / pass=20 文字であって、fail=5 文字 / pass=26 文字ではない。緩いペアはルールの向きしか証明しない(`count(v) < 20` は fail が 5 文字なら定数が `< 10` でも鳴り、pass が 26 文字なら `< 25` でも黙る)ので、定数も比較演算子も固定できないし、実機ゲートの証拠も弱くなる(19 文字が CREATE に失敗して初めて下限 20 が実証される)。ルールが両端を見ているレンジは fail に両端を置く(fail の判定は「自分のルールの診断が 1 件以上」なので、違反リソースを 2 つ並べてよい)。エンジンのスキーマが既に持っている側の端は入れない — ルールもそこは見ていない(原則 1)し、重複ガードが赤くなる。**しきい値はリテラルでなくてもよい** — 限界が別プロパティの値(`MinValue` と `MaxValue`、コンテナの `Memory` とタスクの `Memory`)なら、fail は 2 つの値を違反側に 1 だけずらし、pass は同値にする(同値で既に違反する `>=` / `<=` は逆で、fail が同値・pass が 1 ずれ)。`MinValue 10 / MaxValue 1` ではルールが `mn > mx + 5` でも鳴るので定数も演算子も固定できない。順序の無い制約(プロパティ欠落、enum の値違い、リソース間の不整合)には境界が無いので対象外
29
29
  4. **ローカルゲート**: まず `npx ts-node --transpile-only --project test/tsconfig.json scripts/rule-check.ts check <service|rule-id>...` を回す。`rules/` を直接読んで 1 エンジンに全ルールを載せ、fail が自分のルールで鳴るか / pass が全ルール無音か / どちらも組み込みエンジンに止められないかを返す(`bundle-rules` も meta.yaml の evidence も要らないので、実機ゲート前の直しはここで回す。80 本で数秒)。全部 `ok` になってから `npx projen bundle-rules && npx jest test/rules test/structure.test.ts`(`test/rules` は `rules.test.ts` と、ルール表を回す `rules.shard*.test.ts` の両方に当たる)(`bundle-rules` は `src/rules.generated.ts` / `docs/rules.md` に加えて **README のルール数バッジと対応リソースタイプ一覧も書き換える**。手で直さない。古いままなら `structure.test.ts` が落ちる)。**`rules/<service>/` を新設しても `npx projen` は要らない** — `.github/workflows/monthly-verify.yml` のサービス行列は実行時に `scripts/plan-services.py` が `rules/` を読んで組むので workflow ファイル自体は変わらない(#247 で実行時計算へ移行済み。2026-09-26 に `rules/verifiedpermissions/` を新設した PR #286 / #287 でも self-mutation は skipping のままだった)。2026-09-13 に Athena 追加で踏んだのは移行前の話。`structure.test.ts` は手順 3 の境界値を機械で見る(rego のしきい値ごとに fail へ「限界に最も近い違反値」、pass へ「限界そのもの」が現れるか)。しきい値の検出が意味を持たないルールだけ `rules/_boundary-exceptions.txt` に理由付きで逃がす。**jest は `-t` で対象を絞る**。フルスイートは PR 直前の 1 回だけでよく、実測では 401 回中 73 回がフル実行で合計 5.8 時間を溶かしている。
30
- - **反証ゲート(誤検知を作らないための機械の検査)**: ローカルゲートが通ったら `npx ts-node --transpile-only --project test/tsconfig.json scripts/omission-sweep.ts <rule-id>` を回す。pass テンプレートからプロパティを 1 つずつ抜いて、ルールが鳴る形(「省略すると落ちる」という主張)を列挙する。出てきたものは手順 5 の実機ゲートで「pass からそのプロパティだけを抜いたテンプレート」もデプロイして確かめる。CREATE が落ちたら `meta.yaml#omissionFails` にキーを、エラーを `repro.evidence` に書く。デプロイが通ったら、ルールが省略を値として読んでいるので直す。あわせて `scripts/lint-rules.ts`(`to_number` の直呼びと `object.get` のインライン既定値を禁止)と `rules/_lists.yaml`(8 件以上の手書きリストは台帳に登録。AWS が値を増やす集合の許可リストに頼る検査は WARN にしかできない)も `test/structure.test.ts` が見る。続けて `scripts/variant-sweep.ts <スキーマのディレクトリ> <rule-id>` を回す(スキーマの取得方法はスクリプトの先頭)。fail テンプレートの enum で閉じた値(種類を決める値)を兄弟の値に替えてもルールが鳴り続ける組が出る。ルールの rego に出てこない名前(`LaunchType`、`ProtocolType`、`Artifacts.Type` のような種類の値)が並んだら、その制約がその変種でも本当に成り立つかを考え、怪しければ実機ゲートでその変種も 1 つデプロイするか、ルールを測った変種に絞る。ゲートではない(全ルールで 700 本近くが主張を出し、ほとんどは制約と無関係な値)。PR を出す前に `npx projen corpus` で統合テストのスナップショット(実際にデプロイされた約 4,700 枚)にも掛け、新しい指摘が出たらまず誤検知を疑う(参照を文字列として読んでいないか、エラーメッセージの許可リストを規則と取り違えていないか、測った変種より広く効いていないか)。
30
+ - **反証ゲート(誤検知を作らないための機械の検査)**: ローカルゲートが通ったら `npx ts-node --transpile-only --project test/tsconfig.json scripts/omission-sweep.ts <rule-id>` を回す。pass テンプレートからプロパティを 1 つずつ抜いて、ルールが鳴る形(「省略すると落ちる」という主張)を列挙する。出てきたものは手順 5 の実機ゲートで「pass からそのプロパティだけを抜いたテンプレート」もデプロイして確かめる。CREATE が落ちたら `meta.yaml#omissionFails` にキーを、エラーを `repro.evidence` に書く。デプロイが通ったら、ルールが省略を値として読んでいるので直す。あわせて `scripts/lint-rules.ts`(`to_number` の直呼びと `object.get` のインライン既定値を禁止)と `rules/_lists.yaml`(8 件以上の手書きリストは台帳に登録。AWS が値を増やす集合の許可リストに頼る検査は WARN にしかできない)も `test/structure.test.ts` が見る。続けて `scripts/variant-sweep.ts <スキーマのディレクトリ> <rule-id>` を回す(スキーマの取得方法はスクリプトの先頭)。fail テンプレートの enum で閉じた値(種類を決める値)を兄弟の値に替えてもルールが鳴り続ける組が出る。ルールの rego に出てこない名前(`LaunchType`、`ProtocolType`、`Artifacts.Type` のような種類の値)が並んだら、その制約がその変種でも本当に成り立つかを考え、怪しければ実機ゲートでその変種も 1 つデプロイするか、ルールを測った変種に絞る。新しいルールは主張 0 本でなければ CI(corpus ジョブの `npx projen variant-sweep`)で落ちる。本当にその変種でも落ちると確かめた(実機かドキュメント)ものだけ `meta.yaml` の `variants: [{ path, to, why }]` に書く。PR を出す前に `npx projen corpus` で統合テストのスナップショット(実際にデプロイされた約 4,700 枚)にも掛け、新しい指摘が出たらまず誤検知を疑う(参照を文字列として読んでいないか、エラーメッセージの許可リストを規則と取り違えていないか、測った変種より広く効いていないか)。
31
31
  5. **実機再現ゲート**: `bash bench/verify-rule.sh <rule-id>`(要 AWS 認証)。観測したエラーメッセージと日付を `meta.yaml#repro.evidence` に記録。
32
32
  - **evidence には実際にデプロイした値を書く**(`bench 2026-09-13 us-east-1: 19-char Value -> "...at least 20 characters" (ROLLBACK_COMPLETE); pass 20-char -> CREATE_COMPLETE`)。境界ちょうどのフィクスチャと組で、限界の位置そのものが meta.yaml から読める
33
33
  - **evidence の拒否文から、制約を名指ししている部分を `repro.expect` に写す**(`expect: "must not be longer than 256 characters"`)。1 行のダブルクォート文字列で、中に `"` と `\` を入れない(月次ランナーは YAML パーサ無しに sed で読む)。evidence に逐語で含まれていないと `bundle-rules` が落ちる。月次はこの文面で照合し、別の理由で倒れたら INCONCLUSIVE にする(#264)。**2026-09-27 以降に足す real-deploy ルールでは必須**。サービスが汎用文しか返さない場合(`GeneralServiceException` など)は、その汎用文を写す
package/.jsii CHANGED
@@ -10111,6 +10111,6 @@
10111
10111
  "symbolId": "src/index:PreflightOptions"
10112
10112
  }
10113
10113
  },
10114
- "version": "1.27.1",
10115
- "fingerprint": "s6XAMR34l2LCKZT/zigNbJxifiWQwRzjr+6U6grtqKI="
10114
+ "version": "1.28.0",
10115
+ "fingerprint": "gIlcUV0VwBuGxjs3ZogARKWLOk2jGuik7qT9X4llHeI="
10116
10116
  }
package/AGENTS.md CHANGED
@@ -227,7 +227,7 @@ If you are a subagent running one of these phases, do not spawn further agents.
227
227
 
228
228
  **Deployed stacks (a manual sweep, not a gate).** A stack in `CREATE_COMPLETE`, `UPDATE_COMPLETE` or `IMPORT_COMPLETE` is proof that its template deployed in that account and Region. `AWS_PROFILE=<p> bash scripts/fetch-deployed.sh <out-dir> <region>...` reads those templates (`GetTemplate`, processed stage, so SAM is expanded) with the parameter values the stack was given, skipping the bench's own `cdkpf-*` stacks, and `scripts/deployed-sweep.ts <out-dir>` runs every rule over them with that account and Region injected, which the corpus cannot do. An ERROR there is a false-positive suspect unless AWS tightened the constraint after that deploy. It reads only, creates nothing, and the templates stay outside the repository because they belong to whoever owns the account.
229
229
 
230
- **Variant sweep (a review aid, not a gate).** `scripts/variant-sweep.ts <schema-dir> <rule-id>` replaces each string in the fail template that the registry schema closes with an `enum` (a kind: `LaunchType`, `ProtocolType`, `PipelineType`) with its siblings, one at a time, and lists the ones on which the rule still fires: a claim that the constraint holds for that variant too, which the fail template never measured. A rule scoped wider than what it measured is one of the corpus's four false-positive shapes, and the corpus only finds it when a sibling happens to be in there. The first run over the pack (2026-12-03) listed 2,584 claims from 702 rules, 704 rule/property pairs on properties the rego never names; nearly all are kinds the constraint has nothing to do with (a VPC Lattice CIDR format under `TCP` vs `TCP_UDP`), so the list is read per rule while adding it, not enforced. It only sees `enum` properties: `AWS::CodeBuild::Project.Artifacts.Type` is a plain string in the schema, so the suspect aws-cloudformation-templates turned up there (a constraint measured on `NO_ARTIFACTS`, reported on `CODEPIPELINE`, #456) does not show up.
230
+ **Variant sweep.** `scripts/variant-sweep.ts <schema-dir> <rule-id>` replaces each string in the fail template that the registry schema closes with an `enum` (a kind: `LaunchType`, `ProtocolType`, `PipelineType`) with its siblings, one at a time, and lists the ones on which the rule still fires: a claim that the constraint holds for that variant too, which the fail template never measured. A rule scoped wider than what it measured is one of the corpus's four false-positive shapes, and the corpus only finds it when a sibling happens to be in there. For a string the schema leaves open (`AWS::CodeBuild::Project.Artifacts.Type`, #456) it lists the property when the rule goes quiet on some value its rego names but keeps firing on a value it names nowhere (`to` is `*`): a `!=` that generalises past what was measured. The claims of 2026-12-05 are frozen in `rules/_variant-baseline.txt` (nearly all are kinds the constraint has nothing to do with, such as a VPC Lattice CIDR format under `TCP` vs `TCP_UDP`), which may only shrink. `npx projen variant-sweep` (a step of the `corpus` job) measures the rules changed since `main` and fails on any claim that is neither frozen nor declared, so a new rule starts with none. When the claim is wrong, narrow the rule to the kind it measured. When the constraint really holds for the sibling (you deployed it, or the documentation says it does not depend on the kind), declare it in `meta.yaml`: `variants: [{ path: ProtocolType, to: WEBSOCKET, why: "<run or doc>" }]` (`to: "*"` for an open string). The schema is `https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip`; the whole pack takes about 50 CPU-minutes, so `--write-baseline` is for re-freezing only.
231
231
 
232
232
  **Reference sweep.** `npx projen reference-sweep` (`scripts/reference-sweep.ts`, a step of the `corpus` job) takes each rule's pass template and replaces the string leaves of the rule's resource types, one at a time, with a `Ref` and a `Fn::GetAtt` to a resource no rule reads (strings, numbers and booleans). The value of a reference is unknown until deploy, so a rule that fires on one of these mutants and not on the pass template is reading the reference as a literal. `rules/_lib/value.rego` has the readers: `_pf_lit(name, path)` is the value only when it is a literal (a string that is not a logical id, a number, a boolean), `_pf_is_lit(v)` tests a value already read, `_pf_unknown(name, path)` / `_pf_list_unknown(name, path)` hold when the template writes something there that cannot be read. A rule that fires on an absence or a mismatch (`not x in {...}`, `x != "Y"`, "the list does not contain Z") must add `not _pf_unknown(...)` for the value it compares; a size limit counts `_pf_json_size_min(doc)`. To read a key whose omission has no measured meaning, use `_pf_oval(o, k)` (undefined when absent, so the judgement drops) instead of an `object.get` default. `rules/_reference-baseline.txt` is a ratchet that may only shrink (empty since 2026-11-26: every firing found was fixed). A mutant that makes a rule error at run time fails regardless: one runtime error stops every rule of its service on that template (enforce mode then skips that service with a `pf-engine-error` warning rather than blocking synth, but its rules are lost).
233
233
  **Branch sweep.** `npx projen branch-sweep` (`scripts/branch-sweep.ts`, a step of the `corpus` job, about 4 minutes) takes every rule with two or more `violation` blocks and evaluates its fail template once per block, with only that block left in place. A block the fail template never fires is a claim no deploy has measured: the real-deploy gate and the monthly run deploy only the fail template, so if AWS relaxes that branch's constraint, nothing turns BROKEN and the rule goes on failing synth on templates that deploy. That is how `pf-rds-serverless-v2-capacity` kept Aurora PostgreSQL at 256 ACUs after the raise to 384 (#461): its only fail template was MySQL. `WARN` blocks are not counted: they never fail synth, so a relaxed constraint costs the user nothing there. The first run (2026-12-05) found 538 such blocks in 287 of the 387 multi-block rules (`pf-wafv2-label-syntax` measures one of its nine). They are frozen per rule in `rules/_branch-baseline.txt`, which may only shrink; a rule not listed there, which includes every new rule, must fire from every block on its fail template. To shrink it, add a resource to the fail template that reaches the block (one fail template may violate several ways), measure it with `bench/verify-rule.sh`, and lower the count. A block that cannot be reached by a deployable template is demoted to `WARN` or removed. Cases in `test/rules.test.ts` do not count: they pin the rego, not AWS.
package/docs/rules.md CHANGED
@@ -61,7 +61,7 @@
61
61
  | `pf-apigw-integration-response-selection-pattern` | AWS::ApiGateway::Method | SelectionPattern must be a valid regular expression | ERROR | none |
62
62
  | `pf-apigw-integration-vpc-link-connection-id` | AWS::ApiGateway::Method | A VPC_LINK integration needs a ConnectionId | ERROR | none |
63
63
  | `pf-apigw-lambda-integration-post` | AWS::ApiGateway::Method | A Lambda integration's IntegrationHttpMethod must be POST | ERROR | none |
64
- | `pf-apigw-method-authorization-scopes-cognito` | AWS::ApiGateway::Method | AuthorizationScopes needs COGNITO_USER_POOLS authorization | ERROR | none |
64
+ | `pf-apigw-method-authorization-scopes-cognito` | AWS::ApiGateway::Method | AuthorizationScopes needs COGNITO_USER_POOLS or JWT authorization | ERROR | none |
65
65
  | `pf-apigw-method-authorizer-id` | AWS::ApiGateway::Method | CUSTOM and COGNITO_USER_POOLS authorization need AuthorizerId | ERROR | none |
66
66
  | `pf-apigw-method-http-verb` | AWS::ApiGateway::Method | HttpMethod is one of the eight API Gateway verbs | ERROR | none |
67
67
  | `pf-apigw-method-request-parameter-key` | AWS::ApiGateway::Method | Method request parameter keys are mapping expressions | ERROR | none |
@@ -820,7 +820,7 @@
820
820
  | `pf-agentcore-required-union-empty` | AWS::BedrockAgentCore::Evaluator<br>AWS::BedrockAgentCore::GatewayTarget<br>AWS::BedrockAgentCore::Policy | Required union blocks (EvaluatorConfig, TargetConfiguration, Definition) must not be empty objects | ERROR | retired: engine F3018 covers it from aws-cdk-lib 2.268.0 |
821
821
  | `pf-agentcore-resource-policy-document` | AWS::BedrockAgentCore::ResourcePolicy | A resource policy must be a JSON policy whose statements carry Principal, bedrock-agentcore actions, and exactly one Resource ARN | ERROR | none |
822
822
  | `pf-agentcore-runtime-artifact-exactly-one` | AWS::BedrockAgentCore::Runtime | AgentRuntimeArtifact must hold exactly one of ContainerConfiguration or CodeConfiguration | ERROR | none |
823
- | `pf-agentcore-runtime-byo-filesystem-vpc` | AWS::BedrockAgentCore::Runtime | EfsAccessPoint and S3FilesAccessPoint need a runtime in VPC network mode | ERROR | none |
823
+ | `pf-agentcore-runtime-byo-filesystem-vpc` | AWS::BedrockAgentCore::Runtime | EfsAccessPoint and S3FilesAccessPoint need VPC network mode or platform version V2 | ERROR | none |
824
824
  | `pf-agentcore-runtime-capacity-provider-max-lifetime` | AWS::BedrockAgentCore::Runtime | A runtime's MaxLifetime must not exceed its capacity provider's MaxLifetime (both default to 28800) | ERROR | none |
825
825
  | `pf-agentcore-runtime-capacity-provider-network-config` | AWS::BedrockAgentCore::Runtime | A runtime on a capacity provider cannot set NetworkConfiguration | ERROR | none |
826
826
  | `pf-agentcore-runtime-capacity-provider-region` | AWS::BedrockAgentCore::Runtime | A runtime CapacityProviderArn must name a capacity provider in the deploy region | ERROR | none |
@@ -2905,7 +2905,7 @@
2905
2905
  | `pf-route53-weighted-group-same-ttl` | AWS::Route53::RecordSetGroup | Weighted record sets sharing a name and type must have the same TTL | ERROR | none |
2906
2906
  | `pf-route53-weighted-max-100-same-name-type` | AWS::Route53::RecordSetGroup | A weighted group may hold at most 100 record sets per name and type | ERROR | none |
2907
2907
  | `pf-route53-zonename-trailing-dot` | AWS::Route53::RecordSet<br>AWS::Route53::RecordSetGroup | HostedZoneName must end with a trailing dot | ERROR | none |
2908
- | `pf-route53profiles-profileassociation-one-per-vpc` | AWS::Route53Profiles::ProfileAssociation | A VPC can only be associated with one Route 53 Profile | ERROR | none |
2908
+ | `pf-route53profiles-profileassociation-one-per-vpc` | AWS::Route53Profiles::ProfileAssociation | Every Route 53 Profile association of a VPC after the first needs a Priority | ERROR | none |
2909
2909
  | `pf-route53profiles-profileresourceassociation-priority-range` | AWS::Route53Profiles::ProfileResourceAssociation | A ProfileResourceAssociation priority must be between 101 and 9899 | ERROR | none |
2910
2910
  | `pf-route53profiles-profileresourceassociation-querylogging-max` | AWS::Route53Profiles::ProfileResourceAssociation | A Profile cannot hold more than one Resolver query logging config | ERROR | none |
2911
2911
  | `pf-route53profiles-profileresourceassociation-resourcearn-type` | AWS::Route53Profiles::ProfileResourceAssociation | A Profile can only take a private hosted zone, DNS Firewall rule group, Resolver rule or interface VPC endpoint | ERROR | none |
package/lib/index.js CHANGED
@@ -19,7 +19,7 @@ const rules_generated_1 = require("./rules.generated");
19
19
  * Preflight.apply(app);
20
20
  */
21
21
  class Preflight {
22
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-preflight.Preflight", version: "1.27.1" };
22
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-preflight.Preflight", version: "1.28.0" };
23
23
  /**
24
24
  * Register the cdk-preflight rules on an App or Stage.
25
25
  */