forked from aws-samples/service-screener-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request aws-samples#96 from cykhoo0108/ec2-cis-check
Ec2 cis check
- Loading branch information
Showing
5 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import boto3 | ||
import botocore | ||
|
||
from services.Evaluator import Evaluator | ||
|
||
class Ec2NACL(Evaluator): | ||
def __init__(self, nacl, ec2Client): | ||
super().__init__() | ||
self.nacl = nacl | ||
self.ec2Client = ec2Client | ||
self.init() | ||
return | ||
|
||
def _checkNACLAssociation(self): | ||
if not self.nacl['Associations']: | ||
self.results['NACLAssociated'] = [-1, self.nacl['NetworkAclId']] | ||
|
||
return | ||
|
||
def _checkNACLIngressSensitivePort(self): | ||
sensitivePort = [22, 3389] | ||
for entry in self.nacl['Entries']: | ||
if entry['RuleAction'] == 'allow' and entry['Egress'] == False: | ||
if ('CidrBlock' in entry and entry['CidrBlock'] == '0.0.0.0/0') or ('Ipv6CidrBlock' in entry and entry['Ipv6CidrBlock'] == '::/0'): | ||
if 'PortRange' in entry: | ||
portFrom = entry['PortRange']['From'] | ||
portTo = entry['PortRange']['To'] | ||
for port in sensitivePort: | ||
if portFrom <= port and portTo >= port: | ||
self.results['NACLSensitivePort'] = [-1, self.nacl['NetworkAclId']] | ||
return | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import boto3 | ||
import botocore | ||
|
||
from services.Evaluator import Evaluator | ||
|
||
class Ec2Vpc(Evaluator): | ||
def __init__(self, vpc, flowLogs, ec2Client): | ||
super().__init__() | ||
self.vpc = vpc | ||
self.flowLogs = flowLogs | ||
self.ec2Client = ec2Client | ||
self.init() | ||
return | ||
|
||
def _checkVpcFlowLogEnabled(self): | ||
vpcId = self.vpc['VpcId'] | ||
for flowLog in self.flowLogs: | ||
if flowLog['ResourceId'] == vpcId and flowLog['TrafficType'] != 'ACCEPT': | ||
return | ||
|
||
self.results['VPCFlowLogEnabled'] = [-1, self.vpc['VpcId']] | ||
return | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters