Design and implement a flexible feature set that allows all Hermeto package managers to retrieve packages from various artifact proxy/repository systems.
This will enable hermetic builds in air-gapped environments using configurable content proxies like Pulp, Nexus, Artifactory, or custom solutions.
Extend hermeto/core/config.py:
- Add
ProxyConfigmodel for generic proxy configuration - Add
ProxyProviderenum/registry for different proxy types - Support multiple proxy instances with content type routing
- Include flexible authentication settings (username/password, client certs, tokens)
New config structure:
proxy:
enabled: true
default_instance: "main"
instances:
main:
provider: "pulp" # pulp, nexus, artifactory, generic
base_url: "https://proxy.example.com"
auth:
type: "basic"
username: "user"
password: "pass"
secondary:
provider: "nexus"
base_url: "https://nexus.example.com"
auth:
type: "client_cert"
client_cert: "/path/to/cert.pem"
client_key: "/path/to/key.pem"
rpm_instance:
provider: "artifactory"
base_url: "https://artifactory.example.com"
auth:
type: "token"
token: "art-token-123"
content_mappings:
npm: {instance: "main", repository: "npm-content"}
pip: {instance: "main", repository: "python-content"}
bundler: {instance: "main", repository: "gem-content"}
rpm: {instance: "rpm_instance", repository: "rhel-content"}
cargo: {instance: "main", repository: "cargo-content"}
yarn: {instance: "main", repository: "npm-content"}
gomod: {instance: "main", repository: "go-content"}Create hermeto/core/proxy/client.py:
AbstractProxyClientbase class defining proxy interfaceProxyClientFactoryfor creating provider-specific clients- Common authentication and SSL handling
- Standardized error handling and fallback mechanisms
Create hermeto/core/proxy/providers/:
base.py- Abstract base classes and interfacespulp.py- Pulp-specific client implementationnexus.py- Nexus-specific client implementationartifactory.py- Artifactory-specific client implementationgeneric.py- Generic HTTP proxy client for simple URL rewriting
Create hermeto/core/proxy/url_transformer.py:
AbstractUrlTransformerbase class for URL transformationUrlTransformerRegistryfor registering package-manager-specific transformers- Provider-agnostic URL transformation pipeline
- Support for complex URL patterns and metadata preservation
- Handle special cases (git dependencies, file dependencies, etc.)
Package manager specific transformers:
NpmUrlTransformer- handles npm registry URL patternsPipUrlTransformer- handles PyPI URL patternsBundlerUrlTransformer- handles RubyGems URL patternsCargoUrlTransformer- handles crates.io URL patternsRpmUrlTransformer- handles RPM repository URL patternsGomodUrlTransformer- handles Go module proxy URL patterns
URL transformation patterns:
https://registry.npmjs.org/package/-/package-1.0.0.tgz→https://proxy.example.com/pulp/content/npm-content/package/-/package-1.0.0.tgzhttps://files.pythonhosted.org/packages/.../package-1.0.0.tar.gz→https://proxy.example.com/repository/pypi-proxy/.../package-1.0.0.tar.gz
Create hermeto/core/proxy/providers/base.py:
class AbstractProxyProvider:
def transform_url(self, original_url: str, content_type: str, repository: str) -> str
def get_download_url(self, package_info: dict) -> str
def authenticate(self, request: HttpRequest) -> HttpRequest
def validate_connection(self) -> boolSpecific implementations:
- Pulp Provider: Uses Pulp's distribution/content API patterns
- Nexus Provider: Uses Nexus repository API patterns
- Artifactory Provider: Uses Artifactory repository API patterns
- Generic Provider: Simple URL prefix replacement
Create hermeto/core/proxy/content_types.py:
- Abstract base class for content type handlers
- Specific implementations for each package manager:
NpmContentHandler- maps npm registry URLs to proxy repositoriesPipContentHandler- maps PyPI URLs to proxy repositoriesBundlerContentHandler- maps RubyGems URLs to proxy repositoriesCargoContentHandler- maps crates.io URLs to proxy repositoriesRpmContentHandler- maps RPM repository URLs to proxy repositoriesGomodContentHandler- maps Go module proxy URLs to proxy repositories
Modify each package manager with provider-agnostic integration:
NPM (hermeto/core/package_managers/npm.py):
- Modify
_get_npm_dependencies()to use proxy URLs when enabled - Update registry detection logic to handle proxy URLs
- Use
ProxyClient.transform_url()for registry URL transformation - Preserve integrity checks and validation
Pip (hermeto/core/package_managers/pip/main.py):
- Modify
process_package_distributions()to query proxy for packages - Update index URL handling to use proxy repositories
- Transform index URLs through provider-specific logic
- Maintain requirement file parsing and hash validation
Bundler (hermeto/core/package_managers/bundler/main.py):
- Modify gem resolution to use proxy as source
- Update download logic in parser to use proxy URLs
- Preserve Gemfile.lock integrity
Cargo (hermeto/core/package_managers/cargo/main.py):
- Update crates.io registry URL handling to use proxy
- Maintain Cargo.lock integrity and validation
RPM (hermeto/core/package_managers/rpm/main.py):
- Update repository URL handling to use proxy repositories
- Preserve RPM metadata and signature validation
Yarn (hermeto/core/package_managers/yarn/main.py):
- Similar to NPM integration for registry URL handling
- Update yarn.lock processing to use proxy URLs
Gomod (hermeto/core/package_managers/gomod.py):
- Update GOPROXY environment variable to use proxy
- Handle Go module proxy protocol through proxy
Modify hermeto/core/package_managers/general.py:
- Add proxy-aware download functions using provider abstraction
- Integrate authentication and SSL handling for proxy connections
- Implement provider-specific authentication injection
- Add configurable retry logic and error handling
- Maintain backward compatibility with direct downloads
- Maintain existing fallback mechanisms
Extend CLI options:
- Add
--proxy-configflag for custom proxy configuration - Add
--disable-proxyflag to bypass proxy routing - Add
--proxy-providerto override default provider - Add proxy configuration validation
Input model extensions:
- Add optional
proxy_overridefields to package input models - Allow per-package proxy instance/repository overrides
- Extend configuration system with proxy models
- Implement abstract proxy client framework
- Create provider registry and factory patterns
- Create URL transformation pipeline framework
- Add CLI configuration support
- Implement Pulp provider
- Implement Generic HTTP proxy provider
- Add comprehensive testing framework
- Integrate with NPM and Pip package managers
- Implement Nexus provider
- Implement Artifactory provider
- Add support for Bundler, Cargo, and RPM package managers
- Comprehensive integration testing
- Add Yarn and Gomod proxy integration
- Add provider auto-detection capabilities
- Comprehensive integration testing
- Add proxy content introspection and validation
- Implement intelligent fallback strategies
- Add performance optimizations and caching
- Add detailed logging and monitoring
- Use
/pulp/content/{distribution}/URL patterns - Leverage Pulp's REST API for content discovery
- Handle Pulp-specific authentication (Basic, client certs, tokens)
- Use
/repository/{repo-name}/URL patterns - Leverage Nexus REST API for package metadata
- Handle Nexus authentication (username/password, tokens)
- Use
/{repo-key}/URL patterns - Leverage Artifactory REST API
- Handle Artifactory authentication (API keys, tokens)
- Simple URL prefix/pattern replacement
- Basic HTTP authentication support
- Minimal API requirements for maximum compatibility
- Unit Tests: Test provider abstraction, URL transformation, configuration parsing
- Integration Tests: Test with mock responses for each provider type
- End-to-End Tests: Test with real instances of Pulp, Nexus, Artifactory
- Compatibility Tests: Ensure existing workflows work unchanged
- Proxy integration is completely opt-in via configuration
- Existing workflows continue unchanged when proxy is disabled
- No breaking changes to CLI or API interfaces
- Graceful degradation when proxy is unavailable
- Provider-agnostic credential storage and transmission
- SSL/TLS certificate validation for all proxy connections
- Input validation for proxy URLs and configurations
- Audit logging for all proxy interactions
- Support for various authentication methods per provider
- Secure credential storage and transmission