Skip to content

Commit

Permalink
pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
isimluk committed Nov 25, 2022
1 parent 93be3d3 commit 21a5b63
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 37 deletions.
62 changes: 32 additions & 30 deletions fig/backends/azure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,38 @@ def __init__(self, event):
self.azure_arc_config = self.autodiscovery()

def autodiscovery(self):
if self.event.cloud_provider != 'AZURE' and config.getboolean('azure', 'arc_autodiscovery'):
if self.event.device_details['platform_name'] != 'Linux':
log.debug('Skipping Azure Arc Autodiscovery for %s (aid=%s, name=%s)',
self.event.device_details['platform_name'],
self.event.original_event.sensor_id,
self.event.original_event.computer_name
)
return
if self.event.device_details['product_type_desc'] == 'Pod':
log.debug('Skipping Azure Arc Autodiscovery for k8s pod (aid=%s, name=%s)',
self.event.original_event.sensor_id,
self.event.original_event.computer_name
)
return

try:
azure_arc_config = self.event.azure_arc_config()
except RTRConnectionError as e:
log.error("Cannot fetch Azure Arc info from host (aid=%s, hostname=%s, last_seen=%s): %s",
self.event.original_event.sensor_id,
self.event.device_details['hostname'],
self.event.device_details['last_seen'],
e
)
return

return {k: v
for k, v in azure_arc_config.items()
if k in self.AZURE_ARC_KEYS
}
if self.event.cloud_provider == 'AZURE' or not config.getboolean('azure', 'arc_autodiscovery'):
return None

if self.event.device_details['platform_name'] != 'Linux':
log.debug('Skipping Azure Arc Autodiscovery for %s (aid=%s, name=%s)',
self.event.device_details['platform_name'],
self.event.original_event.sensor_id,
self.event.original_event.computer_name
)
return None
if self.event.device_details['product_type_desc'] == 'Pod':
log.debug('Skipping Azure Arc Autodiscovery for k8s pod (aid=%s, name=%s)',
self.event.original_event.sensor_id,
self.event.original_event.computer_name
)
return None

try:
azure_arc_config = self.event.azure_arc_config()
except RTRConnectionError as e:
log.error("Cannot fetch Azure Arc info from host (aid=%s, hostname=%s, last_seen=%s): %s",
self.event.original_event.sensor_id,
self.event.device_details['hostname'],
self.event.device_details['last_seen'],
e
)
return

return {k: v
for k, v in azure_arc_config.items()
if k in self.AZURE_ARC_KEYS
}

def submit(self):
log.info("Processing detection: %s", self.event.detect_description)
Expand Down
9 changes: 5 additions & 4 deletions fig/falcon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,18 @@ def rtr_fetch_file(self, device_id, filepath):
finally:
session.close()

import io
import py7zr
import io # pylint: disable=C0415
import py7zr # pylint: disable=C0415

flo = io.BytesIO(z7pack)
with py7zr.SevenZipFile(flo, password='infected') as zip:
content = zip.readall()
with py7zr.SevenZipFile(flo, password='infected') as archive:
content = archive.readall()
if len(content) != 1:
raise ApiError('Cannot extract RTR file from 7z')

for _fname, bio in content.items():
return bio.read()
raise ApiError(f'Cannot extract file {filepath} from device {device_id}')

def _resources(self, *args, **kwargs):
response = self._command(*args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions fig/falcon/rtr.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _list_files(self):
parameters={
'session_id': self.id
}
)
) # pylint: disable=W0212

def _fetch_file(self, sha256, filepath):
response = self.falcon.client.command(
Expand All @@ -69,7 +69,7 @@ def _connect(self):
try:
response = self.falcon.init_rtr_session(self.device_id)
except ApiError as e:
raise RTRConnectionError(f"{e}")
raise RTRConnectionError from e

if len(response) != 1:
raise RTRError(f'Unexpected response from RTR Init: {response}')
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ignore = C901,E501

[pylint.MASTER]
disable=
C0114,C0115,C0116,C0209,
C0114,C0115,C0116,C0209,C0103,
R0903,R0912,R0915,
W0511,W0613,C0301

Expand Down

0 comments on commit 21a5b63

Please sign in to comment.