Skip to content

New configurable settings: encryption for audited_changes & filtering encrypted attrs#694

Open
sriddbs wants to merge 4 commits into
collectiveidea:mainfrom
sriddbs:configure-audited-changes-enc-and-filering
Open

New configurable settings: encryption for audited_changes & filtering encrypted attrs#694
sriddbs wants to merge 4 commits into
collectiveidea:mainfrom
sriddbs:configure-audited-changes-enc-and-filering

Conversation

@sriddbs

@sriddbs sriddbs commented Jan 15, 2024

Copy link
Copy Markdown
Contributor

Closes #690

  • Add new configurable vars:
    • encrypt_audited_changes default to false
    • filter_encrypted_attributes default to true

@sriddbs

sriddbs commented Jan 15, 2024

Copy link
Copy Markdown
Contributor Author

@danielmorrison please review and let me if the proposed config in the PR is good, also I wonder why some of the specs are failing 🤔

Comment thread README.md
Audited.filter_encrypted_attributes = false
```

If you want to encrypt the changes that are audited, you can simply add this line to your config

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe another header here to show that these are separate features?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, because we use encrypts, this config is also available only from Rails 7 ... so I grouped it under the same header

should I add a sub-header?

@danielmorrison danielmorrison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me. Test errors are something strange with coverage? Doesn't make sense offhand.

@sriddbs

sriddbs commented Jan 16, 2024

Copy link
Copy Markdown
Contributor Author

Looking good to me. Test errors are something strange with coverage? Doesn't make sense offhand.

I had the same errors with spec/audited/audit_spec, rspec clearly showed me the errors locally and I could fix it

for this it just runs fine

rspec spec/audited/auditor_spec.rb
Created database ':memory:'
............................................................................................................*.....*........................

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Audited::Auditor without auditing should be thread safe using a #without_auditing block
     # No reason given
     # ./spec/audited/auditor_spec.rb:996

  2) Audited::Auditor with auditing should be thread safe using a #with_auditing block
     # No reason given
     # ./spec/audited/auditor_spec.rb:1077

@sriddbs

sriddbs commented Jan 30, 2024

Copy link
Copy Markdown
Contributor Author

@danielmorrison if this PR looks good, please merge?

Comment thread lib/audited/audit.rb
serialize :audited_changes, YAMLIfTextColumnType
end

if Rails.gem_version >= Gem::Version.new("7.0") && Audited.encrypt_audited_changes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to work as expected, it appears that this is evaluated before the Audited.encrypt_audited_changes = true in the initializer runs so it evaluates to false initially and is never re-evaluated. The encrypts call below never runs as a result.

@srg-bnd

srg-bnd commented Jul 12, 2024

Copy link
Copy Markdown

How are you doing with PR?

Comment thread lib/audited/audit.rb
end

if Rails.gem_version >= Gem::Version.new("7.0") && Audited.encrypt_audited_changes
encrypts :audited_changes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to take into account the deterministic encryption?

@jesseduffield

Copy link
Copy Markdown

Just stumbled upon this PR. I'd love to have this functionality. Is anything blocking this currently @danielmorrison ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encryption for audited_changes / disabling the FILTERED feature

5 participants