Added Secondary Color, modified primary and secondary color

This commit is contained in:
Yogesh Ojha
2022-04-24 22:57:30 +05:30
parent 67aad6692b
commit 777e87a2cf
8 changed files with 108 additions and 16 deletions
+2 -2
View File
@@ -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 .
@@ -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),
),
]
@@ -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),
),
]
+2 -1
View File
@@ -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)
@@ -42,12 +42,24 @@ Customize Report
<span class="text-primary new-chk-content font-weight-bold">Primary Color for Report&nbsp;&nbsp;</span>
<label class="new-control new-checkbox new-checkbox-text checkbox-primary">
{{form.primary_color}}
<div class="color-picker"></div>
<div class="primary-color-picker"></div>
</label>
</div>
This color will be used for report cover, and headings.
</div>
</div>
<div class="row mt-4 mb-4">
<div class="col-12">
<div class="n-chk">
<span class="text-primary new-chk-content font-weight-bold">Secondary Color for Report&nbsp;</span>
<label class="new-control new-checkbox new-checkbox-text checkbox-primary">
{{form.secondary_color}}
<div class="secondary-color-picker"></div>
</label>
</div>
Secondary color is currently being used for cover background.
</div>
</div>
<b class="text-primary">Report Generated by:</b>
<div class="row mt-4 mb-4">
<div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-12">
@@ -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);
});
</script>
+4 -1
View File
@@ -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)
+5 -1
View File
@@ -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)
+1 -1
View File
@@ -75,7 +75,7 @@
}
@page :first {
background-color: #424242;
background-color: {{secondary_color}};
background-size: cover;
margin: 0;
}