Skip to content

Commit

Permalink
cleaning up some code
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Dec 9, 2024
1 parent 93004f0 commit 70928a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions engine/plugins/horizontals/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func (h *horContact) check(e *et.Event) error {
return nil
}

func (h *horContact) lookup(e *et.Event, asset *dbt.Entity, conf int) []*scope.Association {
func (h *horContact) lookup(e *et.Event, entity *dbt.Entity, conf int) []*scope.Association {
labels := []string{"organization", "location", "email"}

var results []*scope.Association
if edges, err := e.Session.Cache().OutgoingEdges(asset,
if edges, err := e.Session.Cache().OutgoingEdges(entity,
e.Session.Cache().StartTime(), labels...); err == nil && len(edges) > 0 {
for _, edge := range edges {
entity, err := e.Session.Cache().FindEntityById(edge.ToEntity.ID)
Expand Down
18 changes: 10 additions & 8 deletions engine/plugins/rdap/ipnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ func (r *ipnet) oneOfSources(e *et.Event, edge *dbt.Edge, src *et.Source, since
return false
}

func (r *ipnet) store(e *et.Event, resp *rdap.IPNetwork, asset *dbt.Entity, m *config.Matches) []*support.Finding {
func (r *ipnet) store(e *et.Event, resp *rdap.IPNetwork, entity *dbt.Entity, m *config.Matches) []*support.Finding {
var findings []*support.Finding
iprec := asset.Asset.(*oamreg.IPNetRecord)
iprec := entity.Asset.(*oamreg.IPNetRecord)

if u := r.plugin.getJSONLink(resp.Links); u != nil && m.IsMatch(string(oam.URL)) {
if a, err := e.Session.Cache().CreateAsset(u); err == nil && a != nil {
findings = append(findings, &support.Finding{
From: asset,
From: entity,
FromName: "IPNetRecord: " + iprec.Handle,
To: a,
ToName: u.Raw,
Expand All @@ -153,10 +153,12 @@ func (r *ipnet) store(e *et.Event, resp *rdap.IPNetwork, asset *dbt.Entity, m *c
}
}
if name := iprec.WhoisServer; name != "" && m.IsMatch(string(oam.FQDN)) {
if a, err := e.Session.Cache().CreateAsset(&domain.FQDN{Name: name}); err == nil && a != nil {
if _, conf := e.Session.Scope().IsAssetInScope(a.Asset, 0); conf > 0 {
fqdn := &domain.FQDN{Name: name}

if _, conf := e.Session.Scope().IsAssetInScope(fqdn, 0); conf > 0 {
if a, err := e.Session.Cache().CreateAsset(fqdn); err == nil && a != nil {
findings = append(findings, &support.Finding{
From: asset,
From: entity,
FromName: "IPNetRecord: " + iprec.Handle,
To: a,
ToName: name,
Expand All @@ -167,8 +169,8 @@ func (r *ipnet) store(e *et.Event, resp *rdap.IPNetwork, asset *dbt.Entity, m *c
}

if m.IsMatch(string(oam.ContactRecord)) {
for _, entity := range resp.Entities {
findings = append(findings, r.plugin.storeEntity(e, 1, &entity, asset, r.plugin.source, m)...)
for _, v := range resp.Entities {
findings = append(findings, r.plugin.storeEntity(e, 1, &v, entity, r.plugin.source, m)...)
}
}

Expand Down

0 comments on commit 70928a5

Please sign in to comment.