Skip to content
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

Add different pro banner for databases over 100k findings and endpoints #11665

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,10 @@ def saml2_attrib_map_format(dict):
"task": "dojo.notifications.helper.webhook_status_cleanup",
"schedule": timedelta(minutes=1),
},
"trigger_evaluate_pro_proposition": {
"task": "dojo.tasks.evaluate_pro_proposition",
"schedule": timedelta(hours=8),
},
# 'jira_status_reconciliation': {
# 'task': 'dojo.tasks.jira_status_reconciliation_task',
# 'schedule': timedelta(hours=12),
Expand Down
29 changes: 28 additions & 1 deletion dojo/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.utils import timezone

from dojo.celery import app
from dojo.models import Alerts, Engagement, Finding, Product, System_Settings, User
from dojo.models import Alerts, Announcement, Endpoint, Engagement, Finding, Product, System_Settings, User
from dojo.notifications.helper import create_notification
from dojo.utils import calculate_grade, sla_compute_and_notify

Expand Down Expand Up @@ -190,3 +190,30 @@ def jira_status_reconciliation_task(*args, **kwargs):
def fix_loop_duplicates_task(*args, **kwargs):
from dojo.finding.helper import fix_loop_duplicates
return fix_loop_duplicates()


@app.task
def evaluate_pro_proposition(*args, **kwargs):
# Ensure we should be doing this
if not settings.CREATE_CLOUD_BANNER:
return
# Get the announcement object
announcement = Announcement.objects.get_or_create(id=1)[0]
# Quick check for a user has modified the current banner - if not, exit early as we dont want to stomp
if not any(
entry in announcement.message
for entry in [
"",
"Cloud and On-Premise Subscriptions Now Available!",
"Findings/Endpoints in their systems",
]
):
return
# Count the objects the determine if the banner should be updated
object_count = Finding.objects.count() + Endpoint.objects.count()
# Unless the count is greater than 100k, exit early
if object_count < 100000:
return
# Update the announcement
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!'
announcement.save()
Loading