Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ typer==0.15.1
types-cffi==1.16.0.20240331
types-PyMySQL==1.1.0.20241103
types-pyOpenSSL==24.1.0.20240722
types-pytz==2025.2.0.20250326
types-redis==4.6.0.20241004
types-setuptools==75.6.0.20241126
typing_extensions==4.12.2
Expand Down
11 changes: 11 additions & 0 deletions backend/src/xfd_django/xfd_api/helpers/s3_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def __init__(self, is_local=None):
),
)

def get_xpanse_business_units(self):
"""Retrieve CSV File from S3. Returns the file contents (as bytes)."""
bucket_name = os.getenv("XPANSE_ORG_SYNC_BUCKET_NAME")
response = self.s3.list_objects_v2(Bucket=bucket_name)
contents = response.get("Contents", [])
most_recent = max(contents, key=lambda obj: obj["LastModified"])
key = most_recent["Key"]
obj = self.s3.get_object(Bucket=bucket_name, Key=key)
file_contents = obj["Body"].read().decode("utf-8") # This will be bytes
return file_contents

def save_csv(self, body, name=""):
"""Save a CSV file in S3 and returns a temporary URL for access."""
try:
Expand Down
17 changes: 17 additions & 0 deletions backend/src/xfd_django/xfd_api/schema_models/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,21 @@ class GenericMessageResponseModel(BaseModel):
memory="4096",
description="Fetches and stores the latest CISA Known Exploited Vulnerabilities catalog into the Mini Data Lake and flags relevant CVEs.",
),
"xpanse_alert_pull": ScanSchema(
type="fargate",
is_passive=True,
global_scan=False,
cpu="1024",
memory="8192",
description="Pull in Xpanse alert data from Xpanse API",
max_concurrent_tasks=3,
),
"xpanse_org_sync": ScanSchema(
type="fargate",
is_passive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Pull in Xpanse business units and link them to organizations",
),
}
6 changes: 6 additions & 0 deletions backend/src/xfd_django/xfd_api/tasks/ecs_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def run_command(self, command_options):
"AWS_SECRET_ACCESS_KEY": os.getenv("AWS_SECRET_ACCESS_KEY"),
"LG_API_KEY": os.getenv("LG_API_KEY"),
"LG_WORKSPACE_NAME": os.getenv("LG_WORKSPACE_NAME"),
"QUEUE_URL": os.getenv("QUEUE_URL", ""),
"XPANSE_ORG_SYNC_BUCKET_NAME": os.getenv(
"XPANSE_ORG_SYNC_BUCKET_NAME"
),
"XPANSE_API_KEY": os.getenv("XPANSE_API_KEY"),
"XPANSE_AUTH_ID": os.getenv("XPANSE_AUTH_ID"),
"SERVICE_QUEUE_URL": os.getenv("QUEUE_URL", ""),
"DMZ_SYNC_ENDPOINT": os.getenv("DMZ_SYNC_ENDPOINT", ""),
"DMZ_API_KEY": os.getenv("DMZ_API_KEY", ""),
Expand Down
Loading
Loading