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

feat(ui): bulk remove vulnerabilities #168

Merged
merged 17 commits into from
Sep 22, 2024

Conversation

0b3ud
Copy link
Contributor

@0b3ud 0b3ud commented Aug 26, 2024

Reading this issue I was able to split this feature in two tasks :

  • Selecting all vulnerabilities in vulnerability page
  • Bulk deleting selected vulnerabilities

Selecting all vulnerabilities in vulnerability page :

  1. Edited template in web/templates/base/_items/vulnerability_tab_content.html :
  • Added input called select_all_checkbox
    image


  1. Bulk deleting selected vulnerabilities :
  • Added a button for bulk deleting in template
    File : web/templates/base/_items/vulnerability_tab_content.html
    image

Results :

  • I've tested both function using the results of a scan I did on a metasploitable machine 💯
  • Selecting all seems to work 👍
  • Bulk deletion seems to work 👍

I would appreciate it if you can do some tests on your side and notify me if there are any bugs

Summary by Sourcery

Implement bulk operations for vulnerabilities, including selecting all, resolving, and deleting multiple vulnerabilities at once. Enhance the user interface to support these operations and improve the dynamic status update of vulnerabilities.

New Features:

  • Introduce a feature to select all vulnerabilities on the vulnerability page, allowing users to manage multiple vulnerabilities at once.
  • Add functionality for bulk deleting selected vulnerabilities, streamlining the process of removing multiple vulnerabilities simultaneously.

Enhancements:

  • Improve the user interface by adding buttons for bulk operations such as opening, resolving, and deleting selected vulnerabilities.
  • Enhance the vulnerability status change function to update the UI dynamically, reflecting the current status of vulnerabilities.

@0b3ud 0b3ud added the enhancement New feature or request label Aug 26, 2024
@0b3ud 0b3ud requested a review from psyray August 26, 2024 21:17
@0b3ud 0b3ud self-assigned this Aug 26, 2024
@0b3ud 0b3ud linked an issue Aug 26, 2024 that may be closed by this pull request
1 task
@AnonymousWP
Copy link
Member

Any reason why some of the content of your PR description is quoted?

@0b3ud
Copy link
Contributor Author

0b3ud commented Aug 26, 2024

Nope just wanted it to be easier to read
It turned out to be confusing my bad

@0b3ud 0b3ud added enhancement New feature or request and removed enhancement New feature or request labels Aug 26, 2024
@0b3ud
Copy link
Contributor Author

0b3ud commented Sep 4, 2024

Sept 4th 2024 Update :

This PR will add the following features :

  • Selecting all vulnerabilities in vulnerability page
  • Bulk deleting selected vulnerabilities
  • Bulk changing vulnerabilities status
  • Status Badge is clickable

Screenshot from 2024-09-04 12-05-23

  • I have changed the color of the trash button and put it in red
  • Collaborated with @psyray to make the status badges clickable to change vulnerability status
  • Added buttons resolve all and open all to change status of selected vulnerabilities

On my behalf I have tested it, and it seems to work 💯
Let me know if you identify any bugs 🥇

Copy link
Contributor

@psyray psyray left a comment

Choose a reason for hiding this comment

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

@0b3ud Thanks for this.

Could you use the Blue color for the open state, red is already used for vuln severity and it could be confusing

To be consistent with other tables could you move the mass actions buttons to the left side like in the subdomain table
image

And move the select all checkbox at the top of the table
image

@0b3ud
Copy link
Contributor Author

0b3ud commented Sep 6, 2024

Hey
Thanks for the review
Sure on it

@0b3ud Thanks for this.

Could you use the Blue color for the open state, red is already used for vuln severity and it could be confusing

To be consistent with other tables could you move the mass actions buttons to the left side like in the subdomain table image

And move the select all checkbox at the top of the table image

@0b3ud
Copy link
Contributor Author

0b3ud commented Sep 6, 2024

Sept 6th Update :

As requested I have changed the following :

  • Blue color for the open state
  • The mass actions buttons moved to the left side like in the subdomain table
  • Select all button is now in the table header
  • Changed some text and Added some icons :)

image

@AnonymousWP
Copy link
Member

@0b3ud Can you check the checkboxes where applicable? e.g. beginning of this PR and your latest post. Not checking them indicates it's not done.

@0b3ud
Copy link
Contributor Author

0b3ud commented Sep 7, 2024

@0b3ud Can you check the checkboxes where applicable? e.g. beginning of this PR and your latest post. Not checking them indicates it's not done.

Done :)

@psyray
Copy link
Contributor

psyray commented Sep 7, 2024

