Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/api/src/cloud-security/plan-normalizer-aws-edge-cases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,36 @@ describe('normalizeFixPlan — AWS remediation edge cases', () => {
expect(result.rollbackSteps[0].params.GroupId).toBe('sg-0123abc');
});

it('backfills GroupId on EC2 security-group egress commands from the finding resource id', () => {
const ipPermissions = [
{
IpProtocol: '-1',
IpRanges: [{ CidrIp: '0.0.0.0/0' }],
},
];
const plan = makePlan({
fixSteps: [
makeStep({
service: 'ec2',
command: 'RevokeSecurityGroupEgressCommand',
params: { IpPermissions: ipPermissions },
}),
],
rollbackSteps: [
makeStep({
service: 'ec2',
command: 'AuthorizeSecurityGroupEgressCommand',
params: { IpPermissions: ipPermissions },
}),
],
});

const result = normalizeFixPlan(plan, { resourceId: 'sg-0123abc' });

expect(result.fixSteps[0].params.GroupId).toBe('sg-0123abc');
expect(result.rollbackSteps[0].params.GroupId).toBe('sg-0123abc');
});

it('does not overwrite an explicit security-group GroupName', () => {
const plan = makePlan({
fixSteps: [
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/cloud-security/plan-normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const IAM_LIKE_SERVICES = new Set(['iam', 'sts']);
const EC2_SECURITY_GROUP_COMMANDS = new Set([
'AuthorizeSecurityGroupIngressCommand',
'RevokeSecurityGroupIngressCommand',
'AuthorizeSecurityGroupEgressCommand',
'RevokeSecurityGroupEgressCommand',
]);
const S3_ACL_COMMANDS = new Set(['PutBucketAclCommand']);
const S3_ACL_PERMISSIONS = new Set(['s3:PutBucketAcl']);
Expand Down
Loading