{"id":19755832,"url":"https://github.com/cap-js/audit-logging","last_synced_at":"2025-04-30T11:33:06.231Z","repository":{"id":189082080,"uuid":"653013549","full_name":"cap-js/audit-logging","owner":"cap-js","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.","archived":false,"fork":false,"pushed_at":"2024-10-29T12:51:39.000Z","size":138,"stargazers_count":4,"open_issues_count":10,"forks_count":3,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-10-29T15:19:16.583Z","etag":null,"topics":["audit-logging","cap","cds","nodejs","plugin","sap-btp","sap-cap"],"latest_commit_sha":null,"homepage":"https://cap.cloud.sap/docs/guides/data-privacy","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cap-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-13T08:41:10.000Z","updated_at":"2024-10-29T12:51:41.000Z","dependencies_parsed_at":"2023-08-18T07:29:22.651Z","dependency_job_id":"f6effabe-34a4-474d-b539-4833a4bbd9f0","html_url":"https://github.com/cap-js/audit-logging","commit_stats":null,"previous_names":["cap-js/audit-logging"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Faudit-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Faudit-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Faudit-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Faudit-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cap-js","download_url":"https://codeload.github.com/cap-js/audit-logging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251691523,"owners_count":21628335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit-logging","cap","cds","nodejs","plugin","sap-btp","sap-cap"],"created_at":"2024-11-12T03:13:36.162Z","updated_at":"2025-04-30T11:33:05.830Z","avatar_url":"https://github.com/cap-js.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to @cap-js/audit-logging\n\n[![REUSE status](https://api.reuse.software/badge/github.com/cap-js/audit-logging)](https://api.reuse.software/info/github.com/cap-js/audit-logging)\n\n`@cap-js/audit-logging` is a 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.\n\nDocumentation can be found at [cap.cloud.sap](https://cap.cloud.sap/docs/guides/data-privacy). \n\n\u003e [!IMPORTANT]\n\u003e The information in this file is by no means complete but enables you to get started quickly. Make sure to read the provided documentation at [cap.cloud.sap](https://cap.cloud.sap/docs/guides/data-privacy) to get the full picture. \n\n\n## Preliminaries\n\nIn this guide, we use the [Incidents Management reference sample app](https://github.com/cap-js/incidents-app) as the base to add change tracking to. Clone the repository and apply the step-by-step instructions:\n\n```sh\ngit clone https://github.com/cap-js/incidents-app\ncd incidents-app\nnpm i\n```\n\n\n## Setup\n\nTo enable audit logging, simply add this self-configuring plugin package to your project:\n\n```sh\nnpm add @cap-js/audit-logging\n```\n\n\n## Annotate Personal Data\n\nIdentify entities and elements (potentially) holding personal data using `@PersonalData` annotations. Create a `db/data-privacy.cds` file and add the following:\n\n```cds\nusing { sap.capire.incidents as my } from './schema';\n\nannotate my.Customers with @PersonalData : {\n  DataSubjectRole : 'Customer',\n  EntitySemantics : 'DataSubject'\n} {\n  ID           @PersonalData.FieldSemantics: 'DataSubjectID';\n  firstName    @PersonalData.IsPotentiallyPersonal;\n  lastName     @PersonalData.IsPotentiallyPersonal;\n  email        @PersonalData.IsPotentiallyPersonal;\n  phone        @PersonalData.IsPotentiallyPersonal;\n  creditCardNo @PersonalData.IsPotentiallySensitive;\n};\n\nannotate my.Addresses with @PersonalData: {\n  EntitySemantics : 'DataSubjectDetails'\n} {\n  customer      @PersonalData.FieldSemantics: 'DataSubjectID';\n  city          @PersonalData.IsPotentiallyPersonal;\n  postCode      @PersonalData.IsPotentiallyPersonal;\n  streetAddress @PersonalData.IsPotentiallyPersonal;\n};\n\nannotate my.Incidents with @PersonalData : {\n  EntitySemantics : 'Other'\n} {\n  customer @PersonalData.FieldSemantics: 'DataSubjectID';\n};\n\n```\nLearn more about the annotations in capire:\n- [@PersonalData.EntitySemantics](https://cap.cloud.sap/docs/guides/data-privacy/annotations#entitysemantics)\n- [@PersonalData.EntitySemantics: 'DataSubject'](https://cap.cloud.sap/docs/guides/data-privacy/annotations#datasubjectrole)\n- [@PersonalData.FieldSemantics: 'DataSubjectID'](https://cap.cloud.sap/docs/guides/data-privacy/annotations#fieldsemantics-datasubjectid)\n- [@PersonalData.IsPotentiallyPersonal](https://cap.cloud.sap/docs/guides/data-privacy/annotations#ispotentiallypersonal)\n- [@PersonalData.IsPotentiallySensitive](https://cap.cloud.sap/docs/guides/data-privacy/annotations#ispotentiallysensitive)\n\n\n## Test-Drive Locally\n\nYou've prepared everything to log personal data-related events. Let's see that in action.\n\nStart the server as usual:\n```sh\ncds watch\n```\n\nSend an update request that changes personal data:\n```http\nPATCH http://localhost:4004/odata/v4/admin/Customers('1004155')\nAuthorization: Basic alice:in-wonderland\nContent-Type: application/json\n\n{\n  \"firstName\": \"Danny\",\n  \"lastName\": \"Joules\"\n}\n```\n\nSee the audit logs in the server's console output:\n```sh\n[audit-log] - PersonalDataModified: {\n  data_subject: {\n    id: { ID: '1004155' },\n    role: 'Customer',\n    type: 'AdminService.Customers'\n  },\n  object: {\n   type: 'AdminService.Customers',\n   id: { ID: '1004155' }\n  },\n  attributes: [\n    { name: 'firstName', old: 'Daniel', new: 'Danny' },\n    { name: 'lastName', old: 'Watts', new: 'Joules' }\n  ],\n  uuid: '71fa93d9-c993-405f-ba1b-a9ef42668199',\n  tenant: 't1',\n  user: 'alice',\n  time: 2023-02-26T08:13:48.287Z\n}\n```\n\n\n## In Production\n\nThe 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.\n\n[_Learn more about using the SAP Audit Log service._](https://cap.cloud.sap/docs/guides/data-privacy/audit-logging#use-sap-audit-log-service)\n\n[_Learn more about custom audit logging._](https://cap.cloud.sap/docs/guides/data-privacy/audit-logging#custom-audit-logging)\n\n\n## Support, Feedback, Contributing\n\nThis project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/audit-logging/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).\n\n\n## Code of Conduct\n\nWe as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.\n\n\n## Licensing\n\nCopyright 2023 SAP SE or an SAP affiliate company and contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/cap-js/audit-logging).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-js%2Faudit-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap-js%2Faudit-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-js%2Faudit-logging/lists"}