Skip to content

Commit

Permalink
a pylint (#38093)
Browse files Browse the repository at this point in the history
  • Loading branch information
RotemAmit authored and sdaniel6 committed Jan 27, 2025
1 parent f4effe5 commit 390cc0b
Show file tree
Hide file tree
Showing 29 changed files with 103 additions and 31 deletions.
19 changes: 12 additions & 7 deletions Packs/AHA/Integrations/AHA/AHA.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from CommonServerUserPython import * # noqa

import requests
from typing import Dict
from enum import Enum


Expand Down Expand Up @@ -71,7 +70,7 @@ def get(self,
fields: str,
from_date: str,
page: str,
per_page: str) -> Dict:
per_page: str) -> dict:
"""
Retrieves a list of features/ideas from AHA
Args:
Expand All @@ -93,7 +92,7 @@ def get(self,
url_suffix=f'{self.url}{aha_type.get_url_suffix()}{name}',
headers=headers, params=params, resp_type='json')

def edit(self, aha_object_name: str, aha_type: AHA_TYPE, fields: Dict) -> Dict:
def edit(self, aha_object_name: str, aha_type: AHA_TYPE, fields: dict) -> dict:
"""
Updates fields in a feature/idea from AHA
Args:
Expand All @@ -111,8 +110,8 @@ def edit(self, aha_object_name: str, aha_type: AHA_TYPE, fields: Dict) -> Dict:
''' HELPER FUNCTIONS'''


def build_edit_feature_req_payload(fields: Dict):
payload: Dict = {'feature': {}}
def build_edit_feature_req_payload(fields: dict):
payload: dict = {'feature': {}}
for field in fields:
feature = payload.get('feature', {})
if field == 'status':
Expand All @@ -124,7 +123,7 @@ def build_edit_feature_req_payload(fields: Dict):


