Skip to content

Fix #1155: Refactor TaskExecutor to reduce complexity and improve maintainability#1239

Open
trivikramkalagi91-commits wants to merge 7 commits into
utksh1:mainfrom
trivikramkalagi91-commits:fix/layout-overlap-906-refactor-v2
Open

Fix #1155: Refactor TaskExecutor to reduce complexity and improve maintainability#1239
trivikramkalagi91-commits wants to merge 7 commits into
utksh1:mainfrom
trivikramkalagi91-commits:fix/layout-overlap-906-refactor-v2

Conversation

@trivikramkalagi91-commits

Copy link
Copy Markdown
Contributor

Description

This PR refactors the TaskExecutor component in backend/secuscan/executor.py to reduce complexity and improve maintainability.

Changes Made

  • Extracted guardrail validation logic into _enforce_guardrails()
  • Extracted Docker network setup logic into _ensure_docker_network()
  • Extracted modular scanner execution into _execute_modular_scanner()
  • Extracted standard scanner execution into _execute_standard_scanner()
  • Improved code readability through better separation of concerns
  • Added type hints and documentation for extracted helper methods
  • Added unit tests covering the new helper methods

This refactor preserves existing functionality while making the execution flow easier to understand, maintain, and test.


Related Issues

Fixes #1155


Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Note: This is primarily a code refactoring/maintenance improvement with no functional changes.


How Has This Been Tested?

Unit Tests

.\venv\Scripts\pytest testing/backend/unit/test_executor.py

Result:

27 passed

Integration Tests

.\venv\Scripts\pytest testing/backend/integration/test_docker_hardening.py

Result:

7 passed, 9 skipped

Manual Verification

  • Verified standard scanner execution flow remains unchanged.
  • Verified modular scanner execution works correctly.
  • Verified task status handling remains unchanged.
  • Verified findings and reports continue to be persisted correctly.
  • Verified no public APIs or database schemas were modified.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@trivikramkalagi91-commits

Copy link
Copy Markdown
Contributor Author

@utksh1 i have resolved the issue #1155 and the PR is completed with zero fails and all check have succesfully passed please review it as it is ready for merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor TaskExecutor in backend/secuscan/executor.py to Reduce Complexity and Improve Maintainability

1 participant