mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
fix(glacier): handle no vault policy error (#1650)
Co-authored-by: sergargar <sergio@verica.io>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
from botocore.client import ClientError
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from prowler.lib.logger import logger
|
from prowler.lib.logger import logger
|
||||||
@@ -56,13 +57,16 @@ class Glacier:
|
|||||||
try:
|
try:
|
||||||
for vault in self.vaults.values():
|
for vault in self.vaults.values():
|
||||||
if vault.region == regional_client.region:
|
if vault.region == regional_client.region:
|
||||||
vault_access_policy = regional_client.get_vault_access_policy(
|
try:
|
||||||
vaultName=vault.name
|
vault_access_policy = regional_client.get_vault_access_policy(
|
||||||
)
|
vaultName=vault.name
|
||||||
self.vaults[vault.name].access_policy = json.loads(
|
)
|
||||||
vault_access_policy["policy"]["Policy"]
|
self.vaults[vault.name].access_policy = json.loads(
|
||||||
)
|
vault_access_policy["policy"]["Policy"]
|
||||||
|
)
|
||||||
|
except ClientError as e:
|
||||||
|
if e.response["Error"]["Code"] == "ResourceNotFoundException":
|
||||||
|
self.vaults[vault.name].access_policy = {}
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"{regional_client.region} --"
|
f"{regional_client.region} --"
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ class glacier_vaults_policy_public_access(Check):
|
|||||||
):
|
):
|
||||||
public_access = True
|
public_access = True
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
report.status_extended = f"Vault {vault.name} does not have a policy"
|
||||||
if public_access:
|
if public_access:
|
||||||
report.status = "FAIL"
|
report.status = "FAIL"
|
||||||
report.status_extended = (
|
report.status_extended = (
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class Test_glacier_vaults_policy_public_access:
|
|||||||
assert result[0].status == "PASS"
|
assert result[0].status == "PASS"
|
||||||
assert (
|
assert (
|
||||||
result[0].status_extended
|
result[0].status_extended
|
||||||
== f"Vault {vault_name} has policy which does not allow access to everyone"
|
== f"Vault {vault_name} does not have a policy"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_vault_policy_pricipal_aws_list_asterisk(self):
|
def test_vault_policy_pricipal_aws_list_asterisk(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user