Files
pmg/proxy/interceptors/npm_registry_config.go
T
Sahil BansalandGitHub 0aa82033a5 fix proxy mode failing for GH private packages (#137)
* fix proxy mode failing for GH private packages

* skip analysis for private packages for proxy mode

* introduce npmRegistryConfig and support for handling multiple parsers in future

* refactor name and unexport npm config functions

* rm unused function

* rename & unexport npmRegistryURLParser

* add e2e for malicious pkg blocked using proxy mode
2026-01-23 18:38:54 +05:30

33 lines
851 B
Go

package interceptors
import "strings"
// npmRegistryConfig defines configuration for npm registry endpoints
type npmRegistryConfig struct {
// Hostname
Host string
// Whether this registry is supported for malware analysis
SupportedForAnalysis bool
// Parser for the registry
RegistryParser npmRegistryURLParser
}
// getNpmRegistryConfigForHostname returns the configuration for a hostname (with subdomain matching)
func getNpmRegistryConfigForHostname(hostname string) *npmRegistryConfig {
// Check exact match first
if config, exists := npmRegistryDomains[hostname]; exists {
return config
}
// Check subdomain match: hostname could be "cdn.registry.npmjs.org" matching "registry.npmjs.org"
for endpoint, config := range npmRegistryDomains {
if strings.HasSuffix(hostname, "."+endpoint) {
return config
}
}
return nil
}