Skip to content

Commit

Permalink
Use proper purl type for Alpine in pipeline, models, and views
Browse files Browse the repository at this point in the history
Signed-off-by: Keshav Priyadarshi <[email protected]>
  • Loading branch information
keshav-space committed Jan 13, 2025
1 parent 389eb91 commit 56a76ea
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 102 deletions.
4 changes: 1 addition & 3 deletions vulnerabilities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
import hashlib
import json
import logging
import typing
from contextlib import suppress
from functools import cached_property
from typing import Optional
from typing import Union

from cwe2.database import Database
Expand Down Expand Up @@ -56,7 +54,7 @@
models.CharField.register_lookup(Trim)

# patch univers for missing entry
RANGE_CLASS_BY_SCHEMES["alpine"] = AlpineLinuxVersionRange
RANGE_CLASS_BY_SCHEMES["apk"] = AlpineLinuxVersionRange


class BaseQuerySet(models.QuerySet):
Expand Down
6 changes: 4 additions & 2 deletions vulnerabilities/pipelines/alpine_linux_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ def load_advisories(
affected_packages.append(
AffectedPackage(
package=PackageURL(
type="alpine",
type="apk",
namespace="alpine",
name=pkg_infos["name"],
qualifiers=qualifiers,
),
Expand All @@ -266,7 +267,8 @@ def load_advisories(
affected_packages.append(
AffectedPackage(
package=PackageURL(
type="alpine",
type="apk",
namespace="alpine",
name=pkg_infos["name"],
qualifiers=qualifiers,
),
Expand Down
112 changes: 56 additions & 56 deletions vulnerabilities/tests/pipelines/test_alpine_linux_importer_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def test_process_record():
affected_packages=[
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={
Expand All @@ -52,8 +52,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "armhf", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -64,8 +64,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "armv7", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -76,8 +76,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={
Expand All @@ -92,8 +92,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "s390x", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -104,8 +104,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "x86", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -116,8 +116,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "x86_64", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -143,8 +143,8 @@ def test_process_record():
affected_packages=[
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={
Expand All @@ -159,8 +159,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "armhf", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -171,8 +171,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "armv7", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -183,8 +183,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={
Expand All @@ -199,8 +199,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "s390x", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -211,8 +211,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "x86", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -223,8 +223,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="xen",
version=None,
qualifiers={"arch": "x86_64", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -250,8 +250,8 @@ def test_process_record():
affected_packages=[
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={
Expand All @@ -266,8 +266,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "armhf", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -278,8 +278,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "armv7", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -290,8 +290,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={
Expand All @@ -306,8 +306,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "s390x", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -318,8 +318,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "x86", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -330,8 +330,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "x86_64", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -351,8 +351,8 @@ def test_process_record():
affected_packages=[
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={
Expand All @@ -367,8 +367,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "armhf", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -379,8 +379,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "armv7", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -391,8 +391,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={
Expand All @@ -407,8 +407,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "s390x", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -419,8 +419,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "x86", "distroversion": "v3.11", "reponame": "main"},
Expand All @@ -431,8 +431,8 @@ def test_process_record():
),
AffectedPackage(
package=PackageURL(
type="alpine",
namespace=None,
type="apk",
namespace="alpine",
name="apk-tools",
version=None,
qualifiers={"arch": "x86_64", "distroversion": "v3.11", "reponame": "main"},
Expand Down
Loading

0 comments on commit 56a76ea

Please sign in to comment.