Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions app/service/data_svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,28 +280,34 @@ async def create_or_update_everything_adversary(self):
await self.store(obj)

async def _load(self, plugins=()):
try:
async_tasks = []
if not plugins:
plugins = [p for p in await self.locate('plugins') if p.data_dir and p.enabled]
if not [plugin for plugin in plugins if plugin.data_dir == 'data']:
plugins.append(Plugin(data_dir='data'))
for plug in plugins:
async_tasks = []
if not plugins:
plugins = [p for p in await self.locate('plugins') if p.data_dir and p.enabled]
if not [plugin for plugin in plugins if plugin.data_dir == 'data']:
plugins.append(Plugin(data_dir='data'))

for plug in plugins:
try:
await self._load_payloads(plug)
await self._load_abilities(plug, async_tasks)
await self._load_objectives(plug)
await self._load_adversaries(plug)
await self._load_planners(plug)
await self._load_sources(plug)
await self._load_packers(plug)
for task in async_tasks:
except Exception as e:
self.log.debug(repr(e), exc_info=True)

for task in async_tasks:
try:
await task
await self._load_extensions()
await self._load_data_encoders(plugins)
await self.create_or_update_everything_adversary()
await self._verify_data_sets()
except Exception as e:
self.log.debug(repr(e), exc_info=True)
except Exception as e:
self.log.debug(repr(e), exc_info=True)

await self._load_extensions()
await self._load_data_encoders(plugins)
await self.create_or_update_everything_adversary()
await self._verify_data_sets()

Comment on lines +307 to 311
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These critical operations at the end of the method are no longer wrapped in exception handling. If any of these methods fail, they will cause the entire _load method to fail and potentially crash the application. Consider adding try/except blocks around these operations or ensure they have their own internal error handling.

Copilot uses AI. Check for mistakes.

async def _load_adversaries(self, plugin):
for filename in glob.iglob('%s/adversaries/**/*.yml' % plugin.data_dir, recursive=True):
Expand Down