|
| 1 | +// Copyright © by Jeff Foley 2017-2025. All rights reserved. |
| 2 | +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +package aviato |
| 6 | + |
| 7 | +import ( |
| 8 | + "errors" |
| 9 | + "time" |
| 10 | + |
| 11 | + et "github.com/owasp-amass/amass/v4/engine/types" |
| 12 | + dbt "github.com/owasp-amass/asset-db/types" |
| 13 | + oam "github.com/owasp-amass/open-asset-model" |
| 14 | + "github.com/owasp-amass/open-asset-model/general" |
| 15 | + "golang.org/x/time/rate" |
| 16 | +) |
| 17 | + |
| 18 | +func NewAviato() et.Plugin { |
| 19 | + limit := rate.Every(3 * time.Second) |
| 20 | + |
| 21 | + return &aviato{ |
| 22 | + name: "Aviato", |
| 23 | + rlimit: rate.NewLimiter(limit, 1), |
| 24 | + source: &et.Source{ |
| 25 | + Name: "Aviato", |
| 26 | + Confidence: 90, |
| 27 | + }, |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +func (a *aviato) Name() string { |
| 32 | + return a.name |
| 33 | +} |
| 34 | + |
| 35 | +func (a *aviato) Start(r et.Registry) error { |
| 36 | + a.log = r.Log().WithGroup("plugin").With("name", a.name) |
| 37 | + |
| 38 | + a.log.Info("Plugin started") |
| 39 | + return nil |
| 40 | +} |
| 41 | + |
| 42 | +func (a *aviato) Stop() { |
| 43 | + a.log.Info("Plugin stopped") |
| 44 | +} |
| 45 | + |
| 46 | +func (a *aviato) createRelation(session et.Session, obj *dbt.Entity, rel oam.Relation, subject *dbt.Entity, conf int) error { |
| 47 | + edge, err := session.Cache().CreateEdge(&dbt.Edge{ |
| 48 | + Relation: rel, |
| 49 | + FromEntity: obj, |
| 50 | + ToEntity: subject, |
| 51 | + }) |
| 52 | + if err != nil { |
| 53 | + return err |
| 54 | + } else if edge == nil { |
| 55 | + return errors.New("failed to create the edge") |
| 56 | + } |
| 57 | + |
| 58 | + _, err = session.Cache().CreateEdgeProperty(edge, &general.SourceProperty{ |
| 59 | + Source: a.source.Name, |
| 60 | + Confidence: conf, |
| 61 | + }) |
| 62 | + return err |
| 63 | +} |
0 commit comments