Keeping the code seperate from the function obj

This commit is contained in:
Fennerr
2023-12-13 14:51:17 +02:00
parent 578b21f424
commit 92e0d74055
2 changed files with 4 additions and 5 deletions
@@ -12,8 +12,8 @@ class awslambda_function_no_secrets_in_code(Check):
def execute(self):
findings = []
if awslambda_client.functions:
for function in awslambda_client.__get_function_code__():
if function.code:
for function_code, function in awslambda_client.__get_function_code__():
if function_code:
report = Check_Report_AWS(self.metadata())
report.region = function.region
report.resource_id = function.name
@@ -25,7 +25,7 @@ class awslambda_function_no_secrets_in_code(Check):
f"No secrets found in Lambda function {function.name} code."
)
with tempfile.TemporaryDirectory() as tmp_dir_name:
function.code.code_zip.extractall(tmp_dir_name)
function_code.code_zip.extractall(tmp_dir_name)
# List all files
files_in_zip = next(os.walk(tmp_dir_name))[2]
secrets_findings = []
@@ -77,8 +77,7 @@ class Lambda(AWSService):
try:
function_code = fetched_lambda_code.result()
if function_code:
function.code = function_code
yield function
yield function_code, function
except Exception as error:
logger.error(
f"{function.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"