Skip to content

Commit 3b2e803

Browse files
committed
improvements to the dynamic scoping system
1 parent 9a93650 commit 3b2e803

File tree

13 files changed

+59
-25
lines changed

13 files changed

+59
-25
lines changed

engine/dispatcher/dispatcher.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (d *dynamicDispatcher) completedCallback(ede *et.EventDataElement) {
103103

104104
func (d *dynamicDispatcher) DispatchEvent(e *et.Event) error {
105105
if e == nil || e.Entity == nil || e.Session == nil {
106-
return nil
106+
return errors.New("the event cannot be nil and must include the entity and session")
107107
}
108108

109109
// do not schedule the same asset more than once
@@ -129,6 +129,33 @@ func (d *dynamicDispatcher) DispatchEvent(e *et.Event) error {
129129
return pool.Dispatch(e)
130130
}
131131

132+
func (d *dynamicDispatcher) ResubmitEvent(e *et.Event) error {
133+
if e == nil || e.Entity == nil || e.Session == nil {
134+
return errors.New("the event cannot be nil and must include the entity and session")
135+
}
136+
137+
if !e.Session.Backlog().Has(e.Entity) {
138+
return errors.New("the event must already be in the backlog")
139+
}
140+
141+
if err := d.meta.InsertEntry(e.Session.ID().String(), e.Entity.ID, e.Meta); err != nil {
142+
return err
143+
}
144+
145+
err := e.Session.Backlog().Enqueue(e.Entity)
146+
if err != nil {
147+
return err
148+
}
149+
150+
atype := e.Entity.Asset.AssetType()
151+
pool := d.getOrCreatePool(atype)
152+
if pool == nil {
153+
return fmt.Errorf("no pipeline pool available for asset type %s", string(atype))
154+
}
155+
156+
return pool.Dispatch(e)
157+
}
158+
132159
func (d *dynamicDispatcher) getOrCreatePool(atype oam.AssetType) *pipelinePool {
133160
d.RLock()
134161
pool := d.pools[atype]

engine/plugins/api/dnsrepo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
1+
// Copyright © by Jeff Foley 2017-2026. All rights reserved.
22
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
33
// SPDX-License-Identifier: Apache-2.0
44

engine/plugins/horizontals/contact.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ func (h *horContact) lookup(e *et.Event, entity *dbt.Entity, since time.Time, co
7676
var results []*scope.Association
7777
if edges, err := e.Session.DB().OutgoingEdges(ctx, entity, since, labels...); err == nil && len(edges) > 0 {
7878
for _, edge := range edges {
79-
entity, err := e.Session.DB().FindEntityById(ctx, edge.ToEntity.ID)
79+
to, err := e.Session.DB().FindEntityById(ctx, edge.ToEntity.ID)
8080
if err != nil {
8181
continue
8282
}
8383
// check if these asset discoveries could change the scope
8484
if assocs, err := e.Session.Scope().IsAssociated(e.Session.DB(), &scope.Association{
85-
Submission: entity,
85+
Submission: to,
8686
Confidence: conf,
8787
ScopeChange: true,
8888
}); err == nil && len(assocs) > 0 {

engine/plugins/horizontals/fqdn.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func (h *horfqdn) checkPTR(e *et.Event, edges []*dbt.Edge, fqdn *dbt.Entity, sin
126126
}
127127

128128
for _, edge := range edges {
129+
// acquire the FQDN asset that represents the IP address (a.k.a. the pointer record)
129130
to, err := e.Session.DB().FindEntityById(ctx, edge.ToEntity.ID)
130131
if err != nil {
131132
continue
@@ -143,7 +144,7 @@ func (h *horfqdn) checkPTR(e *et.Event, edges []*dbt.Edge, fqdn *dbt.Entity, sin
143144
if e.Session.Config().Active {
144145
size = 250
145146
}
146-
h.plugin.submitIPAddresses(e, ip, h.plugin.source)
147+
h.plugin.submitIPAddress(e, ip, h.plugin.source)
147148
support.IPAddressSweep(e, ip, h.plugin.source, size, h.plugin.submitIPAddresses)
148149
e.Session.Log().Info(fmt.Sprintf("[%s: %s] was added to the session scope", ip.AssetType(), ip.Key()))
149150
}

engine/plugins/horizontals/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (h *horizPlugin) sweepAroundIPs(ctx context.Context, e *et.Event, nb *dbt.E
324324
}
325325
*/
326326

327-
func (h *horizPlugin) submitIPAddresses(e *et.Event, asset *oamnet.IPAddress, src *et.Source) {
327+
func (h *horizPlugin) submitIPAddress(e *et.Event, asset *oamnet.IPAddress, src *et.Source) {
328328
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
329329
defer cancel()
330330

engine/plugins/known_fqdn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
1+
// Copyright © by Jeff Foley 2017-2026. All rights reserved.
22
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
33
// SPDX-License-Identifier: Apache-2.0
44

engine/plugins/support/support.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ func AddSLDInScope(e *et.Event) {
284284
e.Meta = &FQDNMeta{
285285
SLDInScope: true,
286286
}
287+
return
287288
}
288289

289290
if fm, ok := e.Meta.(*FQDNMeta); ok {

engine/registry/pipelines.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
1+
// Copyright © by Jeff Foley 2017-2026. All rights reserved.
22
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
33
// SPDX-License-Identifier: Apache-2.0
44

engine/registry/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
1+
// Copyright © by Jeff Foley 2017-2026. All rights reserved.
22
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
33
// SPDX-License-Identifier: Apache-2.0
44

engine/registry/registry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © by Jeff Foley 2017-2025. All rights reserved.
1+
// Copyright © by Jeff Foley 2017-2026. All rights reserved.
22
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
33
// SPDX-License-Identifier: Apache-2.0
44

0 commit comments

Comments
 (0)