Skip to content

Commit

Permalink
chore: add verifier skeleton
Browse files Browse the repository at this point in the history
Add a skeleton for the verifier module to allow multiple people to
work on it later.

Signed-off-by: Yftach Herzog <[email protected]>
  • Loading branch information
yftacherzog committed Dec 12, 2023
1 parent 5e9a7c7 commit aab0633
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions verify-rpms/rpm_verifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3

from pathlib import Path
from typing import Callable

import click


def get_rpmdb(container_image: str) -> Path:
raise NotImplementedError()


def get_rpms(rpmdb: Path) -> list[str]:
raise NotImplementedError()


def get_unsigned_rpms(rpms: list[str], verifier: Callable[[str], bool]) -> list[str]:
return [rpm for rpm in rpms if verifier(rpm)]


def is_rpm_unsigned(rpm: str) -> bool:
raise NotImplementedError()


def generate_output(unsigned_rpms: dict[str, list[str]]) -> bool:
raise NotImplementedError()


@click.command()
@click.option(
"--container-image",
help="Reference to container image",
type=str,
multiple=True,
)
def main(container_image: list[str]):
rpms_dbs: dict[str, Path] = {img: get_rpmdb(img) for img in container_image}
rpms_list: dict[str, list[str]] = {
img: get_rpms(rpmdb) for (img, rpmdb) in rpms_dbs.items()
}
unsigned_rpms: dict[str, list[str]] = {
img: get_unsigned_rpms(rpms, is_rpm_unsigned)
for (img, rpms) in rpms_list.items()
}
generate_output(unsigned_rpms)


if __name__ == "__main__":
main() # pylint: disable=no-value-for-parameter

0 comments on commit aab0633

Please sign in to comment.