
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
A9n is a simple tool to keep ruby/rails apps configuration maintanable and verifiable. It supports Rails 6+ and Ruby 2.7+.
Why it's named a9n? It's a numeronym for application (where 9 stands for the number of letters between the first a and last n, similar to i18n or l10n).
Add this line to your application's Gemfile:
gem 'a9n'
And then execute:
$ bundle
Add a9n.yml.example
and/or a9n.yml
file into the config
directory. When none fo these files exists, A9n::MissingConfigurationFile
exception is thrown. You can also use configuration.yml(.example)
.
If both file exist, content of a9n.yml
is validated. It means that
all keys existing in example file must exist in local file - in case of missing
keys A9n::MissingConfigurationVariablesError
is thrown with the explanation what is missing.
Set application root and load configuration by adding to your application.rb
or environment.rb
right
after budler requires:
A9n.root = File.expand_path('..', __dir__)
A9n.load
This step is not required ,if you don't use a9n
in the environment settings or initializers.
It works with Rails
by default. If you want to use A9n
with non-rails app
you may need to tell that to A9n by:
A9n.local_app = MyApp
You can access any variable defined in configuration files by delegating it to
A9n
. E.g:
defaults:
email_from: 'no-reply@knapo.net'
production:
app_host: 'knapo.net'
development:
app_host: 'localhost:3000'
is accessible by:
A9n.app_host # => `knapo.net` in production and `localhost:3000` in development
A9n.email_from # => `no-reply@knapo.net` in both envs
If you want to split configuration, you can use multiple files. All files from config/a9n
are loaded by default, but you may pass custom paths as an argument to A9n.load
e.g. A9n.load('config/aws.yml', 'config/mail.yml')
. In such cases config items are accessible through the scope consistent with the file name.
E.g. if you have config/a9n/mail.yml
:
defaults:
email_from: 'knapo@knapo.net'
delivery_method: 'smtp'
You can access it by:
A9n.mail.email_from # => `knapo@knapo.net`
A9n.mail.delivery_method # => `smtp`
You can set variables manually using A9n.set
method
A9n.set(:app_host, "localhost:3000")
A9n.app_host # => `localhost:3000`
To reload/restore configuration:
A9n.load
Sometimes, you don't want to store a single secret value in the repo and you prefer having it in ENV variable. You can easily map it using :env
symbol as a value:
production:
access_token: :env
If you use capistrano and you feel safe enough to keep all your instance ( staging, production) configuration in the repository, you may find it useful to use capistrano extensions.
Just add an instance configuration file e.g. configuration.yml.staging
, configuration.yml.production
(NOTE: file extension must be consistent with the capistrano stage) and add
require 'a9n/capistrano'
to your Capfile. This way a9n.yml.<stage>
overrides a9n.yml
on each deploy.
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that a9n demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.