-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Per-Project SLA Config #6413
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
Merged
Merged
Per-Project SLA Config #6413
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
5cce1de
manually rebased on upstream/dev
37b 0426e47
rebased and cleaned up
37b 8a93eea
Merge branch 'dev' of https://github.com/DefectDojo/django-DefectDojo…
37b 273723a
updated jira test product data to include sla_configuration
37b 5a0526d
accessibility fix
37b 5517e07
pep8 fixes
37b 122ed28
merged latest from dev
37b bed75cc
merged latest with dev and fixed some tests
37b 14eb5b4
cleaned up imports
37b 782277b
manually rebased on upstream/dev
37b a626e43
rebased and cleaned up
37b df325da
pep8 fixes
37b 63121e2
merged latest with dev and fixed some tests
37b c377386
cleaned up imports
37b 470eefd
rebase changes
37b fa7f6c0
bug fix
37b e9af554
bug fix for default SLA configuration
37b ef4314c
another bug fix for new products
37b a59ef19
Merge branch 'dev' into sla_fix
37b 4ac168f
permission fixes
37b 5f34f31
testing migration
37b 3f5399d
test
37b e7bd53b
Merge branch 'dev' into sla_fix
37b c334038
testing separate migration files
37b bddd592
testing
37b cfe8af9
testing
37b bf03e3b
testing
37b 04826b6
testing
37b 2dd97e8
testing
37b bc5c5af
migrate existing SLA config in System Settings to Default entry
37b 12aef52
pep8 fixes
37b 4c73b9d
pep8 fixes
37b a8f56c2
removed platform specifier from docker-compose files
37b 1ac9305
permission fixes
37b 28e8ed5
pep8 fix
37b 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 hidden or 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 hidden or 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 hidden or 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,59 @@ | ||
# Generated by Django 3.2.13 on 2022-05-28 20:06 | ||
import logging | ||
|
||
from django.db import migrations, models | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# def save_existing_sla(apps, schema_editor): | ||
# system_settings_model = apps.get_model('dojo', 'System_Settings') | ||
# | ||
# try: | ||
# system_settings = system_settings_model.objects.get() | ||
# critical = system_settings.sla_critical, | ||
# high = system_settings.sla_high, | ||
# medium = system_settings.sla_medium, | ||
# low = system_settings.sla_low | ||
# except: | ||
# critical = 7 | ||
# high = 30 | ||
# medium = 90 | ||
# low = 120 | ||
# | ||
# SLA_Configuration = apps.get_model('dojo', 'SLA_Configuration') | ||
# SLA_Configuration.objects.create(name='Default', | ||
# description='The Default SLA Configuration. Products not using an explicit SLA Configuration will use this one.', | ||
# critical=critical, | ||
# high=high, | ||
# medium=medium, | ||
# low=low) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('dojo', '0164_remove_system_settings_staff_user_email_pattern'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='SLA_Configuration', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(help_text='A unique name for the set of SLAs.', max_length=128, unique=True, | ||
verbose_name='Custom SLA Name')), | ||
('description', models.CharField(blank=True, max_length=512, null=True)), | ||
('critical', models.IntegerField(default=7, help_text='number of days to remediate a critical finding.', | ||
verbose_name='Critical Finding SLA Days')), | ||
('high', models.IntegerField(default=30, help_text='number of days to remediate a high finding.', | ||
verbose_name='High Finding SLA Days')), | ||
('medium', models.IntegerField(default=90, help_text='number of days to remediate a medium finding.', | ||
verbose_name='Medium Finding SLA Days')), | ||
('low', models.IntegerField(default=120, help_text='number of days to remediate a low finding.', | ||
verbose_name='Low Finding SLA Days')), | ||
], | ||
options={ | ||
'ordering': ['name'], | ||
}, | ||
) | ||
] |
This file contains hidden or 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,65 @@ | ||
# Generated by Django 3.2.14 on 2022-07-28 13:11 | ||
import logging | ||
|
||
import django.db.models.deletion | ||
|
||
from django.db import migrations, models | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def save_existing_sla(apps, schema_editor): | ||
system_settings_model = apps.get_model('dojo', 'System_Settings') | ||
|
||
try: | ||
system_settings = system_settings_model.objects.get() | ||
critical = system_settings.sla_critical | ||
high = system_settings.sla_high | ||
medium = system_settings.sla_medium | ||
low = system_settings.sla_low | ||
|
||
except: | ||
critical = 7 | ||
high = 30 | ||
medium = 90 | ||
low = 120 | ||
|
||
sla_config = apps.get_model('dojo', 'SLA_Configuration') | ||
sla_config.objects.create(name='Default', | ||
description='The Default SLA Configuration. Products not using an explicit SLA Configuration will use this one.', | ||
critical=critical, | ||
high=high, | ||
medium=medium, | ||
low=low) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('dojo', '0165_custom_sla'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(save_existing_sla), | ||
migrations.RemoveField( | ||
model_name='system_settings', | ||
name='sla_critical', | ||
), | ||
migrations.RemoveField( | ||
model_name='system_settings', | ||
name='sla_high', | ||
), | ||
migrations.RemoveField( | ||
model_name='system_settings', | ||
name='sla_low', | ||
), | ||
migrations.RemoveField( | ||
model_name='system_settings', | ||
name='sla_medium', | ||
), | ||
migrations.AddField( | ||
model_name='product', | ||
name='sla_configuration', | ||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.RESTRICT, related_name='sla_config', | ||
to='dojo.sla_configuration'), | ||
), | ||
] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Empty file.
Oops, something went wrong.
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.
This a good place for this, but I fear product maintainers could swap an SLA conf to something a bit more forgiving (thinking the worst of people here)
Possible solution would be to not display this field unless user has owner role (similar to how jira options are toggled based on enablement)
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.
How would the value be set during creation? I'm still learning Django's idioms...