Skip to content

Commit

Permalink
sbomnix: misc updates
Browse files Browse the repository at this point in the history
- Update flake.lock
- Remove unneeded graphviz installation github action
- utils.py: minor improvements to version regexps

Signed-off-by: Henri Rosten <[email protected]>
  • Loading branch information
henrirosten committed Jun 29, 2023
1 parent 4229dd0 commit 005010b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/test_sbomnix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

name: GitHub Actions CI
name: Test sbomnix

on:
push:
Expand All @@ -17,11 +17,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ts-graphviz/setup-graphviz@v1
- uses: cachix/install-nix-action@v18
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Test nix-build
- name: Make sure nix-build works
run: nix-build '<nixpkgs>' -A hello
- name: Run tests
run: make test-ci
- name: Run sbomnix CI tests
run: nix develop --command make test-ci
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions sbomnix/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def number_distance(n1, n2):
"""
Return float value between [0.0,1.0] indicating the closeness
of the given two numbers.
Returns 1.0 if the two integers are equal.
Returns 1.0 if the two numbers are equal.
Returns 0.0 if either argument is not a number.
"""
if not isinstance(n1, (float, int)) or not isinstance(n2, (float, int)):
Expand All @@ -161,10 +161,9 @@ def version_distance(v1, v2):
"""
v1 = str(v1)
v2 = str(v2)
re_vclean = re.compile(r"[^0-9.]+")
v1_clean = re_vclean.sub(r"", v1)
v2_clean = re_vclean.sub(r"", v2)
re_vsplit = re.compile(r"(?P<ver_beg>[0-9][0-9]*)(?P<ver_end>.*)$")
v1_clean = re.sub(r"[^0-9.]+", "", v1)
v2_clean = re.sub(r"[^0-9.]+", "", v2)
re_vsplit = re.compile(r".*?(?P<ver_beg>[0-9][0-9]*)(?P<ver_end>.*)$")
match = re.match(re_vsplit, v1_clean)
if not match:
logging.getLogger(LOGGER_NAME).warning("Unexpected v1 version '%s'", v1)
Expand All @@ -188,21 +187,21 @@ def parse_version(ver_str):
Returns None if the version string can not be converted to version object.
"""
ver_str = str(ver_str)
re_ver = re.compile(r"(?P<ver_beg>[0-9][0-9.]*)(?P<ver_end>.*)$")
re_ver = re.compile(r".*?(?P<ver_beg>[0-9][0-9.]*)(?P<ver_end>.*)$")
match = re_ver.match(ver_str)
if not match:
logging.getLogger(LOGGER_NAME).warning("Unable to parse version '%s'", ver_str)
return None
ver_beg = match.group("ver_beg").rstrip(".")
ver_end = match.group("ver_end")
re_vclean = re.compile("[^0-9.]+")
ver_end = re_vclean.sub(r"", ver_end)
ver_end = re.sub(r"[^0-9.]+", "", ver_end)
if ver_end:
ver_end = f"+{ver_end}"
else:
ver_end = ""
ver_end = ver_end.rstrip(".")
ver = f"{ver_beg}{ver_end}"
ver = re.sub(r"\.+", ".", ver)
logging.getLogger(LOGGER_NAME).log(LOG_SPAM, "%s --> %s", ver_str, ver)
if not ver:
logging.getLogger(LOGGER_NAME).warning("Invalid version '%s'", ver_str)
Expand Down
2 changes: 1 addition & 1 deletion scripts/nixupdate/nix_secupdates.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def _vuln_nixpkgs_pr(row):
# Query merged PRs based on pkg name and version in title
prs = _github_query(f"{nixpr} {merged} {pkg} in:title {ver} in:title")
_search_result_append(prs, result)
return " \n".join(list(result))
return " \n".join(sorted(list(result)))


def _report(df_vulns):
Expand Down

0 comments on commit 005010b

Please sign in to comment.