def build_edit_idea_req_payload():
payload: Dict = {'idea': {}}
payload: dict = {'idea': {}}
idea = payload.get('idea', {})
idea['workflow_status'] = "Shipped"
return payload
Expand Down Expand Up @@ -201,6 +200,9 @@ def get_command(client: Client,
human_readable = tableToMarkdown(f'Aha! get {aha_type.get_type_plural()}',
message,
removeNull=True)
else:
human_readable = ''
demisto.debug(f"{response=} -> {human_readable=}")
return CommandResults(
outputs_prefix=f'AHA.{aha_type.get_type_for_outputs()}',
outputs_key_field='id',
Expand All @@ -222,6 +224,9 @@ def edit_command(client: Client,
human_readable = tableToMarkdown(f'Aha! edit {aha_type.get_type_singular()}',
message,
removeNull=True)
else:
human_readable = ''
demisto.debug(f"{response=} -> {human_readable=}")
return CommandResults(
outputs_prefix=f'AHA.{aha_type.get_type_for_outputs()}',
outputs_key_field='id',
Expand All @@ -245,7 +250,7 @@ def main() -> None:
verify = not params.get('insecure', False)
demisto.debug(f'Command being called is {demisto.command()}')
try:
headers: Dict = {'Authorization': f'Bearer {api_key}'}
headers: dict = {'Authorization': f'Bearer {api_key}'}
client = Client(
headers=headers,
base_url=base_url,
Expand Down
2 changes: 1 addition & 1 deletion Packs/AHA/Integrations/AHA/AHA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ script:
script: "-"
type: python
subtype: python3
dockerimage: demisto/python3:3.11.10.115186
dockerimage: demisto/python3:3.11.10.116949
fromversion: 6.5.0
tests:
- No tests (auto formatted)
3 changes: 1 addition & 2 deletions Packs/AHA/Integrations/AHA/AHA_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from CommonServerPython import * # noqa: F401
from AHA import Client, get_command, edit_command
from AHA import AHA_TYPE
import io


headers = {
Expand All @@ -27,7 +26,7 @@ def mock_client(mocker, http_request_result=None, throw_error=False):


def util_load_json(path):
with io.open(path, mode='r', encoding='utf-8') as f:
with open(path, encoding='utf-8') as f:
return json.loads(f.read())


Expand Down
5 changes: 5 additions & 0 deletions Packs/AHA/ReleaseNotes/1_0_29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Integrations

##### Aha
- Code functionality improvements.
- Updated the Docker image to: *demisto/python3:3.11.10.116949*.
2 changes: 1 addition & 1 deletion Packs/AHA/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "AHA",
"description": "Use the Aha! integration to edit name/title description and status of features in Aha! according to their status in Jira",
"support": "xsoar",
"currentVersion": "1.0.28",
"currentVersion": "1.0.29",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def __init__(self, input_url: str, api_key: str, verify_certificate: bool, proxy
'auth-token': api_key,
"User-Agent": f"AccentureCTI Pack/{PACK_VERSION} Palo Alto XSOAR/{DEMISTO_VERSION}"
}
super(Client, self).__init__(base_url=base_url,
verify=verify_certificate,
headers=headers,
proxy=proxy)
super().__init__(base_url=base_url,
verify=verify_certificate,
headers=headers,
proxy=proxy)

def threat_indicator_search(self, url_suffix: str, data: dict = {}) -> dict:
return self._http_request(method='GET', url_suffix=url_suffix, params=data)
Expand All @@ -51,9 +51,8 @@ def _validate_args(indicator_type: str, values: list) -> None:
if indicator_type == 'IP':
if not re.match(ipv4Regex, value):
raise DemistoException("Received wrong IP value. Please check values again.")
elif indicator_type == 'URL':
if not re.match(urlRegex, value):
raise DemistoException("Received wrong URL value. Please check values again.")
elif indicator_type == 'URL' and not re.match(urlRegex, value):
raise DemistoException("Received wrong URL value. Please check values again.")


def _calculate_dbot_score(severity: int) -> int:
Expand Down Expand Up @@ -456,6 +455,9 @@ def uuid_command(client: Client, args: dict, reliability: DBotScoreReliability,

analysis_info = _enrich_analysis_result_with_intelligence(analysis_info, doc_search_client)
context = iair_to_context(analysis_info)
else:
context = {}
demisto.debug(f"There is no {res=} -> {context=}")

return CommandResults(indicator=indicator,
outputs=context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ script:
- contextPath: DBotScore.Score
description: The actual score.
type: String
dockerimage: demisto/python3:3.11.10.115186
dockerimage: demisto/python3:3.11.10.116949
runonce: false
script: '-'
subtype: python3
Expand Down
5 changes: 5 additions & 0 deletions Packs/AccentureCTI/ReleaseNotes/2_2_41.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Integrations

##### ACTI Indicator Query
- Code functionality improvements.
- Updated the Docker image to: *demisto/python3:3.11.10.116949*.
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.40",
"currentVersion": "2.2.41",
"author": "Accenture",
"url": "https://www.accenture.com/us-en/services/security/cyber-defense",
"email": "[email protected]",
Expand Down
15 changes: 15 additions & 0 deletions Packs/Akamai_WAF/Integrations/Akamai_WAF/Akamai_WAF.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def update_change(self,
Returns:
Json response as dictionary
"""
payload = ""
if key_algorithm == "RSA":
payload = '{\"certificatesAndTrustChains\":[{\"certificate\":\"' + certificate + '\",' \
' \"keyAlgorithm\":\"RSA\",' \
Expand Down Expand Up @@ -573,6 +574,10 @@ def update_property(self, property_type: str, domain_name: str, property_name: s
}

)
else:
staticRRSets = []
trafficTargets = []
demisto.debug(f"{property_type} -> initialized {staticRRSets=} {trafficTargets=}")

body = {
"balanceByDownloadScore": False,
Expand Down Expand Up @@ -731,6 +736,9 @@ def update_network_list_elements(self, network_list_id: str, elements: Union[lis
Type = raw_response.get('type')

else:
SyncPoint = None
Name = None
Type = None
demisto.results("Could not get the Sync Point...")

body = {
Expand Down Expand Up @@ -3088,6 +3096,7 @@ def update_cps_enrollment_schedule_ec(raw_response: dict) -> tuple[list, list]:
changeId = change.split('/')[6]
else:
changeId = ""
enrollmentId = ""
entry_context.append(assign_params(**{
"id": enrollmentId,
"changeId": changeId,
Expand Down Expand Up @@ -3976,6 +3985,8 @@ def clone_papi_property_command(client: Client,
Returns:
human readable (markdown format), entry context and raw response
"""
title = ""
human_readable_ec: list = []
isExistingOneFound = False
if check_existence_before_create.lower() == "yes":
raw_response: dict = client.list_papi_property_bygroup(contract_id=contract_id, group_id=group_id)
Expand Down Expand Up @@ -4143,6 +4154,8 @@ def new_papi_edgehostname_command(client: Client,
Returns:
human readable (markdown format), entry context and raw response
"""
title = ""
human_readable_ec: list = []
isExistingOneFound = False
if check_existence_before_create.lower() == "yes":
raw_response: dict = client.list_papi_edgehostname_bygroup(contract_id=contract_id,
Expand Down Expand Up @@ -4243,6 +4256,8 @@ def new_papi_cpcode_command(client: Client,
Returns:
human readable (markdown format), entry context and raw response
"""
title = ""
human_readable_ec: list = []
isExistingOneFound = False
if check_existence_before_create.lower() == "yes":
raw_response: dict = client.list_papi_cpcodeid_bygroup(contract_id=contract_id, group_id=group_id)
Expand Down
2 changes: 1 addition & 1 deletion Packs/Akamai_WAF/Integrations/Akamai_WAF/Akamai_WAF.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ script:
- contextPath: Akamai.EdgeDns.ZoneRecordSets
description: A collection of Edge DNS zone's record sets.
type: Dictionary
dockerimage: demisto/auth-utils:1.0.0.115527
dockerimage: demisto/auth-utils:1.0.0.1839651
script: ''
subtype: python3
type: python
Expand Down
5 changes: 5 additions & 0 deletions Packs/Akamai_WAF/ReleaseNotes/2_1_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Integrations

##### Akamai WAF
- Code functionality improvements.
- Updated the Docker image to: *demisto/auth-utils:1.0.0.1839651*.
2 changes: 1 addition & 1 deletion Packs/Akamai_WAF/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Akamai WAF",
"description": "Use the Akamai WAF integration to manage common sets of lists used by various Akamai security products and features.",
"support": "xsoar",
"currentVersion": "2.1.0",
"currentVersion": "2.1.1",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
3 changes: 3 additions & 0 deletions Packs/ArcherRSA/Integrations/ArcherV2/ArcherV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,9 @@ def search_applications_command(client: Client, args: dict[str, str]):
res = client.do_rest_request("GET", endpoint_url)
elif limit:
res = client.do_rest_request("GET", endpoint_url, params={"$top": limit})
else:
res = {}
demisto.debug(f"No condition was met {res=}")

errors = get_errors_from_res(res)
if errors:
Expand Down
2 changes: 1 addition & 1 deletion Packs/ArcherRSA/Integrations/ArcherV2/ArcherV2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ script:
- arguments: []
description: Prints the Archer's integration cache.
name: archer-print-cache
dockerimage: demisto/python3-deb:3.11.10.114849
dockerimage: demisto/python3-deb:3.11.10.117398
isfetch: true
script: ''
subtype: python3
Expand Down
5 changes: 5 additions & 0 deletions Packs/ArcherRSA/ReleaseNotes/1_2_22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Integrations

##### RSA Archer v2
- Code functionality improvements.
- Updated the Docker image to: *demisto/python3-deb:3.11.10.117398*.
2 changes: 1 addition & 1 deletion Packs/ArcherRSA/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "RSA Archer",
"description": "The RSA Archer GRC Platform provides a common foundation for managing policies, controls, risks, assessments and deficiencies across lines of business.",
"support": "xsoar",
"currentVersion": "1.2.21",
"currentVersion": "1.2.22",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ def main(): # pragma: no cover
handle_fetched_events(events, next_run)

if should_return_results:
return_results(events_to_command_results(events=events, event_type=event_type.dataset_name))
return_results(events_to_command_results
(events=events, event_type=event_type.dataset_name)) # pylint: disable=E0606

else:
raise NotImplementedError(f'Command {command} is not implemented')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ script:
script: '-'
type: python
subtype: python3
dockerimage: demisto/python3:3.11.10.115186
dockerimage: demisto/python3:3.11.10.116949
marketplaces:
- marketplacev2
fromversion: 6.10.0
Expand Down
5 changes: 5 additions & 0 deletions Packs/Armis/ReleaseNotes/1_1_19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Integrations

##### Armis Event Collector
- Code functionality improvements.
- Updated the Docker image to: *demisto/python3:3.11.10.116949*.
2 changes: 1 addition & 1 deletion Packs/Armis/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Armis",
"description": "Agentless and passive security platform that sees, identifies, and classifies every device, tracks behavior, identifies threats, and takes action automatically to protect critical information and systems",
"support": "partner",
"currentVersion": "1.1.18",
"currentVersion": "1.1.19",
"author": "Armis Corporation",
"url": "https://support.armis.com/",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,14 @@ def run_search_job_command(args: dict[str, Any], client: Client) -> PollResult:
if argToBoolean(args["first_run"]):
if start_search_time_datetime := arg_to_datetime(args.get('start_search_time', '1 day ago'), "start_search_time"):
start_search_time_iso = start_search_time_datetime.isoformat()
else:
start_search_time_iso = None
demisto.debug(f"{start_search_time_datetime=} -> {start_search_time_iso=}")
if end_search_time_datetime := arg_to_datetime(args.get('end_search_time', 'now'), "end_search_time"):
end_search_time_iso = end_search_time_datetime.isoformat()
else:
end_search_time_iso = None
demisto.debug(f"{end_search_time_datetime=} -> {end_search_time_iso=}")
url_suffix = f"/tables/{table_name}"
data = {
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ script:
name: workspace_name
description: Delete a Log Analytics workspace table. We recommend you delete the search job when you're done querying the table. This reduces workspace clutter and extra charges for data retention.
name: azure-log-analytics-delete-search-job
dockerimage: demisto/crypto:1.0.0.114611
dockerimage: demisto/crypto:1.0.0.117163
runonce: false
script: '-'
subtype: python3
Expand Down
5 changes: 5 additions & 0 deletions Packs/AzureLogAnalytics/ReleaseNotes/1_1_42.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Integrations

##### Azure Log Analytics
- Code functionality improvements.
- Updated the Docker image to: *demisto/crypto:1.0.0.117163*.
2 changes: 1 addition & 1 deletion Packs/AzureLogAnalytics/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Azure Log Analytics",
"description": "Log Analytics is a service that helps you collect and analyze data generated by resources in your cloud and on-premises environments.",
"support": "xsoar",
"currentVersion": "1.1.41",
"currentVersion": "1.1.42",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,19 @@ def risky_users_list_command(client: Client, args: dict[str, str]) -> List[Comma
fmt_updated_before = dateparser.parse(str(args.get('updated_before')), settings={'TIMEZONE': 'UTC'})
if fmt_updated_before is not None:
updated_before = datetime.strftime(fmt_updated_before, '%Y-%m-%dT%H:%M:%S.%f') + '0Z'
else:
updated_before = None
demisto.debug(f"{fmt_updated_before=} -> {updated_before}")
else:
updated_before = None

if args.get('updated_after'):
fmt_updated_after = dateparser.parse(str(args.get('updated_after')), settings={'TIMEZONE': 'UTC'})
if fmt_updated_after is not None:
updated_after = datetime.strftime(fmt_updated_after, '%Y-%m-%dT%H:%M:%S.%f') + '0Z'
else:
updated_after = None
demisto.debug(f"{fmt_updated_after=} -> {updated_after=}")
else:
updated_after = None

Expand Down
Loading

0 comments on commit 390cc0b

Please sign in to comment.