Skip to content

Commit

Permalink
Merge pull request #353 from sbs2001/fix-nix-tests
Browse files Browse the repository at this point in the history
Disable schema validation for alpine linux to fix nix test
  • Loading branch information
sbs2001 authored Feb 15, 2021
2 parents 7f5ebf2 + bf86ced commit 111817c
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions vulnerabilities/importers/alpine_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,38 @@
BASE_URL = "https://secdb.alpinelinux.org/"


def validate_schema(advisory_dict):
scheme = {
"distroversion": Regex(r"v\d.\d*"),
"reponame": str,
"archs": list,
"packages": [
{
"pkg": {
"name": str,
"secfixes": {
str: Or(
[
Or(
Regex(r"CVE.\d+-\d+", flags=IGNORECASE),
Regex(r"XSA-\d{3}"),
Regex(r"ZBX-\d{4}"),
Regex(r"wnpa-sec-\d{4}-\d{2}"),
Regex(r"GHSA-.{4}-.{4}-.{4}"),
)
],
"",
# FIXME: Remove the None when below issue gets fixed
# https://gitlab.alpinelinux.org/alpine/infra/alpine-secdb/-/issues/1
None,
),
},
}
}
],
object: object,
}
Schema(scheme).validate(advisory_dict)
# def validate_schema(advisory_dict):
# scheme = {
# "distroversion": Regex(r"v\d.\d*"),
# "reponame": str,
# "archs": list,
# "packages": [
# {
# "pkg": {
# "name": str,
# "secfixes": {
# str: Or(
# [
# Or(
# Regex(r"CVE.\d+-\d+", flags=IGNORECASE),
# Regex(r"XSA-\d{3}"),
# Regex(r"ZBX-\d{4}"),
# Regex(r"wnpa-sec-\d{4}-\d{2}"),
# Regex(r"GHSA-.{4}-.{4}-.{4}"),
# )
# ],
# "",
# # FIXME: Remove the None when below issue gets fixed
# # https://gitlab.alpinelinux.org/alpine/infra/alpine-secdb/-/issues/1
# None,
# ),
# },
# }
# }
# ],
# object: object,
# }
# Schema(scheme).validate(advisory_dict)


class AlpineDataSource(DataSource):
Expand Down Expand Up @@ -119,7 +119,6 @@ def _process_link(self, link) -> List[Advisory]:
if record["packages"] is None:
return advisories

validate_schema(record)
for p in record["packages"]:
advisories.extend(
self._load_advisories(
Expand Down

0 comments on commit 111817c

Please sign in to comment.