Skip to content

Commit bd613d1

Browse files
authored
Add different pro banner for databases over 100k findings and endpoints (#11665)
* Add different pro banner for databases over 100k * Update message
1 parent 061b20d commit bd613d1

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

dojo/settings/settings.dist.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,10 @@ def saml2_attrib_map_format(dict):
11471147
"task": "dojo.notifications.helper.webhook_status_cleanup",
11481148
"schedule": timedelta(minutes=1),
11491149
},
1150+
"trigger_evaluate_pro_proposition": {
1151+
"task": "dojo.tasks.evaluate_pro_proposition",
1152+
"schedule": timedelta(hours=8),
1153+
},
11501154
# 'jira_status_reconciliation': {
11511155
# 'task': 'dojo.tasks.jira_status_reconciliation_task',
11521156
# 'schedule': timedelta(hours=12),

dojo/tasks.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.utils import timezone
1111

1212
from dojo.celery import app
13-
from dojo.models import Alerts, Engagement, Finding, Product, System_Settings, User
13+
from dojo.models import Alerts, Announcement, Endpoint, Engagement, Finding, Product, System_Settings, User
1414
from dojo.notifications.helper import create_notification
1515
from dojo.utils import calculate_grade, sla_compute_and_notify
1616

@@ -190,3 +190,30 @@ def jira_status_reconciliation_task(*args, **kwargs):
190190
def fix_loop_duplicates_task(*args, **kwargs):
191191
from dojo.finding.helper import fix_loop_duplicates
192192
return fix_loop_duplicates()
193+
194+
195+
@app.task
196+
def evaluate_pro_proposition(*args, **kwargs):
197+
# Ensure we should be doing this
198+
if not settings.CREATE_CLOUD_BANNER:
199+
return
200+
# Get the announcement object
201+
announcement = Announcement.objects.get_or_create(id=1)[0]
202+
# Quick check for a user has modified the current banner - if not, exit early as we dont want to stomp
203+
if not any(
204+
entry in announcement.message
205+
for entry in [
206+
"",
207+
"Cloud and On-Premise Subscriptions Now Available!",
208+
"Findings/Endpoints in their systems",
209+
]
210+
):
211+
return
212+
# Count the objects the determine if the banner should be updated
213+
object_count = Finding.objects.count() + Endpoint.objects.count()
214+
# Unless the count is greater than 100k, exit early
215+
if object_count < 100000:
216+
return
217+
# Update the announcement
218+
announcement.message = f'Only professionals have {object_count:,} Findings and Endpoints in their systems... <a href="https://www.defectdojo.com/pricing" target="_blank">Get DefectDojo Pro</a> today!'
219+
announcement.save()

0 commit comments

Comments
 (0)