Don't have tested yet.
Tomorrow

@psyray
Copy link
Contributor

psyray commented Sep 10, 2024

@sourcery-ai review

Copy link
Contributor

sourcery-ai bot commented Sep 10, 2024

Reviewer's Guide by Sourcery

This pull request implements a new feature for bulk removal of vulnerabilities in the UI. The changes include adding a select-all checkbox for vulnerabilities, implementing bulk deletion functionality, and modifying the vulnerability status change mechanism.

File-Level Changes

Change Details Files
Implemented bulk selection and deletion of vulnerabilities
  • Added a select-all checkbox for vulnerabilities
  • Implemented a bulk delete button and its functionality
  • Created a new function 'bulk_vuln_status_change' to handle bulk status changes
  • Modified the vulnerability table to include checkboxes for each vulnerability
web/templates/base/_items/vulnerability_tab_content.html
web/static/custom/custom.js
web/startScan/templates/startScan/vulnerabilities.html
Updated vulnerability status change mechanism
  • Modified 'vuln_status_change' function to handle both OPEN and RESOLVED statuses
  • Updated the UI to show clickable status badges for each vulnerability
  • Added buttons for bulk opening and resolving of selected vulnerabilities
web/static/custom/custom.js
web/startScan/templates/startScan/vulnerabilities.html
web/templates/base/_items/vulnerability_tab_content.html
Adjusted UI elements and styling
  • Modified badge padding in custom.css
  • Updated click event handling for vulnerability table rows
  • Adjusted column widths and classes in the vulnerability table
web/static/custom/custom.css
web/startScan/templates/startScan/detail_scan.html
web/targetApp/templates/target/summary.html
web/startScan/templates/startScan/vulnerabilities.html

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @0b3ud - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Avoid hardcoding credentials in the code. (link)

Overall Comments:

  • Consider adding an extra confirmation step or more explicit UI warnings for bulk delete operations to prevent accidental data loss.
  • Some JavaScript functions, particularly those handling bulk operations, could be optimized for better performance with large datasets.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🔴 Security: 1 blocking issue
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

web/static/custom/custom.js Show resolved Hide resolved
web/static/custom/custom.js Show resolved Hide resolved
@AnonymousWP
Copy link
Member

Please finish this up so I can test this (after sourcery's suggestions).

@0b3ud
Copy link
Contributor Author

0b3ud commented Sep 12, 2024

Please finish this up so I can test this (after sourcery's suggestions).

Done you can test it now :)

@psyray
Copy link
Contributor

psyray commented Sep 18, 2024

Please finish this up so I can test this (after sourcery's suggestions).

Done you can test it now :)

Near perfect, just one thing, you need to disable mass change buttons if no checkbox is checked.
And if it's checked you display the number of checked vulns
Like in the subdomains list

Disabled
image

Enabled
image

function onchange(event) {
  toggleMultipleSubdomainButton()
}
function toggleMultipleSubdomainButton() {
  var checked_count = checkedCount();
  if (checked_count > 0) {
    $("[data-button=subdomain_btns]").removeClass("disabled");
    $('#subdomain_selected_count').text(checked_count + ' Subdomains Selected x');
  } else {
    $("[data-button=subdomain_btns]").addClass("disabled");
    $('#subdomain_selected_count').empty();
  }
}

@0b3ud
Copy link
Contributor Author

0b3ud commented Sep 20, 2024

Please finish this up so I can test this (after sourcery's suggestions).

Done you can test it now :)

Near perfect, just one thing, you need to disable mass change buttons if no checkbox is checked. And if it's checked you display the number of checked vulns Like in the subdomains list

Disabled image

Enabled image

function onchange(event) {
  toggleMultipleSubdomainButton()
}
function toggleMultipleSubdomainButton() {
  var checked_count = checkedCount();
  if (checked_count > 0) {
    $("[data-button=subdomain_btns]").removeClass("disabled");
    $('#subdomain_selected_count').text(checked_count + ' Subdomains Selected x');
  } else {
    $("[data-button=subdomain_btns]").addClass("disabled");
    $('#subdomain_selected_count').empty();
  }
}

Hey @psyray
Would you able to check
I have added the feature as demanded :)

@@ -298,7 +293,7 @@

$('#vulnerability_results').on('click', 'tr' , function (e) {
console.log(e.target);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove this console log

@psyray psyray merged commit 8b6313b into Security-Tools-Alliance:release/2.1.0 Sep 22, 2024
3 checks passed
@psyray psyray mentioned this pull request Sep 24, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(ui): Bulk remove vulnerabilities
3 participants