This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new 5c64f83d Use the full classifier during checks
5c64f83d is described below

commit 5c64f83dd83ece0779deeacbc02bb579d2e4c07c
Author: Sean B. Palmer <[email protected]>
AuthorDate: Sun Mar 15 18:25:12 2026 +0000

    Use the full classifier during checks
---
 atr/classify.py               |  3 +++
 atr/tasks/checks/__init__.py  | 32 ++++++++++++++++++++------------
 tests/e2e/compose/test_get.py | 20 +++++++++-----------
 3 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/atr/classify.py b/atr/classify.py
index 68b33674..9e57dac3 100644
--- a/atr/classify.py
+++ b/atr/classify.py
@@ -22,6 +22,7 @@ from collections.abc import Callable
 from typing import Final
 
 import atr.analysis as analysis
+import atr.detection as detection
 import atr.util as util
 
 _BINARY_STEM: Final[re.Pattern[str]] = 
re.compile(r"[-_](binary-assembly|binary|bin)(?=[-_]|$)")
@@ -64,6 +65,8 @@ def classify(
             return FileType.SOURCE
         if _BINARY_STEM.search(stem):
             return FileType.BINARY
+        if any(path_str.endswith(suffix) for suffix in 
detection.QUARANTINE_ARCHIVE_SUFFIXES):
+            return FileType.SOURCE
 
     return FileType.BINARY
 
diff --git a/atr/tasks/checks/__init__.py b/atr/tasks/checks/__init__.py
index 842eca10..16f1bb8c 100644
--- a/atr/tasks/checks/__init__.py
+++ b/atr/tasks/checks/__init__.py
@@ -21,6 +21,7 @@ import dataclasses
 import datetime
 import functools
 import json
+import pathlib
 from typing import TYPE_CHECKING, Any, Final
 
 import aiofiles
@@ -29,12 +30,12 @@ import pydantic
 import sqlmodel
 
 if TYPE_CHECKING:
-    import pathlib
     from collections.abc import Awaitable, Callable
 
     import atr.models.schema as schema
 
 import atr.attestable as attestable
+import atr.classify as classify
 import atr.db as db
 import atr.hashes as hashes
 import atr.log as log
@@ -193,22 +194,29 @@ class Recorder:
     async def primary_path_is_binary(self) -> bool:
         if self.primary_rel_path is None:
             return False
-        project = await self.project()
-        if not project.policy_binary_artifact_paths:
-            return False
-        matches = 
util.create_path_matcher(project.policy_binary_artifact_paths, None, 
self.abs_path_base())
-        abs_path = await self.abs_path()
-        return matches(str(abs_path))
+        return (await self._classify_primary_path()) == 
classify.FileType.BINARY
 
     async def primary_path_is_source(self) -> bool:
         if self.primary_rel_path is None:
             return False
+        return (await self._classify_primary_path()) == 
classify.FileType.SOURCE
+
+    async def _classify_primary_path(self) -> classify.FileType:
+        if self.primary_rel_path is None:
+            return classify.FileType.BINARY
         project = await self.project()
-        if not project.policy_source_artifact_paths:
-            return False
-        matches = 
util.create_path_matcher(project.policy_source_artifact_paths, None, 
self.abs_path_base())
-        abs_path = await self.abs_path()
-        return matches(str(abs_path))
+        base_path = self.abs_path_base()
+        source_matcher, binary_matcher = classify.matchers_from_policy(
+            project.policy_source_artifact_paths,
+            project.policy_binary_artifact_paths,
+            base_path,
+        )
+        return classify.classify(
+            pathlib.Path(self.primary_rel_path),
+            base_path=base_path,
+            source_matcher=source_matcher,
+            binary_matcher=binary_matcher,
+        )
 
     @property
     def cached(self) -> bool:
diff --git a/tests/e2e/compose/test_get.py b/tests/e2e/compose/test_get.py
index 589447c9..2c0fcda9 100644
--- a/tests/e2e/compose/test_get.py
+++ b/tests/e2e/compose/test_get.py
@@ -20,17 +20,6 @@ import re
 from playwright.sync_api import Page, expect
 
 
-def test_file_type_badge_binary_for_artifact(page_compose: Page) -> None:
-    """The tar.gz artifact should have a binary badge."""
-    row = page_compose.locator("tr").filter(
-        has=page_compose.locator("code", 
has_text=re.compile(r"^apache-test-0\.2\.tar\.gz$"))
-    )
-    # All non-metadata files are binary by default
-    badge = row.locator('span[title="Binary artifact"]')
-    expect(badge).to_be_visible()
-    expect(badge).to_have_text("bin")
-
-
 def test_file_type_badge_metadata_for_asc(page_compose: Page) -> None:
     """The .asc metadata file should have a metadata badge."""
     row = page_compose.locator("tr").filter(has=page_compose.locator("code", 
has_text=re.compile(r"\.tar\.gz\.asc$")))
@@ -49,6 +38,15 @@ def test_file_type_badge_metadata_for_sha512(page_compose: 
Page) -> None:
     expect(badge).to_have_text("meta")
 
 
+def test_file_type_badge_source_for_archive(page_compose: Page) -> None:
+    row = page_compose.locator("tr").filter(
+        has=page_compose.locator("code", 
has_text=re.compile(r"^apache-test-0\.2\.tar\.gz$"))
+    )
+    badge = row.locator('span[title="Source artifact"]')
+    expect(badge).to_be_visible()
+    expect(badge).to_have_text("src")
+
+
 def test_ongoing_tasks_banner_appears_when_tasks_restart(page_compose: Page) 
-> None:
     """The ongoing tasks banner should appear when tasks are restarted."""
     banner = page_compose.locator("#ongoing-tasks-banner")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to