🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@cap-js/audit-logging

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cap-js/audit-logging - npm Package Compare versions

Comparing version

to
0.3.1

35

lib/utils.js
const WRITE = { CREATE: 1, UPDATE: 1, DELETE: 1 }
const hasPersonalData = entity => {
if (!entity['@PersonalData.DataSubjectRole']) return
if (!entity['@PersonalData.EntitySemantics']) return
// default role to entity name
if (entity['@PersonalData.EntitySemantics'] === 'DataSubject' && !entity['@PersonalData.DataSubjectRole'])
entity['@PersonalData.DataSubjectRole'] = entity.name.match(/\w+/g).pop()
return !!Object.values(entity.elements).some(

@@ -151,11 +153,7 @@ element =>

const _ifDataSubject = (entity, role) => {
return entity['@PersonalData.EntitySemantics'] === 'DataSubject' && entity['@PersonalData.DataSubjectRole'] === role
}
const _getDataSubjectUp = (role, model, entity, prev, next, result) => {
const _getDataSubjectUp = (model, entity, prev, next, result) => {
for (const element of _getUps(entity, model)) {
const me = { entity, relative: element.parent, element }
if (prev) prev.next = me
if (_ifDataSubject(element.parent, role)) {
if (element.parent['@PersonalData.EntitySemantics'] === 'DataSubject') {
if (!result) result = { dataSubjectEntity: element.parent, subs: [] }

@@ -166,3 +164,3 @@ result.subs.push(next || me)

// dfs is a must here
result = _getDataSubjectUp(role, model, element.parent, me, next || me, result)
result = _getDataSubjectUp(model, element.parent, me, next || me, result)
}

@@ -173,7 +171,7 @@ }

const _getDataSubjectDown = (role, entity, prev, next) => {
const _getDataSubjectDown = (entity, prev, next) => {
const associations = Object.values(entity.associations || {}).filter(e => !e._isBacklink)
for (const element of associations) {
const me = { entity, relative: entity, element }
if (_ifDataSubject(element._target, role)) {
if (element._target['@PersonalData.EntitySemantics'] === 'DataSubject') {
if (prev) prev.next = me

@@ -187,3 +185,3 @@ return { dataSubjectEntity: element._target, subs: [next || me] }

if (prev) prev.next = me
const dataSubject = _getDataSubjectDown(role, element._target, me, next || me)
const dataSubject = _getDataSubjectDown(element._target, me, next || me)
if (dataSubject) return dataSubject

@@ -193,15 +191,16 @@ }

const getDataSubject = (entity, model, role) => {
const hash = '__dataSubject4' + role
const getDataSubject = (entity, model) => {
const hash = '__dataSubject'
if (entity.own(hash)) return entity[hash]
// entities with EntitySemantics 'DataSubjectDetails' or 'Other' must not necessarily
// be always below or always above 'DataSubject' entity in CSN tree
let dataSubject = _getDataSubjectUp(role, model, entity)
if (!dataSubject) dataSubject = _getDataSubjectDown(role, entity)
return entity.set(hash, dataSubject)
let dataSubjectInfo = _getDataSubjectUp(model, entity)
if (!dataSubjectInfo) dataSubjectInfo = _getDataSubjectDown(entity)
return entity.set(hash, dataSubjectInfo)
}
const addDataSubjectForDetailsEntity = (row, log, req, entity, model) => {
const role = entity['@PersonalData.DataSubjectRole']
const dataSubjectInfo = getDataSubject(entity, model, role)
const dataSubjectInfo = getDataSubject(entity, model)
const role = dataSubjectInfo.dataSubjectEntity['@PersonalData.DataSubjectRole']
log.data_subject.role ??= role
log.data_subject.type = dataSubjectInfo.dataSubjectEntity.name

@@ -208,0 +207,0 @@ /*

{
"name": "@cap-js/audit-logging",
"version": "0.3.0",
"description": "CDS plugin providing integration to the SAP BTP Audit Logging Service as well as out-of-the-box personal data-related audit logging based on annotations.",
"version": "0.3.1",
"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.",
"repository": "cap-js/audit-logging",

@@ -31,16 +31,15 @@ "author": "SAP SE (https://www.sap.com)",

"requires": {
"audit-log": true,
"audit-log": {
"handle": [
"READ",
"WRITE"
],
"[development]": {
"kind": "audit-log-to-console"
},
"[production]": {
"kind": "audit-log-to-restv2"
}
},
"kinds": {
"audit-log": {
"handle": [
"READ",
"WRITE"
],
"[development]": {
"kind": "audit-log-to-console"
},
"[production]": {
"kind": "audit-log-to-restv2"
}
},
"audit-log-to-console": {

@@ -47,0 +46,0 @@ "impl": "@cap-js/audit-logging/srv/log2console",

# Welcome to @cap-js/audit-logging
[![REUSE status](https://api.reuse.software/badge/github.com/cap-js/audit-logging)](https://api.reuse.software/info/github.com/cap-js/audit-logging)

@@ -13,3 +14,3 @@ ## About this project

The end-to-end out-of-the-box functionality provided by this plugin requires a paid-for instance of the [SAP Audit Logging Service for SAP BTP]([url](https://help.sap.com/docs/application-logging-service?locale=en-US)). However, it is possible to provide an own implementation that writes the audit logs to a custom store.
The end-to-end out-of-the-box functionality provided by this plugin requires a paid-for instance of the [SAP Audit Log service for customers](https://help.sap.com/docs/btp/sap-business-technology-platform/audit-log-write-api-for-customers?locale=en-US). However, it is possible to provide an own implementation that writes the audit logs to a custom store.

@@ -16,0 +17,0 @@ ## Support, Feedback, Contributing