forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 0
[Internal] SentinelOne v2 3.2.37 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
munna-metron
merged 13 commits into
SentinelOne-V2-3.2.37
from
SentinelOne-V2-3.2.37-internal
Feb 20, 2025
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
792e37b
added list-installed-applications-command
munna-metron d7abc88
added get-service-users-command
munna-metron 6b98e86
Updated the release notes
munna-metron ad1f652
Updated the readme
munna-metron 162a032
pre-commit fix
munna-metron c21d15d
pre-commit fix
munna-metron 117060d
adding section order
munna-metron be5d4d9
Review comment fixes
munna-metron 94dde10
Review comment fixes
munna-metron aea2216
Review comment fixes
munna-metron 76320d6
Review comment fixes
munna-metron 825326f
Review comment fixes
munna-metron 79b96f1
Review comment fixes
munna-metron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1039,6 +1039,14 @@ def get_remote_script_results_request(self, computer_names: list, task_ids: list | |
| response = self._http_request(method='POST', url_suffix=endpoint_url, json_data=payload) | ||
| return response.get("data", {}).get("download_links", []) | ||
|
|
||
| def list_installed_applications_request(self, params: dict): | ||
| response = self._http_request(method='GET', url_suffix='singularity-marketplace/applications', params=params) | ||
| return response.get('data', []), response.get('pagination', {}) | ||
|
|
||
| def get_service_users_request(self, params: dict): | ||
| response = self._http_request(method='GET', url_suffix='service-users', params=params) | ||
| return response.get('data', []), response.get('pagination', {}) | ||
|
|
||
| def remove_empty_fields(self, json_payload): | ||
| """ | ||
| Removes empty fields from a JSON payload and returns a new JSON object with non-empty fields. | ||
|
|
@@ -3433,6 +3441,160 @@ def get_power_query_results(client: Client, args: dict): | |
| return poll_power_query_results(client=client, cmd="sentinelone-get-power-query-results", args=args) | ||
|
|
||
|
|
||
| def list_installed_singu_mark_apps_command(client: Client, args: dict) -> CommandResults: | ||
| """ | ||
| List all installed applications matching the input filter | ||
| """ | ||
| installed_applications = [] | ||
| # Get arguments | ||
| query_params = assign_params( | ||
| accountIds=args.get('account_ids'), | ||
| applicationCatalogId=args.get('application_catalog_id'), | ||
| creator__contains=args.get('creator_contains'), | ||
| id=args.get('id'), | ||
| limit=1000, | ||
| name__contains=args.get('name_contains'), | ||
| siteIds=args.get('site_ids') | ||
| ) | ||
|
|
||
| # Make request and get raw response | ||
| installed_applications_page, pagination = client.list_installed_applications_request(query_params) | ||
| installed_applications.extend(installed_applications_page) | ||
|
|
||
| while pagination and pagination.get("nextCursor"): | ||
| demisto.debug("Got the next page for installed applications \n {}".format(pagination['nextCursor'])) | ||
| query_params['cursor'] = pagination['nextCursor'] | ||
| # The SentinelOne API does not accept other pagination parameters if the cursor is provided in the query. | ||
| # Including additional pagination parameters alongside the cursor will result in a 400 error. | ||
| # So removing the limit from the query params | ||
| if query_params.get('limit'): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just add a comment when we need to remove the limit
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets remove limit and cursor because we will get them everything |
||
| del query_params['limit'] | ||
| installed_applications_page, pagination = client.list_installed_applications_request(query_params) | ||
| installed_applications.extend(installed_applications_page) | ||
|
|
||
| all_scopes = [] | ||
| if installed_applications: | ||
| for each_app in installed_applications: | ||
| scopes = each_app.get("scopes") | ||
| if scopes is not None and len(scopes) > 0: | ||
| for scope in scopes: | ||
| scope["applicationCatalogId"] = each_app["applicationCatalogId"] | ||
| scope["applicationCatalogName"] = each_app["name"] | ||
| all_scopes.append(scope) | ||
| meta = "Provides summary information and details for all the installed applications that matched specified filter values" | ||
| else: | ||
| meta = "The search filters provided are returning no results. Please review and adjust them accordingly." | ||
|
|
||
| context_entries = [] | ||
| for each_scope in all_scopes: | ||
| entry = { | ||
| 'ID': each_scope.get('id'), | ||
| 'Account': each_scope.get('account'), | ||
| 'AccountId': each_scope.get('accountId'), | ||
| 'ApplicationCatalogId': each_scope.get('applicationCatalogId'), | ||
| 'ApplicationCatalogName': each_scope.get('applicationCatalogName'), | ||
| 'AlertMessage': each_scope.get('alertMessage'), | ||
| 'CreatedAt': each_scope.get('createdAt'), | ||
| 'Creator': each_scope.get('creator'), | ||
| 'CreatorId': each_scope.get('creatorId'), | ||
| 'DesiredStatus': each_scope.get('desiredStatus'), | ||
| 'HasAlert': each_scope.get('hasAlert'), | ||
| 'LastEntityCreatedAt': each_scope.get('lastEntityCreatedAt'), | ||
| 'Modifier': each_scope.get('modifier'), | ||
| 'ModifierId': each_scope.get('modifierId'), | ||
| 'ScopeId': each_scope.get('scopeId'), | ||
| 'ScopeLevel': each_scope.get('scopeLevel'), | ||
| 'Status': each_scope.get('status'), | ||
| 'UpdatedAt': each_scope.get('updatedAt'), | ||
| 'ApplicationInstanceName': each_scope.get('applicationInstanceName'), | ||
saurabh-metron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| context_entries.append(entry) | ||
|
|
||
| return CommandResults( | ||
| readable_output=tableToMarkdown( | ||
| 'SentinelOne - List of Installed Applications', | ||
| context_entries, | ||
| headerTransform=pascalToSpace, | ||
| removeNull=True, | ||
| metadata=meta | ||
| ), | ||
| outputs_prefix='SentinelOne.InstalledApps', | ||
| outputs_key_field='ID', | ||
| outputs=context_entries, | ||
| raw_response=installed_applications) | ||
|
|
||
|
|
||
| def get_service_users_command(client: Client, args: dict) -> CommandResults: | ||
| """ | ||
| Get all service users matching the input filter | ||
| """ | ||
| service_users = [] | ||
| # Get arguments | ||
| query_params = assign_params( | ||
saurabh-metron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| accountIds=args.get('account_ids'), | ||
| roleIds=args.get('role_ids'), | ||
| ids=args.get('ids'), | ||
| limit=1000, | ||
| siteIds=args.get('site_ids') | ||
| ) | ||
| # Make request and get raw response | ||
| service_users_page, pagination = client.get_service_users_request(query_params) | ||
| service_users.extend(service_users_page) | ||
| while pagination and pagination.get("nextCursor"): | ||
| demisto.debug("Got the next page for service users \n {}".format(pagination['nextCursor'])) | ||
| query_params['cursor'] = pagination['nextCursor'] | ||
| # The SentinelOne API does not accept other pagination parameters if the cursor is provided in the query. | ||
| # Including additional pagination parameters alongside the cursor will result in a 400 error. | ||
| # So removing the limit from the query params | ||
| if query_params.get('limit'): | ||
| del query_params['limit'] | ||
| service_users_page, pagination = client.get_service_users_request(query_params) | ||
| service_users.extend(service_users_page) | ||
|
|
||
| context_entries = [] | ||
| if service_users: | ||
| for each_service_user in service_users: | ||
| entry = { | ||
| 'ID': each_service_user.get('id'), | ||
| 'ApiTokenCreatedAt': each_service_user.get('apiToken', {}).get('createdAt'), | ||
| 'ApiTokenExpiresAt': each_service_user.get('apiToken', {}).get('expiresAt'), | ||
| 'CreatedAt': each_service_user.get('createdAt'), | ||
| 'CreatedById': each_service_user.get('createdBy', {}).get('id'), | ||
| 'CreatedByName': each_service_user.get('createdBy', {}).get('name'), | ||
| 'Description': each_service_user.get('description'), | ||
| 'LastActivation': each_service_user.get('lastActivation'), | ||
| 'Name': each_service_user.get('name'), | ||
| 'Scope': each_service_user.get('scope'), | ||
| 'UpdatedAt': each_service_user.get('updatedAt'), | ||
| 'UpdatedById': each_service_user.get('updatedBy', {}).get("id"), | ||
| 'UpdatedByName': each_service_user.get('updatedBy', {}).get("name"), | ||
| } | ||
| if each_service_user.get('scopeRoles') and len(each_service_user.get('scopeRoles')) > 0: | ||
| scope_role_items = each_service_user['scopeRoles'][0] | ||
| if scope_role_items: | ||
| entry['ScopeRolesRoleId'] = scope_role_items.get('roleId') | ||
| entry['ScopeRolesRoleName'] = scope_role_items.get('roleName') | ||
| entry['ScopeRolesAccountName'] = scope_role_items.get('accountName') | ||
| entry['ScopeRolesId'] = scope_role_items.get('id') | ||
| context_entries.append(entry) | ||
| meta = "Provides summary information and details for all the service users that matched specified filter values" | ||
| else: | ||
| meta = "The search filters provided are returning no results. Please review and adjust them accordingly." | ||
|
|
||
| return CommandResults( | ||
| readable_output=tableToMarkdown( | ||
| 'SentinelOne - Get Service Users', | ||
| context_entries, | ||
| headerTransform=pascalToSpace, | ||
| removeNull=True, | ||
| metadata=meta | ||
| ), | ||
| outputs_prefix='SentinelOne.ServiceUsers', | ||
| outputs_key_field='ID', | ||
| outputs=context_entries, | ||
| raw_response=service_users) | ||
|
|
||
|
|
||
| def get_mapping_fields_command(): | ||
| """ | ||
| Returns the list of fields to map in outgoing mirroring, for incidents. | ||
|
|
@@ -3872,6 +4034,8 @@ def main(): | |
| 'sentinelone-get-remote-script-task-results': get_remote_script_results, | ||
| 'sentinelone-remote-script-automate-results': remote_script_automate_results, | ||
| 'sentinelone-get-power-query-results': get_power_query_results, | ||
| 'sentinelone-list-installed-singularity-marketplace-applications': list_installed_singu_mark_apps_command, | ||
| 'sentinelone-get-service-users': get_service_users_command, | ||
| }, | ||
| 'commands_with_params': { | ||
| 'get-remote-data': get_remote_data_command, | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.