Skip to content
Open
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
2 changes: 1 addition & 1 deletion dojo/api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ def update(self, instance, validated_data):

if push_to_jira or jira_services.is_keep_in_sync(instance):
# Push synchronously so that we can see jira errors in real time
success, message = jira_services.push(instance, sync=True)
success, message = jira_services.push(instance, force_sync=True)
if not success:
raise serializers.ValidationError(message)

Expand Down
2 changes: 1 addition & 1 deletion dojo/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def apply_async(self, args=None, kwargs=None, **options):
kwargs["async_user_id"] = user.id if user else None

# Control flag used for sync/async decision; never pass into the task itself
kwargs.pop("sync", None)
kwargs.pop("force_sync", None)

# Track dispatch
dojo_async_task_counter.incr(
Expand Down
2 changes: 1 addition & 1 deletion dojo/celery_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def dojo_dispatch_task(task_or_sig: _SupportsSi | _SupportsApplyAsync | Signatur

- Inject `async_user_id` if missing.
- Capture and inject pghistory context if available.
- Respect `sync=True` (foreground execution) and user `block_execution`.
- Respect `force_sync=True` (foreground execution) and user `block_execution`.
- Support `countdown=<seconds>` for async dispatch.

Returns:
Expand Down
6 changes: 3 additions & 3 deletions dojo/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def get_tasks(self):
def we_want_async(*args, func=None, **kwargs):
from dojo.utils import get_current_user # noqa: PLC0415 circular import

sync = kwargs.get("sync", False)
if sync:
logger.debug("dojo_async_task %s: running task in the foreground as sync=True has been found as kwarg", func)
force_sync = kwargs.get("force_sync", False)
if force_sync:
logger.debug("dojo_async_task %s: running task in the foreground as force_sync=True has been found as kwarg", func)
return False

user = get_current_user()
Expand Down
4 changes: 2 additions & 2 deletions dojo/finding/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def post_process_findings_batch(
push_to_jira=False,
jira_instance_id=None,
user=None,
sync=False,
force_sync=False,
**kwargs,
):

Expand Down Expand Up @@ -510,7 +510,7 @@ def post_process_findings_batch(
if product_grading_option and system_settings.enable_product_grade:
from dojo.celery_dispatch import dojo_dispatch_task # noqa: PLC0415 circular import

dojo_dispatch_task(calculate_grade, findings[0].test.engagement.product.id, sync=sync)
dojo_dispatch_task(calculate_grade, findings[0].test.engagement.product.id, force_sync=force_sync)

# If we received the ID of a jira instance, then we need to determine the keep in sync behavior
jira_instance = None
Expand Down
4 changes: 2 additions & 2 deletions dojo/finding_group/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def view_finding_group(request, fgid):
elif not finding_group.has_jira_issue:
jira_services.link_finding_group(request, finding_group, jira_issue)
elif push_to_jira:
jira_services.push(finding_group, sync=True)
jira_services.push(finding_group, force_sync=True)

finding_group.save()
return HttpResponseRedirect(reverse("view_test", args=(finding_group.test.id,)))
Expand Down Expand Up @@ -194,7 +194,7 @@ def push_to_jira(request, fgid):

# it may look like success here, but the push_to_jira are swallowing exceptions
# but cant't change too much now without having a test suite, so leave as is for now with the addition warning message to check alerts for background errors.
if jira_services.push(group, sync=True):
if jira_services.push(group, force_sync=True):
messages.add_message(
request,
messages.SUCCESS,
Expand Down
2 changes: 1 addition & 1 deletion dojo/importers/default_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def process_findings(
product_grading_option=True,
issue_updater_option=True,
push_to_jira=push_to_jira,
sync=kwargs.get("sync", False),
force_sync=kwargs.get("force_sync", False),
)

# No chord: tasks are dispatched immediately above per batch
Expand Down
2 changes: 1 addition & 1 deletion dojo/importers/default_reimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def process_findings(
issue_updater_option=True,
push_to_jira=push_to_jira,
jira_instance_id=getattr(self.jira_instance, "id", None),
sync=kwargs.get("sync", False),
force_sync=kwargs.get("force_sync", False),
)

# No chord: tasks are dispatched immediately above per batch
Expand Down
12 changes: 6 additions & 6 deletions unittests/test_async_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ def test_async_delete_product_with_hierarchy(self):
)

@override_settings(ASYNC_OBJECT_DELETE=True)
def test_async_delete_accepts_sync_kwarg(self):
def test_async_delete_accepts_force_sync_kwarg(self):
"""
Test that async_delete passes through the sync kwarg properly.
Test that async_delete passes through the force_sync kwarg properly.

The sync=True kwarg forces synchronous execution for the top-level task.
The force_sync=True kwarg forces synchronous execution for the top-level task.
However, nested task dispatches still need user context to run synchronously,
so we use impersonate here as well.
"""
Expand All @@ -265,14 +265,14 @@ def test_async_delete_accepts_sync_kwarg(self):

# Use impersonate to ensure nested tasks also run synchronously
with impersonate(self.testuser):
# Explicitly pass sync=True
# Explicitly pass force_sync=True
async_del = async_delete()
async_del.delete(product, sync=True)
async_del.delete(product, force_sync=True)

# Verify the product was deleted
self.assertFalse(
Product.objects.filter(pk=product_pk).exists(),
"Product should be deleted with sync=True",
"Product should be deleted with force_sync=True",
)

def test_async_delete_helper_methods(self):
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_reimport_prefetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _reimport_with_overridden_hashcode(self):
minimum_severity="Info",
active=True,
verified=True,
sync=True,
force_sync=True,
scan_type=SCAN_TYPE,
)
return reimporter.process_scan(scan)
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_update_import_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setUp(self):
minimum_severity="Info",
active=True,
verified=True,
sync=True,
force_sync=True,
scan_type="StackHawk HawkScan",
)
# Explicitly create the Test similar to Engagement creation
Expand Down
Loading