Skip to content

Commit

Permalink
initial round of updates for OAM v0.13.0 data types
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Feb 3, 2025
1 parent 5f6ef07 commit fc92b2e
Show file tree
Hide file tree
Showing 44 changed files with 548 additions and 365 deletions.
8 changes: 4 additions & 4 deletions cache/cache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -9,7 +9,7 @@ import (

"github.com/owasp-amass/asset-db/repository"
"github.com/owasp-amass/asset-db/types"
"github.com/owasp-amass/open-asset-model/property"
"github.com/owasp-amass/open-asset-model/general"
)

type Cache struct {
Expand Down Expand Up @@ -46,7 +46,7 @@ func (c *Cache) GetDBType() string {
}

func (c *Cache) createCacheEntityTag(entity *types.Entity, name string, since time.Time) error {
_, err := c.cache.CreateEntityProperty(entity, &property.SimpleProperty{
_, err := c.cache.CreateEntityProperty(entity, &general.SimpleProperty{
PropertyName: name,
PropertyValue: since.Format(time.RFC3339Nano),
})
Expand All @@ -63,7 +63,7 @@ func (c *Cache) checkCacheEntityTag(entity *types.Entity, name string) (*types.E
}

func (c *Cache) createCacheEdgeTag(edge *types.Edge, name string, since time.Time) error {
_, err := c.cache.CreateEdgeProperty(edge, &property.SimpleProperty{
_, err := c.cache.CreateEdgeProperty(edge, &general.SimpleProperty{
PropertyName: name,
PropertyValue: since.Format(time.RFC3339Nano),
})
Expand Down
2 changes: 1 addition & 1 deletion cache/cache_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion cache/edge.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion cache/edge_tag.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand Down
26 changes: 13 additions & 13 deletions cache/edge_tag_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -12,8 +12,8 @@ import (

"github.com/caffix/stringset"
"github.com/owasp-amass/asset-db/types"
"github.com/owasp-amass/open-asset-model/domain"
"github.com/owasp-amass/open-asset-model/property"
"github.com/owasp-amass/open-asset-model/dns"
"github.com/owasp-amass/open-asset-model/general"
"github.com/stretchr/testify/assert"
)

Expand All @@ -34,12 +34,12 @@ func TestCreateEdgeTag(t *testing.T) {
ctime := now.Add(-8 * time.Hour)
before := ctime.Add(-2 * time.Second)
after := ctime.Add(2 * time.Second)
entity, err := c.CreateAsset(&domain.FQDN{Name: "owasp.org"})
entity, err := c.CreateAsset(&dns.FQDN{Name: "owasp.org"})
assert.NoError(t, err)
tag, err := c.CreateEntityTag(entity, &types.EntityTag{
CreatedAt: ctime,
LastSeen: ctime,
Property: &property.SimpleProperty{
Property: &general.SimpleProperty{
PropertyName: "test",
PropertyValue: "foobar",
},
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestCreateEdgeProperty(t *testing.T) {
before := now.Add(-2 * time.Second)
edge, err := createTestEdge(c, now)
assert.NoError(t, err)
tag, err := c.CreateEdgeProperty(edge, &property.SimpleProperty{
tag, err := c.CreateEdgeProperty(edge, &general.SimpleProperty{
PropertyName: "test",
PropertyValue: "foobar",
})
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestFindEdgeTagById(t *testing.T) {

edge, err := createTestEdge(c, time.Now())
assert.NoError(t, err)
tag, err := c.CreateEdgeProperty(edge, &property.SimpleProperty{
tag, err := c.CreateEdgeProperty(edge, &general.SimpleProperty{
PropertyName: "test",
PropertyValue: "foobar",
})
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestFindEdgeTagsByContent(t *testing.T) {
cbefore1 := ctime1.Add(-20 * time.Second)
edge, err := createTestEdge(c, ctime1)
assert.NoError(t, err)
prop1 := &property.SimpleProperty{
prop1 := &general.SimpleProperty{
PropertyName: "test1",
PropertyValue: "foobar",
}
Expand All @@ -210,7 +210,7 @@ func TestFindEdgeTagsByContent(t *testing.T) {
// add some not so old stuff to the database
ctime2 := now.Add(-8 * time.Hour)
cbefore2 := ctime2.Add(-20 * time.Second)
prop2 := &property.SimpleProperty{
prop2 := &general.SimpleProperty{
PropertyName: "test2",
PropertyValue: "foobar",
}
Expand All @@ -222,7 +222,7 @@ func TestFindEdgeTagsByContent(t *testing.T) {
})
assert.NoError(t, err)
// add new entities to the database
prop3 := &property.SimpleProperty{
prop3 := &general.SimpleProperty{
PropertyName: "test3",
PropertyValue: "foobar",
}
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestGetEdgeTags(t *testing.T) {
_, err := c.db.CreateEdgeTag(target, &types.EdgeTag{
CreatedAt: ctime,
LastSeen: ctime,
Property: &property.SimpleProperty{
Property: &general.SimpleProperty{
PropertyName: "test",
PropertyValue: name,
},
Expand All @@ -311,7 +311,7 @@ func TestGetEdgeTags(t *testing.T) {
// add some new stuff to the database
for _, name := range []string{"www.owasp.org", "www.utica.edu", "www.sunypoly.edu"} {
set2.Insert(name)
_, err := c.CreateEdgeProperty(edge, &property.SimpleProperty{
_, err := c.CreateEdgeProperty(edge, &general.SimpleProperty{
PropertyName: "test",
PropertyValue: name,
})
Expand Down Expand Up @@ -405,7 +405,7 @@ func TestDeleteEdgeTag(t *testing.T) {
}
}

tag, err := c.CreateEdgeProperty(edge, &property.SimpleProperty{
tag, err := c.CreateEdgeProperty(edge, &general.SimpleProperty{
PropertyName: "test",
PropertyValue: "foobar",
})
Expand Down
34 changes: 17 additions & 17 deletions cache/edge_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -12,8 +12,8 @@ import (

"github.com/caffix/stringset"
"github.com/owasp-amass/asset-db/types"
"github.com/owasp-amass/open-asset-model/domain"
"github.com/owasp-amass/open-asset-model/relation"
"github.com/owasp-amass/open-asset-model/dns"
"github.com/owasp-amass/open-asset-model/general"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -80,7 +80,7 @@ func createTestEdge(cache *Cache, ctime time.Time) (*types.Edge, error) {
entity1, err := cache.CreateEntity(&types.Entity{
CreatedAt: ctime,
LastSeen: ctime,
Asset: &domain.FQDN{Name: "owasp.org"},
Asset: &dns.FQDN{Name: "owasp.org"},
})
if err != nil {
return nil, err
Expand All @@ -89,7 +89,7 @@ func createTestEdge(cache *Cache, ctime time.Time) (*types.Edge, error) {
entity2, err := cache.CreateEntity(&types.Entity{
CreatedAt: ctime,
LastSeen: ctime,
Asset: &domain.FQDN{Name: "www.owasp.org"},
Asset: &dns.FQDN{Name: "www.owasp.org"},
})
if err != nil {
return nil, err
Expand All @@ -98,9 +98,9 @@ func createTestEdge(cache *Cache, ctime time.Time) (*types.Edge, error) {
edge, err := cache.CreateEdge(&types.Edge{
CreatedAt: ctime,
LastSeen: ctime,
Relation: &relation.BasicDNSRelation{
Relation: &dns.BasicDNSRelation{
Name: "dns_record",
Header: relation.RRHeader{
Header: dns.RRHeader{
RRType: 5,
Class: 1,
TTL: 3600,
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestIncomingEdges(t *testing.T) {
from, err := c.CreateEntity(&types.Entity{
CreatedAt: ctime,
LastSeen: ctime,
Asset: &domain.FQDN{Name: "caffix.com"},
Asset: &dns.FQDN{Name: "caffix.com"},
})
assert.NoError(t, err)
time.Sleep(250 * time.Millisecond)
Expand All @@ -181,13 +181,13 @@ func TestIncomingEdges(t *testing.T) {
e, err := c.db.CreateEntity(&types.Entity{
CreatedAt: ctime,
LastSeen: ctime,
Asset: &domain.FQDN{Name: name},
Asset: &dns.FQDN{Name: name},
})
assert.NoError(t, err)
_, err = c.db.CreateEdge(&types.Edge{
CreatedAt: ctime,
LastSeen: ctime,
Relation: relation.SimpleRelation{Name: "node"},
Relation: general.SimpleRelation{Name: "node"},
FromEntity: dbfrom[0],
ToEntity: e,
})
Expand All @@ -201,10 +201,10 @@ func TestIncomingEdges(t *testing.T) {
var entities2 []*types.Entity
for _, name := range []string{"www.owasp.org", "www.utica.edu", "www.sunypoly.edu"} {
set2.Insert(name)
e, err := c.CreateAsset(&domain.FQDN{Name: name})
e, err := c.CreateAsset(&dns.FQDN{Name: name})
assert.NoError(t, err)
_, err = c.CreateEdge(&types.Edge{
Relation: relation.SimpleRelation{Name: "node"},
Relation: general.SimpleRelation{Name: "node"},
FromEntity: from,
ToEntity: e,
})
Expand Down Expand Up @@ -287,7 +287,7 @@ func TestOutgoingEdges(t *testing.T) {
from, err := c.CreateEntity(&types.Entity{
CreatedAt: ctime,
LastSeen: ctime,
Asset: &domain.FQDN{Name: "caffix.com"},
Asset: &dns.FQDN{Name: "caffix.com"},
})
assert.NoError(t, err)
time.Sleep(250 * time.Millisecond)
Expand All @@ -303,13 +303,13 @@ func TestOutgoingEdges(t *testing.T) {
e, err := c.db.CreateEntity(&types.Entity{
CreatedAt: ctime,
LastSeen: ctime,
Asset: &domain.FQDN{Name: name},
Asset: &dns.FQDN{Name: name},
})
assert.NoError(t, err)
_, err = c.db.CreateEdge(&types.Edge{
CreatedAt: ctime,
LastSeen: ctime,
Relation: relation.SimpleRelation{Name: "node"},
Relation: general.SimpleRelation{Name: "node"},
FromEntity: dbfrom[0],
ToEntity: e,
})
Expand All @@ -321,10 +321,10 @@ func TestOutgoingEdges(t *testing.T) {
// add some new stuff to the database
for _, name := range []string{"www.owasp.org", "www.utica.edu", "www.sunypoly.edu"} {
set2.Insert(name)
e, err := c.CreateAsset(&domain.FQDN{Name: name})
e, err := c.CreateAsset(&dns.FQDN{Name: name})
assert.NoError(t, err)
_, err = c.CreateEdge(&types.Edge{
Relation: relation.SimpleRelation{Name: "node"},
Relation: general.SimpleRelation{Name: "node"},
FromEntity: from,
ToEntity: e,
})
Expand Down
2 changes: 1 addition & 1 deletion cache/entity.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion cache/entity_tag.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

Expand Down
Loading

0 comments on commit fc92b2e

Please sign in to comment.