Skip to content

Commit

Permalink
chore: pass build tool names to super class
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Selwyn-Smith <benselwynsmith@googlemail.com>
  • Loading branch information
benmss committed Feb 10, 2025
1 parent 38b799b commit aec7196
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ def __init__(
self.request_timeout = request_timeout or 10
self.download_timeout = download_timeout or 120
self.enabled = enabled or False
self.build_tool_names = {"maven", "gradle"}
super().__init__("JFrog Maven Registry")
super().__init__("JFrog Maven Registry", {"maven", "gradle"})

def load_defaults(self) -> None:
"""Load the .ini configuration for the current package registry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ def __init__(
self.registry_url_scheme = registry_url_scheme or ""
self.registry_url = "" # Created from the registry_url_scheme and registry_url_netloc.
self.request_timeout = request_timeout or 10
self.build_tool_names = {"maven", "gradle"}
super().__init__("Maven Central Registry")
super().__init__("Maven Central Registry", {"maven", "gradle"})

def load_defaults(self) -> None:
"""Load the .ini configuration for the current package registry.
Expand Down
3 changes: 1 addition & 2 deletions src/macaron/slsa_analyzer/package_registry/npm_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def __init__(
self.attestation_endpoint = attestation_endpoint or ""
self.request_timeout = request_timeout or 10
self.enabled = enabled
self.build_tool_names = {"npm", "yarn"}
super().__init__("npm Registry")
super().__init__("npm Registry", {"npm", "yarn"})

def load_defaults(self) -> None:
"""Load the .ini configuration for the current package registry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class PackageRegistry(ABC):
"""Base package registry class."""

def __init__(self, name: str) -> None:
def __init__(self, name: str, build_tool_names: set[str]) -> None:
self.name = name
self.build_tool_names: set[str] = set()
self.build_tool_names = build_tool_names
self.enabled: bool = True

@abstractmethod
Expand All @@ -44,6 +44,9 @@ def is_detected(self, build_tool_name: str) -> bool:
``True`` if the repo under analysis can be published to this package registry,
based on the given build tool.
"""
print()
print(f"{build_tool_name} in {self.build_tool_names} ?")
print()
if not self.enabled:
return False
return build_tool_name in self.build_tool_names
Expand Down
3 changes: 1 addition & 2 deletions src/macaron/slsa_analyzer/package_registry/pypi_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ def __init__(
self.request_timeout = request_timeout or 10
self.enabled = enabled
self.registry_url = ""
self.build_tool_names = {"pip", "poetry"}
super().__init__("PyPI Registry")
super().__init__("PyPI Registry", {"pip", "poetry"})

def load_defaults(self) -> None:
"""Load the .ini configuration for the current package registry.
Expand Down

0 comments on commit aec7196

Please sign in to comment.