@@ -12,6 +12,7 @@ import (
12
12
13
13
"github.com/caffix/pipeline"
14
14
multierror "github.com/hashicorp/go-multierror"
15
+ "github.com/owasp-amass/amass/v4/config"
15
16
et "github.com/owasp-amass/amass/v4/engine/types"
16
17
)
17
18
@@ -116,25 +117,66 @@ func handlerTask(h *et.Handler) pipeline.TaskFunc {
116
117
}
117
118
}
118
119
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
+ }
130
130
}
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
+ }
135
135
}
136
136
}
137
-
138
137
return data , nil
139
138
})
140
139
}
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