Skip to content

Commit 736a643

Browse files
committed
plugins are now correctly excluded when requested in the configuration
1 parent b2e6cc1 commit 736a643

File tree

1 file changed

+58
-16
lines changed

1 file changed

+58
-16
lines changed

engine/registry/pipelines.go

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/caffix/pipeline"
1414
multierror "github.com/hashicorp/go-multierror"
15+
"github.com/owasp-amass/amass/v4/config"
1516
et "github.com/owasp-amass/amass/v4/engine/types"
1617
)
1718

@@ -116,25 +117,66 @@ func handlerTask(h *et.Handler) pipeline.TaskFunc {
116117
}
117118
}
118119

119-
var pmatch bool
120-
for _, tf := range h.Transforms {
121-
if strings.EqualFold(tf, h.Plugin.Name()) {
122-
pmatch = true
123-
break
124-
}
125-
}
126-
if !pmatch {
127-
from := string(ede.Event.Entity.Asset.AssetType())
128-
if _, err := ede.Event.Session.Config().CheckTransformations(from, h.Transforms...); err == nil {
129-
pmatch = true
120+
pname := h.Plugin.Name()
121+
from := string(ede.Event.Entity.Asset.AssetType())
122+
transformations := transformationsByType(ede.Event.Session.Config(), from)
123+
if len(transformations) > 0 && !allExcludesPlugin(transformations, pname) {
124+
pmatch := tosContainPlugin(transformations, pname)
125+
126+
if !pmatch {
127+
if _, err := ede.Event.Session.Config().CheckTransformations(from, h.Transforms...); err == nil {
128+
pmatch = true
129+
}
130130
}
131-
}
132-
if pmatch {
133-
if err := r.Callback(ede.Event); err != nil {
134-
ede.Error = multierror.Append(ede.Error, err)
131+
if pmatch {
132+
if err := r.Callback(ede.Event); err != nil {
133+
ede.Error = multierror.Append(ede.Error, err)
134+
}
135135
}
136136
}
137-
138137
return data, nil
139138
})
140139
}
140+
141+
func transformationsByType(cfg *config.Config, from string) []*config.Transformation {
142+
var transformations []*config.Transformation
143+
144+
for _, tf := range cfg.Transformations {
145+
if strings.EqualFold(tf.From, from) {
146+
transformations = append(transformations, tf)
147+
}
148+
}
149+
150+
return transformations
151+
}
152+
153+
func tosContainPlugin(transformations []*config.Transformation, pname string) bool {
154+
for _, tf := range transformations {
155+
if strings.EqualFold(tf.To, pname) {
156+
return true
157+
}
158+
}
159+
return false
160+
}
161+
162+
func allExcludesPlugin(transformations []*config.Transformation, pname string) bool {
163+
var all *config.Transformation
164+
165+
for _, tf := range transformations {
166+
if strings.EqualFold(tf.To, "all") {
167+
all = tf
168+
break
169+
}
170+
}
171+
172+
if all == nil {
173+
return false
174+
}
175+
176+
for _, ex := range all.Exclude {
177+
if strings.EqualFold(ex, pname) {
178+
return true
179+
}
180+
}
181+
return false
182+
}

0 commit comments

Comments
 (0)