Skip to content

Commit

Permalink
Fix Pylint errors in S part 2 packs (#38084)
Browse files Browse the repository at this point in the history
* pylint S2 packs

* docker image update
  • Loading branch information
RotemAmit authored Jan 9, 2025
1 parent 62a456f commit be2ced3
Show file tree
Hide file tree
Showing 29 changed files with 135 additions and 79 deletions.
9 changes: 9 additions & 0 deletions Packs/SumoLogic_Cloud_SIEM/ReleaseNotes/1_1_27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#### Scripts

##### SumoLogicCloseLinkSignalIncidents
- Code functionality improvements.
- Updated the Docker image to: *demisto/python3:3.11.10.116949*.

##### SumoLogicLinkSignalIncidents
- Code functionality improvements.
- Updated the Docker image to: *demisto/python3:3.11.10.116949*.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Linting: https://xsoar.pan.dev/docs/integrations/linting
"""

from typing import Dict, Any
from typing import Any
import traceback


Expand All @@ -18,8 +18,8 @@
''' COMMAND FUNCTION '''


def close_linked_signal_incidents_command(args: Dict[str, Any]) -> CommandResults:
if not ('id' in args):
def close_linked_signal_incidents_command(args: dict[str, Any]) -> CommandResults:
if 'id' not in args:
cur_incident = demisto.incident()
# print(f"Get current incident {cur_incident}")
else:
Expand All @@ -30,9 +30,13 @@ def close_linked_signal_incidents_command(args: Dict[str, Any]) -> CommandResult
cur_incident = None
else:
cur_incident = search_raw[0]['Contents']['data'][0]
result = {}
demisto.debug(f"{search_raw[0]['Contents']['total']=} != 0 -> {result=}")
if cur_incident is not None and cur_incident['rawType'] != 'Sumo Logic Insight':
result = {'message': 'Please run this on a valid Sumo Logic Insight incident only'}
elif cur_incident is not None:
result = {}
demisto.debug(f"Initializing {result=}")
linked_incidents = cur_incident.get('linkedIncidents')
if (linked_incidents):
# print('Current Linked Signal Incidents:', linked_incidents)
Expand All @@ -45,6 +49,9 @@ def close_linked_signal_incidents_command(args: Dict[str, Any]) -> CommandResult
else:
# print('There are no linked Signal Incidents')
result = {'message': 'There are no linked incidents'}
else:
result = {}
demisto.debug(f"cur_incident is None. {result=}")

return CommandResults(
outputs_prefix='BaseScript',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ comment: Close the linked signal incidents when the main Insight incident is clo
commonfields:
id: SumoLogicCloseLinkSignalIncidents
version: -1
dockerimage: demisto/python3:3.11.10.115186
dockerimage: demisto/python3:3.11.10.116949
enabled: true
name: SumoLogicCloseLinkSignalIncidents
runas: DBotWeakRole
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
import traceback
from typing import Any, Dict
from typing import Any


''' STANDALONE FUNCTION '''
Expand All @@ -17,15 +17,17 @@ def find_field_from_labels(labels: list, type_name: str) -> Any:
''' COMMAND FUNCTION '''


def link_incidents_command(args: Dict[str, Any]) -> CommandResults:
def link_incidents_command(args: dict[str, Any]) -> CommandResults:
"""Find and link the Signal incidents to the current Insight incident.
:param args
:return: Result of link action
:rtype: CommandResults
"""
result: dict = {}
demisto.debug(f"Initializing {result=}")

if not ('id' in demisto.args()):
if 'id' not in demisto.args():
cur_incident = demisto.incident()
else:
incident_id = demisto.args()['id']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ comment: "Command to link associated Signal Incidents to the Insight Incident."
commonfields:
id: SumoLogicLinkSignalIncidents
version: -1
dockerimage: demisto/python3:3.11.10.115186
dockerimage: demisto/python3:3.11.10.116949
enabled: true
name: SumoLogicLinkSignalIncidents
runas: DBotWeakRole
Expand Down
2 changes: 1 addition & 1 deletion Packs/SumoLogic_Cloud_SIEM/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Sumo Logic Cloud SIEM",
"description": "Sumo Logic Cloud SIEM provides threat detection and incident response for modern IT environments. This content pack will allow you to apply automation to perform actual SOC analyst workflows. Using this content pack you will be able to fetch Incidents via Insights, update status of an Insight, add items to match list, add Threat Intel Indicators to Threat Intel Sources, and so on.",
"support": "partner",
"currentVersion": "1.1.26",
"currentVersion": "1.1.27",
"author": "Sumo Logic",
"url": "https://www.sumologic.com/solutions/cloud-siem-enterprise/",
"email": "[email protected]",
Expand Down
9 changes: 9 additions & 0 deletions Packs/SuspiciousDomainHunting/ReleaseNotes/1_0_10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#### Scripts

##### RasterizeImageSuspicious
- Code functionality improvements.
- Updated the Docker image to: *demisto/processing-image-file:1.0.0.1858714*.

##### RasterizeImageOriginal
- Code functionality improvements.
- Updated the Docker image to: *demisto/processing-image-file:1.0.0.1858714*.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def main():
server_url_res = demisto.executeCommand("GetServerURL", {})
if server_url_res and len(server_url_res) > 0:
server_url = server_url_res[0].get("Contents")
else:
server_url = ""
demisto.debug(f"{server_url_res=} -> {server_url=}")

link = f"{server_url}/entry/download/{entry_id}" if server_url else None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enabled: true
scripttarget: 0
subtype: python3
runonce: false
dockerimage: demisto/processing-image-file:1.0.0.115372
dockerimage: demisto/processing-image-file:1.0.0.1858714
runas: DBotWeakRole
engineinfo: {}
fromversion: 6.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def main():
server_url_res = demisto.executeCommand("GetServerURL", {})
if server_url_res and len(server_url_res) > 0:
server_url = server_url_res[0].get("Contents")
else:
server_url = ""
demisto.debug(f"{server_url_res=} -> {server_url=}")

link = f"{server_url}/entry/download/{entry_id}" if server_url else None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enabled: true
scripttarget: 0
subtype: python3
runonce: false
dockerimage: demisto/processing-image-file:1.0.0.115372
dockerimage: demisto/processing-image-file:1.0.0.1858714
runas: DBotWeakRole
engineinfo: {}
fromversion: 6.10.0
Expand Down
2 changes: 1 addition & 1 deletion Packs/SuspiciousDomainHunting/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Suspicious Domain Hunting",
"description": "This pack provides all the necessary tools for the Suspicious Domain Hunting use case. It uses the CertStream integration to ingest new SSL certificates and alert for type-squatting domains with SSL certificate, these alerts are then analyzed and mitigated.",
"support": "community",
"currentVersion": "1.0.9",
"currentVersion": "1.0.10",
"author": "Cortex XSOAR",
"url": "https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/bd-p/Cortex_XSOAR_Discussions",
"email": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def do_post(token, is_xml, suffix, body):
url = fix_url(server) + suffix
res = requests.post(url, headers={'Authorization': 'Bearer ' + token}, data=body, verify=not insecure)
res.raise_for_status()
parsed_response = {}
if is_xml:
if res.content:
parsed_response = xml2json(res.content)
Expand Down Expand Up @@ -252,6 +253,7 @@ def get_computer_id_by_hostname(token, hostname):


def get_computer_id(token, endpoint_ip, endpoint_host_name):
computer_id = ""
if endpoint_ip:
try:
computer_id = get_computer_id_by_ip(token, endpoint_ip)
Expand Down Expand Up @@ -496,6 +498,7 @@ def get_location_list(token, group_id):


def get_id_by_endpoint(token, endpoint):
computer_id = ""
if not endpoint:
return_error('Please provide the IP address or the hostname of endpoint.')
elif validate_ip(endpoint):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@ script:
name: pageSize
- description: The name of the group to which the endpoint belongs. A wild card search can be done using '*'at the end of the query.
name: groupName
- description: desiredVersion
- description: desiredVersion.
name: desiredVersion
description: Get endpoints for a running version that is different than the target version or the desired version (if specified).
name: sep-identify-old-clients
runonce: false
script: '-'
type: python
subtype: python3
dockerimage: demisto/python3:3.11.10.116439
dockerimage: demisto/python3:3.11.10.116949
tests:
- SymantecEndpointProtection_Test
fromversion: 5.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def mock_demisto(mocker):

def _get_api_response():
response = "test-data/SEPM-endpoint-api-response.json"
with open(response, 'r') as f:
with open(response) as f:
api_response = json.loads(f.read())
return api_response


def _get_expected_output():
response = "test-data/SEPM-expected-endpoint-extract.json"
with open(response, 'r') as f:
with open(response) as f:
api_response = json.loads(f.read())
return api_response

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

##### Symantec Endpoint Protection v2
- Code functionality improvements.
- Updated the Docker image to: *demisto/python3:3.11.10.116949*.
2 changes: 1 addition & 1 deletion Packs/SymantecEndpointProtection/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Symantec Endpoint Protection",
"description": "Query the Symantec Endpoint Protection Manager using the official REST API.",
"support": "xsoar",
"currentVersion": "1.1.15",
"currentVersion": "1.1.16",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ def login():

soup = BeautifulSoup(login_do_response.text, "lxml")
hidden_tags = soup.find_all("input", type="hidden") # Parse <input type=hidden>
last_login = ""
for tag in hidden_tags:
name = tag.attrs.get('name', None)
if name == 'lastlogin':
last_login = tag.attrs['value']
cookies = {
'JSESSIONID': login_jsession
}
demisto.debug(f"{last_login=}")
data = {
'lastlogin': last_login,
'username': USERNAME,
Expand Down
4 changes: 4 additions & 0 deletions Packs/Symantec_Messaging_Gateway/ReleaseNotes/1_0_19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#### Integrations

##### Symantec Messaging Gateway
Code functionality improvements.
2 changes: 1 addition & 1 deletion Packs/Symantec_Messaging_Gateway/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Symantec Messaging Gateway",
"description": "Symantec Messaging Gateway protects against spam, malware, and targeted attacks and provides advanced content filtering, data loss prevention, and email encryption.",
"support": "xsoar",
"currentVersion": "1.0.18",
"currentVersion": "1.0.19",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
16 changes: 8 additions & 8 deletions Packs/Synapse/Integrations/Synapse/Synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, base_url, username, password, proxy, **kwargs):
self.proxy = proxy
self.auth = (username, password)
self.aio_auth = aiohttp.BasicAuth(username, password)
super(Client, self).__init__(base_url, **kwargs)
super().__init__(base_url, **kwargs)

def _check_for_error(self, resp):
"""
Expand Down Expand Up @@ -164,7 +164,7 @@ async def synapse_get_nodes(self, data, limit=100):
address = urljoin(self._base_url, '/storm')
query = {'query': my_query}
async with sess.get(address, json=query, auth=self.aio_auth) as resp:
async for byts, x in resp.content.iter_chunks():
async for byts, _x in resp.content.iter_chunks():
if not byts:
break
mesg = json.loads(byts)
Expand Down Expand Up @@ -214,13 +214,13 @@ def get_full_tags_helper(data):
"""
tags = []

temp_tags = [t for t in data.keys()]
temp_tags = list(data.keys())
if temp_tags:
tags.append(temp_tags.pop(0))
else:
return tags

for i in range(0, len(temp_tags)):
for _i in range(0, len(temp_tags)):
if temp_tags:
temp = temp_tags.pop(0)
else:
Expand Down Expand Up @@ -258,8 +258,8 @@ def model_query_helper(model, query):
Returns properties for given node type. Raises error not found if not present.
"""
parsed_data = {'query': query}
mod_types = [t for t in model['types'].keys()]
mod_forms = [f for f in model['forms'].keys()]
mod_types = list(model['types'].keys())
mod_forms = list(model['forms'].keys())

if (query not in mod_types) and (query not in mod_forms):
raise Exception(f'Error: Query "{query}" not found in model. Try adjusting syntax (i.e. "inet:ipv4").')
Expand Down Expand Up @@ -613,7 +613,7 @@ def storm_query_command(client, args):

if len(nodes) == 1:
name_single = 'Synapse Node Properties'
headers_single = [h for h in data[0][1]['props'].keys()]
headers_single = list(data[0][1]['props'].keys())
readable_output += tableToMarkdown(name_single, data[0][1]['props'], headers=headers_single, removeNull=False)

results = CommandResults(
Expand Down Expand Up @@ -819,7 +819,7 @@ def query_model_command(client, args):

if full_resp.get('Form'):
name_form = f'Synapse `{full_resp.get("Valu")}` Form Properties'
headers_form = [h for h in q_form['Properties'].keys()]
headers_form = list(q_form['Properties'].keys())
readable_output += tableToMarkdown(name_form, q_form['Properties'], headers=headers_form, removeNull=False)

results = CommandResults(
Expand Down
2 changes: 1 addition & 1 deletion Packs/Synapse/Integrations/Synapse/Synapse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ script:
- contextPath: Synapse.Model.Valu
description: The given value of the Synapse object type.
type: String
dockerimage: demisto/py3-tools:1.0.0.114656
dockerimage: demisto/py3-tools:1.0.0.117220
runonce: false
script: '-'
subtype: python3
Expand Down
5 changes: 2 additions & 3 deletions Packs/Synapse/Integrations/Synapse/Synapse_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import json
import io


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())


def util_load_bytes(path):
with io.open(path, mode='r') as f:
with open(path) as f:
return f.read()


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

##### Synapse
- Code functionality improvements.
- Updated the Docker image to: *demisto/py3-tools:1.0.0.117220*.
2 changes: 1 addition & 1 deletion Packs/Synapse/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Synapse",
"description": "Vertex Synapse intelligence analysis framework.",
"support": "community",
"currentVersion": "1.0.8",
"currentVersion": "1.0.9",
"author": "Jordan Berry",
"url": "",
"email": "",
Expand Down
Loading

0 comments on commit be2ced3

Please sign in to comment.