Skip to main content

Adds audit trail to any Google Datastore NDB entity

Project description

Build Status

Adds an immutable audit trail to any NDB entity (including Expando-based models) built by the engineering team at Gain Compliance.

Data structures are optimized for write performance and query-ability at the expense of read performance and size of data. However, it is minimally invasive on the entity you add it to. It only adds two properties to the main entity totalling 32 characters and does not prevent you from doing normal get by key

You should read the below description of the data model (and especially entity groups) to ensure you don’t cause datastore contention problems with EGs that are too big

Features

  • Full history of an entity’s changes are recorded in a way that should be easily query-able

  • Audit history is atomically updated when the entity is put, even if all the entity’s properties are the same

  • Supports account (string), timestamp (datetime), data_hash (SHA-1 of properties) tracking

  • Strongly consistent retrieval of audit history

  • (WIP)Flexible “tagging” system to track progress along the chain of changes by a user, system, etc

  • (Future) “at revision” fetching of data

  • (Future) Diffing between revisions

  • (Future) Collision detection and merging

Data Model

For a given entity ‘E’ of kind ‘EKind’, ndb_audit will monitor all puts to entities who include the AuditMixin. Upon put a new Audit entity ‘A’ will be created which will be a complete copy of the entity. The entity A will have the following:

  • A will be of kind ‘Audit’

  • A will carry the namespace if the namespace_manager is used

  • A will contain a copy of every datastore property of E as it was when it was put

  • The parent entity of A will be E

  • The key of A will be ndb.Key(parent=, pairs=[(‘Audit’, )])

  • An attribute will be added to E called ‘d’, and a python property will be added to your class to access this value as data_hash. This value is added to your entity to allow caching based on the data_hash by all clients. At a given value for data_hash E will always be the same. The data_hash is a truncated SHA-1 hash of properties of the entity

  • An attribute will be added to E called ‘h’, and a python property will be added to your class to access this value as rev_hash. This value is added to your entity to allow you to track which revision the current entity is at. The rev_hash is a truncated SHA-1 hash of parent rev_hash, account string, and data_hash properties of the entity

  • No other properties will be added to E, instead you will have to fetch the audit entities – this is to keep overhead on E as small as possible

Usage

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndb_audit-1.1.10.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

ndb_audit-1.1.10-py2-none-any.whl (6.0 kB view details)

Uploaded Python 2

File details

Details for the file ndb_audit-1.1.10.tar.gz.

File metadata

  • Download URL: ndb_audit-1.1.10.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ndb_audit-1.1.10.tar.gz
Algorithm Hash digest
SHA256 215f82eaf5d52920a86e4d8fc636011f6a239e9dbbd18234ba212ebeb433cfce
MD5 579f7339dce9a007422dbc7aa4a36d52
BLAKE2b-256 48a8288baac0db1b3d23df1ff74b51e4e9e309c87c96dab5104a531b2e76c371

See more details on using hashes here.

File details

Details for the file ndb_audit-1.1.10-py2-none-any.whl.

File metadata

File hashes

Hashes for ndb_audit-1.1.10-py2-none-any.whl
Algorithm Hash digest
SHA256 9209d7de0e5b8f3e331ab8f0df62d57690950029dd20ab7eabee4cbaac192aae
MD5 4fa5f3eff96f621ce54e7391df4ce9d0
BLAKE2b-256 b50e6c6eb971500cd84d90f8fc752dae061029a1e83fd72dc1ece7982842b77d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page