diff --git a/cmd/oam_assoc/main.go b/cmd/oam_assoc/main.go index a8cdafb1..5eec3804 100644 --- a/cmd/oam_assoc/main.go +++ b/cmd/oam_assoc/main.go @@ -36,7 +36,7 @@ import ( "github.com/owasp-amass/amass/v4/config" "github.com/owasp-amass/amass/v4/utils" "github.com/owasp-amass/amass/v4/utils/afmt" - assetdb "github.com/owasp-amass/asset-db" + "github.com/owasp-amass/asset-db/repository" dbt "github.com/owasp-amass/asset-db/types" "github.com/owasp-amass/open-asset-model/domain" oamreg "github.com/owasp-amass/open-asset-model/registration" @@ -191,11 +191,11 @@ func main() { } } -func printContactInfo(assoc *dbt.Entity, regrel string, since time.Time, db *assetdb.AssetDB) { +func printContactInfo(assoc *dbt.Entity, regrel string, since time.Time, db repository.Repository) { var contact *dbt.Entity - if edges, err := db.Repo.OutgoingEdges(assoc, since, regrel); err == nil && len(edges) > 0 { - if a, err := db.Repo.FindEntityById(edges[0].ToEntity.ID); err == nil && a != nil { + if edges, err := db.OutgoingEdges(assoc, since, regrel); err == nil && len(edges) > 0 { + if a, err := db.FindEntityById(edges[0].ToEntity.ID); err == nil && a != nil { contact = a } } @@ -204,9 +204,9 @@ func printContactInfo(assoc *dbt.Entity, regrel string, since time.Time, db *ass } for _, out := range []string{"person", "organization", "location", "phone", "email"} { - if edges, err := db.Repo.OutgoingEdges(contact, since, out); err == nil && len(edges) > 0 { + if edges, err := db.OutgoingEdges(contact, since, out); err == nil && len(edges) > 0 { for _, edge := range edges { - if a, err := db.Repo.FindEntityById(edge.ToEntity.ID); err == nil && a != nil { + if a, err := db.FindEntityById(edge.ToEntity.ID); err == nil && a != nil { fmt.Fprintf(color.Output, "%s%s%s\n", afmt.Blue(string(a.Asset.AssetType())), afmt.Blue(": "), afmt.Green(a.Asset.Key())) } @@ -215,19 +215,19 @@ func printContactInfo(assoc *dbt.Entity, regrel string, since time.Time, db *ass } } -func getAssociations(name string, since time.Time, db *assetdb.AssetDB) []*dbt.Entity { +func getAssociations(name string, since time.Time, db repository.Repository) []*dbt.Entity { var results []*dbt.Entity - fqdns, err := db.Repo.FindEntityByContent(&domain.FQDN{Name: name}, since) + fqdns, err := db.FindEntityByContent(&domain.FQDN{Name: name}, since) if err != nil || len(fqdns) == 0 { return results } var assets []*dbt.Entity for _, fqdn := range fqdns { - if edges, err := db.Repo.OutgoingEdges(fqdn, since, "registration"); err == nil && len(edges) > 0 { + if edges, err := db.OutgoingEdges(fqdn, since, "registration"); err == nil && len(edges) > 0 { for _, edge := range edges { - if a, err := db.Repo.FindEntityById(edge.ToEntity.ID); err == nil && a != nil { + if a, err := db.FindEntityById(edge.ToEntity.ID); err == nil && a != nil { assets = append(assets, a) } } @@ -246,9 +246,9 @@ func getAssociations(name string, since time.Time, db *assetdb.AssetDB) []*dbt.E findings = []*dbt.Entity{} for _, a := range assets { - if edges, err := db.Repo.OutgoingEdges(a, since, "associated_with"); err == nil && len(edges) > 0 { + if edges, err := db.OutgoingEdges(a, since, "associated_with"); err == nil && len(edges) > 0 { for _, edge := range edges { - asset, err := db.Repo.FindEntityById(edge.ToEntity.ID) + asset, err := db.FindEntityById(edge.ToEntity.ID) if err != nil || asset == nil { continue } diff --git a/cmd/oam_subs/main.go b/cmd/oam_subs/main.go index 0ae3aeaf..4e0dcae1 100644 --- a/cmd/oam_subs/main.go +++ b/cmd/oam_subs/main.go @@ -39,7 +39,7 @@ import ( "github.com/owasp-amass/amass/v4/config" "github.com/owasp-amass/amass/v4/utils" "github.com/owasp-amass/amass/v4/utils/afmt" - assetdb "github.com/owasp-amass/asset-db" + "github.com/owasp-amass/asset-db/repository" dbt "github.com/owasp-amass/asset-db/types" "github.com/owasp-amass/open-asset-model/domain" ) @@ -175,7 +175,7 @@ func main() { showData(&args, asninfo, db) } -func showData(args *dbArgs, asninfo bool, db *assetdb.AssetDB) { +func showData(args *dbArgs, asninfo bool, db repository.Repository) { var total int var err error var outfile *os.File @@ -265,7 +265,7 @@ func showData(args *dbArgs, asninfo bool, db *assetdb.AssetDB) { } } -func getNames(ctx context.Context, domains []string, asninfo bool, db *assetdb.AssetDB) []*utils.Output { +func getNames(ctx context.Context, domains []string, asninfo bool, db repository.Repository) []*utils.Output { if len(domains) == 0 { return nil } @@ -276,8 +276,8 @@ func getNames(ctx context.Context, domains []string, asninfo bool, db *assetdb.A var assets []*dbt.Entity for _, d := range domains { - if ents, err := db.Repo.FindEntityByContent(&domain.FQDN{Name: d}, qtime); err == nil && len(ents) == 1 { - if n, err := utils.FindByFQDNScope(db.Repo, ents[0], qtime); err == nil && len(n) > 0 { + if ents, err := db.FindEntityByContent(&domain.FQDN{Name: d}, qtime); err == nil && len(ents) == 1 { + if n, err := utils.FindByFQDNScope(db, ents[0], qtime); err == nil && len(n) > 0 { assets = append(assets, n...) } } @@ -296,7 +296,7 @@ func getNames(ctx context.Context, domains []string, asninfo bool, db *assetdb.A return names } -func addAddresses(ctx context.Context, db *assetdb.AssetDB, names []*utils.Output, asninfo bool, cache *utils.ASNCache) []*utils.Output { +func addAddresses(ctx context.Context, db repository.Repository, names []*utils.Output, asninfo bool, cache *utils.ASNCache) []*utils.Output { var namestrs []string lookup := make(outLookup, len(names)) for _, n := range names { diff --git a/cmd/oam_track/main.go b/cmd/oam_track/main.go index 1a4b0f80..ae38ce46 100644 --- a/cmd/oam_track/main.go +++ b/cmd/oam_track/main.go @@ -35,7 +35,7 @@ import ( "github.com/owasp-amass/amass/v4/config" "github.com/owasp-amass/amass/v4/utils" "github.com/owasp-amass/amass/v4/utils/afmt" - assetdb "github.com/owasp-amass/asset-db" + "github.com/owasp-amass/asset-db/repository" dbt "github.com/owasp-amass/asset-db/types" "github.com/owasp-amass/open-asset-model/domain" ) @@ -153,15 +153,15 @@ func main() { } } -func getNewNames(domains []string, since time.Time, db *assetdb.AssetDB) []string { +func getNewNames(domains []string, since time.Time, db repository.Repository) []string { if len(domains) == 0 { return []string{} } var assets []*dbt.Entity for _, d := range domains { - if ents, err := db.Repo.FindEntityByContent(&domain.FQDN{Name: d}, since); err == nil && len(ents) == 1 { - if n, err := utils.FindByFQDNScope(db.Repo, ents[0], since); err == nil && len(n) > 0 { + if ents, err := db.FindEntityByContent(&domain.FQDN{Name: d}, since); err == nil && len(ents) == 1 { + if n, err := utils.FindByFQDNScope(db, ents[0], since); err == nil && len(n) > 0 { assets = append(assets, n...) } } diff --git a/engine/plugins/service_discovery/http_probes/plugin.go b/engine/plugins/service_discovery/http_probes/plugin.go index 403bcc06..efae8c72 100644 --- a/engine/plugins/service_discovery/http_probes/plugin.go +++ b/engine/plugins/service_discovery/http_probes/plugin.go @@ -19,7 +19,7 @@ import ( oam "github.com/owasp-amass/open-asset-model" oamcert "github.com/owasp-amass/open-asset-model/certificate" "github.com/owasp-amass/open-asset-model/relation" - "github.com/owasp-amass/open-asset-model/service" + oamserv "github.com/owasp-amass/open-asset-model/service" ) type httpProbing struct { @@ -174,7 +174,7 @@ func (hp *httpProbing) store(e *et.Event, resp *http.Response, entity *dbt.Entit return findings } - serv = s.Asset.(*service.Service) + serv = s.Asset.(*oamserv.Service) // for adding the source information findings = append(findings, &support.Finding{ From: entity, diff --git a/engine/sessions/session.go b/engine/sessions/session.go index 2e342d9c..b85202b8 100644 --- a/engine/sessions/session.go +++ b/engine/sessions/session.go @@ -32,7 +32,7 @@ type Session struct { ps *pubsub.Logger cfg *config.Config scope *scope.Scope - db *assetdb.AssetDB + db repository.Repository dsn string dbtype string c *cache.Cache @@ -71,7 +71,7 @@ func CreateSession(cfg *config.Config) (et.Session, error) { } s.tmpdir = dir - s.c, err = cache.New(c, s.db.Repo, time.Minute) + s.c, err = cache.New(c, s.db, time.Minute) if err != nil || s.c == nil { return nil, errors.New("failed to create the session cache") } @@ -98,7 +98,7 @@ func (s *Session) Scope() *scope.Scope { return s.scope } -func (s *Session) DB() *assetdb.AssetDB { +func (s *Session) DB() repository.Repository { return s.db } @@ -178,8 +178,8 @@ func (s *Session) selectDBMS() error { return errors.New("no primary database specified in the configuration") } // Initialize the database store - store := assetdb.New(s.dbtype, s.dsn) - if store == nil { + store, err := assetdb.New(s.dbtype, s.dsn) + if err != nil { return errors.New("failed to initialize database store") } s.db = store @@ -192,10 +192,11 @@ func createFileCacheRepo() (repository.Repository, string, error) { return nil, "", errors.New("failed to create the temp dir") } - c := assetdb.New(sqlrepo.SQLite, filepath.Join(dir, "cache.sqlite")) - if c == nil { - return nil, "", errors.New("failed to create the cache db") + //c := assetdb.New(sqlrepo.SQLite, filepath.Join(dir, "cache.sqlite")) + c, err := assetdb.New(sqlrepo.SQLiteMemory, "") + if err != nil { + return nil, "", fmt.Errorf("failed to create the cache db: %s", err.Error()) } - return c.Repo, dir, nil + return c, dir, nil } diff --git a/engine/types/sessions.go b/engine/types/sessions.go index 44658e9d..b326ed6d 100644 --- a/engine/types/sessions.go +++ b/engine/types/sessions.go @@ -13,8 +13,8 @@ import ( "github.com/owasp-amass/amass/v4/config" "github.com/owasp-amass/amass/v4/engine/pubsub" "github.com/owasp-amass/amass/v4/engine/sessions/scope" - assetdb "github.com/owasp-amass/asset-db" "github.com/owasp-amass/asset-db/cache" + "github.com/owasp-amass/asset-db/repository" ) type Session interface { @@ -23,7 +23,7 @@ type Session interface { PubSub() *pubsub.Logger Config() *config.Config Scope() *scope.Scope - DB() *assetdb.AssetDB + DB() repository.Repository Cache() *cache.Cache TmpDir() string Stats() *SessionStats diff --git a/utils/addr.go b/utils/addr.go index 8982f722..40b42a5a 100644 --- a/utils/addr.go +++ b/utils/addr.go @@ -9,7 +9,6 @@ import ( "time" "github.com/caffix/stringset" - assetdb "github.com/owasp-amass/asset-db" "github.com/owasp-amass/asset-db/repository" dbt "github.com/owasp-amass/asset-db/types" "github.com/owasp-amass/open-asset-model/domain" @@ -17,18 +16,18 @@ import ( "github.com/owasp-amass/open-asset-model/relation" ) -func ReadASPrefixes(db *assetdb.AssetDB, asn int, since time.Time) []string { +func ReadASPrefixes(db repository.Repository, asn int, since time.Time) []string { var prefixes []string - fqdns, err := db.FindByContent(&network.AutonomousSystem{Number: asn}, since) + fqdns, err := db.FindEntityByContent(&network.AutonomousSystem{Number: asn}, since) if err != nil || len(fqdns) != 1 { return prefixes } fqdn := fqdns[0] - if edges, err := db.Repo.OutgoingEdges(fqdn, since, "announces"); err == nil && len(edges) > 0 { + if edges, err := db.OutgoingEdges(fqdn, since, "announces"); err == nil && len(edges) > 0 { for _, edge := range edges { - if a, err := db.Repo.FindEntityById(edge.ToEntity.ID); err != nil { + if a, err := db.FindEntityById(edge.ToEntity.ID); err != nil { continue } else if netblock, ok := a.Asset.(*network.Netblock); ok { prefixes = append(prefixes, netblock.CIDR.String()) @@ -44,10 +43,10 @@ type NameAddrPair struct { Addr *network.IPAddress } -func NamesToAddrs(db *assetdb.AssetDB, since time.Time, names ...string) ([]*NameAddrPair, error) { +func NamesToAddrs(db repository.Repository, since time.Time, names ...string) ([]*NameAddrPair, error) { var fqdns []*dbt.Entity for _, name := range names { - if ents, err := db.Repo.FindEntityByContent(&domain.FQDN{Name: name}, since); err == nil && len(ents) == 1 { + if ents, err := db.FindEntityByContent(&domain.FQDN{Name: name}, since); err == nil && len(ents) == 1 { fqdns = append(fqdns, ents[0]) } } @@ -56,12 +55,12 @@ func NamesToAddrs(db *assetdb.AssetDB, since time.Time, names ...string) ([]*Nam // get the IPs associated with SRV, NS, and MX records loop: for _, fqdn := range fqdns { - if edges, err := db.Repo.OutgoingEdges(fqdn, since, "dns_record"); err == nil && len(edges) > 0 { + if edges, err := db.OutgoingEdges(fqdn, since, "dns_record"); err == nil && len(edges) > 0 { for _, edge := range edges { switch v := edge.Relation.(type) { case *relation.BasicDNSRelation: if v.Header.RRType == 1 || v.Header.RRType == 28 { - if ip, err := getAddr(db.Repo, edge.ToEntity, since); err == nil { + if ip, err := getAddr(db, edge.ToEntity, since); err == nil { results = append(results, &NameAddrPair{ FQDN: fqdn.Asset.(*domain.FQDN), Addr: ip, @@ -69,7 +68,7 @@ loop: continue loop } } else if v.Header.RRType == 5 { - if ip, err := cnameQuery(db.Repo, edge.ToEntity, since); err == nil { + if ip, err := cnameQuery(db, edge.ToEntity, since); err == nil { results = append(results, &NameAddrPair{ FQDN: fqdn.Asset.(*domain.FQDN), Addr: ip, @@ -79,7 +78,7 @@ loop: } case *relation.PrefDNSRelation: if v.Header.RRType == 2 || v.Header.RRType == 15 { - if ip, err := oneMoreName(db.Repo, edge.ToEntity, since); err == nil { + if ip, err := oneMoreName(db, edge.ToEntity, since); err == nil { results = append(results, &NameAddrPair{ FQDN: fqdn.Asset.(*domain.FQDN), Addr: ip, @@ -89,7 +88,7 @@ loop: } case *relation.SRVDNSRelation: if v.Header.RRType == 33 { - if ip, err := oneMoreName(db.Repo, edge.ToEntity, since); err == nil { + if ip, err := oneMoreName(db, edge.ToEntity, since); err == nil { results = append(results, &NameAddrPair{ FQDN: fqdn.Asset.(*domain.FQDN), Addr: ip, diff --git a/utils/asncache.go b/utils/asncache.go index 88271c36..edddc7cd 100644 --- a/utils/asncache.go +++ b/utils/asncache.go @@ -11,7 +11,7 @@ import ( "time" "github.com/caffix/stringset" - assetdb "github.com/owasp-amass/asset-db" + "github.com/owasp-amass/asset-db/repository" oam "github.com/owasp-amass/open-asset-model" "github.com/owasp-amass/open-asset-model/network" oamreg "github.com/owasp-amass/open-asset-model/registration" @@ -222,9 +222,9 @@ func (c *ASNCache) AddrSearch(addr string) *ASNRequest { } } -func FillCache(cache *ASNCache, db *assetdb.AssetDB) error { +func FillCache(cache *ASNCache, db repository.Repository) error { start := time.Now().Add(-730 * time.Hour) - assets, err := db.Repo.FindEntitiesByType(oam.AutonomousSystem, start) + assets, err := db.FindEntitiesByType(oam.AutonomousSystem, start) if err != nil { return err } @@ -236,13 +236,13 @@ func FillCache(cache *ASNCache, db *assetdb.AssetDB) error { } var desc string - edges, err := db.Repo.OutgoingEdges(a, start, "registration") + edges, err := db.OutgoingEdges(a, start, "registration") if err != nil || len(edges) == 0 { continue } for _, edge := range edges { - if asset, err := db.Repo.FindEntityById(edge.ToEntity.ID); err == nil && asset != nil { + if asset, err := db.FindEntityById(edge.ToEntity.ID); err == nil && asset != nil { if autnum, ok := asset.Asset.(*oamreg.AutnumRecord); ok && autnum != nil { desc = autnum.Handle + " - " + autnum.Name break diff --git a/utils/graph.go b/utils/graph.go index 5eb1673a..48df9135 100644 --- a/utils/graph.go +++ b/utils/graph.go @@ -5,29 +5,22 @@ package utils import ( - "embed" "fmt" - "math/rand" "path/filepath" - "github.com/glebarez/sqlite" "github.com/owasp-amass/amass/v4/config" - assetdb "github.com/owasp-amass/asset-db" - pgmigrations "github.com/owasp-amass/asset-db/migrations/postgres" - sqlitemigrations "github.com/owasp-amass/asset-db/migrations/sqlite3" + assetdb "github.com/owasp-amass/asset-db/" + "github.com/owasp-amass/asset-db/repository" "github.com/owasp-amass/asset-db/repository/sqlrepo" - migrate "github.com/rubenv/sql-migrate" - "gorm.io/driver/postgres" - "gorm.io/gorm" ) -func OpenGraphDatabase(cfg *config.Config) *assetdb.AssetDB { +func OpenGraphDatabase(cfg *config.Config) repository.Repository { // Add the local database settings to the configuration cfg.GraphDBs = append(cfg.GraphDBs, cfg.LocalDatabaseSettings(cfg.GraphDBs)) for _, db := range cfg.GraphDBs { if db.Primary { - var dbase *assetdb.AssetDB + var dbase repository.Repository if db.System == "local" { dbase = NewGraph(db.System, filepath.Join(config.OutputDirectory(cfg.Dir), "amass.sqlite"), db.Options) @@ -46,14 +39,13 @@ func OpenGraphDatabase(cfg *config.Config) *assetdb.AssetDB { return NewGraph("memory", "", "") } -func NewGraph(system, path string, options string) *assetdb.AssetDB { +func NewGraph(system, path string, options string) repository.Repository { var dsn string var dbtype string switch system { case "memory": - dbtype = sqlrepo.SQLite - dsn = fmt.Sprintf("file:sqlite%d?mode=memory&cache=shared", rand.Int31n(100)) + dbtype = sqlrepo.SQLiteMemory case "local": dbtype = sqlrepo.SQLite dsn = path @@ -64,43 +56,8 @@ func NewGraph(system, path string, options string) *assetdb.AssetDB { return nil } - store := assetdb.New(dbtype, dsn) - if store == nil { - return nil - } - - var name string - var fs embed.FS - var database gorm.Dialector - switch dbtype { - case sqlrepo.SQLite: - name = "sqlite3" - fs = sqlitemigrations.Migrations() - database = sqlite.Open(dsn) - case sqlrepo.Postgres: - name = "postgres" - fs = pgmigrations.Migrations() - database = postgres.Open(dsn) - } - - sql, err := gorm.Open(database, &gorm.Config{}) - if err != nil { - return nil - } - - migrationsSource := migrate.EmbedFileSystemMigrationSource{ - FileSystem: fs, - Root: "/", - } - - sqlDb, err := sql.DB() - if err != nil { - panic(err) - } - - _, err = migrate.Exec(sqlDb, name, migrationsSource, migrate.Up) - if err != nil { - panic(err) + if store, err := assetdb.New(dbtype, dsn); err == nil { + return store } - return store + return nil } diff --git a/utils/viz/viz.go b/utils/viz/viz.go index 871e1f46..b8b705ae 100644 --- a/utils/viz/viz.go +++ b/utils/viz/viz.go @@ -9,7 +9,7 @@ import ( "time" "github.com/owasp-amass/amass/v4/utils" - assetdb "github.com/owasp-amass/asset-db" + "github.com/owasp-amass/asset-db/repository" "github.com/owasp-amass/asset-db/types" oam "github.com/owasp-amass/open-asset-model" oamcert "github.com/owasp-amass/open-asset-model/certificate" @@ -35,15 +35,15 @@ type Node struct { } // VizData returns the current state of the Graph as viz package Nodes and Edges. -func VizData(domains []string, since time.Time, db *assetdb.AssetDB) ([]Node, []Edge) { +func VizData(domains []string, since time.Time, db repository.Repository) ([]Node, []Edge) { if len(domains) == 0 { return []Node{}, []Edge{} } var next []*types.Entity for _, d := range domains { - if ents, err := db.Repo.FindEntityByContent(&domain.FQDN{Name: d}, since); err == nil && len(ents) == 1 { - if n, err := utils.FindByFQDNScope(db.Repo, ents[0], since); err == nil && len(n) > 0 { + if ents, err := db.FindEntityByContent(&domain.FQDN{Name: d}, since); err == nil && len(ents) == 1 { + if n, err := utils.FindByFQDNScope(db, ents[0], since); err == nil && len(n) > 0 { next = append(next, n...) } } @@ -127,10 +127,10 @@ func VizData(domains []string, since time.Time, db *assetdb.AssetDB) ([]Node, [] } // Obtain relations to additional assets in the graph if out { - if edges, err := db.Repo.OutgoingEdges(a, since, outRels...); err == nil && len(edges) > 0 { + if edges, err := db.OutgoingEdges(a, since, outRels...); err == nil && len(edges) > 0 { fromID := id for _, edge := range edges { - if to, err := db.Repo.FindEntityById(edge.ToEntity.ID); err == nil { + if to, err := db.FindEntityById(edge.ToEntity.ID); err == nil { toID := idx n2 := newNode(db, toID, to, since) if n2 == nil { @@ -157,10 +157,10 @@ func VizData(domains []string, since time.Time, db *assetdb.AssetDB) ([]Node, [] } } if in { - if edges, err := db.Repo.IncomingEdges(a, since, inRels...); err == nil && len(edges) > 0 { + if edges, err := db.IncomingEdges(a, since, inRels...); err == nil && len(edges) > 0 { toID := id for _, edge := range edges { - if from, err := db.Repo.FindEntityById(edge.FromEntity.ID); err == nil { + if from, err := db.FindEntityById(edge.FromEntity.ID); err == nil { fromID := idx n2 := newNode(db, fromID, from, since) if n2 == nil { @@ -193,7 +193,7 @@ func VizData(domains []string, since time.Time, db *assetdb.AssetDB) ([]Node, [] return viznodes, vizedges } -func newNode(db *assetdb.AssetDB, idx int, a *types.Entity, since time.Time) *Node { +func newNode(db repository.Repository, idx int, a *types.Entity, since time.Time) *Node { if a == nil || a.Asset == nil { return nil } @@ -242,10 +242,10 @@ func domainNameInScope(name string, scope []string) bool { return discovered } -func associatedWithScope(db *assetdb.AssetDB, asset *types.Entity, scope []string, since time.Time) bool { - if edges, err := db.Repo.OutgoingEdges(asset, since, "dns_record"); err == nil && len(edges) > 0 { +func associatedWithScope(db repository.Repository, asset *types.Entity, scope []string, since time.Time) bool { + if edges, err := db.OutgoingEdges(asset, since, "dns_record"); err == nil && len(edges) > 0 { for _, edge := range edges { - if to, err := db.Repo.FindEntityById(edge.ToEntity.ID); err == nil { + if to, err := db.FindEntityById(edge.ToEntity.ID); err == nil { if n, ok := to.Asset.(*domain.FQDN); ok && n != nil && domainNameInScope(n.Name, scope) { return true } @@ -256,8 +256,8 @@ func associatedWithScope(db *assetdb.AssetDB, asset *types.Entity, scope []strin return followBackForScope(db, asset, scope, since) } -func followBackForScope(db *assetdb.AssetDB, asset *types.Entity, scope []string, since time.Time) bool { - if edges, err := db.Repo.IncomingEdges(asset, since, "dns_record"); err == nil && len(edges) > 0 { +func followBackForScope(db repository.Repository, asset *types.Entity, scope []string, since time.Time) bool { + if edges, err := db.IncomingEdges(asset, since, "dns_record"); err == nil && len(edges) > 0 { for _, edge := range edges { if rel, ok := edge.Relation.(*relation.BasicDNSRelation); ok && rel.Header.RRType != 5 { continue @@ -266,7 +266,7 @@ func followBackForScope(db *assetdb.AssetDB, asset *types.Entity, scope []string } else if rel, ok := edge.Relation.(*relation.SRVDNSRelation); ok && rel.Header.RRType != 33 { continue } - if from, err := db.Repo.FindEntityById(edge.FromEntity.ID); err == nil { + if from, err := db.FindEntityById(edge.FromEntity.ID); err == nil { if n, ok := from.Asset.(*domain.FQDN); ok && n != nil && domainNameInScope(n.Name, scope) { return true } else if followBackForScope(db, from, scope, since) {