Skip to content

Commit

Permalink
fix pylint issues + refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Feb 25, 2021
1 parent 53481e5 commit 7757cf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/plugins/analysis/cve_lookup/internal/data_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def get_cve_links(url: str, selected_years: Optional[List[int]] = None) -> List[
def process_url(download_url: str, path: str):
try:
request = _retrieve_url(download_url)
except requests.exceptions.RequestException:
raise CveLookupException(f'URL {download_url} not found. URL might have changed.')
except RequestException as exception:
raise CveLookupException(f'URL {download_url} not found. URL might have changed.') from exception

zipped_data = ZipFile(BytesIO(request.content))
zipped_data.extractall(path)
Expand Down Expand Up @@ -80,8 +80,8 @@ def extract_cve_impact(entry: dict) -> dict:
return {}
impact = {}
for version in [2, 3]:
metric_key = 'baseMetricV{}'.format(version)
cvss_key = 'cvssV{}'.format(version)
metric_key = f'baseMetricV{version}'
cvss_key = f'cvssV{version}'
if metric_key in entry and cvss_key in entry[metric_key]:
impact[cvss_key] = entry[metric_key][cvss_key]['baseScore']
return impact
Expand All @@ -108,8 +108,8 @@ def extract_cve(cve_file: str) -> Tuple[List[CveEntry], List[CveSummaryEntry]]:
def extract_cpe(file: str) -> list:
try:
tree = parse(file)
except ParseError:
raise CveLookupException('could not extract CPE file: {}'.format(file))
except ParseError as error:
raise CveLookupException(f'could not extract CPE file: {file}') from error
return [
item.attrib['name']
for entry in tree.getroot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def cve_was_chosen(self):
return self.value in [self.cve.value, self.both.value]

def __str__(self):
return self.value
return str(self.value)


def update_repository(extraction_path: str, choice: Choice):
Expand Down

0 comments on commit 7757cf1

Please sign in to comment.