sonarjs/aws-restricted-ip-admin-access
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/aws-restricted-ip-admin-access": "error",
},
},
];Administration services access should be restricted to specific IP addresses
import {aws_ec2 as ec2} from 'aws-cdk-lib'
const instance = new ec2.Instance(this, "default-own-security-group",{
instanceType: nanoT2,
machineImage: ec2.MachineImage.latestAmazonLinux(),
vpc: vpc,
instanceName: "test-instance"
})
instance.connections.allowFrom(
ec2.Peer.anyIpv4(), // Noncompliant
ec2.Port.tcp(22),
/*description*/ "Allows SSH from all IPv4"
)import {aws_ec2 as ec2} from 'aws-cdk-lib'
const securityGroup = new ec2.SecurityGroup(this, "custom-security-group", {
vpc: vpc
})
securityGroup.addIngressRule(
ec2.Peer.anyIpv4(), // Noncompliant
ec2.Port.tcpRange(1, 1024)
)import {aws_ec2 as ec2} from 'aws-cdk-lib'
new ec2.CfnSecurityGroup(
this,
"cfn-based-security-group", {
groupDescription: "cfn based security group",
groupName: "cfn-based-security-group",
vpcId: vpc.vpcId,
securityGroupIngress: [
{
ipProtocol: "6",
cidrIp: "0.0.0.0/0", // Noncompliant
fromPort: 22,
toPort: 22
}
]
}
)import {aws_ec2 as ec2} from 'aws-cdk-lib'
const instance = new ec2.Instance(this, "default-own-security-group",{
instanceType: nanoT2,
machineImage: ec2.MachineImage.latestAmazonLinux(),
vpc: vpc,
instanceName: "test-instance"
})
instance.connections.allowFrom(
ec2.Peer.ipv4("192.0.2.0/24"),
ec2.Port.tcp(22),
/*description*/ "Allows SSH from a trusted range"
)import {aws_ec2 as ec2} from 'aws-cdk-lib'
const securityGroup3 = new ec2.SecurityGroup(this, "custom-security-group", {
vpc: vpc
})
securityGroup3.addIngressRule(
ec2.Peer.anyIpv4(),
ec2.Port.tcpRange(1024, 1048)
)import {aws_ec2 as ec2} from 'aws-cdk-lib'
new ec2.CfnSecurityGroup(
this,
"cfn-based-security-group", {
groupDescription: "cfn based security group",
groupName: "cfn-based-security-group",
vpcId: vpc.vpcId,
securityGroupIngress: [
{
ipProtocol: "6",
cidrIp: "192.0.2.0/24", // Compliant
fromPort: 22,
toPort: 22
}
]
}
)Examples from the ESLint documentation.
sonarjs/aws-restricted-ip-admin-access
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/aws-restricted-ip-admin-access": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Amazon RDS resources should be encrypted at rest
S3 buckets should not grant access to all users or authenticated users
OpenSearch domains should have encryption at rest enabled
S3 buckets should enforce HTTPS-only access
AWS resource-based policies should not grant public access
Amazon S3 bucket public access should be fully blocked