intrigueio / intrigue-core

Discover Your Attack Surface!
https://core.intrigue.io
Other
1.35k stars 262 forks source link

Fix enrichment notracecondition #372

Closed shpendk closed 3 years ago

shpendk commented 3 years ago

This small change fixes a bug that would fail to run tasks that have require_enrichment, and the entity type has more than 1 enrichment tasks. Although the changes to the entity are handled in a transaction, for some reason, the variable @entity would not get updated if another task sets @entity.enrichment_tasks_completed = etc(line 219 - 226 in lib/tasks/base.rb). Therefore, the condition in line 229 in file lib/tasks/base.rb would never fulfil:

is_fully_enriched = @entity.enrichment_tasks_completed.count == @entity.enrichment_tasks.count

As a result, the entity is never marked fully enriched, and any tasks that have require_enrichment fail to run.

The solution was to reload the @entity variable through Intrigue::Core::Model::Entity.find. There may be better ways, but this one definitely solves the problem.