feat: integrate cloud folder virus scanning into the frontend#274
Conversation
There was a problem hiding this comment.
Pull request overview
Integrates the backend async “folder virus scan” workflow into the Cloud UI by adding scan API calls, a polling-based scan dialog, and DTOs/tests to support the full scan state machine.
Changes:
- Added
CloudServiceAPIs to start a folder scan and poll scan job status. - Added scan dialog UI + polling lifecycle management and result rendering (infected / errored / clean / unavailable).
- Added DTOs for scan jobs/results and a dedicated
CloudComponentspec covering the scan state machine.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/app/services/cloud.service.ts | Adds startFolderScan and getScanJob HTTP APIs. |
| frontend/src/app/pages/cloud/cloud.component.ts | Implements scan state, polling control, and scan-result helpers. |
| frontend/src/app/pages/cloud/cloud.component.html | Adds “Scan” action and a scan status/results dialog. |
| frontend/src/app/pages/cloud/cloud.component.scss | Styles the scan dialog states and findings lists. |
| frontend/src/app/pages/cloud/cloud.component.spec.ts | Adds tests for scan polling, terminal states, and error/unavailable handling. |
| frontend/src/app/models/dtos/ScanJobDto.ts | Introduces ScanJobDto / ScanStatus types mirroring backend. |
| frontend/src/app/models/dtos/FileScanResultDto.ts | Introduces FileScanResultDto / ScanVerdict types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
A 429 while polling only means we asked too often; the scan itself is untouched and keeps running on the server. Tearing the dialog down and reporting "Lost track of the scan" was both wrong and unrecoverable. Back off to 5s and keep polling, giving up after 5 consecutive throttled attempts with a message that says the scan may still be running rather than claiming it failed. The counter resets on a successful poll and on each new scan.
|
Done in 3cfba9a — thanks for the catch, and it turned out to be more than a missing message. Aborting on a throttled poll was the wrong behaviour regardless of wording: a 429 says our polling was too frequent, not that the scan died. It keeps running server-side, so the old code threw away a scan that was still in progress, with no way back to it. Now a rate-limited poll backs off to 5s and keeps waiting. Only after 5 consecutive throttled attempts does it stop, and the message says the scan may still be running rather than claiming failure. The counter resets on any successful poll and on each new scan. Two tests added: one where a 429 is followed by a successful poll (the scan must stay in its running state, then complete normally), and one where the backend stays throttled (bounded retries, no false failure). |
DenizAltunkapan
left a comment
There was a problem hiding this comment.
@GabrielBBaldez thank you for your contribution!
Wires the Cloud Page folder virus scanning (backend Vault-Web/cloud-page#96) into the Cloud frontend.
What
POST /api/files/scan?path=<relative>.GET /api/files/scan/{jobId}(1.2s) and stops on a terminal status (COMPLETED/FAILED).PENDING/RUNNINGwith live files-scanned / infected counters, then renders findings on completion:ERRORverdict for every file) is surfaced as one clear message instead of a wall of per-file errors — "turned off on the server" vs. "currently unavailable, try again later".429) on start and start/poll failures (incl. an evicted job404) are handled with friendly messages rather than a generic crash.How
ScanJobDto/FileScanResultDtotypes mirror the backend DTOs.CloudService.startFolderScan/getScanJob.CloudComponent(dialog + toolbar action), with ascanRunIdgeneration guard (mirroring the existingcontentRequestIdpattern) so a closed dialog or a superseding scan can't leave a poll running.Testing
cloud.component.spec.tsexercises the full state machine with a mockedCloudServiceand Jasmine's fake clock: running→completed transition, polling termination, disabled/unreachable detection, clean result,429,404, and dialog-close (including a close that races the initial start request).ng test→ all green.ng build+ prettier clean.Closes #272