-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more services and moved to separate folder
- Loading branch information
Showing
12 changed files
with
143 additions
and
17 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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
plugins: | ||
- module: .s3 | ||
- module: s3 | ||
class: S3 | ||
- module: .s3 | ||
- module: s3 | ||
class: S3ACL | ||
- module: .iam | ||
- module: s3 | ||
class: S3Glacier | ||
- module: iam | ||
class: IAM | ||
- module: .kms | ||
- module: kms | ||
class: KMS | ||
- module: .secretsmanager | ||
- module: secretsmanager | ||
class: SecretsManager | ||
- module: eventbridge | ||
class: EventBus | ||
- module: lambda | ||
class: LambdaResource | ||
- module: sqs | ||
class: SQS |
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
Empty file.
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,22 @@ | ||
import json | ||
from typing import DefaultDict, Set | ||
|
||
import boto3 # type: ignore | ||
|
||
from awsxenos.finding import Findings, Resources, Service | ||
|
||
"""EventBridge Bus Resource Policies""" | ||
|
||
|
||
class EventBus(Service): | ||
|
||
def fetch(self, accounts: DefaultDict[str, Set]) -> Findings: # type: ignore | ||
return super().collate(accounts, self.get_eb_policies()) | ||
|
||
def get_eb_policies(self) -> Resources: | ||
buses = Resources() | ||
eb = boto3.client("events") | ||
for bus in eb.list_event_buses(): | ||
if "Policy" in bus: | ||
buses[bus["Arn"]] = json.loads(bus["Policy"]) | ||
return buses |
File renamed without changes.
File renamed without changes.
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,40 @@ | ||
import json | ||
from typing import DefaultDict, Set | ||
|
||
import boto3 # type: ignore | ||
from botocore.exceptions import ClientError # type: ignore | ||
|
||
from awsxenos.finding import Findings, Resources, Service | ||
|
||
"""Lambda Resource Policies""" | ||
|
||
|
||
class LambdaResource(Service): | ||
|
||
def fetch(self, accounts: DefaultDict[str, Set]) -> Findings: # type: ignore | ||
return super().collate(accounts, self.get_lambda_policies()) | ||
|
||
def get_lambda_policies(self) -> Resources: | ||
lambdas = Resources() | ||
lam = boto3.client("lambda") | ||
paginator = lam.get_paginator("list_functions") | ||
for lam_resp in paginator.paginate(): | ||
for func in lam_resp["Functions"]: | ||
try: | ||
lambdas[func["FunctionArn"]] = json.loads( | ||
lam.get_policy(FunctionName=func["FunctionName"])["Policy"] | ||
) | ||
except ClientError as err: | ||
lambdas[func["FunctionArn"]] = { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": f"{err}", | ||
"Effect": "Allow", | ||
"Principal": {"AWS": ["arn:aws:iam::111122223333:root"]}, | ||
"Action": ["lambda:*"], | ||
"Resource": f'{func["FunctionArn"]}', | ||
} | ||
], | ||
} | ||
return lambdas |
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
File renamed without changes.
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 json | ||
from typing import DefaultDict, Optional, Set | ||
|
||
import boto3 # type: ignore | ||
|
||
from awsxenos.finding import Findings, Resources, Service | ||
|
||
"""SQS Access/Resource Policy""" | ||
|
||
|
||
class SQS(Service): | ||
|
||
def fetch( # type: ignore | ||
self, | ||
accounts: DefaultDict[str, Set], | ||
exclude_service: Optional[bool] = True, | ||
exclude_aws: Optional[bool] = True, | ||
) -> Findings: | ||
return super().collate(accounts, self.get_sqs_policies(exclude_service, exclude_aws)) | ||
|
||
def get_sqs_policies(self, exclude_service: Optional[bool] = True, exclude_aws: Optional[bool] = True) -> Resources: | ||
queues = Resources() | ||
sqs = boto3.client("sqs") | ||
paginator = sqs.get_paginator("list_queues") | ||
for sqs_resp in paginator.paginate(): | ||
for queue in sqs_resp["QueueUrls"]: | ||
queues[queue["QueueUrl"]] = json.loads( | ||
sqs.get_queue_attributes(QueueUrl=queue["QueueUrl"], AttributeNames=["Policy"])["Attributes"][ | ||
"Policy" | ||
] | ||
) | ||
|
||
return queues |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
policyuniverse==1.5.1.20231109 | ||
boto3==1.34.101 | ||
jinja2==3.0.1 | ||
jinja2==3.1.3 | ||
pyyaml==6.0.1 |