Skip to content

Commit e184be4

Browse files
committed
changed how the IP sweep filtering works
1 parent fb14be8 commit e184be4

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

engine/plugins/dns/plugin.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,17 @@ func (d *dnsPlugin) lookupWithinTTL(session et.Session, name string, atype oam.A
236236
}
237237

238238
func sweepCallback(e *et.Event, ip *oamnet.IPAddress, src *et.Source) {
239-
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
239+
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
240240
defer cancel()
241241

242+
// ensure we do not work on an IP address that was processed previously
243+
_, err := e.Session.DB().FindEntitiesByContent(ctx, oam.IPAddress, e.Session.StartTime(), 1, dbt.ContentFilters{
244+
"address": ip.Address.String(),
245+
})
246+
if err == nil {
247+
return
248+
}
249+
242250
entity, err := e.Session.DB().CreateAsset(ctx, ip)
243251
if err == nil && entity != nil {
244252
_, _ = e.Session.DB().CreateEntityProperty(ctx, entity, &general.SourceProperty{

engine/plugins/horizontals/plugin.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,17 @@ func (h *horizPlugin) sweepAroundIPs(ctx context.Context, e *et.Event, nb *dbt.E
325325
*/
326326

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

331+
// ensure we do not work on an IP address that was processed previously
332+
_, err := e.Session.DB().FindEntitiesByContent(ctx, oam.IPAddress, e.Session.StartTime(), 1, dbt.ContentFilters{
333+
"address": asset.Address.String(),
334+
})
335+
if err == nil {
336+
return
337+
}
338+
331339
addr, err := e.Session.DB().CreateAsset(ctx, asset)
332340
if err == nil && addr != nil {
333341
_, _ = e.Session.DB().CreateEntityProperty(ctx, addr, &oamgen.SourceProperty{

engine/plugins/support/support.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,10 @@ func AddNetblock(session et.Session, cidr string, asn int, src *et.Source) error
170170
}
171171

172172
func IPAddressSweep(e *et.Event, addr *oamnet.IPAddress, src *et.Source, size int, callback SweepCallback) {
173-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
174-
defer cancel()
175-
176-
// ensure we do not work on an IP address that was processed previously
177-
_, err := e.Session.DB().FindEntitiesByContent(ctx, oam.IPAddress, e.Session.StartTime(), 1, dbt.ContentFilters{
178-
"address": addr.Address.String(),
179-
})
180-
if err == nil {
181-
return
182-
}
183-
184173
var mask net.IPMask
185174
addrstr := addr.Address.String()
186175
ip := net.ParseIP(addrstr)
176+
187177
if amassnet.IsIPv4(ip) {
188178
mask = net.CIDRMask(18, 32)
189179
} else if amassnet.IsIPv6(ip) {

0 commit comments

Comments
 (0)