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
@@ -38,6 +38,7 @@ type PypiRegistryInterceptor struct {
}
var _ proxy.Interceptor = (*PypiRegistryInterceptor)(nil)
var _ proxy.MITMDecider = (*PypiRegistryInterceptor)(nil)
// NewPypiRegistryInterceptor creates a new PyPI registry interceptor
func NewPypiRegistryInterceptor(
@@ -61,6 +62,15 @@ func (i *PypiRegistryInterceptor) Name() string {
return "pypi-registry-interceptor"
}
func (i *PypiRegistryInterceptor) ShouldMITM(ctx *proxy.RequestContext) bool {
config := pypiRegistryDomains.GetConfigForHostname(ctx.Hostname)
if config == nil {
return false
}
return config.SupportedForAnalysis
}
// ShouldIntercept determines if this interceptor should handle the given request
func (i *PypiRegistryInterceptor) ShouldIntercept(ctx *proxy.RequestContext) bool {
return pypiRegistryDomains.ContainsHostname(ctx.Hostname)