Skip to content

Commit 84a91ed

Browse files
authored
Merge pull request #3 from fgu-vectra/fgu_br1
Call account API endpoint for get_account_details tool
2 parents df7e65b + b2a5e43 commit 84a91ed

File tree

2 files changed

+64
-12
lines changed

2 files changed

+64
-12
lines changed

tool/entity_tools.py

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,53 @@ async def list_entities(
100100

101101
async def get_account_details(
102102
self,
103-
account_id: Annotated[int, Field(description="ID of the account in Vectra platform to retrieve details for", ge=1)]
103+
account_id: Annotated[int, Field(description="ID of the account in Vectra platform to retrieve details for", ge=1)],
104+
fields: Annotated[
105+
list[str] | None,
106+
Field(description="Fields to return in the results. Available fields: id, url, account_type, assignment, associated_accounts, certainty, data_source, detection_set, detection_summaries, last_detection_timestamp, name, note, note_modified_by, note_modified_timestamp, notes, past_assignments, privilege_category, privilege_level, probable_home, sensors, severity, state, tags, threat")
107+
] = None,
108+
exclude_fields: Annotated[
109+
list[str] | None,
110+
Field(description="Fields to exclude in the response object. Accepts comma-separated list.")
111+
] = None,
112+
include_access_history: Annotated[
113+
bool,
114+
Field(description="Include account access history in the response")
115+
] = False,
116+
include_detection_summaries: Annotated[
117+
bool,
118+
Field(description="Include detection summaries for the detections on the account in the response object.")
119+
] = True,
120+
include_external: Annotated[
121+
bool,
122+
Field(description="Include external data in the response object.")
123+
] = False,
124+
src_linked_account: Annotated[
125+
str | None,
126+
Field(description="Source linked account filter")
127+
] = False
104128
) -> str:
105129
"""
106-
Get complete detailed information about a specific account entity.
130+
Get complete detailed information about a specific account entity. This tool returns account details including detections, scoring information, associated accounts, access history, detection summaries, external data, and more. Response can be customized using various parameters to include or exclude specific fields and related data.
107131
108132
Returns:
109-
str: Formatted string with detailed information about the account entity.
133+
str: JSON string with detailed information about the account. It includes detections, scoring information, associated accounts, access history, detection summaries, external data, and more.
110134
If the account is not found, returns a message indicating that no account was found with the specified ID.
111135
If an error occurs during the request, raises an exception with the error message.
112136
"""
113137
try:
114-
# Fetch account details using the client
115-
account_details = await self.client.get_entity(
116-
entity_id = account_id,
117-
entity_type = "account" # Specify the type as account
138+
# Fetch account details using the v3.4 accounts API endpoint
139+
account_details = await self.client.get_account(
140+
account_id=account_id,
141+
fields=fields,
142+
exclude_fields=exclude_fields,
143+
include_access_history=include_access_history,
144+
include_detection_summaries=include_detection_summaries,
145+
include_external=include_external,
146+
src_linked_account=src_linked_account
118147
)
119-
# Check if the host was found
148+
149+
# Check if the account was found
120150
if 'detail' in account_details and account_details['detail'] == 'Not found.':
121151
return f"No account found with ID: {account_id}."
122152

@@ -223,4 +253,4 @@ async def lookup_host_by_ip(
223253
return f"No hosts found associated with IP address: {host_ip}."
224254

225255
except Exception as e:
226-
raise Exception(f"Failed to fetch host info: {str(e)}")
256+
raise Exception(f"Failed to fetch host info: {str(e)}")

vectra_client.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,31 @@ async def get_accounts(
406406
else:
407407
return await self._make_request("GET", "accounts", params=params)
408408

409-
async def get_account(self, account_id: int) -> Dict[str, Any]:
410-
"""Get specific account by ID."""
411-
return await self._make_request("GET", f"accounts/{account_id}")
409+
async def get_account(
410+
self,
411+
account_id: int,
412+
fields: Optional[List[str]] = None,
413+
exclude_fields: Optional[List[str]] = None,
414+
include_access_history: Optional[bool] = None,
415+
include_detection_summaries: Optional[bool] = None,
416+
include_external: Optional[bool] = None,
417+
src_linked_account: Optional[str] = None
418+
) -> Dict[str, Any]:
419+
"""Get specific account by ID with optional field filtering and additional parameters."""
420+
params = {}
421+
if fields:
422+
params["fields"] = ",".join(fields)
423+
if exclude_fields:
424+
params["exclude_fields"] = ",".join(exclude_fields)
425+
if include_access_history is not None:
426+
params["include_access_history"] = include_access_history
427+
if include_detection_summaries is not None:
428+
params["include_detection_summaries"] = include_detection_summaries
429+
if include_external is not None:
430+
params["include_external"] = include_external
431+
if src_linked_account:
432+
params["src_linked_account"] = src_linked_account
433+
return await self._make_request("GET", f"accounts/{account_id}", params=params)
412434

413435
# Host endpoints
414436
async def get_hosts(

0 commit comments

Comments
 (0)