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 trail more configurable. #90

Closed
jhomarolo opened this issue Jan 2, 2023 · 4 comments
Closed

Audit trail more configurable. #90

jhomarolo opened this issue Jan 2, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@jhomarolo
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Today the herbs audit trail provided us with many inputs, but sometimes too much, especially when we are in a local environment (debug).

This has already generated some problems, such as writing bottlenecks, unnecessary information traffic, etc.

It would be nice to have the option of not displaying/generating a field in the audit trail.

@jhomarolo jhomarolo added the enhancement New feature or request label Jan 2, 2023
@dalssoft
Copy link
Member

dalssoft commented Jan 2, 2023

The way I see it, these are the problems with the current implementation

  • not configurable on the small details of the audit trail
  • not able to disable the audit trail for a specific step
  • doesn't handle big number of returned data
  • doesn't handle sensitive data
  • can be hard to read

With that, here are some ideas to improve the audit trail:

  • make the audit trail configurable
const changeUserToAdmin = injection =>
    usecase('Change User to Admin', {

        auditTrail: {
            step: (step, auditTrail) => delete auditTrail.password, // function to be executed on each step
            usecase: (auditTrail) => delete auditTrail.return, // function to be executed on the end of the usecase
            auditUseCaseReturn: false, // if the audit trail should return the usecase return
            auditStepReturn: false, // if the audit trail should return the step return,
            auditElapsedTime: false, // if the audit trail should return the elapsed time
        },

        'Retrieve the User': step(async ctx => {

it could have multiple options, for each environment, for example:

config.auditTrail = isProd ? {
    auditStepReturn: false, 
} : {

}

const changeUserToAdmin = injection =>
    usecase('Change User to Admin', {

        auditTrail: config.auditTrail,

        'Retrieve the User': step(async ctx => {
  • make audit trail easier to read
uc.auditTrail.format()

// would output a readable audit trail
  • handle sensitive data

Audit Trail should, by default, not log sensitive data, like passwords, credit card numbers, etc. and have some convention to handle it.

This could be turned off by the user, but by default, it should be on.

@jhomarolo
Copy link
Contributor Author

Does it make sense to put some global configuration for herbs? I don't know if the audit trail configuration should stay as a usecase parameter for an exception as the first choice.

What if I wanted all auditTrails to behave differently than the default?

About your auditTrail suggestions I think many are valid, but perhaps they should be treated more generally for now.

I believe that, for example, a functionality to handle sensitive data, could be discussed in another issue, because in my view this could be a configuration of the entity itself and the auditTrail just follows its configuration.

@dalssoft
Copy link
Member

dalssoft commented Jan 3, 2023

Does it make sense to put some global configuration for herbs?

It can be done, but as of now, we don't have a global configuration. There is a discussion about a global configuration file on the CLI, but it's not implemented yet.

As a workaround, a configuration file exporting a object with the configuration can be used, as shown in the example 2 (config.auditTrail).

What if I wanted all auditTrails to behave differently than the default?

Like different format / structure? I thought about it, but I'm more inclined to use just one structure for all audit trails in name of interoperability. If we have different formats, future consumers of the audit trail will lose the ability to consume a standard structure.

Since we have no consumers yet, we can change the structure now, but once it is defined, it will be the standard for all audit trails.

Another approach for what was presented is to have different audit trails levels, like auditTrail: 'full' or auditTrail: 'minimal', and the consumer can choose which level to consume.

I believe that, for example, a functionality to handle sensitive data, could be discussed in another issue, because in my view this could be a configuration of the entity itself and the auditTrail just follows its configuration.

Nice. I like the idea of having the sensitive metadata on the entity itself. After it is implemented, the audit trail must be aware of it.

jhomarolo added a commit to jhomarolo/buchu that referenced this issue Feb 14, 2023
… type to ignore some fields

You can also configure the output to ignore some fields of the audit trail by choosing those options
(mode or output)

herbsjs#90
herbsjs-robot pushed a commit that referenced this issue Mar 6, 2023
# [2.1.0](v2.0.0...v2.1.0) (2023-03-06)

### Features

* **audittrail:** now audit trail can be configured by mode or output type to ignore some fields ([41f5f8b](41f5f8b)), closes [#90](#90)
@jhomarolo
Copy link
Contributor Author

Fixed with #92

@jhomarolo jhomarolo self-assigned this Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants