Skip to content

Commit

Permalink
[pre-commit ruff] Align the entire repo with ruff #2 (demisto#29754)
Browse files Browse the repository at this point in the history
* [pre-commit ruff] Align the entire repo with ruff #2

* Add RN

* Update the docker image
  • Loading branch information
mmhw authored Sep 20, 2023
1 parent 8850430 commit 44352ab
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 85 deletions.
32 changes: 16 additions & 16 deletions Documentation/common_server_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@


def read_json_file(file_path):
with open(file_path, 'r') as f:
with open(file_path) as f:
out = json.load(f)
return out


def read_yml_file(filepath):
with open(filepath, 'r') as f:
with open(filepath) as f:
out = yaml.safe_load(f)
return out

Expand All @@ -63,7 +63,7 @@ def reformat_python_output(output, origin, language):
continue

if a.get("description", "") == "":
logging.error("Description is missing for Python function", a["name"])
logging.error("Description is missing for Python function %s", a["name"])
is_error = True

# format arguments
Expand All @@ -77,7 +77,7 @@ def reformat_python_output(output, origin, language):
arg_info["type"] = arg_info["type_name"]
if arg_info.get("description", "") == "":
is_error = True
logging.info("Missing description for argument", arg_name, "in python function", a["name"])
logging.info("Missing description for argument %s in python function %s", arg_name, a["name"])
del arg_info["type_name"]
z.append(arg_info)

Expand Down Expand Up @@ -105,14 +105,14 @@ def create_js_documentation(path, origin, language):
if (a.get("deprecated", None) is not None) or a.get("name", "") in JS_PRIVATE_FUNCS:
continue

y = dict()
y = {}
y["name"] = a.get("name", "")
if y["name"] == "":
logging.error("Error extracting function name for JS function with the following data:\n", a)
logging.error("Error extracting function name for JS function with the following data:\n%s", a)
is_error = True
y["description"] = a.get("description", "")
if y["description"] == "":
logging.error("Description is missing for JS function", y["name"])
logging.error("Description is missing for JS function %s", y["name"])
is_error = True

for arg in a.get("params", []):
Expand All @@ -123,8 +123,8 @@ def create_js_documentation(path, origin, language):
del arg["optional"]
if arg.get("name", "") == "" or arg.get("description", "") == "":
is_error = True
logging.error("Missing name/description for argument in JS function", y["name"], ".\n Arg name is",
arg.get("name", ""), ", args description is", arg.get("description", ""))
logging.error("Missing name/description for argument in JS function %s.\nArg name is %s, args description is %s",
y["name"], arg.get("name", ""), arg.get("description", ""))
y["arguments"] = a.get("params", [])

returns = a.get("returns", None)[0]
Expand All @@ -144,7 +144,7 @@ def create_js_documentation(path, origin, language):
def create_py_documentation(path, origin, language):
is_error_py = False

with open(path, 'r') as file:
with open(path) as file:
py_script = YmlUnifier.clean_python_code(file.read(), remove_print_future=False)

logging.info("replacing DemistoClassApiModule: ")
Expand All @@ -163,15 +163,15 @@ def create_py_documentation(path, origin, language):

docstring = inspect.getdoc(a_object)
if not docstring:
logging.error("docstring for function {} is empty".format(a))
logging.error(f"docstring for function {a} is empty")
is_error_py = True
elif 'ignore docstring' in docstring:
continue
else:
try:
y = parser.parse_docstring(docstring)
y["name"] = a
logging.info('Processing {}'.format(a))
logging.info(f'Processing {a}')

if inspect.isclass(a_object):
y["argList"] = list(inspect.getfullargspec(a_object.__init__))[0] \
Expand All @@ -187,7 +187,7 @@ def create_py_documentation(path, origin, language):

x.append(y)
except parser.MethodParsingException:
logging.exception('Failed to parse {} class/function'.format(a))
logging.exception(f'Failed to parse {a} class/function')
is_error_py = True

if is_error_py:
Expand All @@ -198,10 +198,10 @@ def create_py_documentation(path, origin, language):
def create_ps_documentation(path, origin, language):
is_error_ps = False

with open(path, 'r') as file:
with open(path) as file:
ps_script = file.read()

function_doc_list = list()
function_doc_list = []
functions_list = re.findall(r'function\s([\w_]*)\s{\s*<#\s*(.*?)#>', ps_script, re.S)

