Skip to content

Commit e0ea7f6

Browse files
sjvansBobdenOs
andauthored
fix: data subject lookup when not exposed (#185)
Co-authored-by: Bob den Os <108393871+BobdenOs@users.noreply.github.com>
1 parent 709e2cc commit e0ea7f6

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## Version 1.1.1 - 2025-10-27
8+
9+
### Fixed
10+
11+
- Data subject lookup when data subject is not exposed in the same service
12+
713
## Version 1.1.0 - 2025-09-08
814

915
### Added

lib/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ const _keyColumns = (keys, alias) => {
108108
.map(key => ({ ref: [alias, key.name] }))
109109
}
110110

111-
const _alias = entity => entity.name.replace(`${entity._service.name}.`, '').replace('.', '_')
111+
const _alias = entity => {
112+
// REVISIT: we should not rely on entity._service (but I don't want to break existing behavior right now)
113+
if (!entity._service) return `${entity}`
114+
return entity.name.replace(`${entity._service.name}.`, '').replace(/\./g, '_')
115+
}
112116

113117
const _buildSubSelect = (model, { entity, relative, element, next }, row, previousCqn) => {
114118
// relative is a parent or an entity itself

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cap-js/audit-logging",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "CDS plugin providing integration to the SAP Audit Log service as well as out-of-the-box personal data-related audit logging based on annotations.",
55
"repository": "cap-js/audit-logging",
66
"author": "SAP SE (https://www.sap.com)",

test/personal-data/crud.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,4 +2054,17 @@ describe('personal data audit logging in CRUD', () => {
20542054
await POST('/crud-5/A', { text: 'foo' }, { auth: ALICE })
20552055
expect(_logs.length).toBe(1)
20562056
})
2057+
2058+
test('with data subject not in service', async () => {
2059+
await POST('/crud-6/D', { c_ID: '17609000-3860-415b-b007-1b59dae2a198', text: 'I am personal' }, { auth: ALICE })
2060+
expect(_logs.length).toBe(1)
2061+
expect(_logs[0]).toMatchObject({
2062+
data_subject: { role: 'C', type: 'sap.auditlog.test.personal_data.db.C' },
2063+
object: { type: 'CRUD_6.D', id: { ID: expect.any(String) } },
2064+
attributes: [{ name: 'text', new: 'I am personal' }],
2065+
uuid: expect.any(String),
2066+
user: 'alice',
2067+
time: expect.any(Date)
2068+
})
2069+
})
20572070
})

test/personal-data/db/schema.cds

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ type dummies {
9191
}
9292

9393
entity Notes : cuid {
94-
note : String;
95-
attachment : Association to AddressAttachment;
96-
customerStatus : Association to CustomerStatus;
94+
note : String;
95+
attachment : Association to AddressAttachment;
96+
customerStatus : Association to CustomerStatus;
9797
dummyArray : many dummies;
9898
}
9999

@@ -169,6 +169,12 @@ entity C {
169169
text : String;
170170
}
171171

172+
entity D {
173+
key ID : UUID;
174+
text : String;
175+
c : Association to C;
176+
}
177+
172178
annotate A with @PersonalData : {EntitySemantics: 'DataSubjectDetails'} {
173179
c @PersonalData.FieldSemantics: 'DataSubjectID';
174180
text @PersonalData.IsPotentiallyPersonal;
@@ -183,3 +189,8 @@ annotate C with @PersonalData : {EntitySemantics: 'DataSubject'} {
183189
ID @PersonalData.FieldSemantics: 'DataSubjectID';
184190
text @PersonalData.IsPotentiallyPersonal;
185191
}
192+
193+
annotate D with @PersonalData : {EntitySemantics: 'Other'} {
194+
c @PersonalData.FieldSemantics: 'DataSubjectID';
195+
text @PersonalData.IsPotentiallyPersonal;
196+
}

test/personal-data/srv/crud-service.cds

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,9 @@ service CRUD_5 {
216216
entity C as projection on db.C;
217217

218218
}
219+
220+
@path : '/crud-6'
221+
@requires: 'admin'
222+
service CRUD_6 {
223+
entity D as projection on db.D;
224+
}

0 commit comments

Comments
 (0)