Repository navigation
fix[backend+frontend](data-sources): applying a note no longer removes a source from its group (#2967) - #2975
Merged
Merged
Conversation
…via dedicated field endpoints (#2967)
❌ Go dependencies check failedThere are outdated Go dependencies, or modules that could not be inspected. Script output |
✅ AI review — Approved with warningsOnly minor (medium/low) issues were found. They won't block the merge, but consider addressing them.
|
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.
fixbackend+frontend: applying a note no longer removes a source from its group (#2967)
Problem
In Data Sources → Sources, clicking the pencil (Note) icon and "Apply note"
silently removed the source from its group:
dropped;
assetGroupId/assetGroupName, so theydropped out of the Datasource Group filter in Threat Management.
The note itself was saved — the group membership was collateral damage.
Root cause
assets-apply-note.component.ts(andasset-edit-alias.component.ts) calledutmNetScanService.update(asset)— the whole-entityPUT /api/utm-network-scans.The
assetwas the row fromsearch-by-filters, aNetworkScanDTO. That DTOcarries the group/type only as read-only objects (
group,assetType), notthe persisted
groupId/assetTypeIdcolumns (the entity maps them withinsertable = false, updatable = false). The endpoint deserializes the bodystraight into the
UtmNetworkScanentity andsave()s it, so the missing idswere persisted as
NULL→ the group was wiped.Any row action that sends the list row to that endpoint would clobber the same
columns — this is why the fix introduces dedicated single-field endpoints rather
than patching the DTO.
Fix
Backend — new field-scoped endpoints (mirroring the existing, safe
updateGroup/updateType), so only the intended column changes:PUT /api/utm-network-scans/updateNotes→UPDATE ... SET asset_notes = :v WHERE id IN :idsPUT /api/utm-network-scans/updateAlias→UPDATE ... SET asset_alias = :v WHERE id IN :idsupdateGroup/updateType: a missing id is ano-op (the
@Modifyingquery matches nothing), no extra existence check.@Modifyingqueries + service methods (updateNotes,updateAlias).Frontend —
assets-apply-notenow callsupdateNotes({value, assetsIds:[id]})and
asset-edit-aliasnow callsupdateAlias({value, assetsIds:[id]}). Bothpreviously sent the full row to the entity PUT.
Tests
Backend compiles clean (Maven, Java 17). No new JUnit test: the change is two
@ModifyingJPQL statements + a thin controller, verified by compile and by thefrontend pointing at the new endpoints. (A repository-integration test would need
a live DB, which this module's harness does not spin up.)
Files
backend/.../repository/network_scan/UtmNetworkScanRepository.javabackend/.../service/network_scan/UtmNetworkScanService.javabackend/.../web/rest/network_scan/UtmNetworkScanResource.javafrontend/.../assets-discover/shared/services/utm-net-scan.service.tsfrontend/.../assets-discover/shared/components/assets-apply-note/assets-apply-note.component.tsfrontend/.../assets-discover/shared/components/asset-edit-alias/asset-edit-alias.component.tsFixes #2967