Avoid using ENV[]

trunk
Matt Brictson 2 years ago
parent e2f48d7957
commit fc26cb3218
No known key found for this signature in database
GPG Key ID: E379525AE7FB9561

@ -8,12 +8,13 @@ module BasicAuth
private
def require_basic_auth
return true if ENV["BASIC_AUTH_USERNAME"].blank?
return true if ENV["BASIC_AUTH_PASSWORD"].blank?
expected_username = ENV.fetch("BASIC_AUTH_USERNAME", nil)
expected_password = ENV.fetch("BASIC_AUTH_PASSWORD", nil)
return true if expected_username.blank? || expected_password.blank?
authenticate_or_request_with_http_basic do |username, password|
ActiveSupport::SecurityUtils.secure_compare(username, ENV["BASIC_AUTH_USERNAME"]) & \
ActiveSupport::SecurityUtils.secure_compare(password, ENV["BASIC_AUTH_PASSWORD"])
ActiveSupport::SecurityUtils.secure_compare(username, expected_username) & \
ActiveSupport::SecurityUtils.secure_compare(password, expected_password)
end
end
end

@ -32,7 +32,7 @@ commands:
steps:
- run:
name: Set Up Database
command: bundle exec rake db:setup
command: bundle exec rake db:schema:load
jobs:
static_analysis:

@ -1,5 +1,5 @@
insert_into_file "config.ru", before: /^run Rails.application/ do
<<-RUBY
use Rack::CanonicalHost, ENV["RAILS_HOSTNAME"] if ENV["RAILS_HOSTNAME"].present?
use Rack::CanonicalHost, ENV.fetch("RAILS_HOSTNAME", nil) if ENV["RAILS_HOSTNAME"].present?
RUBY
end

@ -18,7 +18,7 @@ insert_into_file "config/environments/production.rb", after: /config\.action_mai
# Production email config
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = {
api_token: ENV["POSTMARK_API_KEY"]
api_token: ENV.fetch("POSTMARK_API_KEY", nil)
}
config.action_mailer.default_url_options = {
host: "#{production_hostname}",

@ -17,8 +17,8 @@ require "sidekiq/web"
Sidekiq::Web.app_url = "/"
sidekiq_username = ENV["SIDEKIQ_WEB_USERNAME"]
sidekiq_password = ENV["SIDEKIQ_WEB_PASSWORD"]
sidekiq_username = ENV.fetch("SIDEKIQ_WEB_USERNAME", nil)
sidekiq_password = ENV.fetch("SIDEKIQ_WEB_PASSWORD", nil)
Sidekiq::Web.use(Rack::Auth::Basic, "Sidekiq") do |username, password|
if sidekiq_username.present? && sidekiq_password.present?

@ -1,8 +1,8 @@
release_data = \
if (tomo_json = Rails.root.join(".tomo_release.json")).file?
JSON.parse(File.read(tomo_json))
elsif (heroku_commit = ENV["HEROKU_SLUG_COMMIT"]).present?
{ "revision" => heroku_commit, "revision_date" => ENV["HEROKU_RELEASE_CREATED_AT"] }
elsif (heroku_commit = ENV.fetch("HEROKU_SLUG_COMMIT", nil)).present?
{ "revision" => heroku_commit, "revision_date" => ENV.fetch("HEROKU_RELEASE_CREATED_AT", nil) }
else
{ "revision" => "N/A", "revision_date" => Time.current.to_s }
end

@ -12,7 +12,7 @@ empty_directory_with_keep_file "test/unit/lib/tasks"
gsub_file "test/application_system_test_case.rb", /^ driven_by :selenium.*$/, <<~RUBY
driven_by :selenium,
using: (ENV["DISABLE_HEADLESS_CHROME"] ? :chrome : :headless_chrome),
using: (ENV["DISABLE_HEADLESS_CHROME"].present? ? :chrome : :headless_chrome),
screen_size: [1400, 1400] do |options|
options.add_argument("no-sandbox")
end

Loading…
Cancel
Save