Skip mitm for unsupported registries (#185)

* implement mitm decider for npm

* fix: Skip MITM for registries not supported for analysis
This commit is contained in:
Sahil Bansal
2026-03-24 21:50:13 +05:30
committed by GitHub
parent 19e04b71b4
commit 8e563ee5a1
4 changed files with 105 additions and 0 deletions
+10
View File
@@ -37,6 +37,7 @@ type NpmRegistryInterceptor struct {
}
var _ proxy.Interceptor = (*NpmRegistryInterceptor)(nil)
var _ proxy.MITMDecider = (*NpmRegistryInterceptor)(nil)
// NewNpmRegistryInterceptor creates a new NPM registry interceptor
func NewNpmRegistryInterceptor(
@@ -60,6 +61,15 @@ func (i *NpmRegistryInterceptor) Name() string {
return "npm-registry-interceptor"
}
func (i *NpmRegistryInterceptor) ShouldMITM(ctx *proxy.RequestContext) bool {
config := npmRegistryDomains.GetConfigForHostname(ctx.Hostname)
if config == nil {
return false
}
return config.SupportedForAnalysis
}
// ShouldIntercept determines if this interceptor should handle the given request
func (i *NpmRegistryInterceptor) ShouldIntercept(ctx *proxy.RequestContext) bool {
return npmRegistryDomains.ContainsHostname(ctx.Hostname)