mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user