Repository navigation
Cleanup threat intel resources - #109
Open
caffeinatedpixel wants to merge 1 commit into
Open
caffeinatedpixel wants to merge 1 commit into
caffeinatedpixel wants to merge 1 commit into
Conversation
caffeinatedpixel
commented
Sep 28, 2026
Contributor
- Closes threat intel feed files opened during the threat intel sync process
- Adds a timeout to the online feed request
lisaSW
requested changes
Oct 29, 2026
| err = server.updateFeed(&entry, feeds[entry.Path].LastModified, feed, writer.WriteChannel) | ||
| if feed != nil { | ||
| if closeErr := feed.Close(); closeErr != nil { | ||
| return fmt.Errorf("failed to close threat intel feed after updating: %w", closeErr) |
Contributor
There was a problem hiding this comment.
Would it make sense to just log a warning here if the close fails instead of returning an error? If the cleanup fails we would be cancelling the whole import, and if updateFeed also errored this ends up returning the close error instead of the real one below. Would something like this work?
logger.Warn().Err(closeErr).Str("feed", entry.Path).Msg("[THREAT INTEL] Failed to close feed")| if err = server.addNewFeed(path, &entry, feed, writer.WriteChannel); err != nil { | ||
| err = server.addNewFeed(path, &entry, feed, writer.WriteChannel) | ||
| if closeErr := feed.Close(); closeErr != nil { | ||
| return fmt.Errorf("failed to close threat intel feed after adding as new: %w", closeErr) |
Contributor
There was a problem hiding this comment.
Same question as on line 192
| checkThreatIntel(t, db) | ||
| } | ||
|
|
||
| func (d *ThreatIntelSuite) TestThreatIntelFeedFilesClosing() { |
Contributor
There was a problem hiding this comment.
Could we add a case where a feed fails partway through being read, kind of like the “Server Stops Partway Through The Feed” case you did in the database package, but for a file? Then check that the sync returns the error, opened still equals closed, and no writer goroutine is left over.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.