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

Change plugins enabling in report flow to checkboxes #3747

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

noamblitz
Copy link
Contributor

@noamblitz noamblitz commented Oct 28, 2024

Changes

This PR changes the plugin tiles in the report flow to use checkboxes. This fixes the report flow because the checkboxes use a post request.

Issue link

Please add the link to the issue after "Closes".

Closes ...

Demo

image

QA notes

There might be regressions in the report flow because I renamed a variable that I think is unused, but I am not sure about that.

Code Checklist

  • All the commits in this PR are properly PGP-signed and verified.
  • This PR only contains functionality relevant to the issue.
  • I have written unit tests for the changes or fixes I made.
  • I have checked the documentation and made changes where necessary.
  • I have performed a self-review of my code and refactored it to the best of my abilities.
  • Tickets have been created for newly discovered issues.
  • For any non-trivial functionality, I have added integration and/or end-to-end tests.
  • I have informed others of any required .env changes files if required and changed the .env-dist accordingly.
  • I have included comments in the code to elaborate on what is not self-evident from the code itself, including references to issues and discussions online, or implicit behavior of an interface.

Checklist for code reviewers:

Copy-paste the checklist from the docs/source/templates folder into your comment.


Checklist for QA:

Copy-paste the checklist from the docs/source/templates folder into your comment.

@noamblitz noamblitz requested a review from a team as a code owner October 28, 2024 17:25
Copy link
Contributor

@ammar92 ammar92 left a comment

Choose a reason for hiding this comment

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

Nice work 👍 I just have a few tiny remarks, shouldn't be much work

rocky/reports/views/aggregate_report.py Outdated Show resolved Hide resolved

for selected_plugin in selected_plugins:
try:
get_katalogus(self.organization.code).enable_boefje_by_id(selected_plugin)
Copy link
Contributor

Choose a reason for hiding this comment

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

See earlier remark about the client

@@ -18,7 +18,7 @@
{% endfor %}
{% endif %}
{% for required_optional_plugin, plugins_ in plugins.items %}
{% for plugin in plugins_ %}<input type="hidden" name="plugin" value="{{ plugin.id }}">{% endfor %}
{% for plugin in plugins_ %}<input type="hidden" name="all_plugins" value="{{ plugin.id }}">{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be sure: The views still seem to refer to the plugin query parameter, so I'm unsure if this change works. Regardless, I think plugins as a query parameter list would've been a better name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah weird right. It seems that this variable is and was not used... But I'm afraid to delete it.

@stephanie0x00
Copy link
Contributor

Checklist for QA:

  • I have checked out this branch, and successfully ran a fresh make reset.
  • I confirmed that there are no unintended functional regressions in this branch:
    • I have managed to pass the onboarding flow
    • Objects and Findings are created properly
    • Tasks are created and completed properly
  • I confirmed that the PR's advertised feature or hotfix works as intended.
  • I checked the logs for errors and/or warnings and made issues where necessary

What works:

Seems to work. Couldn't find anything that breaks obviously.

What doesn't work:

n/a

Bug or feature?:

n/a

for selected_plugin in selected_plugins:
try:
client.enable_boefje_by_id(selected_plugin)
except HTTPError:
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate that we bubble up the http errors from the client to here. Lets move that away asap, the katalogusclient already has some localized exceptions for other issues.

Comment on lines 106 to 120
def post(self, request, *args, **kwargs):
selected_plugins = request.POST.getlist("plugin", [])

client = get_katalogus(self.organization.code)
for selected_plugin in selected_plugins:
try:
client.enable_boefje_by_id(selected_plugin)
except HTTPError:
messages.error(
request,
_("An error occurred while enabling {}. The plugin is not available.").format(selected_plugin),
)
return self.post(request, *args, **kwargs)
return super().post(request, *args, **kwargs)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this post to the ReportFinalSettingsView in base.py? Then it will be implemented for aggregate and multireport

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make sure that the user knows that by checking the checkboxes that it means enable and continue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm no I cant move it to there because these plugins are enabled only in the export step, and not taken all the way to the final step like the other settings.

And the button already says: enable and continue

@underdarknl underdarknl added the 😸 Review/QA feedback Review/QA feedback provided label Oct 31, 2024
@noamblitz
Copy link
Contributor Author

Permission checking now works. Can be tested by:

  • create new org member that is client
  • login with that member
  • follow report creation flow where not all plugins are enabled
  • check one of the checkboxes
  • see that report flow continues with error message

Copy link

sonarcloud bot commented Nov 12, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
16.7% Coverage on New Code (required ≥ 80%)
77.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@noamblitz noamblitz changed the title Change plugins enabling in report flwo to checkboxes Change plugins enabling in report flow to checkboxes Nov 13, 2024
@Rieven
Copy link
Contributor

Rieven commented Nov 20, 2024

I did a QA test and this was the result of it:

WHAT WORKS

  • Plugins checkboxes are visible
image
  • When not checking plugins, it will continue to next page. This is the intention, for those plugins then no enabling possible.
  • I can fully generate a report
  • When there is a required report, checkboxes are default checked.
image
  • Show enabled plugins shows other plugins already checked.
image

What doesn't work:

  • I have unchecked one of the required plugins and got a permissions error. I have a superuser status.
image
  • Even though there is a permissions error it continues to configuration page.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😸 Review/QA feedback Review/QA feedback provided
Projects
Status: QA review / functional testing
Development

Successfully merging this pull request may close these issues.

5 participants