Skip to content

Commit

Permalink
add region as filter for ecr repository
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Oct 30, 2024
1 parent ff3f265 commit 998b9d5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugins/aws/fix_plugin_aws/resource/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from attrs import define, field
from boto3.exceptions import Boto3Error

from fix_plugin_aws.resource.base import AwsResource, AwsApiSpec, GraphBuilder
from fix_plugin_aws.resource.base import AwsResource, AwsApiSpec, GraphBuilder, AwsRegion
from fix_plugin_aws.resource.ec2 import AwsEc2Instance
from fix_plugin_aws.resource.ecr import AwsEcrRepository
from fix_plugin_aws.resource.lambda_ import AwsLambdaFunction
Expand Down Expand Up @@ -428,19 +428,19 @@ def parse_finding(self, source: Json) -> Finding:
@classmethod
def collect_resources(cls, builder: GraphBuilder) -> None:
def check_type_and_adjust_id(
class_type: Optional[str], class_id: Optional[str]
class_type: Optional[str], resource_id: Optional[str]
) -> Tuple[Optional[Type[Any]], Optional[Dict[str, Any]]]:
if not class_id or not class_type:
if not resource_id or not class_type:
return None, None
match class_type:
case "AWS_LAMBDA_FUNCTION":
# remove lambda's version from arn
lambda_arn = class_id.rsplit(":", 1)[0]
lambda_arn = resource_id.rsplit(":", 1)[0]
return AwsLambdaFunction, dict(arn=lambda_arn)
case "AWS_EC2_INSTANCE":
return AwsEc2Instance, dict(id=class_id)
return AwsEc2Instance, dict(id=resource_id)
case "AWS_ECR_REPOSITORY":
return AwsEcrRepository, dict(id=class_id)
return AwsEcrRepository, dict(id=resource_id, _region=builder.region)
case _:
return None, None

Expand Down

0 comments on commit 998b9d5

Please sign in to comment.