Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop multiple or all scans at once. #844

Merged
merged 8 commits into from
Dec 3, 2024

Conversation

elyousfi5
Copy link
Member

@elyousfi5 elyousfi5 commented Dec 3, 2024

This PR enhances the scan stop command to allow stopping multiple scans or all scans at once, improving the functionality from only stopping a single scan previously. The new feature provides more flexibility and efficiency in managing scans via the CLI.

Changes Introduced

  1. New Features:

    • Stop Multiple Scans: Users can now provide multiple scan IDs to stop them in a single command:
      ostorlab scan --runtime=local stop 1 2 3
    • Stop All Scans: Added --all flag to stop all running scans:
      ostorlab scan --runtime=local stop --all
  2. Error Handling:

    • If neither scan IDs nor the --all flag is provided, the command raises a UsageError.
  3. Improvements:

    • Clear and actionable console messages:
      • Number of scans being stopped is displayed.
      • Warning is shown if --all is used but no scans are running.
  4. Backward Compatibility:

    • The command still supports stopping a single scan as before.

Testing

Added new unit tests to ensure the functionality works as expected:

  1. Stopping multiple scans: Verified that the stop method is called for each provided scan ID.
  2. Stopping all scans: Validated that all running scans are stopped when --all is used.
  3. No scans running: Confirmed appropriate warning message is displayed when --all is used but no scans are found.

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 91.30435% with 6 lines in your changes missing coverage. Please review.

Project coverage is 62.69%. Comparing base (b985335) to head (2517c31).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/ostorlab/cli/scan/stop/stop.py 66.66% 5 Missing ⚠️
src/ostorlab/runtimes/local/runtime.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #844      +/-   ##
==========================================
+ Coverage   62.62%   62.69%   +0.06%     
==========================================
  Files         342      342              
  Lines       14430    14491      +61     
==========================================
+ Hits         9037     9085      +48     
- Misses       5393     5406      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

3asm
3asm previously approved these changes Dec 3, 2024
src/ostorlab/cli/scan/stop/stop.py Show resolved Hide resolved
src/ostorlab/cli/scan/stop/stop.py Outdated Show resolved Hide resolved
src/ostorlab/cli/scan/stop/stop.py Outdated Show resolved Hide resolved
src/ostorlab/cli/scan/stop/stop.py Outdated Show resolved Hide resolved
@elyousfi5 elyousfi5 merged commit 9f51337 into main Dec 3, 2024
12 checks passed
@elyousfi5 elyousfi5 deleted the feature/stop-multiple-or-all-scans-at-once branch December 3, 2024 12:02
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.

3 participants