Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit-entity generation and automatic auditing #2349

Open
homedirectory opened this issue Oct 25, 2024 · 0 comments
Open

Audit-entity generation and automatic auditing #2349

homedirectory opened this issue Oct 25, 2024 · 0 comments

Comments

@homedirectory
Copy link
Contributor

homedirectory commented Oct 25, 2024

Description

The goals of this issue are:

  1. Introduce a simple tool to generate audit-entities, which should work similary to the GenDdl tool, which is used in TG applications.
  2. Implement automatic auditing, which would automatically create an audit record whenever an audited entity is saved.

It is a non-goal to implement an all-encompassing solution for auditing.
Rather, a minimal, manually controlled tool should be provided with the sole purpose of generating audit-entities, and a basic form of auditing should be implemented, which would use the generated audit-entities.

The tool should accept a set of entity types as input, and generate source code for the corresponding audit-entity types, which should be written to an appropriate location in the project tree.

It is proposed to introduce an abbreviation for the term "audit" - a3t.

Requirements for the general structure of audit-entities:

  • Class name follows a standard naming scheme - Entity_a3t_i, where
    • Entity is a placeholder for the simple name of the audited entity;
    • i is a number, representing the version of an audit-entity.
  • Contains a reifiable reference to the audited entity (e.g., annotation).
  • Extends a basic audit-entity type, which should declare the following service properties, common to all audit-entities:
    • auditDate: Date (key member) - date/time the audited event took place;
    • user: User (key member) - user that performed the audited event;
    • auditTransactionGuid - identifier of the transaction associated with the audit record.
  • Declares a key member property that represents a reference to the audited entity.
    For example, if the audited entity was WorkActivity, then such a property would be auditedEntity: WorkActivity.
  • Declares all persistent properties of the audited entity.
    • Care should be taken to avoid name collisions with the basic properties1.
      Names of audited properties should be prefixed with a3t_.
    • Entity-exists validation should be disabled for entity-typed properties.
      This will enable deletion of audied entities while preserving their audit records.

Additionally, an entity type representing a one-to-many association with the audit-entity should be generated. This type should model properties of an audited entity that changed as part of an audit event.
The essential structural elements of this type are:

  1. A property that represents the audit-entity (the "one" side of the one-to-many association); should be a key-member.
  2. A property descriptor representing the property that changed; should be a key-member.

The structure of audit-entities should include a corresponding collectional property.

Expected outcome

  • A minimal tool to generate audit-entities is introduced.
  • Automatic auditing is implemented.

Footnotes

  1. Basic properties are defined as basic properties + the property that represents a reference to the audited entity.

@homedirectory homedirectory self-assigned this Oct 25, 2024
@homedirectory homedirectory changed the title A minimal tool to generate audit-entities Audit-entity generation and automatic auditing Oct 25, 2024
homedirectory added a commit that referenced this issue Oct 25, 2024
This commit enhances the generator with the ability to generate the
essential structural components of audit-entities.
homedirectory added a commit that referenced this issue Oct 28, 2024
homedirectory added a commit that referenced this issue Oct 28, 2024
homedirectory added a commit that referenced this issue Oct 28, 2024
…y type

This change is required for further work - generation of ModProp entity
types. Such types will have a property typed with an audit-entity, which
may not necessarily exist at generation time, thus there will be no Type
object to represent it.

To accomodate for the lack of access to Type, which this change resulted
in, utility method `reflectType` was introduced.
homedirectory added a commit that referenced this issue Oct 28, 2024
…ne-to-many association with ModProp entities
homedirectory added a commit that referenced this issue Oct 29, 2024
homedirectory added a commit that referenced this issue Oct 29, 2024
homedirectory added a commit that referenced this issue Oct 29, 2024
This commit modifies the generation of collectional properties:
* Property declaration includes `final` and an initialiser.
* Property accessor returns an unmodifiable view.
* Property setter clears and populates the property value.
homedirectory added a commit that referenced this issue Oct 29, 2024
…etter and accessor of audit-entity property
homedirectory added a commit that referenced this issue Oct 29, 2024
homedirectory added a commit that referenced this issue Oct 30, 2024
This is necessary to overcome the inability to use underscore characters
in property names (due to specifics of mapping property names to
database column names).
homedirectory added a commit that referenced this issue Nov 1, 2024
homedirectory added a commit that referenced this issue Dec 2, 2024
…ider to correct the IoC configuration

4ae670e introduced IUrlGenerator but bound it only in IBasicWebApplicationServerModule,
which caused some other IoC modules to break (TgTestApplicationServerModule in particular, which
is used by DataPopulationConfig in PopulateDb).
homedirectory added a commit that referenced this issue Dec 6, 2024
homedirectory added a commit that referenced this issue Dec 21, 2024
…tTypeFinder

A step toward supporting multiple versions of audit types.
homedirectory added a commit that referenced this issue Dec 21, 2024
…r of manual generation

The dynamic approach that had been used is no longer viable due to the
possibility of existence of multiple audit type versions.
It could be made viable by enhancing it with the ability to detect
whether a new version of audit types needs to be generated, but that is
out of scope of this work.
homedirectory added a commit that referenced this issue Dec 21, 2024
homedirectory added a commit that referenced this issue Dec 21, 2024
…ations

This enables its usage by the generator of audit types.
homedirectory added a commit that referenced this issue Dec 21, 2024
…ion processors

Audit types are registered dynamically. The verifier operates with
static properties of the program, therefore it will report errors on
audit types due to the use of unregistered entities as property types
(e.g, `auditEntity` in audit-prop types and `changedProps` in
audit-entity types).
homedirectory added a commit that referenced this issue Jan 10, 2025
This enables correct support for names that start with a dollar sign.
homedirectory added a commit that referenced this issue Jan 14, 2025
Caused by a blunder in 0131e66.
homedirectory added a commit that referenced this issue Jan 14, 2025
…the default value

"null" cannot be yielded into boolean properties, as their type is
the primitive type 'boolean'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant