Skip to content

Commit

Permalink
Fix PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shabina-metron committed Nov 3, 2023
1 parent 570105e commit 00075f9
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 110 deletions.
24 changes: 3 additions & 21 deletions Packs/Cybereason/Integrations/Cybereason/Cybereason.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from demisto_sdk.commands.generate_yml_from_python.yml_metadata_collector import (
CommandMetadata, ConfKey, InputArgument, YMLMetadataCollector, OutputArgument, ParameterTypes)
from CommonServerPython import BaseClient, CommandResults, datetime

import demistomock as demisto
from CommonServerPython import *

Expand Down Expand Up @@ -160,7 +156,6 @@ def cybereason_api_call(
error_msg = 'Authentication failed, verify the credentials are correct.'
raise ValueError(
f'Failed to process the API response. {str(error_msg)} {str(error_content)} - {str(e)}')
return None

def error_handler(self, res: requests.Response):
# Handle error responses gracefully
Expand Down Expand Up @@ -416,7 +411,6 @@ def query_connections_command(client: Client, args: dict):
outputs_prefix='Cybereason.Connection',
outputs_key_field='Name',
outputs=context)
return None


def query_connections(client: Client, machine: str, ip: str, filter_input: str) -> dict:
Expand Down Expand Up @@ -917,7 +911,6 @@ def kill_process_command(client: Client, args: dict):
action_status, ['Remediation status'])} \n Reason: {dict_safe_get(
action_status, ['Reason'])} \n Remediation ID: {dict_safe_get(action_status, ['Remediation ID'])}'''
raise DemistoException(failure_response)
return None
else:
raise DemistoException('Machine must be connected to Cybereason in order to perform this action.')

Expand All @@ -942,7 +935,6 @@ def quarantine_file_command(client: Client, args: dict):
action_status, ['Remediation status'])} \n Reason: {dict_safe_get(
action_status, ['Reason'])} \n Remediation ID: {dict_safe_get(action_status, ['Remediation ID'])}'''
raise DemistoException(failure_response)
return None
else:
raise DemistoException('Machine must be connected to Cybereason in order to perform this action.')

Expand All @@ -967,7 +959,6 @@ def unquarantine_file_command(client: Client, args: dict):
action_status, ['Remediation status'])} \n Reason: {dict_safe_get(
action_status, ['Reason'])} \n Remediation ID: {dict_safe_get(action_status, ['Remediation ID'])}'''
raise DemistoException(failure_response)
return None
else:
raise DemistoException('Machine must be connected to Cybereason in order to perform this action.')

Expand All @@ -992,7 +983,6 @@ def block_file_command(client: Client, args: dict):
action_status, ['Remediation status'])} \n Reason: {dict_safe_get(
action_status, ['Reason'])} \n Remediation ID: {dict_safe_get(action_status, ['Remediation ID'])}'''
raise DemistoException(failure_response)
return None
else:
raise DemistoException('Machine must be connected to Cybereason in order to perform this action.')

Expand All @@ -1017,7 +1007,6 @@ def delete_registry_key_command(client: Client, args: dict):
action_status, ['Remediation status'])} \n Reason: {dict_safe_get(
action_status, ['Reason'])} \n Remediation ID: {dict_safe_get(action_status, ['Remediation ID'])}'''
raise DemistoException(failure_response)
return None
else:
raise DemistoException('Machine must be connected to Cybereason in order to perform this action.')

Expand All @@ -1042,7 +1031,6 @@ def kill_prevent_unsuspend_command(client: Client, args: dict):
action_status, ['Remediation status'])} \n" Reason: {dict_safe_get(
action_status, ['Reason'])} \n Remediation ID: {dict_safe_get(action_status, ['Remediation ID'])}'''
raise DemistoException(failure_response)
return None
else:
raise DemistoException('Machine must be connected to Cybereason in order to perform this action.')

Expand All @@ -1067,7 +1055,6 @@ def unsuspend_process_command(client: Client, args: dict):
action_status, ['Remediation status'])} \n Reason: {dict_safe_get(
action_status, ['Reason'])} \n Remediation ID: {dict_safe_get(action_status, ['Remediation ID'])}'''
raise DemistoException(failure_response)
return None
else:
raise DemistoException('Machine must be connected to Cybereason in order to perform this action.')

Expand Down Expand Up @@ -1221,7 +1208,6 @@ def query_file_command(client: Client, args: dict) -> Any:
outputs=cybereason_outputs)
else:
raise DemistoException('No results found.')
return None


def query_file(client: Client, filters: list) -> dict:
Expand Down Expand Up @@ -1312,7 +1298,6 @@ def query_domain_command(client: Client, args: dict) -> Any:
outputs=cybereason_outputs)
else:
raise DemistoException('No results found.')
return None


def query_domain(client: Client, filters: list) -> dict:
Expand Down Expand Up @@ -1374,7 +1359,6 @@ def query_user_command(client: Client, args: dict):
outputs=cybereason_outputs)
else:
raise DemistoException('No results found.')
return None


def query_user(client: Client, filters: list) -> dict:
Expand Down Expand Up @@ -1735,7 +1719,6 @@ def start_fetchfile_command(client: Client, args: dict):
return CommandResults(readable_output="Successfully started fetching file for the given malop")
except Exception:
raise Exception("Failed to start fetch file process")
return None


def start_fetchfile(client: Client, element_id: str, user_name: str) -> dict:
Expand Down Expand Up @@ -1838,7 +1821,6 @@ def malware_query_command(client: Client, args: dict):
if limit_range > 0:
filter_response = malware_query_filter(client, needs_attention, malware_type, malware_status, time_stamp, limit_range)
return CommandResults(raw_response=filter_response)
return None
else:
raise DemistoException("Limit cannot be zero or a negative number.")

Expand Down Expand Up @@ -1930,7 +1912,7 @@ def get_sensor_id_command(client: Client, args: dict):
return CommandResults(readable_output=f"Available Sensor IDs are {output}")


def get_machine_sensors_command(client: Client, args: dict):
def fetch_machine_details_command(client: Client, args: dict):
machine_name = str(args.get('machineName'))
json_body = {
"limit": 1000,
Expand All @@ -1942,7 +1924,7 @@ def get_machine_sensors_command(client: Client, args: dict):
else:
outputs = []
for single_sensor in response.get('sensors'):
if single_sensor['machineName'] == machine_name:
if single_sensor.get('machineName') == machine_name:
outputs.append({
"MachineID": single_sensor["sensorId"],
"MachineName": single_sensor["machineName"],
Expand Down Expand Up @@ -2091,7 +2073,7 @@ def main():
return_results(get_sensor_id_command(client, args))

elif demisto.command() == 'cybereason-get-machine-sensors':
return_results(get_machine_sensors_command(client, args))
return_results(fetch_machine_details_command(client, args))

else:
raise NotImplementedError(f'Command {demisto.command()} is not implemented.')
Expand Down
Loading

0 comments on commit 00075f9

Please sign in to comment.