mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
chore(mongodbatlas): remove unused attributtes
This commit is contained in:
@@ -2,26 +2,6 @@ from prowler.lib.logger import logger
|
||||
|
||||
# MongoDB Atlas Provider Configuration
|
||||
|
||||
# Default API version
|
||||
ATLAS_API_VERSION = "2025-01-01"
|
||||
|
||||
# Default base URL
|
||||
ATLAS_BASE_URL = "https://cloud.mongodb.com/api/atlas/v2"
|
||||
|
||||
# Default timeout for API requests (in seconds)
|
||||
ATLAS_REQUEST_TIMEOUT = 30
|
||||
|
||||
# Default pagination settings
|
||||
ATLAS_DEFAULT_PAGE_SIZE = 100
|
||||
ATLAS_MAX_PAGES = 50
|
||||
|
||||
# Rate limiting settings
|
||||
ATLAS_MAX_RETRIES = 3
|
||||
ATLAS_RETRY_DELAY = 1
|
||||
|
||||
# Supported cluster types for encryption checks
|
||||
ATLAS_CLUSTER_TYPES = ["REPLICASET", "SHARDED", "GEOSHARDED"]
|
||||
|
||||
# Supported encryption providers
|
||||
ATLAS_ENCRYPTION_PROVIDERS = ["AWS", "AZURE", "GCP", "NONE"]
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class MongoDBAtlasMutelist(Mutelist):
|
||||
return self.is_muted(
|
||||
account_name,
|
||||
finding.check_metadata.CheckID,
|
||||
"*", # MongoDB Atlas doesn't have regions in the same way as AWS
|
||||
"*", # TODO: Study regions in MongoDB Atlas
|
||||
finding.resource_name,
|
||||
unroll_dict(unroll_tags(finding.resource_tags)),
|
||||
)
|
||||
|
||||
@@ -19,9 +19,6 @@ class MongoDBAtlasIdentityInfo(BaseModel):
|
||||
|
||||
user_id: str
|
||||
username: str
|
||||
email: Optional[str] = None
|
||||
first_name: Optional[str] = None
|
||||
last_name: Optional[str] = None
|
||||
roles: Optional[List[str]] = []
|
||||
|
||||
|
||||
|
||||
@@ -247,9 +247,6 @@ class MongodbatlasProvider(Provider):
|
||||
identity = MongoDBAtlasIdentityInfo(
|
||||
user_id=session.public_key, # Use public key as identifier
|
||||
username=f"api-key-{session.public_key[:8]}", # Create a username from public key
|
||||
email=None, # Not available from orgs endpoint
|
||||
first_name=None, # Not available from orgs endpoint
|
||||
last_name=None, # Not available from orgs endpoint
|
||||
roles=["API_KEY"], # Indicate this is an API key authentication
|
||||
)
|
||||
|
||||
@@ -268,15 +265,9 @@ class MongodbatlasProvider(Provider):
|
||||
def print_credentials(self):
|
||||
"""Print the MongoDB Atlas credentials"""
|
||||
report_lines = [
|
||||
f"MongoDB Atlas User: {Fore.YELLOW}{self.identity.username}{Style.RESET_ALL}",
|
||||
f"MongoDB Atlas User ID: {Fore.YELLOW}{self.identity.user_id}{Style.RESET_ALL}",
|
||||
]
|
||||
|
||||
if self.identity.email:
|
||||
report_lines.append(
|
||||
f"MongoDB Atlas Email: {Fore.YELLOW}{self.identity.email}{Style.RESET_ALL}"
|
||||
)
|
||||
|
||||
if self.organization_id:
|
||||
report_lines.append(
|
||||
f"Organization ID Filter: {Fore.YELLOW}{self.organization_id}{Style.RESET_ALL}"
|
||||
|
||||
@@ -49,7 +49,6 @@ class Clusters(MongoDBAtlasService):
|
||||
clusters = {}
|
||||
|
||||
try:
|
||||
# Get projects first to iterate through them
|
||||
from prowler.providers.mongodbatlas.services.projects.projects_client import (
|
||||
projects_client,
|
||||
)
|
||||
@@ -82,7 +81,6 @@ class Clusters(MongoDBAtlasService):
|
||||
project_clusters = {}
|
||||
|
||||
try:
|
||||
# Get all clusters in the project with pagination
|
||||
clusters_data = self._paginate_request(f"/groups/{project_id}/clusters")
|
||||
|
||||
for cluster_data in clusters_data:
|
||||
@@ -112,25 +110,18 @@ class Clusters(MongoDBAtlasService):
|
||||
"""
|
||||
cluster_name = cluster_data.get("name", "")
|
||||
|
||||
# Get encryption at rest configuration
|
||||
encryption_provider = self._get_encryption_at_rest_provider(cluster_data)
|
||||
|
||||
# Get backup configuration
|
||||
backup_enabled = self._get_backup_enabled(cluster_data)
|
||||
|
||||
# Extract provider settings
|
||||
provider_settings = cluster_data.get("providerSettings", {})
|
||||
|
||||
# Extract replication specs
|
||||
replication_specs = cluster_data.get("replicationSpecs", [])
|
||||
|
||||
# Extract auto scaling settings
|
||||
auto_scaling = cluster_data.get("autoScaling", {})
|
||||
|
||||
# Extract connection strings
|
||||
connection_strings = cluster_data.get("connectionStrings", {})
|
||||
|
||||
# Extract tags
|
||||
tags = cluster_data.get("tags", [])
|
||||
|
||||
return Cluster(
|
||||
@@ -167,13 +158,11 @@ class Clusters(MongoDBAtlasService):
|
||||
Optional[str]: Encryption provider or None
|
||||
"""
|
||||
try:
|
||||
# Check if encryption at rest is enabled
|
||||
encryption_at_rest = cluster_data.get("encryptionAtRestProvider")
|
||||
|
||||
if encryption_at_rest:
|
||||
return encryption_at_rest
|
||||
|
||||
# Check provider settings for encryption
|
||||
provider_settings = cluster_data.get("providerSettings", {})
|
||||
encrypt_ebs_volume = provider_settings.get("encryptEBSVolume", False)
|
||||
|
||||
@@ -197,10 +186,9 @@ class Clusters(MongoDBAtlasService):
|
||||
bool: True if backup is enabled, False otherwise
|
||||
"""
|
||||
try:
|
||||
# Check for backup enabled flag
|
||||
backup_enabled = cluster_data.get("backupEnabled", False)
|
||||
|
||||
# Also check for pit enabled as an indicator of backup
|
||||
# Also check for point-in-time enabled as an indicator of backup
|
||||
pit_enabled = cluster_data.get("pitEnabled", False)
|
||||
|
||||
return backup_enabled or pit_enabled
|
||||
|
||||
@@ -16,9 +16,6 @@ ATLAS_BASE_URL = "https://cloud.mongodb.com/api/atlas/v2"
|
||||
# Test user identity
|
||||
USER_ID = "test_public_key"
|
||||
USERNAME = "api-key-test_pub"
|
||||
EMAIL = None
|
||||
FIRST_NAME = None
|
||||
LAST_NAME = None
|
||||
|
||||
# Test project
|
||||
PROJECT_ID = "test_project_id"
|
||||
@@ -95,9 +92,7 @@ def set_mocked_mongodbatlas_provider(
|
||||
identity: MongoDBAtlasIdentityInfo = MongoDBAtlasIdentityInfo(
|
||||
user_id=USER_ID,
|
||||
username=USERNAME,
|
||||
email=EMAIL,
|
||||
first_name=FIRST_NAME,
|
||||
last_name=LAST_NAME,
|
||||
roles=["API_KEY"],
|
||||
),
|
||||
audit_config: dict = None,
|
||||
organization_id: str = None,
|
||||
|
||||
@@ -17,9 +17,6 @@ from tests.providers.mongodbatlas.mongodbatlas_fixtures import (
|
||||
ATLAS_BASE_URL,
|
||||
ATLAS_PRIVATE_KEY,
|
||||
ATLAS_PUBLIC_KEY,
|
||||
EMAIL,
|
||||
FIRST_NAME,
|
||||
LAST_NAME,
|
||||
MOCK_ORGS_RESPONSE,
|
||||
USER_ID,
|
||||
USERNAME,
|
||||
@@ -43,9 +40,7 @@ class TestMongodbatlasProvider:
|
||||
return_value=MongoDBAtlasIdentityInfo(
|
||||
user_id=USER_ID,
|
||||
username=USERNAME,
|
||||
email=EMAIL,
|
||||
first_name=FIRST_NAME,
|
||||
last_name=LAST_NAME,
|
||||
roles=["API_KEY"],
|
||||
),
|
||||
),
|
||||
):
|
||||
@@ -58,7 +53,6 @@ class TestMongodbatlasProvider:
|
||||
assert provider.session.public_key == ATLAS_PUBLIC_KEY
|
||||
assert provider.session.private_key == ATLAS_PRIVATE_KEY
|
||||
assert provider.identity.username == USERNAME
|
||||
assert provider.identity.email == EMAIL
|
||||
|
||||
def test_setup_session_with_credentials(self):
|
||||
"""Test session setup with provided credentials"""
|
||||
@@ -108,9 +102,6 @@ class TestMongodbatlasProvider:
|
||||
|
||||
assert identity.user_id == USER_ID
|
||||
assert identity.username == USERNAME
|
||||
assert identity.email == EMAIL
|
||||
assert identity.first_name == FIRST_NAME
|
||||
assert identity.last_name == LAST_NAME
|
||||
assert identity.roles == ["API_KEY"]
|
||||
|
||||
@patch("requests.get")
|
||||
@@ -159,7 +150,7 @@ class TestMongodbatlasProvider:
|
||||
return_value=MongoDBAtlasIdentityInfo(
|
||||
user_id=USER_ID,
|
||||
username=USERNAME,
|
||||
email=EMAIL,
|
||||
roles=["API_KEY"],
|
||||
),
|
||||
),
|
||||
):
|
||||
@@ -198,7 +189,7 @@ class TestMongodbatlasProvider:
|
||||
return_value=MongoDBAtlasIdentityInfo(
|
||||
user_id=USER_ID,
|
||||
username=USERNAME,
|
||||
email=EMAIL,
|
||||
roles=["API_KEY"],
|
||||
),
|
||||
),
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user