
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
AuditedAsync is a plugin for the audited gem which allows to create audits asynchronously using ActiveJob.
It works by injecting the async
option into audited model option using functional programming. If enabled, it'll move audit creation logic into an ActiveJob instance, then it's sent to the queue to be executed later.
Add this line to your application's Gemfile, right after audited gem:
gem 'audited'
gem 'audited_async'
And then execute:
$ bundle
class Post < ApplicationRecord
audited async: true
end
Depending on your active job adapter, you may need to make the queue name visible to the adapter.
# config/sidekiq.yml
...
:queues:
- [audits, 1] # add this line
All done! Although you can optionally configure some more stuff, check below.
# config/initializers/audited_async.rb
AuditedAsync.configure do |config|
config.enabled = Rails.env.production?
end
# config/initializers/audited_async.rb
AuditedAsync.configure do |config|
config.job_name = 'JobityJob'
config.job_options = { wait: 1.second }
end
Create your own job:
class JobityJob < ApplicationJob
queue_as :audits
def perform(audit_info)
# audit_info = {
# class_name: 'Post',
# record_id: 2,
# audited_changes: "{\"json_stringified_changes\": \"with_values\"}",
# action: one of %w[create update destroy],
# comment: there will be some string here if audited comments are enabled,
# }
# ...
# run your logic
# ...
# job must have this line at the end
class_name.constantize.send(:write_audit, attributes)
# attributes = {
# audited_changes: {hash_changes: :with_values},
# action: one of %w[create update destroy],
# comment: comment, if enabled
# }
end
end
To see how the default job performs, look here.
https://github.com/leonardofalk/audited_async_sample.git
Checkout the repository, execute bundle install
and you're good to go.
There are some unit tests now but integration tests are missing. You can run the suite by executing rspec
.
Bug reports and pull requests are welcome on GitHub at https://github.com/leonardofalk/audited_async. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that audited_async demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.