Skip to content

Commit

Permalink
Merge pull request #52 from sgallagher/validate
Browse files Browse the repository at this point in the history
Add more validation for content resolver input
  • Loading branch information
tdawson authored Sep 5, 2023
2 parents 6792d19 + df0a37e commit 28b72ed
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
setup_and_test:
runs-on: ubuntu-latest
container:
image: registry.fedoraproject.org/fedora:37
image: registry.fedoraproject.org/fedora:38
steps:

- name: Checkout code
Expand Down
56 changes: 56 additions & 0 deletions feedback_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,25 @@ def _load_config_workload(document_id, document, settings):

# Step 1: Mandatory fields
try:
if "data" not in document:
raise ConfigError(f"Missing 'data' field in {document_id}")

for key in document["data"]:
if key not in [
"arch_packages",
"description",
"groups",
"labels",
"maintainer",
"modules_disable",
"modules_enabled",
"name",
"options",
"package_placeholders",
"packages",
]:
raise ConfigError(f"Unknown key '{key}' in 'data' section of {document_id}")

# Name is an identifier for humans
config["name"] = str(document["data"]["name"])

Expand Down Expand Up @@ -711,6 +730,21 @@ def _load_config_unwanted(document_id, document, settings):

# Step 1: Mandatory fields
try:
if "data" not in document:
raise ConfigError(f"Missing 'data' field in {document_id}")

for key in document["data"]:
if key not in [
"description",
"labels",
"maintainer",
"name",
"unwanted_arch_packages",
"unwanted_arch_source_packages",
"unwanted_packages",
"unwanted_source_packages",
]:
raise ConfigError(f"Unknown key '{key}' in 'data' section of {document_id}")
# Name is an identifier for humans
config["name"] = str(document["data"]["name"])

Expand Down Expand Up @@ -921,6 +955,28 @@ def get_configs(settings):


# === Case: Repository config ===
if document["document"] not in [
"content-resolver-buildroot",
"content-resolver-compose-view",
"content-resolver-environment",
"content-resolver-label",
"content-resolver-repository",
"content-resolver-unwanted",
"content-resolver-view",
"content-resolver-view-addon",
"content-resolver-workload",
"feedback-pipeline-buildroot",
"feedback-pipeline-compose-view",
"feedback-pipeline-environment",
"feedback-pipeline-label",
"feedback-pipeline-repository",
"feedback-pipeline-unwanted",
"feedback-pipeline-view",
"feedback-pipeline-view-addon",
"feedback-pipeline-workload",
]:
raise ConfigError(f"Unknown document type: {document['document']}")

if document["document"] in ["content-resolver-repository", "feedback-pipeline-repository"]:
if document["version"] == 1:
configs["repos"][document_id] = _load_config_repo(document_id, document, settings)
Expand Down
Empty file modified test_config_files.py
100644 → 100755
Empty file.
3 changes: 0 additions & 3 deletions test_configs/repo-rawhide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ data:

everything:
baseurl: https://kojipkgs.fedoraproject.org/compose/rawhide/latest-Fedora-Rawhide/compose/Everything/$basearch/os/

modular:
baseurl: https://kojipkgs.fedoraproject.org/compose/rawhide/latest-Fedora-Rawhide/compose/Modular/$basearch/os/

releasever: "rawhide"

Expand Down

0 comments on commit 28b72ed

Please sign in to comment.