forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update versions in application files * Update versions * Parse GitHub vulnerability version (DefectDojo#9462) * Fix SARIF parser with CodeQL rules (DefectDojo#9440) * fix for sarif parser with codeql rules * add check for extensions property * flake8 comparsion * finding sla expiration date field (part two) (DefectDojo#9494) * finding sla expiration date field (part two) * sla violation check updates * clean up of finding violates_sla property * flake8 fix * Update dojo/models.py Co-authored-by: Charles Neill <1749665+cneill@users.noreply.github.com> * Update 0201_populate_finding_sla_expiration_date.py --------- Co-authored-by: Charles Neill <1749665+cneill@users.noreply.github.com> * Jira Server/DataCenter: Update meta methods (DefectDojo#9512) * Jira Webhook: Catch comments from other issue updates (DefectDojo#9513) * Jira Webhook: Catch comments from other issue updates * Accommodate redirect responses * Update dojo/jira_link/views.py Co-authored-by: Charles Neill <1749665+cneill@users.noreply.github.com> * Fix syntax --------- Co-authored-by: Charles Neill <1749665+cneill@users.noreply.github.com> * add metrics page: "Product Tag Count" (fixes DefectDojo#9151) (DefectDojo#9152) * add metrics page: "Product Tag Count" It is fully based on "Product Type Count" metrics page. * fixup! add metrics page: "Product Tag Count" * Fix Flake8 * Update views.py --------- Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com> * Release Drafter: Try validating inputs * Disallow duplicate tool types (DefectDojo#9530) * Disallow duplicate tool types * Fix Flake8 * Only validate on new creations * Force new name on tool type unit test * Engagement Surveys: Add missing leading slash (DefectDojo#9531) URL redirects were behaving strangely without this leading slash. it seems it was missed when all the others were added * Update versions in application files * Update versions in application files * Dojo_Group: Support for "RemoteUser" in model (DefectDojo#9405) * Use correct name references * fix db_mig * Update and rename 0201_alter_dojo_group_social_provider.py to 0202_alter_dojo_group_social_provider.py --------- Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com> * Update rabbitmq:3.12.12-alpine Docker digest from 3.12.12 to 3.12.12-alpine (docker-compose.yml) (DefectDojo#9535) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * remove flot-axis library (DefectDojo#9540) * use full url for helm-repos and alias in renovate.json (DefectDojo#9525) With this change, renovate will create PRs to update the helm-dependencies, just as with docker-compose. Note that only setting the repository to the full URL did not work, I also had to add the registryAlias. * Update Helm release redis from 16.12.3 to ~16.13.0 (helm/defectdojo/Chart.yaml) (DefectDojo#9550) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update rabbitmq:3.12.12-alpine Docker digest from 3.12.12 to 3.12.12-alpine (docker-compose.yml) (DefectDojo#9541) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update postgres Docker tag from 16.1 to v16.2 (docker-compose.yml) (DefectDojo#9536) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update Helm release mysql from 9.1.8 to ~9.19.0 (helm/defectdojo/Chart.yaml) (DefectDojo#9545) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --------- Co-authored-by: DefectDojo release bot <dojo-release-bot@users.noreply.github.com> Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com> Co-authored-by: Colm O hEigeartaigh <coheigea@users.noreply.github.com> Co-authored-by: Andrei Serebriakov <ansereb@toloka.ai> Co-authored-by: Blake Owens <76979297+blakeaowens@users.noreply.github.com> Co-authored-by: Charles Neill <1749665+cneill@users.noreply.github.com> Co-authored-by: tomaszn <tomaszn@users.noreply.github.com> Co-authored-by: kiblik <tomas@kubla.sk> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Felix Hernandez <ffhg_920522@hotmail.com> Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
- Loading branch information
1 parent
8d71ee4
commit 187309a
Showing
40 changed files
with
693 additions
and
178 deletions.
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
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
133 changes: 133 additions & 0 deletions
133
dojo/db_migrations/0201_populate_finding_sla_expiration_date.py
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 |
---|---|---|
@@ -0,0 +1,133 @@ | ||
from django.db import migrations | ||
from django.utils import timezone | ||
from datetime import datetime | ||
from django.conf import settings | ||
from dateutil.relativedelta import relativedelta | ||
import logging | ||
|
||
from dojo.utils import get_work_days | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def calculate_sla_expiration_dates(apps, schema_editor): | ||
System_Settings = apps.get_model('dojo', 'System_Settings') | ||
|
||
ss, _ = System_Settings.objects.get_or_create() | ||
if not ss.enable_finding_sla: | ||
return | ||
|
||
logger.info('Calculating SLA expiration dates for all findings') | ||
|
||
SLA_Configuration = apps.get_model('dojo', 'SLA_Configuration') | ||
Finding = apps.get_model('dojo', 'Finding') | ||
|
||
findings = Finding.objects.filter(sla_expiration_date__isnull=True).order_by('id').only('id', 'sla_start_date', 'date', 'severity', 'test', 'mitigated') | ||
|
||
page_size = 1000 | ||
total_count = Finding.objects.filter(id__gt=0).count() | ||
logger.info('Found %d findings to be updated', total_count) | ||
|
||
i = 0 | ||
batch = [] | ||
last_id = 0 | ||
total_pages = (total_count // page_size) + 2 | ||
for p in range(1, total_pages): | ||
page = findings.filter(id__gt=last_id)[:page_size] | ||
for find in page: | ||
i += 1 | ||
last_id = find.id | ||
|
||
start_date = find.sla_start_date if find.sla_start_date else find.date | ||
|
||
sla_config = SLA_Configuration.objects.filter(id=find.test.engagement.product.sla_configuration_id).first() | ||
sla_period = getattr(sla_config, find.severity.lower(), None) | ||
|
||
days = None | ||
if settings.SLA_BUSINESS_DAYS: | ||
if find.mitigated: | ||
days = get_work_days(find.date, find.mitigated.date()) | ||
else: | ||
days = get_work_days(find.date, timezone.now().date()) | ||
else: | ||
if isinstance(start_date, datetime): | ||
start_date = start_date.date() | ||
|
||
if find.mitigated: | ||
days = (find.mitigated.date() - start_date).days | ||
else: | ||
days = (timezone.now().date() - start_date).days | ||
|
||
days = days if days > 0 else 0 | ||
|
||
days_remaining = None | ||
if sla_period: | ||
days_remaining = sla_period - days | ||
|
||
if days_remaining: | ||
if find.mitigated: | ||
find.sla_expiration_date = find.mitigated.date() + relativedelta(days=days_remaining) | ||
else: | ||
find.sla_expiration_date = timezone.now().date() + relativedelta(days=days_remaining) | ||
|
||
batch.append(find) | ||
|
||
if (i > 0 and i % page_size == 0): | ||
Finding.objects.bulk_update(batch, ['sla_expiration_date']) | ||
batch = [] | ||
logger.info('%s out of %s findings processed...', i, total_count) | ||
|
||
Finding.objects.bulk_update(batch, ['sla_expiration_date']) | ||
batch = [] | ||
logger.info('%s out of %s findings processed...', i, total_count) | ||
|
||
|
||
def reset_sla_expiration_dates(apps, schema_editor): | ||
System_Settings = apps.get_model('dojo', 'System_Settings') | ||
|
||
ss, _ = System_Settings.objects.get_or_create() | ||
if not ss.enable_finding_sla: | ||
return | ||
|
||
logger.info('Resetting SLA expiration dates for all findings') | ||
|
||
Finding = apps.get_model('dojo', 'Finding') | ||
|
||
findings = Finding.objects.filter(sla_expiration_date__isnull=False).order_by('id').only('id') | ||
|
||
page_size = 1000 | ||
total_count = Finding.objects.filter(id__gt=0).count() | ||
logger.info('Found %d findings to be reset', total_count) | ||
|
||
i = 0 | ||
batch = [] | ||
last_id = 0 | ||
total_pages = (total_count // page_size) + 2 | ||
for p in range(1, total_pages): | ||
page = findings.filter(id__gt=last_id)[:page_size] | ||
for find in page: | ||
i += 1 | ||
last_id = find.id | ||
|
||
find.sla_expiration_date = None | ||
batch.append(find) | ||
|
||
if (i > 0 and i % page_size == 0): | ||
Finding.objects.bulk_update(batch, ['sla_expiration_date']) | ||
batch = [] | ||
logger.info('%s out of %s findings processed...', i, total_count) | ||
|
||
Finding.objects.bulk_update(batch, ['sla_expiration_date']) | ||
batch = [] | ||
logger.info('%s out of %s findings processed...', i, total_count) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dojo', '0200_finding_sla_expiration_date_product_async_updating_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(calculate_sla_expiration_dates, reset_sla_expiration_dates), | ||
] |
18 changes: 18 additions & 0 deletions
18
dojo/db_migrations/0202_alter_dojo_group_social_provider.py
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.1.13 on 2024-01-25 00:07 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dojo', '0201_populate_finding_sla_expiration_date'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='dojo_group', | ||
name='social_provider', | ||
field=models.CharField(blank=True, choices=[('AzureAD', 'AzureAD'), ('Remote', 'Remote')], help_text='Group imported from a social provider.', max_length=10, null=True, verbose_name='Social Authentication Provider'), | ||
), | ||
] |
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
Oops, something went wrong.