Open
Conversation
Contributor
There was a problem hiding this comment.
The PR introduces a useful rescan-on-download feature but has several correctness issues: the DB update predicate uses contentId instead of the row's primary key (risking unintended multi-row updates), the staleness boundary condition is ambiguous due to strict isAfter semantics, and the "exactly at threshold" test actually tests a 2-day-old scan rather than the real 3-day boundary—meaning the true edge case goes untested. Please address these before merging.
PR Bot Information
Version: 1.19.1 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback
- Event Trigger:
pull_request.opened - LLM:
anthropic--claude-4.6-sonnet - Correlation ID:
c303a440-25ff-11f1-8efb-8ca01d295655
.../java/com/sap/cds/feature/attachments/handler/applicationservice/ReadAttachmentsHandler.java
Show resolved
Hide resolved
.../java/com/sap/cds/feature/attachments/handler/applicationservice/ReadAttachmentsHandler.java
Show resolved
Hide resolved
...a/com/sap/cds/feature/attachments/handler/applicationservice/ReadAttachmentsHandlerTest.java
Outdated
Show resolved
Hide resolved
...a/com/sap/cds/feature/attachments/handler/applicationservice/ReadAttachmentsHandlerTest.java
Show resolved
Hide resolved
Add scannedAt to AttachmentModificationResult so that when an attachment service handler (e.g. TestPluginAttachmentsServiceHandler) sets both status=CLEAN and scannedAt on create, the timestamp is persisted to the DB via CreateAttachmentEvent. Without this, scannedAt remained null for CLEAN attachments, causing the rescan-on-download logic to incorrectly treat them as stale.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Rescan-on-Download Check for Attachments
New Feature
✨ Implements a rescan-on-download mechanism for attachments. When a user attempts to download an attachment that was last scanned more than 3 days ago (as recommended by the SAP Malware Scanning Service FAQ), the handler automatically transitions the attachment status to
SCANNING, triggers an asynchronous malware rescan, and rejects the current download. The client must retry after the rescan completes.Previously, only attachments with
UNSCANNED,SCANNING, ornullstatus were blocked/rescanned. Now, evenCLEANattachments are rescanned if their scan timestamp is stale or missing.Changes
Registration.java: Passes thePersistenceServiceto theReadAttachmentsHandlerconstructor.ReadAttachmentsHandler.java:PersistenceServiceas a constructor dependency.RESCAN_THRESHOLDconstant (3 days) to define the staleness window.needsScan(status, scannedAt)andisScanStale(scannedAt)helper methods.transitionToScanning(entity, attachment)method that updates the attachment status toSCANNINGin the persistence layer before triggering the async scan.BeforeReadItemsModifier.java: Extended the CQN modifier to also include thescannedAtfield in select items, ensuring the timestamp is available during the read event for staleness checks. Updated log messages and Javadoc accordingly.ReadAttachmentsHandlerTest.java: Added new test cases covering:nullscannedAttriggers rescan.PersistenceServiceis not called forUNSCANNEDattachments.BeforeReadItemsModifierTest.java: Added test helpers and assertions to verify thatscannedAtis included in select items for both expand and direct select scenarios.📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!
PR Bot Information
Version:
1.19.1| 📖 Documentation | 🚨 Create Incident | 💬 Feedbackanthropic--claude-4.6-sonnetpull_request.openedc303a440-25ff-11f1-8efb-8ca01d295655