Skip to content

Commit

Permalink
Apply ruff formatter
Browse files Browse the repository at this point in the history
Signed-off-by: Henri Rosten <[email protected]>
  • Loading branch information
henrirosten committed Jan 5, 2025
1 parent 5a324c7 commit 562dc5c
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 55 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# pylint: disable=missing-function-docstring

""" setup.py for setuptools """
"""setup.py for setuptools"""

import os.path

Expand Down
2 changes: 1 addition & 1 deletion src/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# pylint: disable=abstract-method

""" sbomnix utils """
"""sbomnix utils"""

import argparse
import csv
Expand Down
12 changes: 9 additions & 3 deletions src/nixgraph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pylint: disable=too-few-public-methods
# pylint: disable=too-many-instance-attributes

""" Python script to query and visualize nix package dependencies """
"""Python script to query and visualize nix package dependencies"""

import html
import logging
Expand All @@ -19,8 +19,14 @@
import graphviz as gv
import pandas as pd

from common.utils import (LOG, LOG_SPAM, df_regex_filter, df_to_csv_file,
exec_cmd, regex_match)
from common.utils import (
LOG,
LOG_SPAM,
df_regex_filter,
df_to_csv_file,
exec_cmd,
regex_match,
)
from sbomnix.nix import find_deriver

###############################################################################
Expand Down
12 changes: 8 additions & 4 deletions src/nixgraph/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
#
# SPDX-License-Identifier: Apache-2.0

""" Python script to query and visualize nix package dependencies """
"""Python script to query and visualize nix package dependencies"""

import argparse
import pathlib

from common.utils import (check_positive, exit_unless_nix_artifact,
get_py_pkg_version, set_log_verbosity,
try_resolve_flakeref)
from common.utils import (
check_positive,
exit_unless_nix_artifact,
get_py_pkg_version,
set_log_verbosity,
try_resolve_flakeref,
)
from nixgraph.graph import NixDependencies

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/nixmeta/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
# SPDX-License-Identifier: Apache-2.0

""" Python script for summarizing nixpkgs meta-attributes """
"""Python script for summarizing nixpkgs meta-attributes"""

import argparse
import pathlib
Expand Down
3 changes: 1 addition & 2 deletions src/nixmeta/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

import pandas as pd

from common.utils import (LOG, LOG_SPAM, df_from_csv_file, df_to_csv_file,
exec_cmd)
from common.utils import LOG, LOG_SPAM, df_from_csv_file, df_to_csv_file, exec_cmd

###############################################################################

Expand Down
18 changes: 13 additions & 5 deletions src/nixupdate/nix_outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

""" Command-line tool to list outdated nix dependencies in priority order"""
"""Command-line tool to list outdated nix dependencies in priority order"""

import logging
import os
Expand All @@ -15,10 +15,18 @@
from tabulate import tabulate

import repology.repology_cli
from common.utils import (LOG, LOG_SPAM, df_from_csv_file, df_log,
df_to_csv_file, exec_cmd, exit_unless_nix_artifact,
nix_to_repology_pkg_name, set_log_verbosity,
try_resolve_flakeref)
from common.utils import (
LOG,
LOG_SPAM,
df_from_csv_file,
df_log,
df_to_csv_file,
exec_cmd,
exit_unless_nix_artifact,
nix_to_repology_pkg_name,
set_log_verbosity,
try_resolve_flakeref,
)
from sbomnix.sbomdb import SbomDb

###############################################################################
Expand Down
15 changes: 11 additions & 4 deletions src/repology/repology_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pylint: disable=too-few-public-methods, too-many-statements
# pylint: disable=too-many-instance-attributes, too-many-locals

""" Command-line interface to repology.org """
"""Command-line interface to repology.org"""

import json
import os
Expand All @@ -22,9 +22,16 @@
from tabulate import tabulate

import repology.exceptions
from common.utils import (LOG, LOG_SPAM, CachedLimiterSession, df_regex_filter,
df_to_csv_file, nix_to_repology_pkg_name,
parse_version, set_log_verbosity)
from common.utils import (
LOG,
LOG_SPAM,
CachedLimiterSession,
df_regex_filter,
df_to_csv_file,
nix_to_repology_pkg_name,
parse_version,
set_log_verbosity,
)

###############################################################################

Expand Down
12 changes: 9 additions & 3 deletions src/repology/repology_cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# pylint: disable=too-many-locals

""" Command-line interface to query CVE info from repology.org """
"""Command-line interface to query CVE info from repology.org"""

import os
import re
Expand All @@ -20,8 +20,14 @@
from tabulate import tabulate

import repology.exceptions
from common.utils import (LOG, LOG_SPAM, CachedLimiterSession, df_to_csv_file,
parse_version, set_log_verbosity)
from common.utils import (
LOG,
LOG_SPAM,
CachedLimiterSession,
df_to_csv_file,
parse_version,
set_log_verbosity,
)

###############################################################################

Expand Down
2 changes: 1 addition & 1 deletion src/sbomnix/cdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

""" CycloneDX utils """
"""CycloneDX utils"""

import re

Expand Down
2 changes: 1 addition & 1 deletion src/sbomnix/derivation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pylint: disable=invalid-name, eval-used
# pylint: disable=too-many-instance-attributes

""" Nix derivation, originally from https://github.com/flyingcircusio/vulnix """
"""Nix derivation, originally from https://github.com/flyingcircusio/vulnix"""

import bisect
import json
Expand Down
1 change: 0 additions & 1 deletion src/sbomnix/dfcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self):
self.dflock = FileLock(DFCACHE_LOCK)

