-
Notifications
You must be signed in to change notification settings - Fork 58
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
noamblitz
wants to merge
13
commits into
main
Choose a base branch
from
fix/report-flow-plugins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0ddb769
change plugins to checkboxes
noamblitz 9c7503b
lang update
noamblitz 55e76da
Update rocky/reports/views/aggregate_report.py
noamblitz 32fe327
update generate_report.py
noamblitz 0cfb16a
Merge branch 'main' into fix/report-flow-plugins
noamblitz 8803173
Merge branch 'main' into fix/report-flow-plugins
stephanie0x00 c06d271
Merge branch 'main' into fix/report-flow-plugins
underdarknl 74327ea
check for permissions
noamblitz b80fde3
Merge branch 'main' into fix/report-flow-plugins
noamblitz 43edb75
make lang
noamblitz 9b9f04b
Merge branch 'fix/report-flow-plugins' of https://github.com/minvws/n…
noamblitz eb13517
permission checking for aggregate report
noamblitz 7ed66fd
make lang
noamblitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
from typing import Any | ||
|
||
from django.contrib import messages | ||
from django.http import HttpRequest, HttpResponse | ||
from django.shortcuts import redirect | ||
from django.urls import reverse | ||
from django.utils.translation import gettext_lazy as _ | ||
from django.views.generic import TemplateView | ||
from httpx import HTTPError | ||
from katalogus.client import get_katalogus | ||
|
||
from reports.report_types.aggregate_organisation_report.report import AggregateOrganisationReport | ||
from reports.views.base import ( | ||
|
@@ -107,6 +110,28 @@ class ExportSetupAggregateReportView( | |
current_step = 4 | ||
report_type = AggregateOrganisationReport | ||
|
||
def post(self, request, *args, **kwargs): | ||
selected_plugins = request.POST.getlist("plugin", []) | ||
|
||
if not selected_plugins: | ||
return super().post(request, *args, **kwargs) | ||
|
||
if not self.organization_member.has_perms("tools.can_enable_disable_boefje"): | ||
messages.error(request, _("You do not have the required permissions to enable plugins.")) | ||
super().post(request, *args, **kwargs) | ||
|
||
client = get_katalogus(self.organization.code) | ||
for selected_plugin in selected_plugins: | ||
try: | ||
client.enable_boefje_by_id(selected_plugin) | ||
except HTTPError: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
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) | ||
|
||
|
||
class SaveAggregateReportView(SaveAggregateReportMixin, BreadcrumbsAggregateReportView, SaveReportView): | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-11-11 15:02+0000\n" | ||
"POT-Creation-Date: 2024-11-12 10:48+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -1599,7 +1599,6 @@ msgstr "" | |
#: onboarding/templates/account/step_2a_organization_update.html | ||
#: onboarding/templates/account/step_2b_indemnification_setup.html | ||
#: onboarding/templates/step_3d_clearance_level_introduction.html | ||
#: reports/templates/partials/report_setup_scan.html | ||
msgid "Continue" | ||
msgstr "" | ||
|
||
|
@@ -2365,7 +2364,8 @@ msgstr "" | |
msgid "Please select all required plugins to proceed." | ||
msgstr "" | ||
|
||
#: onboarding/views.py | ||
#: onboarding/views.py reports/views/aggregate_report.py | ||
#: reports/views/generate_report.py | ||
msgid "An error occurred while enabling {}. The plugin is not available." | ||
msgstr "" | ||
|
||
|
@@ -4030,6 +4030,10 @@ msgstr "" | |
msgid "There are no optional plugins." | ||
msgstr "" | ||
|
||
#: reports/templates/partials/report_setup_scan.html | ||
msgid "Enable plugins and continue" | ||
msgstr "" | ||
|
||
#: reports/templates/partials/report_severity_totals.html | ||
#: reports/templates/partials/report_severity_totals_table.html | ||
msgid "Findings overview" | ||
|
@@ -4349,6 +4353,10 @@ msgstr "" | |
msgid "Save report" | ||
msgstr "" | ||
|
||
#: reports/views/aggregate_report.py reports/views/generate_report.py | ||
msgid "You do not have the required permissions to enable plugins." | ||
msgstr "" | ||
|
||
#: reports/views/base.py | ||
msgid "Select at least one OOI to proceed." | ||
msgstr "" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 thinkplugins
as a query parameter list would've been a better nameThere was a problem hiding this comment.
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.