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