From 777e87a2cfb1cc2bee483c4e4ae26f8980fa0d77 Mon Sep 17 00:00:00 2001 From: Yogesh Ojha Date: Tue, 12 Oct 2021 01:29:50 +0530 Subject: [PATCH] Added Secondary Color, modified primary and secondary color --- web/scanEngine/forms.py | 4 +- ...erabilityreportsettings_secondary_color.py | 18 ++++++ .../migrations/0020_auto_20211011_1959.py | 23 +++++++ web/scanEngine/models.py | 3 +- .../templates/scanEngine/settings/report.html | 63 ++++++++++++++++--- web/scanEngine/views.py | 5 +- web/startScan/views.py | 6 +- web/templates/report/template.html | 2 +- 8 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 web/scanEngine/migrations/0019_vulnerabilityreportsettings_secondary_color.py create mode 100644 web/scanEngine/migrations/0020_auto_20211011_1959.py diff --git a/web/scanEngine/forms.py b/web/scanEngine/forms.py index 98a40609..b1174001 100644 --- a/web/scanEngine/forms.py +++ b/web/scanEngine/forms.py @@ -604,8 +604,8 @@ class ReportForm(forms.ModelForm): self.initial['show_rengine_banner'] = True self.initial['show_footer'] = False self.initial['show_executive_summary'] = False - self.initial['primary_color'] = '#FF7043' - self.initial['secondary_color'] = '#424242' + self.initial['primary_color'] = '#FFB74D' + self.initial['secondary_color'] = '#212121' self.initial['executive_summary_description'] = '''On **{scan_date}**, **{target_name}** engaged **{company_name}** to perform a security audit on their Web application. **{company_name}** performed both Security Audit and Reconnaissance using automated tool reNgine. https://github.com/yogeshojha/rengine . diff --git a/web/scanEngine/migrations/0019_vulnerabilityreportsettings_secondary_color.py b/web/scanEngine/migrations/0019_vulnerabilityreportsettings_secondary_color.py new file mode 100644 index 00000000..b94afa0e --- /dev/null +++ b/web/scanEngine/migrations/0019_vulnerabilityreportsettings_secondary_color.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.4 on 2021-10-11 19:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scanEngine', '0018_alter_vulnerabilityreportsettings_primary_color'), + ] + + operations = [ + migrations.AddField( + model_name='vulnerabilityreportsettings', + name='secondary_color', + field=models.CharField(blank=True, default='#424242', max_length=10, null=True), + ), + ] diff --git a/web/scanEngine/migrations/0020_auto_20211011_1959.py b/web/scanEngine/migrations/0020_auto_20211011_1959.py new file mode 100644 index 00000000..c33575e3 --- /dev/null +++ b/web/scanEngine/migrations/0020_auto_20211011_1959.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.4 on 2021-10-11 19:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scanEngine', '0019_vulnerabilityreportsettings_secondary_color'), + ] + + operations = [ + migrations.AlterField( + model_name='vulnerabilityreportsettings', + name='primary_color', + field=models.CharField(blank=True, default='#FFB74D', max_length=10, null=True), + ), + migrations.AlterField( + model_name='vulnerabilityreportsettings', + name='secondary_color', + field=models.CharField(blank=True, default='#212121', max_length=10, null=True), + ), + ] diff --git a/web/scanEngine/models.py b/web/scanEngine/models.py index 6f6570f3..4c975175 100644 --- a/web/scanEngine/models.py +++ b/web/scanEngine/models.py @@ -95,7 +95,8 @@ class Hackerone(models.Model): class VulnerabilityReportSettings(models.Model): id = models.AutoField(primary_key=True) - primary_color = models.CharField(max_length=10, null=True, blank=True, default='#FF7043') + primary_color = models.CharField(max_length=10, null=True, blank=True, default='#FFB74D') + secondary_color = models.CharField(max_length=10, null=True, blank=True, default='#212121') company_name = models.CharField(max_length=100, null=True, blank=True) company_address = models.CharField(max_length=200, null=True, blank=True) company_email = models.CharField(max_length=100, null=True, blank=True) diff --git a/web/scanEngine/templates/scanEngine/settings/report.html b/web/scanEngine/templates/scanEngine/settings/report.html index ee3d0bbc..b24de5d0 100644 --- a/web/scanEngine/templates/scanEngine/settings/report.html +++ b/web/scanEngine/templates/scanEngine/settings/report.html @@ -42,12 +42,24 @@ Customize Report Primary Color for Report   This color will be used for report cover, and headings. +
+
+
+ Secondary Color for Report  + +
+ Secondary color is currently being used for cover background. +
+
Report Generated by:
@@ -146,16 +158,16 @@ new SimpleMDE({ spellChecker: false, }); -const pickr = Pickr.create({ - el: '.color-picker', +const primary_pickr = Pickr.create({ + el: '.primary-color-picker', theme: 'monolith', // or 'monolith', or 'nano' swatches: [ - 'rgb(57, 73, 171)', - 'rgb(30, 136, 229)', - 'rgb(69, 90, 100)', - 'rgb(229, 57, 53)', - 'rgb(0, 150, 136)', + 'rgb(79, 195, 247)', + 'rgb(100, 181, 246)', + 'rgb(77, 208, 225)', + 'rgb(255, 183, 77)', + 'rgb(255, 138, 101)', ], default: '{{primary_color}}', @@ -174,8 +186,39 @@ const pickr = Pickr.create({ } }); -pickr.on('save', (color, instance) => { - document.getElementById("primary_color").value = pickr.getColor().toHEXA().toString(0); +primary_pickr.on('save', (color, instance) => { + document.getElementById("primary_color").value = primary_pickr.getColor().toHEXA().toString(0); +}); + +const secondary_pickr = Pickr.create({ + el: '.secondary-color-picker', + theme: 'monolith', // or 'monolith', or 'nano' + + swatches: [ + 'rgb(33,33,33)', + 'rgb(66,66,66)', + 'rgb(52, 73, 94)', + 'rgb(44, 62, 80)', + ], + + default: '{{secondary_color}}', + + components: { + // Main components + preview: true, + opacity: true, + hue: true, + // Input / output Options + interaction: { + hex: true, + input: true, + save: true + } + } +}); + +secondary_pickr.on('save', (color, instance) => { + document.getElementById("secondary_color").value = secondary_pickr.getColor().toHEXA().toString(0); }); diff --git a/web/scanEngine/views.py b/web/scanEngine/views.py index d7b8fbc7..62330fe1 100644 --- a/web/scanEngine/views.py +++ b/web/scanEngine/views.py @@ -443,12 +443,14 @@ def report_settings(request): form = ReportForm() context['form'] = form - primary_color = '#FF7043' + primary_color = '#FFB74D' + secondary_color = '#212121' report = None if VulnerabilityReportSettings.objects.all().exists(): report = VulnerabilityReportSettings.objects.all()[0] primary_color = report.primary_color + secondary_color = report.secondary_color form.set_value(report) else: form.set_initial() @@ -472,5 +474,6 @@ def report_settings(request): context['report_settings_li'] = 'active' context['settings_ul_show'] = 'show' context['primary_color'] = primary_color + context['secondary_color'] = secondary_color return render(request, 'scanEngine/settings/report.html', context) diff --git a/web/startScan/views.py b/web/startScan/views.py index 312a4fae..7c6b75de 100644 --- a/web/startScan/views.py +++ b/web/startScan/views.py @@ -639,7 +639,9 @@ def customize_report(request, id): def create_report(request, id): - primary_color = '#FF7043' + primary_color = '#FFB74D' + secondary_color = '#212121' + scan_object = ScanHistory.objects.get(id=id) unique_vulnerabilities = Vulnerability.objects.filter(scan_history=scan_object).values("name", "severity").annotate(count=Count('name')).order_by('-severity', '-count') all_vulnerabilities = Vulnerability.objects.filter(scan_history=scan_object).order_by('-severity') @@ -675,6 +677,7 @@ def create_report(request, id): data['show_executive_summary'] = report.show_executive_summary primary_color = report.primary_color + secondary_color = report.secondary_color description = report.executive_summary_description @@ -696,6 +699,7 @@ def create_report(request, id): data['executive_summary_description'] = markdown.markdown(description) data['primary_color'] = primary_color + data['secondary_color'] = secondary_color template = get_template('report/template.html') html = template.render(data) diff --git a/web/templates/report/template.html b/web/templates/report/template.html index caa36c24..50ba6657 100644 --- a/web/templates/report/template.html +++ b/web/templates/report/template.html @@ -75,7 +75,7 @@ } @page :first { - background-color: #424242; + background-color: {{secondary_color}}; background-size: cover; margin: 0; }