fixed: Replaced Scans alert() failures with toast feedback - #626
fixed: Replaced Scans alert() failures with toast feedback#626pranavv2707 wants to merge 874 commits into
Conversation
utksh1
left a comment
There was a problem hiding this comment.
The toast replacement is a useful direction, but this head is behind and required checks are failing. Please rebase on latest main/current CI baseline and fix frontend-checks/backend-lint before requesting review again.
a6a39cc to
fb56811
Compare
utksh1
left a comment
There was a problem hiding this comment.
Re-reviewed the latest push. This still has broad Scans/Workflows/phase test churn, no-final-newline changes, and production formatting churn around the toast change. Please narrow the PR to replacing alert failures with toast feedback, remove unrelated test rewrites, and rerun frontend checks.
utksh1
left a comment
There was a problem hiding this comment.
Rechecking after the latest commit: this is still blocked.
The frontend-checks job is failing on the current head. Please fix CI and keep the patch focused on replacing Scans alert failures with toast handling; unrelated Scans/Workflows churn should stay out of this PR.
Hi @utksh1 The ToastContext mock additions to Scans.test.tsx, ScansPhases.test.tsx, and Scans.polling.test.tsx are necessary because adding useToast() to Scans.tsx causes those tests to fail and those are minimal 5-line additions with no other changes to those files. Please do let know if i may remove all of them and commit just the scans alert page or any other alternative approach. |
…mit inside transactions The execute() method was auto-committing after every query, which broke the transaction semantics when used inside async with db.transaction() blocks. The first execute() call would commit the BEGIN, and subsequent operations would run outside the transaction. - Add _in_transaction flag (initially False) - begin() sets _in_transaction = True - commit() and rollback() reset _in_transaction = False - execute() only auto-commits when _in_transaction is False This was described in the original commit message for efa59f0 but the database.py changes were not included.
…icate anyio_backend fixture - Revert validation.py hostname regex changes (out of PR scope) - Revert ci.yml backend-tests condition rewrite (out of PR scope, use original) - Remove duplicate anyio_backend fixture in conftest.py to fix event loop issues
replace_asset_services in platform_resources.py calls db.transaction(), but _upsert_findings_and_report and _upsert_findings_and_report_from_scanner already wrap the call in an outer transaction, causing the SQLite error 'cannot start a transaction within a transaction'. fix: transaction()/begin()/commit()/rollback() all check _in_transaction and become no-ops when already inside a transaction, allowing safe nesting.
…tandard_scanner This call was added as part of the PR scope but does not exist on main. ScannerBase._execute_command already handles this validation for modular scanners. For standard scanners, command args are plugin-provided module names (e.g. 'windows.pslist.PsList') that falsely trigger the hostname regex and cause 'Hostname did not resolve' errors, breaking the volatility integration test.
On main, _execute_standard_scanner does not accept safe_mode. This param was added as part of the scope-creep validation call which has now been removed. Restoring the original signature.
Co-authored-by: Utkarsh Singh <[email protected]>
…ksh1#1328) wpscan is a Ruby gem, not a standalone binary, so the availability check reports it unavailable without explaining the prerequisites. Expand long_description, populate dependencies.system_packages with ruby/rubygems, clarify the API-token help, and refresh the checksum. Closes utksh1#842 Co-authored-by: Utkarsh Singh <[email protected]>
…ask status (utksh1#1312) * fix(cancel_task): add status guard to prevent overwriting completed task status Add AND status = ? WHERE clause to the cancel_task() UPDATE statement so that only RUNNING tasks can be transitioned to CANCELLED. Without this guard, a task that completes normally during the termination grace period (up to 5s) would have its COMPLETED status silently overwritten to CANCELLED, corrupting scan history. Fixes utksh1#1272 * fix: add safe_mode argument to test_execute_standard_scanner call * fix(ci): set asyncio_default_fixture_loop_scope to prevent Event loop is closed error --------- Co-authored-by: opencode-bot <[email protected]> Co-authored-by: Utkarsh Singh <[email protected]>
Closes utksh1#1623 The audit log only recorded scans that passed consent and safe-mode validation and began executing. Attempts rejected by the consent gate or blocked by safe-mode target validation left no entry, so an administrator could not reconstruct misuse attempts after the fact. Add audit log entries at the two points the issue describes: - scan_blocked_consent: logged when a request is rejected because consent was not granted. - scan_blocked_target_validation: logged when safe-mode target validation rejects the target (for example, a public IP or a domain resolving outside the allowed private ranges). Both entries record the plugin ID and are queryable via the existing audit_log table (event_type, plugin_id, context_json), consistent with the report_downloaded audit entries already in this codebase. Testing: - Added testing/backend/integration/test_scan_block_audit_log.py covering: consent rejection creates an entry, safe-mode target rejection creates an entry with target/safe_mode/reason in context, and a successful scan start creates neither entry. - Full backend unit suite: 2210 passed (6 pre-existing failures in test_parser_sandbox*/test_plugin_validator, confirmed present on main before this change, unrelated to routes.py). - Full backend integration suite: 287 passed, 9 skipped. - Parser contract tests (all 4 capability groups): passed. - ruff check backend testing/backend: passed. - scripts/check-artifacts.sh: passed. Signed-off-by: Anshul Jain <[email protected]>
The previous run failed on backend-unit due to pre-existing test flakiness (subprocess sandbox timing tests: test_parser_sandbox.py, test_parser_sandbox_timeout_cleanup.py, test_plugin_validator.py), confirmed present intermittently on main itself (3 of the last 4 main CI runs also failed on backend-unit with the same tests, unrelated to this PR's changes). Retriggering to get a clean run. Signed-off-by: Anshul Jain <[email protected]>
…ocked-scans fix: log blocked and failed scan attempts to the audit trail
…ualizer-deps-1407 fix(frontend): remove exhaustive-deps suppression from Findings virtualizer effect
…pi-client-return-types fix: tighten API client response types
…rror-handling test: add ApiKeySetupScreen error-handling tests
…-alerts-with-toast fix(scans): replace error banner with toast feedback for delete and rescan failures
…out-overlap-906-refactor-v2 refactor(plugins): decompose build_command, load_plugins, and validat…
fix: deduplicate findings across tasks using finding_group_id
…ction-atomicity fix(atomicity): wrap multi-step finding persistence in DB transactions
…-fallback fix: replace fail-open with in-memory fallback in rate limiter
|
Hello @utksh1 , |
utksh1
left a comment
There was a problem hiding this comment.
The production toast change has already landed, and the remaining diff is useful focused frontend regression coverage with the necessary ToastContext mocks. Please rebase this test-only branch onto current so GitHub can calculate a clean merge; after that, it is ready for merge review.
|
Clarification: please rebase this test-only branch onto the current main branch. Once GitHub reports a clean merge state, the focused regression coverage can proceed to merge review. |
Description
Replaced
alert()dialogs in the Scans page destructive-action failure paths with accessible toast notifications using the existingToastContext. Also adds test coverage for all three failure paths:Related Issues
Closes issue number #469
Type of Change
How Has This Been Tested?
Unit tests — 5 new tests in
Scans.failures.test.tsx:deleteTaskfailure shows error toast and keeps task in listbulkDeleteTasksfailure shows error toast and keeps tasks in listclearAllTasksfailure shows error toastChecklist
Issues Fixed
alert()dialogs for delete and clear-history failure paths, which block the page, cannot be styled, and are inaccessible to screen readers.alert()calls inhandleTaskDelete,handleClearAll, andhandleBulkDeletefailure paths withaddToast()from the existingToastContext.role="alert"so screen readers announce them automatically.Tests Added
frontend/testing/unit/pages/Scans.failures.test.tsx— 5 new tests covering:deleteTaskfailure shows error toast and keeps task in listbulkDeleteTasksfailure shows error toast and keeps tasks in listclearAllTasksfailure shows error toastHow to Test
cd frontend && npm run test— all 5 new tests should pass.npm run build— build should complete with no errors.Comments:
The npm audit failure is a pre-existing vulnerability on upstream main, not introduced by this PR.
This change only modifies frontend/src/pages/Scans.tsx and frontend/testing/unit/pages/Scans.failures.test.tsx.
I have sought assistance from LLMs and gituhub copilot to understand the codebase and guide implementation, as disclosed per the contributing guidelines.
I apologise for the large number of commits.
Screenshots for checks
Description: The screenshot shows the passing of all 5 tests.
Description: The screenshot shows the successful building after the running of the tests, generating no warnings.