implement mitm decider for npm

This commit is contained in:
Sahilb315
2026-03-23 12:29:22 +05:30
parent 19e04b71b4
commit 8cd68b15c2
+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)