Skip to content

Commit a5d9bd4

Browse files
fix(rules): renumber ec2 rule ids (#40)
1 parent 241b219 commit a5d9bd4

15 files changed

+70
-36
lines changed

.changeset/clean-rules-renumber.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudburn/rules': patch
3+
---
4+
5+
Renumber the AWS EC2 built-in rule IDs to keep the service sequence contiguous and add metadata coverage that fails when rule numbers are duplicated or skipped.

docs/guides/adding-a-rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Use this guide for both:
99

1010
## 1. Choose an ID
1111

12-
Format: `CLDBRN-{PROVIDER}-{SERVICE}-{N}`. Check [rule-ids.md](../reference/rule-ids.md) for the next available number in your service. Never reuse or renumber existing IDs.
12+
Format: `CLDBRN-{PROVIDER}-{SERVICE}-{N}`. Check [rule-ids.md](../reference/rule-ids.md) for the next contiguous number in your service. Keep each provider/service sequence gap-free, and if you remove or reorder a rule, renumber later IDs and update references in the same change.
1313

1414
## 2. Decide Whether You Need a Dataset Change
1515

docs/reference/rule-ids.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Format: `CLDBRN-{PROVIDER}-{SERVICE}-{N}`
88

99
- All uppercase
1010
- No zero-padding on the sequence number
11-
- IDs are stable — no renumbering when rules are removed (gaps are allowed)
11+
- IDs stay contiguous within each provider/service sequence; when a change affects the sequence, renumber later entries and update references in the same change
1212
- Provider: `AWS`, `AZURE`, `GCP`
1313
- Service: short name matching the directory (e.g. `EBS`, `EC2`, `RDS`, `S3`, `LAMBDA`)
1414

@@ -25,10 +25,10 @@ Format: `CLDBRN-{PROVIDER}-{SERVICE}-{N}`
2525
| `CLDBRN-AWS-EC2-3` | Elastic IP Address Unassociated | ec2 | discovery | Implemented |
2626
| `CLDBRN-AWS-EC2-4` | VPC Interface Endpoint Inactive | ec2 | discovery | Implemented |
2727
| `CLDBRN-AWS-EC2-5` | EC2 Instance Low Utilization | ec2 | discovery | Implemented |
28-
| `CLDBRN-AWS-EC2-9` | EC2 Instance Without Graviton | ec2 | discovery | Implemented |
29-
| `CLDBRN-AWS-EC2-10` | EC2 Reserved Instance Expiring | ec2 | discovery | Implemented |
30-
| `CLDBRN-AWS-EC2-11` | EC2 Instance Large Size | ec2 | discovery | Implemented |
31-
| `CLDBRN-AWS-EC2-12` | EC2 Instance Long Running | ec2 | discovery | Implemented |
28+
| `CLDBRN-AWS-EC2-6` | EC2 Instance Without Graviton | ec2 | discovery | Implemented |
29+
| `CLDBRN-AWS-EC2-7` | EC2 Reserved Instance Expiring | ec2 | discovery | Implemented |
30+
| `CLDBRN-AWS-EC2-8` | EC2 Instance Large Size | ec2 | discovery | Implemented |
31+
| `CLDBRN-AWS-EC2-9` | EC2 Instance Long Running | ec2 | discovery | Implemented |
3232
| `CLDBRN-AWS-ECS-1` | ECS Container Instance Without Graviton | ecs | discovery | Implemented |
3333
| `CLDBRN-AWS-ECS-2` | ECS Cluster Low CPU Utilization | ecs | discovery | Implemented |
3434
| `CLDBRN-AWS-ECS-3` | ECS Service Missing Autoscaling Policy | ecs | discovery | Implemented |
@@ -56,13 +56,13 @@ Format: `CLDBRN-{PROVIDER}-{SERVICE}-{N}`
5656

5757
`CLDBRN-AWS-CLOUDWATCH-2` flags log streams with no observed event history and log streams whose `lastIngestionTime` is more than 90 days old. Delivery-managed log groups remain exempt.
5858

59-
`CLDBRN-AWS-EC2-9` flags only families with a curated Graviton-equivalent path. Instances without architecture metadata or outside the curated family set are skipped.
59+
`CLDBRN-AWS-EC2-6` flags only families with a curated Graviton-equivalent path. Instances without architecture metadata or outside the curated family set are skipped.
6060

61-
`CLDBRN-AWS-EC2-10` reviews only active reserved instances with an `endTime` inside the next 60 days.
61+
`CLDBRN-AWS-EC2-7` reviews only active reserved instances with an `endTime` inside the next 60 days.
6262

63-
`CLDBRN-AWS-EC2-11` treats `2xlarge` and above, plus `metal`, as the large-instance review threshold.
63+
`CLDBRN-AWS-EC2-8` treats `2xlarge` and above, plus `metal`, as the large-instance review threshold.
6464

65-
`CLDBRN-AWS-EC2-12` flags only instances with a parsed launch timestamp at least 180 days old.
65+
`CLDBRN-AWS-EC2-9` flags only instances with a parsed launch timestamp at least 180 days old.
6666

6767
`CLDBRN-AWS-ECS-1` flags only EC2-backed container instances whose instance families have a curated Graviton-equivalent path. Fargate and unclassified backing instances are skipped.
6868

packages/rules/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Rule Authoring
44

55
- `createRule` is mandatory for built-in rule declarations.
6-
- Rule IDs must use `CLDBRN-{PROVIDER}-{SERVICE}-{N}` in uppercase with no zero-padding. Never renumber existing IDs; gaps are allowed.
6+
- Rule IDs must use `CLDBRN-{PROVIDER}-{SERVICE}-{N}` in uppercase with no zero-padding. Keep numbering contiguous within each provider/service sequence; if a rule is removed or reordered, renumber later IDs and update references in the same change.
77
- Rule evaluators return lean rule-level groups that include `ruleId`, `service`, `source`, `message`, and nested `FindingMatch[]`.
88
- Rule names must describe the policy being enforced, not the migration or fix action.
99
- Rule-level `message` is the canonical public policy text for scan output.

packages/rules/src/aws/ec2/graviton-review.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createFinding, createFindingMatch, createRule } from '../../shared/helpers.js';
22
import { shouldReviewAwsEc2InstanceForGraviton } from './preferred-instance-families.js';
33