for function in functions_list:
Expand All @@ -217,7 +217,7 @@ def create_ps_documentation(path, origin, language):
description = parameters[0].split('.DESCRIPTION')[1].strip()
if not description:
is_error_ps = True
logging.error("Missing description for PS function {}.\n".format(function_name))
logging.error(f"Missing description for PS function {function_name}.\n")
function_doc['description'] = description

arguments = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def _enrich_analysis_result_with_intelligence(analysis_info, doc_search_client,
client: ACTI Document search contoller client
Returns:
analysis_result enriched with intelligence alert and intelligence report information if available for the indicator
"""
""" # noqa: E501

indicator = analysis_info['MD5'] if indicatorTypeHash else analysis_info['Name']
demisto.debug(f"getting ia for indicator {indicator}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,112 +195,112 @@ script:
description: Unique ID of the specific Malware Family/ Threat Campaign/ Threat Group/ Threat Actor.
outputs:
- contextPath: ACTI_MalwareFamily.display_text
description: The display text of the Malware Family, for example, 'Artemis'
description: The display text of the Malware Family, for example, 'Artemis'.
type: String
- contextPath: ACTI_MalwareFamily.threat_types
description: The threat type of the Malware Family.
type: String
- contextPath: ACTI_MalwareFamily.type
description: The type of fundamental i.e. an Malware Family , for example, 'malware_family'
description: The type of fundamental i.e. an Malware Family , for example, 'malware_family'.
type: String
- contextPath: ACTI_MalwareFamily.last_published
description: The last published date of the Malware Family, for example, '2022-02-11T17:24:03.604Z'
description: The last published date of the Malware Family, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_MalwareFamily.last_modified
description: The last modified date of the Malware Family, for example, '2022-02-11T17:24:03.604Z'
description: The last modified date of the Malware Family, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_MalwareFamily.index_timestamp
description: The index timestamp of the Malware Family, for example, '2022-02-11T17:24:03.604Z'
description: The index timestamp of the Malware Family, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_MalwareFamily.created_on
description: The creation timestamp of the Malware Family, for example, '2020-03-12T22:22:25.000Z'
description: The creation timestamp of the Malware Family, for example, '2020-03-12T22:22:25.000Z'.
type: String
- contextPath: ACTI_MalwareFamily.description
description: The description of the Malware Family
description: The description of the Malware Family.
type: String
- contextPath: ACTI_MalwareFamily.analysis
description: The analysis of the Malware Family
description: The analysis of the Malware Family.
type: String
- contextPath: ACTI_ThreatGroup.display_text
description: The display text of the Threat Group, for example, 'Black Shadow'
description: The display text of the Threat Group, for example, 'Black Shadow'.
type: String
- contextPath: ACTI_ThreatGroup.threat_types
description: The threat type of the Threat Group.
type: String
- contextPath: ACTI_ThreatGroup.type
description: The type of fundamental i.e. an Threat Group, for example, 'threat_group'
description: The type of fundamental i.e. an Threat Group, for example, 'threat_group'.
type: String
- contextPath: ACTI_ThreatGroup.last_published
description: The last published date of the Threat Group, for example, '2022-02-11T17:24:03.604Z'
description: The last published date of the Threat Group, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatGroup.last_modified
description: The last modified date of the Threat Group, for example, '2022-02-11T17:24:03.604Z'
description: The last modified date of the Threat Group, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatGroup.index_timestamp
description: The index timestamp of the Threat Group, for example, '2022-02-11T17:24:03.604Z'
description: The index timestamp of the Threat Group, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatGroup.created_on
description: The creation timestamp of the Threat Group, for example, '2020-03-12T22:22:25.000Z'
description: The creation timestamp of the Threat Group, for example, '2020-03-12T22:22:25.000Z'.
type: String
- contextPath: ACTI_ThreatGroup.description
description: The description of the Threat Group
description: The description of the Threat Group.
type: String
- contextPath: ACTI_ThreatGroup.analysis
description: The analysis of the Threat Group
description: The analysis of the Threat Group.
type: String
- contextPath: ACTI_ThreatActor.display_text
description: The display text of the Threat Actor, for example, 'RastaFarEye'
description: The display text of the Threat Actor, for example, 'RastaFarEye'.
type: String
- contextPath: ACTI_ThreatActor.threat_types
description: The threat type of the Threat Actor.
type: String
- contextPath: ACTI_ThreatActor.type
description: The type of fundamental i.e. an Threat Actor, for example, 'threat_actor'
description: The type of fundamental i.e. an Threat Actor, for example, 'threat_actor'.
type: String
- contextPath: ACTI_ThreatActor.last_published
description: The last published date of the Threat Actor, for example, '2022-02-11T17:24:03.604Z'
description: The last published date of the Threat Actor, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatActor.last_modified
description: The last modified date of the Threat Actor, for example, '2022-02-11T17:24:03.604Z'
description: The last modified date of the Threat Actor, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatActor.index_timestamp
description: The index timestamp of the Threat Actor, for example, '2022-02-11T17:24:03.604Z'
description: The index timestamp of the Threat Actor, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatActor.created_on
description: The creation timestamp of the Threat Actor, for example, '2020-03-12T22:22:25.000Z'
description: The creation timestamp of the Threat Actor, for example, '2020-03-12T22:22:25.000Z'.
type: String
- contextPath: ACTI_ThreatActor.description
description: The description of the Threat Actor
description: The description of the Threat Actor.
type: String
- contextPath: ACTI_ThreatActor.analysis
description: The analysis of the Threat Actor
description: The analysis of the Threat Actor.
type: String
- contextPath: ACTI_ThreatCampaign.display_text
description: The display text of the Threat Campaign, for example, 'FBI Flash CU-000141-MW'
description: The display text of the Threat Campaign, for example, 'FBI Flash CU-000141-MW'.
type: String
- contextPath: ACTI_ThreatCampaign.threat_types
description: The threat type of the Threat Campaign.
type: String
- contextPath: ACTI_ThreatCampaign.type
description: The type of fundamental i.e. an Threat Campaign , for example, 'threat_campaign'
description: The type of fundamental i.e. an Threat Campaign , for example, 'threat_campaign'.
type: String
- contextPath: ACTI_ThreatCampaign.last_published
description: The last published date of the Threat Campaign, for example, '2022-02-11T17:24:03.604Z'
description: The last published date of the Threat Campaign, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatCampaign.last_modified
description: The last modified date of the Threat Campaign, for example, '2022-02-11T17:24:03.604Z'
description: The last modified date of the Threat Campaign, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatCampaign.index_timestamp
description: The index timestamp of the Threat Campaign, for example, '2022-02-11T17:24:03.604Z'
description: The index timestamp of the Threat Campaign, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: ACTI_ThreatCampaign.created_on
description: The creation timestamp of the Threat Campaign, for example, '2020-03-12T22:22:25.000Z'
description: The creation timestamp of the Threat Campaign, for example, '2020-03-12T22:22:25.000Z'.
type: String
- contextPath: ACTI_ThreatCampaign.description
description: The description of the Threat Campaign
description: The description of the Threat Campaign.
type: String
- contextPath: ACTI_ThreatCampaign.analysis
description: The analysis of the Threat Campaign
description: The analysis of the Threat Campaign.
type: String
- contextPath: DBotScore.Indicator
description: The indicator that was tested.
Expand All @@ -326,52 +326,52 @@ script:
required: true
outputs:
- contextPath: IAIR.abstract
description: This field is specific to Intelligence Alert and provides a summarised context, for example, 'The worldwide COVID-19 outbreak...'
description: This field is specific to Intelligence Alert and provides a summarised context, for example, 'The worldwide COVID-19 outbreak...'.
type: String
- contextPath: IAIR.last_published
description: The last published timestamp of the IA/IR, for example, '2020-06-26T01:14:56.000Z'
description: The last published timestamp of the IA/IR, for example, '2020-06-26T01:14:56.000Z'.
type: String
- contextPath: IAIR.index_timestamp
description: The index timestamp of the IA/IR, for example, '2022-02-11T17:24:03.604Z'
description: The index timestamp of the IA/IR, for example, '2022-02-11T17:24:03.604Z'.
type: String
- contextPath: IAIR.display_text
description: The display text of the IA/IR, for example, 'SITREP Cybersecurity Risks Related to COVID-19'
description: The display text of the IA/IR, for example, 'SITREP Cybersecurity Risks Related to COVID-19'.
type: String
- contextPath: IAIR.value
description: The value of the IA/IR, for example, '8b8b48f1-92a0-411a-a073-3241f6819f8b'
description: The value of the IA/IR, for example, '8b8b48f1-92a0-411a-a073-3241f6819f8b'.
type: String
- contextPath: IAIR.last_modified
description: The last modified timestamp of the IA/IR, for example, '2022-02-11T17:21:48.000Z'
description: The last modified timestamp of the IA/IR, for example, '2022-02-11T17:21:48.000Z'.
type: String
- contextPath: IAIR.threat_types
description: The threat type of the IA/IR, for example, '- Hacktivism- Cyber Espionage- Cyber Crime- Vulnerability'. It's formatted in such a way that it gets displayed better.
type: String
- contextPath: IAIR.created_on
description: The creation timestamp of the IA/IR, for example, '2020-03-12T22:22:25.000Z'
description: The creation timestamp of the IA/IR, for example, '2020-03-12T22:22:25.000Z'.
type: String
- contextPath: IAIR.title
description: The title of the IA/IR, for example, 'SITREP Cybersecurity Risks Related to COVID-19'
description: The title of the IA/IR, for example, 'SITREP Cybersecurity Risks Related to COVID-19'.
type: String
- contextPath: IAIR.type
description: The type of report i.e. an IA/IR , for example, 'intelligence_alert'
description: The type of report i.e. an IA/IR , for example, 'intelligence_alert'.
type: String
- contextPath: IAIR.uuid
description: The uuid of the IA/IR, for example, '8b8b48f1-92a0-411a-a073-3241f6819f8b'
description: The uuid of the IA/IR, for example, '8b8b48f1-92a0-411a-a073-3241f6819f8b'.
type: String
- contextPath: IAIR.analysis
description: The analysis of the IA/IR, for example, 'COVID-19 Introduces Cyberthreat Opportunities...'
description: The analysis of the IA/IR, for example, 'COVID-19 Introduces Cyberthreat Opportunities...'.
type: String
- contextPath: IAIR.attachment_links
description: Provides with the document links related to the Intelligence Alert. This field is specific to Intelligence Alert, for example, 'https://intelgraph.idefense.com/rest/files/download/...'
description: Provides with the document links related to the Intelligence Alert. This field is specific to Intelligence Alert, for example, 'https://intelgraph.idefense.com/rest/files/download/...'.
type: String
- contextPath: IAIR.severity
description: Provides severity rating. This field is specific to Intelligence Alert, for example, '4'
description: Provides severity rating. This field is specific to Intelligence Alert, for example, '4'.
type: String
- contextPath: IAIR.mitigation
description: Provides info on how to mitigate. This field is specific to Intelligence Alert, for example, '## Expert, Experienced Advice Will be CriticalTo minimize targeting opportunities...'
description: Provides info on how to mitigate. This field is specific to Intelligence Alert, for example, '## Expert, Experienced Advice Will be CriticalTo minimize targeting opportunities...'.
type: String
- contextPath: IAIR.conclusion
description: Provides conclusion of the report. This field is specific to Intelligence Report
description: Provides conclusion of the report. This field is specific to Intelligence Report.
type: String
- contextPath: IAIR.summary
description: Provides with a summary of the report. This field is specific to Intelligence Report.
Expand Down Expand Up @@ -400,8 +400,7 @@ script:
- contextPath: DBotScore.Score
description: The actual score.
type: String

dockerimage: demisto/python3:3.10.13.72123
dockerimage: demisto/python3:3.10.13.74666
runonce: false
script: '-'
subtype: python3
Expand Down
6 changes: 6 additions & 0 deletions Packs/AccentureCTI/ReleaseNotes/2_2_25.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### ACTI Indicator Query

Updated the Docker image to: *demisto/python3:3.10.13.74666*.
2 changes: 1 addition & 1 deletion Packs/AccentureCTI/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Accenture CTI v2",
"description": "Accenture CTI provides intelligence regarding security threats and vulnerabilities.",
"support": "partner",
"currentVersion": "2.2.24",
"currentVersion": "2.2.25",
"author": "Accenture",
"url": "https://www.accenture.com/us-en/services/security/cyber-defense",
"email": "[email protected]",
Expand Down
Loading

0 comments on commit 44352ab

Please sign in to comment.