def __getattr__(self, name):

def wrap(*a, **k):
with self.dflock:
# We intentionally do not store the dfcache as object variable
Expand Down
12 changes: 8 additions & 4 deletions src/sbomnix/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
#
# SPDX-License-Identifier: Apache-2.0

""" Python script that generates SBOMs from nix packages """
"""Python script that generates SBOMs from nix packages"""

import argparse
import pathlib

from common.utils import (check_positive, exit_unless_nix_artifact,
get_py_pkg_version, set_log_verbosity,
try_resolve_flakeref)
from common.utils import (
check_positive,
exit_unless_nix_artifact,
get_py_pkg_version,
set_log_verbosity,
try_resolve_flakeref,
)
from sbomnix.sbomdb import SbomDb

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/sbomnix/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# SPDX-FileCopyrightText: 2022-2023 Technology Innovation Institute (TII)

""" Nix store, originally from https://github.com/flyingcircusio/vulnix """
"""Nix store, originally from https://github.com/flyingcircusio/vulnix"""

import json
import os
Expand Down
5 changes: 2 additions & 3 deletions src/sbomnix/sbomdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pylint: disable=too-many-instance-attributes, too-many-arguments
# pylint: disable=too-many-locals, too-many-statements

""" Module for generating SBOMs in various formats """
"""Module for generating SBOMs in various formats"""

import argparse
import json
Expand All @@ -23,8 +23,7 @@

from common.utils import LOG, df_to_csv_file, get_py_pkg_version
from nixgraph.graph import NixDependencies
from sbomnix.cdx import (_drv_to_cdx_component, _drv_to_cdx_dependency,
_vuln_to_cdx_vuln)
from sbomnix.cdx import _drv_to_cdx_component, _drv_to_cdx_dependency, _vuln_to_cdx_vuln
from sbomnix.meta import Meta
from sbomnix.nix import Store, find_deriver
from vulnxscan.vulnscan import VulnScan
Expand Down
2 changes: 1 addition & 1 deletion src/vulnxscan/osv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

""" Demonstrate querying OSV db for vulnerabilities based on cdx SBOM """
"""Demonstrate querying OSV db for vulnerabilities based on cdx SBOM"""

import argparse
import json
Expand Down
13 changes: 9 additions & 4 deletions src/vulnxscan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@
Utility functions
"""


import json
import re
import time
import urllib.parse

import pandas as pd

from common.utils import (LOG, LOG_SPAM, CachedLimiterSession, df_log,
nix_to_repology_pkg_name, parse_version,
version_distance)
from common.utils import (
LOG,
LOG_SPAM,
CachedLimiterSession,
df_log,
nix_to_repology_pkg_name,
parse_version,
version_distance,
)
from repology.exceptions import RepologyNoMatchingPackages
from repology.repology_cli import Repology
from repology.repology_cli import getargs as cli_getargs
Expand Down
15 changes: 9 additions & 6 deletions src/vulnxscan/vulnscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
import pandas as pd
from tabulate import tabulate

from common.utils import (LOG, LOG_SPAM, df_from_csv_file, df_to_csv_file,
exec_cmd)
from common.utils import LOG, LOG_SPAM, df_from_csv_file, df_to_csv_file, exec_cmd
from vulnxscan.osv import OSV
from vulnxscan.utils import (_is_patched, _reformat_scanner, _triage,
_vuln_sortcol, _vuln_url)
from vulnxscan.whitelist import (df_apply_whitelist, df_drop_whitelisted,
load_whitelist)
from vulnxscan.utils import (
_is_patched,
_reformat_scanner,
_triage,
_vuln_sortcol,
_vuln_url,
)
from vulnxscan.whitelist import df_apply_whitelist, df_drop_whitelisted, load_whitelist


class VulnScan:
Expand Down
11 changes: 7 additions & 4 deletions src/vulnxscan/vulnxscan_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
open-source vulnerability scanners.
"""


import argparse
import logging
import pathlib
import sys
from tempfile import NamedTemporaryFile

from common.utils import (LOG, exit_unless_command_exists,
exit_unless_nix_artifact, set_log_verbosity,
try_resolve_flakeref)
from common.utils import (
LOG,
exit_unless_command_exists,
exit_unless_nix_artifact,
set_log_verbosity,
try_resolve_flakeref,
)
from sbomnix.sbomdb import SbomDb
from vulnxscan.utils import _is_json
from vulnxscan.vulnscan import VulnScan
Expand Down
1 change: 0 additions & 1 deletion src/vulnxscan/whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

# Whitelist


import sys

from common.utils import LOG, LOG_SPAM, df_from_csv_file, df_log
Expand Down
12 changes: 9 additions & 3 deletions tests/compare_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# pylint: disable=too-many-locals

""" Python script that compares dependencies between sbomnix and nixgraph """
"""Python script that compares dependencies between sbomnix and nixgraph"""

import argparse
import json
Expand All @@ -17,8 +17,14 @@

import pandas as pd

from common.utils import (LOG, LOG_SPAM, df_from_csv_file, df_to_csv_file,
regex_match, set_log_verbosity)
from common.utils import (
LOG,
LOG_SPAM,
df_from_csv_file,
df_to_csv_file,
regex_match,
set_log_verbosity,
)

###############################################################################

Expand Down
2 changes: 1 addition & 1 deletion tests/compare_sboms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

""" Python script that compares two sboms """
"""Python script that compares two sboms"""

import argparse
import json
Expand Down

0 comments on commit 562dc5c

Please sign in to comment.