4-
const RULE_ID = 'CLDBRN-AWS-EC2-9';
4+
const RULE_ID = 'CLDBRN-AWS-EC2-6';
55
const RULE_SERVICE = 'ec2';
66
const RULE_MESSAGE = 'EC2 instances without a Graviton equivalent in use should be reviewed.';
77

packages/rules/src/aws/ec2/large-instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createFinding, createFindingMatch, createRule } from '../../shared/helpers.js';
22

3-
const RULE_ID = 'CLDBRN-AWS-EC2-11';
3+
const RULE_ID = 'CLDBRN-AWS-EC2-8';
44
const RULE_SERVICE = 'ec2';
55
const RULE_MESSAGE = 'EC2 large instances of 2xlarge or greater should be reviewed.';
66
// Treat 2xlarge and above as the right-sizing review threshold.

packages/rules/src/aws/ec2/long-running-instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createFinding, createFindingMatch, createRule } from '../../shared/helpers.js';
22

3-
const RULE_ID = 'CLDBRN-AWS-EC2-12';
3+
const RULE_ID = 'CLDBRN-AWS-EC2-9';
44
const RULE_SERVICE = 'ec2';
55
const RULE_MESSAGE = 'EC2 instances running for 180 days or longer should be reviewed.';
66
const DAY_MS = 24 * 60 * 60 * 1000;

packages/rules/src/aws/ec2/reserved-instance-expiring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createFinding, createFindingMatch, createRule } from '../../shared/helpers.js';
22

3-
const RULE_ID = 'CLDBRN-AWS-EC2-10';
3+
const RULE_ID = 'CLDBRN-AWS-EC2-7';
44
const RULE_SERVICE = 'ec2';
55
const RULE_MESSAGE = 'EC2 reserved instances expiring within 60 days should be reviewed.';
66
const DAY_MS = 24 * 60 * 60 * 1000;

packages/rules/test/ec2-graviton-review.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('ec2GravitonReviewRule', () => {
2626
});
2727

2828
expect(finding).toEqual({
29-
ruleId: 'CLDBRN-AWS-EC2-9',
29+
ruleId: 'CLDBRN-AWS-EC2-6',
3030
service: 'ec2',
3131
source: 'discovery',
3232
message: 'EC2 instances without a Graviton equivalent in use should be reviewed.',

packages/rules/test/ec2-large-instance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('ec2LargeInstanceRule', () => {
2525
});
2626

2727
expect(finding).toEqual({
28-
ruleId: 'CLDBRN-AWS-EC2-11',
28+
ruleId: 'CLDBRN-AWS-EC2-8',
2929
service: 'ec2',
3030
source: 'discovery',
3131
message: 'EC2 large instances of 2xlarge or greater should be reviewed.',

0 commit comments

Comments
 (0)