Skip to content

Commit

Permalink
flatmanager: Extend to catch apps abusing "branch/" to push non-stabl…
Browse files Browse the repository at this point in the history
…e branches
  • Loading branch information
barthalion committed Nov 3, 2023
1 parent 4f52cfc commit fdae27b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions flatpak_builder_lint/checks/flatmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ def check_repo(self, path: str) -> None:
token_type = build_info["token_type"]
target_repo = build_info["repo"]

refs = [
build_ref["ref_name"]
for build_ref in build_extended.get("build_refs", [])
]

if token_type == "app":
refs = [
build_ref["ref_name"]
for build_ref in build_extended.get("build_refs", [])
]
has_app_ref = any(ref.startswith("app/") for ref in refs)
if not has_app_ref:
self.errors.add("flat-manager-no-app-ref-uploaded")
Expand All @@ -65,3 +66,20 @@ def check_repo(self, path: str) -> None:
if ref_branch != target_repo:
self.errors.add("flat-manager-branch-repo-mismatch")
break
else:
appref_list = [ref for ref in refs if ref.startswith("app/")]
if not appref_list:
return

appref = appref_list[0]
_, appid, _, branch = appref.split("/")

if (
not (
appid.split(".")[-1] == "BaseApp"
or appid.startswith("org.freedesktop.Platform.")
or appid == "org.winehq.Wine"
)
and branch != target_repo
):
self.errors.add("flat-manager-branch-repo-mismatch")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "flatpak_builder_lint"
version = "2.0.12"
version = "2.0.13"
description = "A linter for flatpak-builder manifests"
authors = ["Bartłomiej Piotrowski <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit fdae27b

Please sign in to comment.