Skip to content

Commit

Permalink
Apply new config defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrino committed Sep 16, 2024
1 parent b02904d commit fe8ba18
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"
gem "rails", "7.1.4"

gem "aws-sdk-s3", "~> 1"
gem "bootsnap", require: false
gem "bootsnap"
gem "bootstrap-kaminari-views"
gem "dartsass-rails"
gem "diffy"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ GEM
http-accept (1.7.0)
http-cookie (1.0.7)
domain_name (~> 0.5)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
inherited_resources (1.14.0)
actionpack (>= 6.0)
Expand Down
14 changes: 13 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ class Application < Rails::Application
config.flipflop.raise_strategy_errors = nil

# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
config.load_defaults 7.1

# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets tasks))

Check failure on line 35 in config/application.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/PercentLiteralDelimiters: `%w`-literals should be delimited by `[` and `]`. (https://rubystyle.guide#percent-literal-braces)

# Starting with Rails 7.1, autoloaded directories are no longer handled by the $LOAD_PATH.
# Unfortunately in this case it breaks the special handling we have for state_count_reporter.rb, so
# we have to use the flag that reverts this behaviour.
# https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#autoloaded-paths-are-no-longer-in-$load-path
config.add_autoload_paths_to_load_path = true

# Configuration object for the fact check email fetch script
# See `script/mail_fetcher`
Expand Down Expand Up @@ -64,6 +75,7 @@ class Application < Rails::Application

config.action_dispatch.rack_cache = nil


Check failure on line 78 in config/application.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/EmptyLines: Extra blank line detected. (https://rubystyle.guide#two-or-more-empty-lines)
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default set by govuk_app_config is London.
config.govuk_time_zone = "London"
Expand Down
2 changes: 1 addition & 1 deletion config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup"
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
9 changes: 6 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
config.enable_reloading = true

# Do not eager load code on boot.
config.eager_load = false
Expand All @@ -38,7 +38,7 @@

config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}",
"Cache-Control" => "public, max-age=#{2.days.to_i}"

Check failure on line 41 in config/environments/development.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/TrailingCommaInHashLiteral: Put a comma after the last item of a multiline hash.
}
else
config.action_controller.perform_caching = false
Expand Down Expand Up @@ -81,8 +81,11 @@
config.assets.raise_runtime_errors = true

# Raises error for missing translations.
config.i18n.raise_on_missing_translations = true
# config.i18n.raise_on_missing_translations = true

# Annotate rendered view with file names.
config.action_view.annotate_rendered_view_with_filenames = true

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true

Check failure on line 90 in config/environments/development.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/IndentationConsistency: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions)
end
19 changes: 14 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
config.cache_classes = true
config.enable_reloading = false

# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
Expand All @@ -16,8 +16,8 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true

# Disable serving static files from the `/public` folder by default since
Expand All @@ -40,12 +40,21 @@
# config.asset_host = "http://assets.example.com"

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX

# Assume all access to the app is happening through a SSL-terminating reverse proxy.
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
# config.assume_ssl = true

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)

Check failure on line 54 in config/environments/production.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`. (https://rubystyle.guide#global-stdout)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }

# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", :info)
Expand Down
6 changes: 5 additions & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false

Check failure on line 26 in config/environments/test.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/TrailingWhitespace: Trailing whitespace detected. (https://rubystyle.guide#no-trailing-whitespace)
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
Expand Down Expand Up @@ -65,10 +66,13 @@
config.active_support.disallowed_deprecation_warnings = []

# Raises error for missing translations.
config.i18n.raise_on_missing_translations = true
# config.i18n.raise_on_missing_translations = true

config.jwt_auth_secret = "123"

# Annotate rendered view with file names.
config.action_view.annotate_rendered_view_with_filenames = true

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true
end
13 changes: 6 additions & 7 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header

# Rails.application.configure do
# config.content_security_policy do |policy|
Expand All @@ -16,12 +16,11 @@
# # policy.report_uri "/csp-violation-report-endpoint"
# end
#
# # Generate session nonces for permitted importmap and inline scripts
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src)
# config.content_security_policy_nonce_directives = %w(script-src style-src)
#
# # Report CSP violations to a specified URI. See:
# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
# end

Expand Down
10 changes: 5 additions & 5 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.

# Configure parameters to be filtered from the log file. Use this to limit dissemination of
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
# notations and behaviors.
Rails.application.config.filter_parameters += %i[
passw secret token _key crypt salt certificate otp ssn
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [

Check failure on line 6 in config/initializers/filter_parameter_logging.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/SymbolArray: Use `%i` or `%I` for an array of symbols. (https://rubystyle.guide#percent-i)
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]
18 changes: 9 additions & 9 deletions config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
# Rails.application.config.permissions_policy do |f|
# f.camera :none
# f.gyroscope :none
# f.microphone :none
# f.usb :none
# f.fullscreen :self
# f.payment :self, "https://secure.example.com"
# information see: https://developers.google.com/web/updates/2018/06/feature-policy

# Rails.application.config.permissions_policy do |policy|
# policy.camera :none
# policy.gyroscope :none
# policy.microphone :none
# policy.usb :none
# policy.fullscreen :self
# policy.payment :self, "https://secure.example.com"
# end
3 changes: 0 additions & 3 deletions config/mongoid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ development:
default:
uri: <%= ENV["MONGODB_URI"] || "mongodb://localhost/govuk_content_development" %>
options:
use_activesupport_time_zone: true
belongs_to_required_by_default: false

test:
Expand All @@ -16,7 +15,6 @@ test:
mode: :primary
max_pool_size: 1
options:
use_activesupport_time_zone: true
belongs_to_required_by_default: false

# set these environment variables on your prod server
Expand All @@ -25,5 +23,4 @@ production:
default:
uri: <%= ENV['MONGODB_URI'] %>
options:
use_activesupport_time_zone: true
belongs_to_required_by_default: false

0 comments on commit fe8ba18

Please sign in to comment.