Skip to content

Commit

Permalink
Merge pull request #157 from safing/feature/delete-empty-filterlist-u…
Browse files Browse the repository at this point in the history
…pdate-entries

Delete filterlist entry if update has no sources
  • Loading branch information
dhaavi authored Sep 25, 2020
2 parents 32752b5 + 3474b04 commit 991d3eb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions intel/filterlists/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func normalizeEntry(entry *listEntry) {
func processEntry(ctx context.Context, filter *scopedBloom, entry *listEntry, records chan<- record.Record) error {
normalizeEntry(entry)

// Only add the entry to the bloom filter if it has any sources.
if len(entry.Sources) > 0 {
filter.add(entry.Type, entry.Entity)
}
Expand All @@ -208,6 +209,12 @@ func processEntry(ctx context.Context, filter *scopedBloom, entry *listEntry, re
UpdatedAt: time.Now().Unix(),
}

// If the entry is a "delete" update, actually delete it to save space.
if entry.Whitelist {
r.CreateMeta()
r.Meta().Delete()
}

key := makeListCacheKey(strings.ToLower(r.Type), r.Value)
r.SetKey(key)

Expand Down

0 comments on commit 991d3eb

Please sign in to comment.