You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by ar...@apache.org on 2026/05/11 14:36:18 UTC

(tooling-trusted-releases) 01/01: #1177 - fix archive types and add additionals

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

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

commit 7b1ef1fca0749b99b8f2997e5ada601a0be07078
Author: Alastair McFarlane <ar...@apache.org>
AuthorDate: Mon May 11 15:36:03 2026 +0100

    #1177 - fix archive types and add additionals
---
 atr/classify.py  | 14 ++++++--------
 atr/detection.py | 14 ++++++++++++--
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/atr/classify.py b/atr/classify.py
index 1b5882fb..795998db 100644
--- a/atr/classify.py
+++ b/atr/classify.py
@@ -110,7 +110,7 @@ _SRC_SOURCE_RE: Final[re.Pattern[str]] = re.compile(r"(^|[-_.])(project|source|s
 
 _TOKEN_SPLIT_RE: Final[re.Pattern[str]] = re.compile(r"[-_.]+")
 
-_UNCLASSIFIED_SOURCE_SUFFIXES: Final[frozenset[str]] = frozenset({"-source.jar", "-sources.jar", "-src.jar"})
+_DEFAULT_BINARY_EXTENSIONS: Final[frozenset[str]] = frozenset({".jar"})
 
 
 class FileType(enum.Enum):
@@ -140,7 +140,7 @@ def archive_marker_counts(stem: str, path: pathlib.PurePath) -> tuple[int, int,
     return source_count, binary_count, docs_count
 
 
-async def classify(  # noqa: C901
+async def classify(
     path: safe.RelPath,
     base_path: safe.StatePath | None = None,
     source_matcher: Callable[[str], bool] | None = None,
@@ -172,22 +172,20 @@ async def classify(  # noqa: C901
         return FileType.BINARY
     stem = path_str[: search.start()]
     if not any(path_str.endswith(suffix) for suffix in detection.QUARANTINE_ARCHIVE_SUFFIXES):
-        if any(path_str.endswith(suffix) for suffix in _UNCLASSIFIED_SOURCE_SUFFIXES):
-            # This is a temporary workaround for some archives that are not yet quarantined
-            # TODO: Remove this once these archives are quarantined
-            return FileType.SOURCE
         return FileType.BINARY
     if archive_cache_dir is not None:
         marker = await _content_markers(archive_cache_dir)
         if marker is not None:
             return marker
-    return classify_from_counts(*archive_marker_counts(stem, path.as_path()))
+    return classify_from_counts(path_str, *archive_marker_counts(stem, path.as_path()))
 
 
-def classify_from_counts(source_count: int, binary_count: int, docs_count: int) -> FileType:
+def classify_from_counts(path_str: str, source_count: int, binary_count: int, docs_count: int) -> FileType:
     if (source_count == 0) and (binary_count == 0):
         if docs_count > 0:
             return FileType.DOCS
+        if any(path_str.endswith(suffix) for suffix in _DEFAULT_BINARY_EXTENSIONS):
+            return FileType.BINARY
         return FileType.SOURCE
     if source_count >= binary_count:
         return FileType.SOURCE
diff --git a/atr/detection.py b/atr/detection.py
index 7fc99071..025a45ef 100644
--- a/atr/detection.py
+++ b/atr/detection.py
@@ -23,8 +23,18 @@ import puremagic
 import atr.models.attestable as models
 import atr.models.safe as safe
 
-# TODO: Widen the range of types checked here
-QUARANTINE_ARCHIVE_SUFFIXES: Final[tuple[str, ...]] = (".tar.gz", ".tgz", ".zip", ".bz2", ".xz")
+QUARANTINE_ARCHIVE_SUFFIXES: Final[tuple[str, ...]] = (
+    ".tar.gz",
+    ".tgz",
+    ".zip",
+    ".tar.bz2",
+    ".tar.xz",
+    ".jar",
+    ".war",
+    ".apk",
+    ".nar",
+    ".whl",
+)
 
 _BZIP2_TYPES: Final[set[str]] = {"application/x-bzip2"}
 _DEB_TYPES: Final[set[str]] = {"application/vnd.debian.binary-package", "application/x-archive"}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org