From 6bda1d28335cb52e0d6142a68973fb7ba9e85f8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:52:35 +0000 Subject: [PATCH 01/16] Bump ddtrace from 1.14.0 to 1.15.0 Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 1.14.0 to 1.15.0. - [Release notes](https://github.com/DataDog/dd-trace-rb/releases) - [Changelog](https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md) - [Commits](https://github.com/DataDog/dd-trace-rb/compare/v1.14.0...v1.15.0) --- updated-dependencies: - dependency-name: ddtrace dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index a59a44361c..0caea4e110 100644 --- a/Gemfile +++ b/Gemfile @@ -135,7 +135,7 @@ gem 'memory_profiler', '~> 1.0.1' gem 'rack-mini-profiler', '~> 3.1.1' gem 'stackprof', '~> 0.2.25' -gem 'ddtrace', '~> 1.14.0' +gem 'ddtrace', '~> 1.15.0' # Make sure filesystem changes only happen at the end of a transaction gem 'after_commit_everywhere', '~> 1.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 66b1a3cb9c..d6fd8f5505 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -133,13 +133,16 @@ GEM railties (>= 6.0.0) daemons (1.4.1) dalli (3.2.6) + datadog-ci (0.2.0) + msgpack date (3.3.3) - ddtrace (1.14.0) - debase-ruby_core_source (= 3.2.1) - libdatadog (~> 3.0.0.1.0) - libddwaf (~> 1.9.0.0.0) + ddtrace (1.15.0) + datadog-ci (~> 0.2.0) + debase-ruby_core_source (= 3.2.2) + libdatadog (~> 5.0.0.1.0) + libddwaf (~> 1.14.0.0.0) msgpack - debase-ruby_core_source (3.2.1) + debase-ruby_core_source (3.2.2) delayed_job (4.1.10) activesupport (>= 3.0, < 8.0) delayed_job_active_record (4.1.7) @@ -181,7 +184,7 @@ GEM faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) faraday-net_http (3.0.2) - ffi (1.15.5) + ffi (1.16.3) flamegraph (0.9.5) glob (0.4.0) globalid (1.2.1) @@ -235,8 +238,8 @@ GEM addressable (~> 2.7) letter_opener (1.8.1) launchy (>= 2.2, < 3) - libdatadog (3.0.0.1.0-x86_64-linux) - libddwaf (1.9.0.0.1-x86_64-linux) + libdatadog (5.0.0.1.0-x86_64-linux) + libddwaf (1.14.0.0.0-x86_64-linux) ffi (~> 1.0) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) @@ -542,7 +545,7 @@ DEPENDENCIES counter_culture (~> 3.5) cssbundling-rails (~> 1.3.3) dalli (~> 3.2.6) - ddtrace (~> 1.14.0) + ddtrace (~> 1.15.0) delayed_job_active_record (~> 4.1.7) delayed_job_web (~> 1.4.4) devise (~> 4.9.2) From 2e9d76ab746825ed77b45bec1f2f8138c26e5e81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:56:05 +0000 Subject: [PATCH 02/16] Bump rails from 7.0.8 to 7.1.0 Bumps [rails](https://github.com/rails/rails) from 7.0.8 to 7.1.0. - [Release notes](https://github.com/rails/rails/releases) - [Commits](https://github.com/rails/rails/compare/v7.0.8...v7.1.0) --- updated-dependencies: - dependency-name: rails dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 168 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 100 insertions(+), 70 deletions(-) diff --git a/Gemfile b/Gemfile index a59a44361c..4f5f388a77 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '~> 3.1.2' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 7.0.8' +gem 'rails', '~> 7.1.0' # Use mysql as the database for Active Record gem 'mysql2', '~> 0.5.5' # Use Puma as the app server diff --git a/Gemfile.lock b/Gemfile.lock index 66b1a3cb9c..d8fada2973 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,70 +2,78 @@ GEM remote: https://rubygems.org/ specs: ace-rails-ap (4.5) - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + zeitwerk (~> 2.6) + actionmailbox (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.1.0) + actionpack (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activesupport (= 7.1.0) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.0) + actionview (= 7.1.0) + activesupport (= 7.1.0) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.0) + actionpack (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.1.0) + activesupport (= 7.1.0) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.0) + activesupport (= 7.1.0) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.1.0) + activesupport (= 7.1.0) + activerecord (7.1.0) + activemodel (= 7.1.0) + activesupport (= 7.1.0) + timeout (>= 0.4.0) + activestorage (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activesupport (= 7.1.0) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.1.0) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) @@ -85,6 +93,7 @@ GEM base64 (0.1.1) bcrypt (3.1.18) bcrypt_pbkdf (1.1.0) + bigdecimal (3.1.4) bindata (2.4.15) bindex (0.8.1) bootsnap (1.16.0) @@ -121,6 +130,7 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) concurrent-ruby (1.2.2) + connection_pool (2.4.1) counter_culture (3.5.0) activerecord (>= 4.2) activesupport (>= 4.2) @@ -161,6 +171,8 @@ GEM docker-api (2.2.0) excon (>= 0.47.0) multi_json + drb (2.1.1) + ruby2_keywords ed25519 (1.3.0) erubi (1.12.0) exception_notification (4.5.0) @@ -209,6 +221,10 @@ GEM image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) + io-console (0.6.0) + irb (1.8.1) + rdoc + reline (>= 0.3.8) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -255,7 +271,6 @@ GEM marcel (1.0.2) matrix (0.4.2) memory_profiler (1.0.1) - method_source (1.0.0) mini_magick (4.11.0) mini_mime (1.1.5) minitest (5.20.0) @@ -270,8 +285,9 @@ GEM multi_xml (0.6.0) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) + mutex_m (0.1.2) mysql2 (0.5.5) - net-imap (0.3.7) + net-imap (0.4.0) date net-protocol net-pop (0.1.2) @@ -280,7 +296,7 @@ GEM timeout net-scp (4.0.0) net-ssh (>= 2.6.5, < 8.0.0) - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol net-ssh (7.1.0) nio4r (2.5.9) @@ -339,6 +355,8 @@ GEM premailer (~> 1.7, >= 1.7.9) pretender (0.5.0) actionpack (>= 6.1) + psych (5.1.0) + stringio public_suffix (5.0.3) puma (6.4.0) nio4r (~> 2.0) @@ -357,22 +375,27 @@ GEM rack (>= 2.1.0) rack-protection (3.0.4) rack + rack-session (1.0.1) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.0) + actioncable (= 7.1.0) + actionmailbox (= 7.1.0) + actionmailer (= 7.1.0) + actionpack (= 7.1.0) + actiontext (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activemodel (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.1.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -387,20 +410,25 @@ GEM rails-i18n (7.0.8) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) rb-readline (0.5.5) + rdoc (6.5.0) + psych (>= 4.0.0) regexp_parser (2.8.1) + reline (0.3.9) + io-console (~> 0.5) responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) @@ -473,6 +501,7 @@ GEM net-scp (>= 1.1.2) net-ssh (>= 2.8.0) stackprof (0.2.25) + stringio (3.0.8) swd (2.0.2) activesupport (>= 3) attr_required (>= 0.0.5) @@ -512,6 +541,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.8.1) websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -519,7 +549,7 @@ GEM will_paginate (4.0.0) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS x86_64-linux @@ -584,7 +614,7 @@ DEPENDENCIES puma (~> 6.4.0) pundit (~> 2.3.1) rack-mini-profiler (~> 3.1.1) - rails (~> 7.0.8) + rails (~> 7.1.0) rails-controller-testing (~> 1.0.5) rails-i18n (~> 7.0.8) rb-readline (~> 0.5.5) From 2d62e5200b534bd3f5ffd63b0ef47541472f4c13 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 9 Oct 2023 14:35:31 +0200 Subject: [PATCH 03/16] Remove incorrect use of popularity enum --- app/models/activity.rb | 1 - app/views/activities/index.html.erb | 2 +- app/views/series/edit.html.erb | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/activity.rb b/app/models/activity.rb index 9409641565..1541fecc4e 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -103,7 +103,6 @@ class Activity < ApplicationRecord scope :order_by_name, ->(direction) { reorder(Arel.sql("name_#{I18n.locale} IS NULL, name_#{I18n.locale} #{direction}")).order(path: direction) } scope :order_by_popularity, ->(direction) { reorder("series_count #{direction}") } - enum popularity: { unpopular: 0, neutral: 1, popular: 2, very_popular: 3 }, _prefix: true POPULARITY_THRESHOLDS = { unpopular: { min: 0, max: 2 }, neutral: { min: 3, max: 10 }, diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb index c928cc4978..3b39cd7929 100644 --- a/app/views/activities/index.html.erb +++ b/app/views/activities/index.html.erb @@ -6,7 +6,7 @@
- <%= render partial: 'layouts/searchbar', locals: {labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], judges: @judges, popularity: Activity.popularities.keys, no_dropdown_for: ["judges"]} %> + <%= render partial: 'layouts/searchbar', locals: {labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], judges: @judges, popularity: Activity::POPULARITY_THRESHOLDS.keys, no_dropdown_for: ["judges"]} %>
<%= render partial: 'activities_table', locals: {activities: @activities} %>
diff --git a/app/views/series/edit.html.erb b/app/views/series/edit.html.erb index 13b5ef0a22..f317fe88bd 100644 --- a/app/views/series/edit.html.erb +++ b/app/views/series/edit.html.erb @@ -67,7 +67,7 @@

<%= t ".add_activities" %>

- <%= render partial: 'layouts/searchbar', locals: {baseUrl: available_activities_series_path(@series), eager: true, labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], popularity: Activity.popularities.keys, local_storage_key: 'seriesActivitySearch'} %> + <%= render partial: 'layouts/searchbar', locals: {baseUrl: available_activities_series_path(@series), eager: true, labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], popularity: Activity::POPULARITY_THRESHOLDS.keys, local_storage_key: 'seriesActivitySearch'} %>
From b048a89ac779259a02c9871de3f3ca8c39cbb0ce Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 9 Oct 2023 14:38:29 +0200 Subject: [PATCH 04/16] Assert redirect when expecting a redirect --- test/controllers/courses_controller_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/controllers/courses_controller_test.rb b/test/controllers/courses_controller_test.rb index 935892b1cd..4f5f9c8deb 100644 --- a/test/controllers/courses_controller_test.rb +++ b/test/controllers/courses_controller_test.rb @@ -836,7 +836,7 @@ def with_users_signed_in(users) assert_difference 'Course.count', -1 do delete course_url(@course) end - assert_includes response.body, courses_url + assert_redirected_to courses_url end test 'should not destroy course as course admin if too many submissions' do @@ -860,7 +860,7 @@ def with_users_signed_in(users) assert_difference 'Course.count', -1 do delete course_url(@course) end - assert_includes response.body, courses_url + assert_redirected_to courses_url end test 'super admins are able to view questions' do From b55e689c9b8394d972dc5f45614453b08263be8c Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 9 Oct 2023 15:07:50 +0200 Subject: [PATCH 05/16] Fix i18n key path --- app/controllers/api_tokens_controller.rb | 2 +- test/controllers/api_tokens_controller_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api_tokens_controller.rb b/app/controllers/api_tokens_controller.rb index af92344118..a39b62e601 100644 --- a/app/controllers/api_tokens_controller.rb +++ b/app/controllers/api_tokens_controller.rb @@ -18,7 +18,7 @@ def create f.js { render 'create', locals: { toast: message, new_token: @token } } else errors = @token.errors.full_messages - errors << I18n.t('errors.models.api_token.attributes.not_permitted') unless can_create + errors << I18n.t('activerecord.errors.models.api_token.not_permitted') unless can_create message = errors.join(', ') f.html do redirect_back fallback_location: root_path, diff --git a/test/controllers/api_tokens_controller_test.rb b/test/controllers/api_tokens_controller_test.rb index cec8dc4576..fd295853ce 100644 --- a/test/controllers/api_tokens_controller_test.rb +++ b/test/controllers/api_tokens_controller_test.rb @@ -30,7 +30,7 @@ def create_request(attr_hash: nil) assert_difference('ApiToken.count', 0) do post user_api_tokens_url(:nl, @other_user), params: model_params(generate_attr_hash) end - assert_equal flash[:alert], I18n.t('errors.models.api_token.attributes.not_permitted') + assert_equal flash[:alert], I18n.t('activerecord.errors.models.api_token.not_permitted') end test 'should not be able to delete token from other user' do From 01bd79f0a25c5439a35940aa60ae4ac5b539cf49 Mon Sep 17 00:00:00 2001 From: Bart Mesuere Date: Mon, 9 Oct 2023 15:10:00 +0200 Subject: [PATCH 06/16] add slack invite link --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 72340e1079..eeb105e5bc 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/dodona-edu/dodona) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dodona-edu/dodona/test.yml?branch=main) ![Codecov](https://img.shields.io/codecov/c/github/dodona-edu/dodona) -[![Support chat](https://img.shields.io/static/v1?label=support%20chat&message=on%20matrix&color=informational)](https://matrix.to/#/#dodona-support:vanpetegem.me?via=vanpetegem.me) -[![General chat](https://img.shields.io/static/v1?label=general%20chat&message=on%20matrix&color=informational)](https://matrix.to/#/#dodona-general:vanpetegem.me?via=vanpetegem.me&via=matrix.org&via=beardhatcode.be) +[![Support chat](https://img.shields.io/static/v1?label=support%20chat&message=on%20slack&color=informational)](https://join.slack.com/t/dodona-edu/shared_invite/zt-24o2an3bp-fFR_TTM0fB_kmlCvkS2ckA) > Dodona is an online exercise platform for **learning to code**. It wants to teach students how to program in the most meaningful and effective way possible. Dodona acts as an **online co-teacher**, designed to give every student access to high quality education. The focus is on automatic corrections and giving **meaningful feedback** on the submitted solutions from students. From 927e28361908fead401cb8e8079bfdecec61187d Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 9 Oct 2023 16:11:29 +0200 Subject: [PATCH 07/16] Run 'bin/rails app:update' --- bin/rails | 2 +- bin/setup | 23 ++- config/application.rb | 34 +---- config/boot.rb | 2 +- config/environment.rb | 6 - config/environments/development.rb | 89 ++---------- config/environments/production.rb | 131 ++++++------------ config/environments/test.rb | 38 ++--- config/initializers/assets.rb | 6 +- .../initializers/content_security_policy.rb | 68 +++------ .../initializers/filter_parameter_logging.rb | 4 +- config/initializers/inflections.rb | 12 +- config/initializers/permissions_policy.rb | 20 +-- 13 files changed, 128 insertions(+), 307 deletions(-) diff --git a/bin/rails b/bin/rails index 6fb4e4051c..efc0377492 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) +APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/bin/setup b/bin/setup index 90700ac4f9..3cd5a9d780 100755 --- a/bin/setup +++ b/bin/setup @@ -2,10 +2,10 @@ require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do @@ -13,24 +13,21 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') - - # Install JavaScript dependencies - system! 'bin/yarn' + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/config/application.rb b/config/application.rb index 7c9eda4730..bd4990a73a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,7 +11,11 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.0 - config.dodona_email = 'dodona@ugent.be' + # 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)) + # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files @@ -19,33 +23,5 @@ class Application < Rails::Application # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") - # Application hosts - - # The main webapp - config.default_host = 'dodona.localhost' - - # The sandboxed host with user provided content, without authentication - config.sandbox_host = 'sandbox.localhost' - config.tutor_url = URI::HTTP.build(host: 'tutor.localhost', port: 8080, path: "/cgi-bin/build_trace.py") - - # Where we host our assets (a single domain, for caching) - # Port is needed somehow... - config.action_controller.asset_host = 'dodona.localhost:3000' - - config.time_zone = 'Brussels' - - config.i18n.available_locales = %w[en nl] - config.i18n.default_locale = :nl - config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] - - config.eager_load_paths += Dir[Rails.root.join('app', 'helpers', 'renderers')] - config.eager_load_paths += Dir[Rails.root.join('app', 'models', 'transient')] - - config.active_job.queue_adapter = :delayed_job - - config.active_storage.queues.analysis = :default - config.active_storage.queues.purge = :default - - config.action_view.default_form_builder = "StandardFormBuilder" end end diff --git a/config/boot.rb b/config/boot.rb index 3cda23b4db..988a5ddc46 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/environment.rb b/config/environment.rb index 455a4cbc96..cac5315775 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,9 +1,3 @@ -# Default environment is development -ENV['RAILS_ENV'] ||= 'development' -# Set NODE_ENV to match 'RAILS_ENV' -# Staging builds in production mode -ENV['NODE_ENV'] = 'production' unless ENV['RAILS_ENV'] == 'development' - # Load the Rails application. require_relative "application" diff --git a/config/environments/development.rb b/config/environments/development.rb index db09ee286f..2e7fb486b6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,29 +3,10 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Application hosts - - config.hosts << ENV['RAILS_APPLICATION_HOST'] if ENV['RAILS_APPLICATION_HOST'].present? - config.hosts << ENV['RAILS_SANDBOX_HOST'] if ENV['RAILS_SANDBOX_HOST'].present? - - # The main webapp - config.default_host = ENV['RAILS_APPLICATION_HOST'] || 'dodona.localhost' - config.action_mailer.default_url_options = { host: ENV['RAILS_APPLICATION_HOST'] || 'dodona.localhost:3000' } - - config.web_hosts = [config.default_host] - - # The sandboxed host with user provided content, without authentication - config.sandbox_host = ENV['RAILS_SANDBOX_HOST'] || 'sandbox.localhost' - config.tutor_url = URI::HTTP.build(host: 'tutor.localhost', port: 8080, path: '/cgi-bin/build_trace.py') - - # Where we host our assets (a single domain, for caching) - # Port is needed somehow... - config.action_controller.asset_host = ENV['RAILS_APPLICATION_HOST'] || 'dodona.localhost:3000' - # 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 @@ -33,20 +14,19 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - - config.public_file_server.headers = { - 'Cross-Origin-Resource-Policy' => 'cross-origin' - } - if Rails.root.join('tmp', 'caching-dev.txt').exist? || ENV['RAILS_DO_CACHING'].present? + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true - config.cache_store = :mem_cache_store, { namespace: :"2" } - config.public_file_server.headers.merge!({ - 'Cache-Control' => "public, max-age=#{2.days.to_i}" - }) + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } else config.action_controller.perform_caching = false @@ -76,62 +56,21 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true # Suppress logger output for asset requests. config.assets.quiet = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - 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 - # Regenerate js translation files - config.after_initialize do - require 'i18n-js/listen' - I18nJS.listen - end - - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker - # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true - # Exception notifications - config.middleware.use ExceptionNotification::Rack, - ignore_if: ->(env, _exception) { env['HTTP_HOST'] == 'localhost:3000' || env['HTTP_HOST'] == 'dodona.localhost:3000' }, - email: { - email_prefix: '[Dodona-dev] ', - sender_address: %("Dodona" ), - exception_recipients: %w[dodona@ugent.be] - } - config.action_mailer.delivery_method = :letter_opener - # Defaults to: - # config.action_mailer.sendmail_settings = { - # :location => '/usr/sbin/sendmail', - # :arguments => '-i -t' - # } - if ENV['RAILS_NO_ACTION_MAILER'].present? - config.action_mailer.perform_deliveries = false - else - config.action_mailer.perform_deliveries = true - end - config.action_mailer.raise_delivery_errors = true - - config.submissions_storage_path = Rails.root.join('data', 'storage', 'submissions') + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 79e4e7cb61..69a3d96125 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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 @@ -12,75 +12,60 @@ # Rake tasks automatically ignore this option for performance. config.eager_load = true - # The main webapp - config.default_host = 'dodona.be' - config.action_mailer.default_url_options = { host: 'dodona.be' } - - # alternative host name - config.alt_host = 'dodona.ugent.be' - - config.web_hosts = [config.default_host, config.alt_host] - - # The sandboxed host with user provided content, without authentication - config.sandbox_host = 'sandbox.dodona.be' - config.tutor_url = URI::HTTPS.build(host: 'pandora.ugent.be', path: '/tutor/cgi-bin/build_trace.py') - - # Where we host our assets (a single domain, for caching) - config.action_controller.asset_host = 'dodona.be' - - # Allowed hostnames - config.hosts << config.default_host << config.sandbox_host << config.alt_host - - # Where we host our assets (a single domain, for caching) - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - config.asset_host = 'dodona.be' - - # 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). - config.require_master_key = true - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + # 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 + + # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it). + config.public_file_server.enabled = true - # Compress JavaScripts and CSS. - config.assets.js_compressor = :terser + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # 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 # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + + # 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 + config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] + # Info include generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # Use a different cache store in production. - config.cache_store = :mem_cache_store, 'calliope.ugent.be', {namespace: :"2"} + # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque @@ -96,53 +81,17 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Log disallowed deprecations. - config.active_support.disallowed_deprecation = :log - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + # Don't log any deprecations. + config.active_support.report_deprecations = false # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - config.middleware.use ExceptionNotification::Rack, - ignore_crawlers: %w[Googlebot BingPreview bingbot Applebot], - ignore_if: lambda { |env, exception| - env['action_controller.instance'].is_a?(PagesController) && - env['action_controller.instance'].action_name == 'create_contact' && - exception.is_a?(ActionController::InvalidAuthenticityToken) - }, - email: { - email_prefix: '[Dodona] ', - sender_address: %("Dodona" ), - exception_recipients: %w[dodona@ugent.be] - }, - slack: { - webhook_url: Rails.application.credentials[:slack_notifications_url], - channel: '#notifications', - username: 'Dodona-server', - additional_parameters: { - icon_url: 'https://dodona.be/icon.png', - mrkdwn: true - } - } - - - config.action_mailer.delivery_method = :sendmail - # Defaults to: - # config.action_mailer.sendmail_settings = { - # :location => '/usr/sbin/sendmail', - # :arguments => '-i -t' - # } - config.action_mailer.perform_deliveries = true - config.action_mailer.raise_delivery_errors = true - config.action_mailer.deliver_later_queue_name = 'default' - - config.submissions_storage_path = Rails.root.join('data', 'storage', 'submissions') + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index b8d89cb031..0dda9f9fbe 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,36 +8,28 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.default_host = 'www.example.com' - config.action_mailer.default_url_options = { host: 'www.example.com' } - config.sandbox_host = 'sandbox.example.com' - config.tutor_url = URI::HTTPS.build(host: "tutor.example.com", path: "/cgi-bin/build_trace.py") + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - config.web_hosts = [config.default_host] - - config.action_controller.asset_host = nil - - config.cache_classes = false - config.action_view.cache_template_loading = true - - # Do not eager load code on boot. This avoids loading your whole application - # 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 + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -62,15 +54,11 @@ 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 # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - Delayed::Worker.delay_jobs = ->(job) { !%w[default exports git statistics].include?(job.queue) } - - config.submissions_storage_path = Rails.root.join('tmp/data/storage/submissions') - - routes.default_url_options[:trailing_slash] = true - routes.default_url_options[:locale] = 'en' + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 5536ac4aa7..2eeef966fe 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,16 +1,12 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) - -Rails.application.config.assets.nodigest = [] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index bc3e0d196d..b3076b38fe 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,47 +1,25 @@ # 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 - -Rails.application.configure do - config.content_security_policy do |policy| - policy.default_src :self - - policy.frame_ancestors :none - - if Rails.env.development? - # Allow webpack-dev-server - policy.connect_src :self, Rails.configuration.tutor_url.to_s, - 'https://*.googleapis.com', - 'http://localhost:3035', 'ws://localhost:3035' - else - policy.connect_src :self, Rails.configuration.tutor_url.to_s, - 'https://cdn.jsdelivr.net/npm/mathjax@3/' - end - - policy.font_src :self, 'https://fonts.gstatic.com', - 'https://cdn.jsdelivr.net/npm/@mdi/font@5.x/', - 'https://cdn.jsdelivr.net/npm/mathjax@3/' - - policy.img_src :self, :data, :https - - policy.object_src :none - - policy.script_src :self, :unsafe_inline, :unsafe_eval, - 'https://cdn.jsdelivr.net/npm/mathjax@3/' - - policy.style_src :self, :unsafe_inline, - 'https://fonts.googleapis.com', - 'https://cdn.jsdelivr.net/npm/@mdi/font@5.x/' - end - # # Generate session nonces for permitted importmap and inline scripts - # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } - # config.content_security_policy_nonce_directives = %w(script-src) - # - # # Report CSP violations to a specified URI. See: - # # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only - # # config.content_security_policy_report_only = true -end - -# Rails.application.config.content_security_policy_report_only = true +# 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| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # 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 style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4b34a03668..41551f646a 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,6 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. +# 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 += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 2dc73995ef..3860f659ea 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: -ActiveSupport::Inflector.inflections(:en) do |inflect| - inflect.acronym 'LCS' -end +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 00f64d71b0..7db3b9577e 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,11 +1,13 @@ +# Be sure to restart your server when you modify this file. + # 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 From f67a9601a69129f1f116af5e6c96bab3014940fd Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 9 Oct 2023 16:14:09 +0200 Subject: [PATCH 08/16] Revert "Run 'bin/rails app:update'" This reverts commit 927e28361908fead401cb8e8079bfdecec61187d. --- bin/rails | 2 +- bin/setup | 23 +-- config/application.rb | 34 ++++- config/boot.rb | 2 +- config/environment.rb | 6 + config/environments/development.rb | 89 ++++++++++-- config/environments/production.rb | 131 ++++++++++++------ config/environments/test.rb | 38 +++-- config/initializers/assets.rb | 6 +- .../initializers/content_security_policy.rb | 68 ++++++--- .../initializers/filter_parameter_logging.rb | 4 +- config/initializers/inflections.rb | 12 +- config/initializers/permissions_policy.rb | 20 ++- 13 files changed, 307 insertions(+), 128 deletions(-) diff --git a/bin/rails b/bin/rails index efc0377492..6fb4e4051c 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/bin/setup b/bin/setup index 3cd5a9d780..90700ac4f9 100755 --- a/bin/setup +++ b/bin/setup @@ -2,10 +2,10 @@ require "fileutils" # path to your application root. -APP_ROOT = File.expand_path("..", __dir__) +APP_ROOT = File.expand_path('..', __dir__) def system!(*args) - system(*args, exception: true) + system(*args) || abort("\n== Command #{args} failed ==") end FileUtils.chdir APP_ROOT do @@ -13,21 +13,24 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies + system! 'bin/yarn' # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # FileUtils.cp "config/database.yml.sample", "config/database.yml" + # unless File.exist?('config/database.yml') + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system! "bin/rails db:prepare" + system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! "bin/rails restart" + system! 'bin/rails restart' end diff --git a/config/application.rb b/config/application.rb index bd4990a73a..7c9eda4730 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,11 +11,7 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.0 - # 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)) - + config.dodona_email = 'dodona@ugent.be' # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files @@ -23,5 +19,33 @@ class Application < Rails::Application # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") + # Application hosts + + # The main webapp + config.default_host = 'dodona.localhost' + + # The sandboxed host with user provided content, without authentication + config.sandbox_host = 'sandbox.localhost' + config.tutor_url = URI::HTTP.build(host: 'tutor.localhost', port: 8080, path: "/cgi-bin/build_trace.py") + + # Where we host our assets (a single domain, for caching) + # Port is needed somehow... + config.action_controller.asset_host = 'dodona.localhost:3000' + + config.time_zone = 'Brussels' + + config.i18n.available_locales = %w[en nl] + config.i18n.default_locale = :nl + config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] + + config.eager_load_paths += Dir[Rails.root.join('app', 'helpers', 'renderers')] + config.eager_load_paths += Dir[Rails.root.join('app', 'models', 'transient')] + + config.active_job.queue_adapter = :delayed_job + + config.active_storage.queues.analysis = :default + config.active_storage.queues.purge = :default + + config.action_view.default_form_builder = "StandardFormBuilder" end end diff --git a/config/boot.rb b/config/boot.rb index 988a5ddc46..3cda23b4db 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/environment.rb b/config/environment.rb index cac5315775..455a4cbc96 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,3 +1,9 @@ +# Default environment is development +ENV['RAILS_ENV'] ||= 'development' +# Set NODE_ENV to match 'RAILS_ENV' +# Staging builds in production mode +ENV['NODE_ENV'] = 'production' unless ENV['RAILS_ENV'] == 'development' + # Load the Rails application. require_relative "application" diff --git a/config/environments/development.rb b/config/environments/development.rb index 2e7fb486b6..db09ee286f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,10 +3,29 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Application hosts + + config.hosts << ENV['RAILS_APPLICATION_HOST'] if ENV['RAILS_APPLICATION_HOST'].present? + config.hosts << ENV['RAILS_SANDBOX_HOST'] if ENV['RAILS_SANDBOX_HOST'].present? + + # The main webapp + config.default_host = ENV['RAILS_APPLICATION_HOST'] || 'dodona.localhost' + config.action_mailer.default_url_options = { host: ENV['RAILS_APPLICATION_HOST'] || 'dodona.localhost:3000' } + + config.web_hosts = [config.default_host] + + # The sandboxed host with user provided content, without authentication + config.sandbox_host = ENV['RAILS_SANDBOX_HOST'] || 'sandbox.localhost' + config.tutor_url = URI::HTTP.build(host: 'tutor.localhost', port: 8080, path: '/cgi-bin/build_trace.py') + + # Where we host our assets (a single domain, for caching) + # Port is needed somehow... + config.action_controller.asset_host = ENV['RAILS_APPLICATION_HOST'] || 'dodona.localhost:3000' + # 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.enable_reloading = true + config.cache_classes = false # Do not eager load code on boot. config.eager_load = false @@ -14,19 +33,20 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing - config.server_timing = true - # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? + + config.public_file_server.headers = { + 'Cross-Origin-Resource-Policy' => 'cross-origin' + } + if Rails.root.join('tmp', 'caching-dev.txt').exist? || ENV['RAILS_DO_CACHING'].present? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true - config.cache_store = :memory_store - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" - } + config.cache_store = :mem_cache_store, { namespace: :"2" } + config.public_file_server.headers.merge!({ + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + }) else config.action_controller.perform_caching = false @@ -56,21 +76,62 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Highlight code that enqueued background job in logs. - config.active_job.verbose_enqueue_logs = true + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + 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 + # Regenerate js translation files + config.after_initialize do + require 'i18n-js/listen' + I18nJS.listen + end + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true - # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true + # Exception notifications + config.middleware.use ExceptionNotification::Rack, + ignore_if: ->(env, _exception) { env['HTTP_HOST'] == 'localhost:3000' || env['HTTP_HOST'] == 'dodona.localhost:3000' }, + email: { + email_prefix: '[Dodona-dev] ', + sender_address: %("Dodona" ), + exception_recipients: %w[dodona@ugent.be] + } + config.action_mailer.delivery_method = :letter_opener + # Defaults to: + # config.action_mailer.sendmail_settings = { + # :location => '/usr/sbin/sendmail', + # :arguments => '-i -t' + # } + if ENV['RAILS_NO_ACTION_MAILER'].present? + config.action_mailer.perform_deliveries = false + else + config.action_mailer.perform_deliveries = true + end + config.action_mailer.raise_delivery_errors = true + + config.submissions_storage_path = Rails.root.join('data', 'storage', 'submissions') end diff --git a/config/environments/production.rb b/config/environments/production.rb index 69a3d96125..79e4e7cb61 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.enable_reloading = false + config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -12,60 +12,75 @@ # Rake tasks automatically ignore this option for performance. config.eager_load = true + # The main webapp + config.default_host = 'dodona.be' + config.action_mailer.default_url_options = { host: 'dodona.be' } + + # alternative host name + config.alt_host = 'dodona.ugent.be' + + config.web_hosts = [config.default_host, config.alt_host] + + # The sandboxed host with user provided content, without authentication + config.sandbox_host = 'sandbox.dodona.be' + config.tutor_url = URI::HTTPS.build(host: 'pandora.ugent.be', path: '/tutor/cgi-bin/build_trace.py') + + # Where we host our assets (a single domain, for caching) + config.action_controller.asset_host = 'dodona.be' + + # Allowed hostnames + config.hosts << config.default_host << config.sandbox_host << config.alt_host + + # Where we host our assets (a single domain, for caching) + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + config.asset_host = 'dodona.be' + + # 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). + config.require_master_key = true + # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true - # 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 - - # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it). - config.public_file_server.enabled = true + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress CSS using a preprocessor. - # config.assets.css_compressor = :sass + # Compress JavaScripts and CSS. + config.assets.js_compressor = :terser # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true # 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 # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - - # 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 + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - config.force_ssl = true + # config.force_ssl = true - # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] - # Info include generic and useful information about system operation, but avoids logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). If you - # want to log everything, set the level to "debug". - config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") - # Use a different cache store in production. - # config.cache_store = :mem_cache_store + config.cache_store = :mem_cache_store, 'calliope.ugent.be', {namespace: :"2"} # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque @@ -81,17 +96,53 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Don't log any deprecations. - config.active_support.report_deprecations = false + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - # Enable DNS rebinding protection and other `Host` header attacks. - # config.hosts = [ - # "example.com", # Allow requests from example.com - # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` - # ] - # Skip DNS rebinding protection for the default health check endpoint. - # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } + config.middleware.use ExceptionNotification::Rack, + ignore_crawlers: %w[Googlebot BingPreview bingbot Applebot], + ignore_if: lambda { |env, exception| + env['action_controller.instance'].is_a?(PagesController) && + env['action_controller.instance'].action_name == 'create_contact' && + exception.is_a?(ActionController::InvalidAuthenticityToken) + }, + email: { + email_prefix: '[Dodona] ', + sender_address: %("Dodona" ), + exception_recipients: %w[dodona@ugent.be] + }, + slack: { + webhook_url: Rails.application.credentials[:slack_notifications_url], + channel: '#notifications', + username: 'Dodona-server', + additional_parameters: { + icon_url: 'https://dodona.be/icon.png', + mrkdwn: true + } + } + + + config.action_mailer.delivery_method = :sendmail + # Defaults to: + # config.action_mailer.sendmail_settings = { + # :location => '/usr/sbin/sendmail', + # :arguments => '-i -t' + # } + config.action_mailer.perform_deliveries = true + config.action_mailer.raise_delivery_errors = true + config.action_mailer.deliver_later_queue_name = 'default' + + config.submissions_storage_path = Rails.root.join('data', 'storage', 'submissions') end diff --git a/config/environments/test.rb b/config/environments/test.rb index 0dda9f9fbe..b8d89cb031 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,28 +8,36 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # While tests run files are not watched, reloading is not necessary. - config.enable_reloading = false + config.default_host = 'www.example.com' + config.action_mailer.default_url_options = { host: 'www.example.com' } + config.sandbox_host = 'sandbox.example.com' + config.tutor_url = URI::HTTPS.build(host: "tutor.example.com", path: "/cgi-bin/build_trace.py") - # Eager loading loads your entire application. When running a single test locally, - # this is usually not necessary, and can slow down your test suite. However, it's - # recommended that you enable it in continuous integration systems to ensure eager - # loading is working properly before deploying your code. - config.eager_load = ENV["CI"].present? + config.web_hosts = [config.default_host] + + config.action_controller.asset_host = nil + + config.cache_classes = false + config.action_view.cache_template_loading = true + + # Do not eager load code on boot. This avoids loading your whole application + # 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 # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = :rescuable + config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -54,11 +62,15 @@ 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 # 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 + Delayed::Worker.delay_jobs = ->(job) { !%w[default exports git statistics].include?(job.queue) } + + config.submissions_storage_path = Rails.root.join('tmp/data/storage/submissions') + + routes.default_url_options[:trailing_slash] = true + routes.default_url_options[:locale] = 'en' end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 2eeef966fe..5536ac4aa7 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,12 +1,16 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = "1.0" +Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) + +Rails.application.config.assets.nodigest = [] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index b3076b38fe..bc3e0d196d 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,25 +1,47 @@ # Be sure to restart your server when you modify this file. -# 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| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end -# -# # 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 style-src) -# -# # Report violations without enforcing the policy. -# # config.content_security_policy_report_only = true -# end +# 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 + +Rails.application.configure do + config.content_security_policy do |policy| + policy.default_src :self + + policy.frame_ancestors :none + + if Rails.env.development? + # Allow webpack-dev-server + policy.connect_src :self, Rails.configuration.tutor_url.to_s, + 'https://*.googleapis.com', + 'http://localhost:3035', 'ws://localhost:3035' + else + policy.connect_src :self, Rails.configuration.tutor_url.to_s, + 'https://cdn.jsdelivr.net/npm/mathjax@3/' + end + + policy.font_src :self, 'https://fonts.gstatic.com', + 'https://cdn.jsdelivr.net/npm/@mdi/font@5.x/', + 'https://cdn.jsdelivr.net/npm/mathjax@3/' + + policy.img_src :self, :data, :https + + policy.object_src :none + + policy.script_src :self, :unsafe_inline, :unsafe_eval, + 'https://cdn.jsdelivr.net/npm/mathjax@3/' + + policy.style_src :self, :unsafe_inline, + 'https://fonts.googleapis.com', + 'https://cdn.jsdelivr.net/npm/@mdi/font@5.x/' + end + # # Generate session nonces for permitted importmap and inline scripts + # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } + # config.content_security_policy_nonce_directives = %w(script-src) + # + # # Report CSP violations to a specified URI. See: + # # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only + # # config.content_security_policy_report_only = true +end + +# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 41551f646a..4b34a03668 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,6 @@ # Be sure to restart your server when you modify this file. -# 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. +# Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3860f659ea..2dc73995ef 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, "\\1en" -# inflect.singular /^(ox)en/i, "\\1" -# inflect.irregular "person", "people" +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym "RESTful" -# end +ActiveSupport::Inflector.inflections(:en) do |inflect| + inflect.acronym 'LCS' +end diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 7db3b9577e..00f64d71b0 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,13 +1,11 @@ -# Be sure to restart your server when you modify this file. - # 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 |policy| -# policy.camera :none -# policy.gyroscope :none -# policy.microphone :none -# policy.usb :none -# policy.fullscreen :self -# policy.payment :self, "https://secure.example.com" +# 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" # end From 58650a9ec10d5f68a810e3a6e9547fa31b35c2bf Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 10 Oct 2023 09:57:34 +0200 Subject: [PATCH 09/16] Run 'bin/rails app:update' --- bin/rails | 2 +- bin/setup | 23 +- config/boot.rb | 2 +- config/environments/development.rb | 11 +- config/environments/production.rb | 26 +- config/environments/test.rb | 16 +- .../new_framework_defaults_7_1.rb | 223 ++++++++++++++++++ 7 files changed, 277 insertions(+), 26 deletions(-) create mode 100644 config/initializers/new_framework_defaults_7_1.rb diff --git a/bin/rails b/bin/rails index 6fb4e4051c..efc0377492 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) +APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/bin/setup b/bin/setup index 90700ac4f9..3cd5a9d780 100755 --- a/bin/setup +++ b/bin/setup @@ -2,10 +2,10 @@ require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do @@ -13,24 +13,21 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') - - # Install JavaScript dependencies - system! 'bin/yarn' + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/config/boot.rb b/config/boot.rb index 3cda23b4db..988a5ddc46 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/environments/development.rb b/config/environments/development.rb index db09ee286f..c25e2a5aa7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -25,7 +25,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 @@ -33,6 +33,9 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. @@ -76,6 +79,9 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. @@ -112,6 +118,9 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + # Exception notifications config.middleware.use ExceptionNotification::Rack, ignore_if: ->(env, _exception) { env['HTTP_HOST'] == 'localhost:3000' || env['HTTP_HOST'] == 'dodona.localhost:3000' }, diff --git a/config/environments/production.rb b/config/environments/production.rb index 79e4e7cb61..11acfd200e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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 @@ -57,6 +57,9 @@ # yet still be able to expire them through the digest params. config.assets.digest = true + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # 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 @@ -69,16 +72,25 @@ # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # 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 - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Log to STDOUT by default + # config.logger = ActiveSupport::Logger.new(STDOUT) + # .tap { |logger| logger.formatter = ::Logger::Formatter.new } + # .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + # Use a different cache store in production. config.cache_store = :mem_cache_store, 'calliope.ugent.be', {namespace: :"2"} @@ -111,6 +123,12 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + config.middleware.use ExceptionNotification::Rack, ignore_crawlers: %w[Googlebot BingPreview bingbot Applebot], ignore_if: lambda { |env, exception| diff --git a/config/environments/test.rb b/config/environments/test.rb index b8d89cb031..9d21a27639 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -17,13 +17,14 @@ config.action_controller.asset_host = nil - config.cache_classes = false + config.enable_reloading = true config.action_view.cache_template_loading = true - # Do not eager load code on boot. This avoids loading your whole application - # 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 + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true @@ -37,7 +38,7 @@ config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -67,6 +68,9 @@ # 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 + Delayed::Worker.delay_jobs = ->(job) { !%w[default exports git statistics].include?(job.queue) } config.submissions_storage_path = Rails.root.join('tmp/data/storage/submissions') diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb new file mode 100644 index 0000000000..d41af162ad --- /dev/null +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -0,0 +1,223 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.1 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.1`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able +# to manually require files that are managed by the autoloader, which you shouldn't do anyway. +# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size +# of the bootsnap cache if you use it. +# Rails.application.config.add_autoload_paths_to_load_path = false + +# Remove the default X-Download-Options headers since it is used only by Internet Explorer. +# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. +# Rails.application.config.action_dispatch.default_headers = { +# "X-Frame-Options" => "SAMEORIGIN", +# "X-XSS-Protection" => "0", +# "X-Content-Type-Options" => "nosniff", +# "X-Permitted-Cross-Domain-Policies" => "none", +# "Referrer-Policy" => "strict-origin-when-cross-origin" +# } + +# Do not treat an `ActionController::Parameters` instance +# as equal to an equivalent `Hash` by default. +# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false + +# Active Record Encryption now uses SHA-256 as its hash digest algorithm. Important: If you have +# data encrypted with previous Rails versions, there are two scenarios to consider: +# +# 1. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default +# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too: +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1 +# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default +# in 7.0), then you need to configure SHA-256 for Active Record Encryption: +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256 +# +# If you don't currently have data encrypted with Active Record encryption, you can disable this setting to +# configure the default behavior starting 7.1+: +# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false + +# No longer run after_commit callbacks on the first of multiple Active Record +# instances to save changes to the same database row within a transaction. +# Instead, run these callbacks on the instance most likely to have internal +# state which matches what was committed to the database, typically the last +# instance to save. +# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false + +# Configures SQLite with a strict strings mode, which disables double-quoted string literals. +# +# SQLite has some quirks around double-quoted string literals. +# It first tries to consider double-quoted strings as identifier names, but if they don't exist +# it then considers them as string literals. Because of this, typos can silently go unnoticed. +# For example, it is possible to create an index for a non existing column. +# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. +# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true + +# Disable deprecated singular associations names +# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false + +# Enable the Active Job `BigDecimal` argument serializer, which guarantees +# roundtripping. Without this serializer, some queue adapters may serialize +# `BigDecimal` arguments as simple (non-roundtrippable) strings. +# +# When deploying an application with multiple replicas, old (pre-Rails 7.1) +# replicas will not be able to deserialize `BigDecimal` arguments from this +# serializer. Therefore, this setting should only be enabled after all replicas +# have been successfully upgraded to Rails 7.1. +# Rails.application.config.active_job.use_big_decimal_serializer = true + +# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or +# `write` are given an invalid `expires_at` or `expires_in` time. +# Options are `true`, and `false`. If `false`, the exception will be reported +# as `handled` and logged instead. +# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true + +# Specify whether Query Logs will format tags using the SQLCommenter format +# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. +# Options are `:legacy` and `:sqlcommenter`. +# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter + +# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` +# instances. +# +# The legacy default is `:marshal`, which is a potential vector for +# deserialization attacks in cases where a message signing secret has been +# leaked. +# +# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and +# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing +# with `Marshal` so that legacy messages can still be read. +# +# In Rails 7.2, the default will become `:json` which serializes and +# deserializes with `ActiveSupport::JSON` only. +# +# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`, +# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack` +# can roundtrip some Ruby types that are not supported by JSON, and may provide +# improved performance, but it requires the `msgpack` gem. +# +# For more information, see +# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer +# +# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers +# that have not yet been upgraded must be able to read messages from upgraded +# servers, first deploy without changing the serializer, then set the serializer +# in a subsequent deploy. +# Rails.application.config.active_support.message_serializer = :json_allow_marshal + +# Enable a performance optimization that serializes message data and metadata +# together. This changes the message format, so messages serialized this way +# cannot be read by older versions of Rails. However, messages that use the old +# format can still be read, regardless of whether this optimization is enabled. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read messages from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +# Rails.application.config.active_support.use_message_serializer_for_metadata = true + +# Set the maximum size for Rails log files. +# +# `config.load_defaults 7.1` does not set this value for environments other than +# development and test. +# +# if Rails.env.local? +# Rails.application.config.log_file_size = 100 * 1024 * 1024 +# end + +# Enable raising on assignment to attr_readonly attributes. The previous +# behavior would allow assignment but silently not persist changes to the +# database. +# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true + +# Enable validating only parent-related columns for presence when the parent is mandatory. +# The previous behavior was to validate the presence of the parent record, which performed an extra query +# to get the parent every time the child record was updated, even when parent has not changed. +# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false + +# Enable precompilation of `config.filter_parameters`. Precompilation can +# improve filtering performance, depending on the quantity and types of filters. +# Rails.application.config.precompile_filter_parameters = true + +# Enable before_committed! callbacks on all enrolled records in a transaction. +# The previous behavior was to only run the callbacks on the first copy of a record +# if there were multiple copies of the same record enrolled in the transaction. +# Rails.application.config.active_record.before_committed_on_all_records = true + +# Disable automatic column serialization into YAML. +# To keep the historic behavior, you can set it to `YAML`, however it is +# recommended to explicitly define the serialization method for each column +# rather than to rely on a global default. +# Rails.application.config.active_record.default_column_serializer = nil + +# Enable a performance optimization that serializes Active Record models +# in a faster and more compact way. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read caches from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +# Rails.application.config.active_record.marshalling_format_version = 7.1 + +# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. +# This matches the behaviour of all other callbacks. +# In previous versions of Rails, they ran in the inverse order. +# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true + +# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. +# +# Rails.application.config.active_record.commit_transaction_on_non_local_return = true + +# Controls when to generate a value for has_secure_token declarations. +# +# Rails.application.config.active_record.generate_secure_token_on = :initialize + +# ** Please read carefully, this must be configured in config/application.rb ** +# Change the format of the cache entry. +# Changing this default means that all new cache entries added to the cache +# will have a different format that is not supported by Rails 7.0 +# applications. +# Only change this value after your application is fully deployed to Rails 7.1 +# and you have no plans to rollback. +# When you're ready to change format, add this to `config/application.rb` (NOT +# this file): +# config.active_support.cache_format_version = 7.1 + +# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. +# +# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. +# +# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +# Configure the log level used by the DebugExceptions middleware when logging +# uncaught exceptions during requests +# Rails.application.config.action_dispatch.debug_exception_log_level = :error + +# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 +# parsers. +# +# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4. +# +# In previous versions of Rails, these test helpers always used an HTML4 parser. +# +# Rails.application.config.dom_testing_default_html_version = :html5 From c8252717a229d8797b187c21477afeb38fe006bf Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 10 Oct 2023 10:14:46 +0200 Subject: [PATCH 10/16] Ignore missing callbacks and throw errors in tests --- config/environments/development.rb | 3 ++- config/environments/test.rb | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index c25e2a5aa7..3641cc6774 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -119,7 +119,8 @@ # config.action_cable.disable_request_forgery_protection = true # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true + # Disable because application_controller.rb mentions a lot of actions that are only defined in some subclasses + config.action_controller.raise_on_missing_callback_actions = false # Exception notifications config.middleware.use ExceptionNotification::Rack, diff --git a/config/environments/test.rb b/config/environments/test.rb index 9d21a27639..fe0bc10bf2 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -38,7 +38,7 @@ config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = :rescuable + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -69,7 +69,8 @@ # 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 + # Disable because application_controller.rb mentions a lot of actions that are only defined in some subclasses + config.action_controller.raise_on_missing_callback_actions = false Delayed::Worker.delay_jobs = ->(job) { !%w[default exports git statistics].include?(job.queue) } From 37de3c194ef042fa50dd8504f1e64821a3223213 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 10 Oct 2023 15:01:51 +0200 Subject: [PATCH 11/16] Apply new defaults --- bin/setup | 3 + config/application.rb | 24 ++++++- .../new_framework_defaults_7_1.rb | 71 ++++++++++--------- test/helpers/application_helper_test.rb | 4 +- test/runners/result_constructor_test.rb | 2 +- test/testhelpers/git_helper.rb | 1 - 6 files changed, 66 insertions(+), 39 deletions(-) diff --git a/bin/setup b/bin/setup index 3cd5a9d780..2cc4794838 100755 --- a/bin/setup +++ b/bin/setup @@ -17,6 +17,9 @@ FileUtils.chdir APP_ROOT do system! "gem install bundler --conservative" system("bundle check") || system!("bundle install") + # Install JavaScript dependencies + system! 'bin/yarn' + # puts "\n== Copying sample files ==" # unless File.exist?("config/database.yml") # FileUtils.cp "config/database.yml.sample", "config/database.yml" diff --git a/config/application.rb b/config/application.rb index 7c9eda4730..43566df44f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,29 @@ module Dodona class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.1 + + # ** Please read carefully, this must be configured in config/application.rb ** + # Change the format of the cache entry. + # Changing this default means that all new cache entries added to the cache + # will have a different format that is not supported by Rails 7.0 + # applications. + # Only change this value after your application is fully deployed to Rails 7.1 + # and you have no plans to rollback. + # When you're ready to change format, add this to `config/application.rb` (NOT + # this file): + config.active_support.cache_format_version = 7.0 + + # Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your + # platform. + # + # `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant + # sanitizers if they are supported, else fall back to HTML4 sanitizers. + # + # In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. + + # we stick to HTML4 until https://github.com/rails/rails-html-sanitizer/issues/169 is fixed + Rails.application.config.action_view.sanitizer_vendor = Rails::HTML4::Sanitizer config.dodona_email = 'dodona@ugent.be' # Configuration for the application, engines, and railties goes here. diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index d41af162ad..ab93bf2b70 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -13,21 +13,21 @@ # to manually require files that are managed by the autoloader, which you shouldn't do anyway. # This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size # of the bootsnap cache if you use it. -# Rails.application.config.add_autoload_paths_to_load_path = false +Rails.application.config.add_autoload_paths_to_load_path = false # Remove the default X-Download-Options headers since it is used only by Internet Explorer. # If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. -# Rails.application.config.action_dispatch.default_headers = { -# "X-Frame-Options" => "SAMEORIGIN", -# "X-XSS-Protection" => "0", -# "X-Content-Type-Options" => "nosniff", -# "X-Permitted-Cross-Domain-Policies" => "none", -# "Referrer-Policy" => "strict-origin-when-cross-origin" -# } +Rails.application.config.action_dispatch.default_headers = { + "X-Frame-Options" => "SAMEORIGIN", + "X-XSS-Protection" => "0", + "X-Content-Type-Options" => "nosniff", + "X-Permitted-Cross-Domain-Policies" => "none", + "Referrer-Policy" => "strict-origin-when-cross-origin" +} # Do not treat an `ActionController::Parameters` instance # as equal to an equivalent `Hash` by default. -# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false +Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false # Active Record Encryption now uses SHA-256 as its hash digest algorithm. Important: If you have # data encrypted with previous Rails versions, there are two scenarios to consider: @@ -41,14 +41,14 @@ # # If you don't currently have data encrypted with Active Record encryption, you can disable this setting to # configure the default behavior starting 7.1+: -# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false +Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false # No longer run after_commit callbacks on the first of multiple Active Record # instances to save changes to the same database row within a transaction. # Instead, run these callbacks on the instance most likely to have internal # state which matches what was committed to the database, typically the last # instance to save. -# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false +Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false # Configures SQLite with a strict strings mode, which disables double-quoted string literals. # @@ -57,10 +57,10 @@ # it then considers them as string literals. Because of this, typos can silently go unnoticed. # For example, it is possible to create an index for a non existing column. # See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. -# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true +Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true # Disable deprecated singular associations names -# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false +Rails.application.config.active_record.allow_deprecated_singular_associations_name = false # Enable the Active Job `BigDecimal` argument serializer, which guarantees # roundtripping. Without this serializer, some queue adapters may serialize @@ -70,18 +70,18 @@ # replicas will not be able to deserialize `BigDecimal` arguments from this # serializer. Therefore, this setting should only be enabled after all replicas # have been successfully upgraded to Rails 7.1. -# Rails.application.config.active_job.use_big_decimal_serializer = true +Rails.application.config.active_job.use_big_decimal_serializer = true # Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or # `write` are given an invalid `expires_at` or `expires_in` time. # Options are `true`, and `false`. If `false`, the exception will be reported # as `handled` and logged instead. -# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true +Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true # Specify whether Query Logs will format tags using the SQLCommenter format # (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. # Options are `:legacy` and `:sqlcommenter`. -# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter +Rails.application.config.active_record.query_log_tags_format = :sqlcommenter # Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` # instances. @@ -109,7 +109,7 @@ # that have not yet been upgraded must be able to read messages from upgraded # servers, first deploy without changing the serializer, then set the serializer # in a subsequent deploy. -# Rails.application.config.active_support.message_serializer = :json_allow_marshal +Rails.application.config.active_support.message_serializer = :json_allow_marshal # Enable a performance optimization that serializes message data and metadata # together. This changes the message format, so messages serialized this way @@ -120,41 +120,41 @@ # not yet been upgraded must be able to read messages from upgraded servers, # leave this optimization off on the first deploy, then enable it on a # subsequent deploy. -# Rails.application.config.active_support.use_message_serializer_for_metadata = true +Rails.application.config.active_support.use_message_serializer_for_metadata = true # Set the maximum size for Rails log files. # # `config.load_defaults 7.1` does not set this value for environments other than # development and test. # -# if Rails.env.local? -# Rails.application.config.log_file_size = 100 * 1024 * 1024 -# end +if Rails.env.local? + Rails.application.config.log_file_size = 100 * 1024 * 1024 +end # Enable raising on assignment to attr_readonly attributes. The previous # behavior would allow assignment but silently not persist changes to the # database. -# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true +Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true # Enable validating only parent-related columns for presence when the parent is mandatory. # The previous behavior was to validate the presence of the parent record, which performed an extra query # to get the parent every time the child record was updated, even when parent has not changed. -# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false +Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false # Enable precompilation of `config.filter_parameters`. Precompilation can # improve filtering performance, depending on the quantity and types of filters. -# Rails.application.config.precompile_filter_parameters = true +Rails.application.config.precompile_filter_parameters = true # Enable before_committed! callbacks on all enrolled records in a transaction. # The previous behavior was to only run the callbacks on the first copy of a record # if there were multiple copies of the same record enrolled in the transaction. -# Rails.application.config.active_record.before_committed_on_all_records = true +Rails.application.config.active_record.before_committed_on_all_records = true # Disable automatic column serialization into YAML. # To keep the historic behavior, you can set it to `YAML`, however it is # recommended to explicitly define the serialization method for each column # rather than to rely on a global default. -# Rails.application.config.active_record.default_column_serializer = nil +Rails.application.config.active_record.default_column_serializer = nil # Enable a performance optimization that serializes Active Record models # in a faster and more compact way. @@ -163,20 +163,20 @@ # not yet been upgraded must be able to read caches from upgraded servers, # leave this optimization off on the first deploy, then enable it on a # subsequent deploy. -# Rails.application.config.active_record.marshalling_format_version = 7.1 +Rails.application.config.active_record.marshalling_format_version = 7.1 # Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. # This matches the behaviour of all other callbacks. # In previous versions of Rails, they ran in the inverse order. -# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true +Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true # Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. # -# Rails.application.config.active_record.commit_transaction_on_non_local_return = true +Rails.application.config.active_record.commit_transaction_on_non_local_return = true # Controls when to generate a value for has_secure_token declarations. # -# Rails.application.config.active_record.generate_secure_token_on = :initialize +Rails.application.config.active_record.generate_secure_token_on = :initialize # ** Please read carefully, this must be configured in config/application.rb ** # Change the format of the cache entry. @@ -196,8 +196,9 @@ # sanitizers if they are supported, else fall back to HTML4 sanitizers. # # In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. -# -# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +# we stick to HTML4 until https://github.com/rails/rails-html-sanitizer/issues/169 is fixed +Rails.application.config.action_view.sanitizer_vendor = Rails::HTML4::Sanitizer # Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your # platform. @@ -207,11 +208,11 @@ # # In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. # -# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor +Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor # Configure the log level used by the DebugExceptions middleware when logging # uncaught exceptions during requests -# Rails.application.config.action_dispatch.debug_exception_log_level = :error +Rails.application.config.action_dispatch.debug_exception_log_level = :error # Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 # parsers. @@ -220,4 +221,4 @@ # # In previous versions of Rails, these test helpers always used an HTML4 parser. # -# Rails.application.config.dom_testing_default_html_version = :html5 +Rails.application.config.dom_testing_default_html_version = :html5 diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 6c4295191c..34e661962b 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -84,7 +84,9 @@ class ApplicationHelperTest < ActiveSupport::TestCase dirty_html = <<~HTML - + + + diff --git a/test/runners/result_constructor_test.rb b/test/runners/result_constructor_test.rb index e3ba4203e5..451a01f665 100644 --- a/test/runners/result_constructor_test.rb +++ b/test/runners/result_constructor_test.rb @@ -1,6 +1,6 @@ require 'json' require 'test_helper' -require 'result_constructor' +require_relative '../../app/runners/result_constructor' class ResultConstructorTest < ActiveSupport::TestCase MINIMAL_FULL_S = diff --git a/test/testhelpers/git_helper.rb b/test/testhelpers/git_helper.rb index b1a266e7da..f523235607 100644 --- a/test/testhelpers/git_helper.rb +++ b/test/testhelpers/git_helper.rb @@ -1,7 +1,6 @@ require 'pathname' require 'fileutils' -require 'concerns/gitable' module Gitable def git_repository GitRepository.new full_path From 41635ce73e2f82f5e0a6769e2e8dc9f06c85eff8 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 10 Oct 2023 15:02:22 +0200 Subject: [PATCH 12/16] Remove new deaults file --- .../new_framework_defaults_7_1.rb | 224 ------------------ 1 file changed, 224 deletions(-) delete mode 100644 config/initializers/new_framework_defaults_7_1.rb diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb deleted file mode 100644 index ab93bf2b70..0000000000 --- a/config/initializers/new_framework_defaults_7_1.rb +++ /dev/null @@ -1,224 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.1 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.1`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able -# to manually require files that are managed by the autoloader, which you shouldn't do anyway. -# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size -# of the bootsnap cache if you use it. -Rails.application.config.add_autoload_paths_to_load_path = false - -# Remove the default X-Download-Options headers since it is used only by Internet Explorer. -# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. -Rails.application.config.action_dispatch.default_headers = { - "X-Frame-Options" => "SAMEORIGIN", - "X-XSS-Protection" => "0", - "X-Content-Type-Options" => "nosniff", - "X-Permitted-Cross-Domain-Policies" => "none", - "Referrer-Policy" => "strict-origin-when-cross-origin" -} - -# Do not treat an `ActionController::Parameters` instance -# as equal to an equivalent `Hash` by default. -Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false - -# Active Record Encryption now uses SHA-256 as its hash digest algorithm. Important: If you have -# data encrypted with previous Rails versions, there are two scenarios to consider: -# -# 1. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default -# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too: -# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1 -# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default -# in 7.0), then you need to configure SHA-256 for Active Record Encryption: -# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256 -# -# If you don't currently have data encrypted with Active Record encryption, you can disable this setting to -# configure the default behavior starting 7.1+: -Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false - -# No longer run after_commit callbacks on the first of multiple Active Record -# instances to save changes to the same database row within a transaction. -# Instead, run these callbacks on the instance most likely to have internal -# state which matches what was committed to the database, typically the last -# instance to save. -Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false - -# Configures SQLite with a strict strings mode, which disables double-quoted string literals. -# -# SQLite has some quirks around double-quoted string literals. -# It first tries to consider double-quoted strings as identifier names, but if they don't exist -# it then considers them as string literals. Because of this, typos can silently go unnoticed. -# For example, it is possible to create an index for a non existing column. -# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. -Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true - -# Disable deprecated singular associations names -Rails.application.config.active_record.allow_deprecated_singular_associations_name = false - -# Enable the Active Job `BigDecimal` argument serializer, which guarantees -# roundtripping. Without this serializer, some queue adapters may serialize -# `BigDecimal` arguments as simple (non-roundtrippable) strings. -# -# When deploying an application with multiple replicas, old (pre-Rails 7.1) -# replicas will not be able to deserialize `BigDecimal` arguments from this -# serializer. Therefore, this setting should only be enabled after all replicas -# have been successfully upgraded to Rails 7.1. -Rails.application.config.active_job.use_big_decimal_serializer = true - -# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or -# `write` are given an invalid `expires_at` or `expires_in` time. -# Options are `true`, and `false`. If `false`, the exception will be reported -# as `handled` and logged instead. -Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true - -# Specify whether Query Logs will format tags using the SQLCommenter format -# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. -# Options are `:legacy` and `:sqlcommenter`. -Rails.application.config.active_record.query_log_tags_format = :sqlcommenter - -# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` -# instances. -# -# The legacy default is `:marshal`, which is a potential vector for -# deserialization attacks in cases where a message signing secret has been -# leaked. -# -# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and -# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing -# with `Marshal` so that legacy messages can still be read. -# -# In Rails 7.2, the default will become `:json` which serializes and -# deserializes with `ActiveSupport::JSON` only. -# -# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`, -# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack` -# can roundtrip some Ruby types that are not supported by JSON, and may provide -# improved performance, but it requires the `msgpack` gem. -# -# For more information, see -# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer -# -# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers -# that have not yet been upgraded must be able to read messages from upgraded -# servers, first deploy without changing the serializer, then set the serializer -# in a subsequent deploy. -Rails.application.config.active_support.message_serializer = :json_allow_marshal - -# Enable a performance optimization that serializes message data and metadata -# together. This changes the message format, so messages serialized this way -# cannot be read by older versions of Rails. However, messages that use the old -# format can still be read, regardless of whether this optimization is enabled. -# -# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have -# not yet been upgraded must be able to read messages from upgraded servers, -# leave this optimization off on the first deploy, then enable it on a -# subsequent deploy. -Rails.application.config.active_support.use_message_serializer_for_metadata = true - -# Set the maximum size for Rails log files. -# -# `config.load_defaults 7.1` does not set this value for environments other than -# development and test. -# -if Rails.env.local? - Rails.application.config.log_file_size = 100 * 1024 * 1024 -end - -# Enable raising on assignment to attr_readonly attributes. The previous -# behavior would allow assignment but silently not persist changes to the -# database. -Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true - -# Enable validating only parent-related columns for presence when the parent is mandatory. -# The previous behavior was to validate the presence of the parent record, which performed an extra query -# to get the parent every time the child record was updated, even when parent has not changed. -Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false - -# Enable precompilation of `config.filter_parameters`. Precompilation can -# improve filtering performance, depending on the quantity and types of filters. -Rails.application.config.precompile_filter_parameters = true - -# Enable before_committed! callbacks on all enrolled records in a transaction. -# The previous behavior was to only run the callbacks on the first copy of a record -# if there were multiple copies of the same record enrolled in the transaction. -Rails.application.config.active_record.before_committed_on_all_records = true - -# Disable automatic column serialization into YAML. -# To keep the historic behavior, you can set it to `YAML`, however it is -# recommended to explicitly define the serialization method for each column -# rather than to rely on a global default. -Rails.application.config.active_record.default_column_serializer = nil - -# Enable a performance optimization that serializes Active Record models -# in a faster and more compact way. -# -# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have -# not yet been upgraded must be able to read caches from upgraded servers, -# leave this optimization off on the first deploy, then enable it on a -# subsequent deploy. -Rails.application.config.active_record.marshalling_format_version = 7.1 - -# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. -# This matches the behaviour of all other callbacks. -# In previous versions of Rails, they ran in the inverse order. -Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true - -# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. -# -Rails.application.config.active_record.commit_transaction_on_non_local_return = true - -# Controls when to generate a value for has_secure_token declarations. -# -Rails.application.config.active_record.generate_secure_token_on = :initialize - -# ** Please read carefully, this must be configured in config/application.rb ** -# Change the format of the cache entry. -# Changing this default means that all new cache entries added to the cache -# will have a different format that is not supported by Rails 7.0 -# applications. -# Only change this value after your application is fully deployed to Rails 7.1 -# and you have no plans to rollback. -# When you're ready to change format, add this to `config/application.rb` (NOT -# this file): -# config.active_support.cache_format_version = 7.1 - -# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your -# platform. -# -# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant -# sanitizers if they are supported, else fall back to HTML4 sanitizers. -# -# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. - -# we stick to HTML4 until https://github.com/rails/rails-html-sanitizer/issues/169 is fixed -Rails.application.config.action_view.sanitizer_vendor = Rails::HTML4::Sanitizer - -# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your -# platform. -# -# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant -# sanitizers if they are supported, else fall back to HTML4 sanitizers. -# -# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. -# -Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor - -# Configure the log level used by the DebugExceptions middleware when logging -# uncaught exceptions during requests -Rails.application.config.action_dispatch.debug_exception_log_level = :error - -# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 -# parsers. -# -# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4. -# -# In previous versions of Rails, these test helpers always used an HTML4 parser. -# -Rails.application.config.dom_testing_default_html_version = :html5 From a1a6948a6324ffd54172259dac3ddd120470fb9d Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 10 Oct 2023 15:08:53 +0200 Subject: [PATCH 13/16] Do not eager load tests --- config/environments/test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index fe0bc10bf2..70908d9747 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -24,7 +24,7 @@ # this is usually not necessary, and can slow down your test suite. However, it's # recommended that you enable it in continuous integration systems to ensure eager # loading is working properly before deploying your code. - config.eager_load = ENV["CI"].present? + config.eager_load = false # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true From 3aca6b66151c6c22783e2abe5d5c36d5f6198c37 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 11 Oct 2023 13:16:21 +0200 Subject: [PATCH 14/16] Use viewBox to support HTML5 --- app/helpers/application_helper.rb | 2 +- config/application.rb | 11 ----------- test/helpers/application_helper_test.rb | 2 +- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 89f54ca91f..30b108dab7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -149,7 +149,7 @@ def sanitize(html) %w[svg g style circle line rect path polygon text] @attributes ||= Rails::Html::SafeListSanitizer.allowed_attributes.to_a + %w[style target data-bs-toggle data-parent data-tab data-line data-element id] + - %w[viewbox width height version style class transform id x y rx ry x1 y1 x2 y2 d points fill stroke stroke-width cx cy r font-size font-family font-weight font-variant] + %w[viewBox width height version style class transform id x y rx ry x1 y1 x2 y2 d points fill stroke stroke-width cx cy r font-size font-family font-weight font-variant] # Filters allowed tags and attributes sanitized = ActionController::Base.helpers.sanitize html, diff --git a/config/application.rb b/config/application.rb index 43566df44f..bd4ddf1bd1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,17 +22,6 @@ class Application < Rails::Application # this file): config.active_support.cache_format_version = 7.0 - # Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your - # platform. - # - # `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant - # sanitizers if they are supported, else fall back to HTML4 sanitizers. - # - # In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. - - # we stick to HTML4 until https://github.com/rails/rails-html-sanitizer/issues/169 is fixed - Rails.application.config.action_view.sanitizer_vendor = Rails::HTML4::Sanitizer - config.dodona_email = 'dodona@ugent.be' # Configuration for the application, engines, and railties goes here. # diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 34e661962b..50697c5361 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -102,7 +102,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase test 'sanitize helper should allow a selection of svg tags' do dirty_html = <<~HTML - + From 9f2d546bfa6daa7516fc4f4290b4145875757778 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 11 Oct 2023 13:35:16 +0200 Subject: [PATCH 15/16] Move to new to_time default --- config/initializers/new_framework_defaults.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 2cb708e72a..c9bf79d301 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -12,9 +12,5 @@ # Enable origin-checking CSRF mitigation. Previous versions had false. Rails.application.config.action_controller.forgery_protection_origin_check = false -# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. -# Previous versions had false. -ActiveSupport.to_time_preserves_timezone = false - # Require `belongs_to` associations by default. Previous versions had false. Rails.application.config.active_record.belongs_to_required_by_default = false From c7cb3ff8c16a2fe8053eed0c3d919f4b980e08ee Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 11 Oct 2023 15:26:59 +0200 Subject: [PATCH 16/16] Update rails js packages --- app/javascript/packs/application_pack.js | 4 ++-- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/javascript/packs/application_pack.js b/app/javascript/packs/application_pack.js index 90ad7a54f9..06411ace4c 100644 --- a/app/javascript/packs/application_pack.js +++ b/app/javascript/packs/application_pack.js @@ -10,9 +10,9 @@ import "core-js/stable"; import "regenerator-runtime/runtime"; -import { start as startRails } from "@rails/ujs"; +import Rails from "@rails/ujs"; -startRails(); +Rails.start(); import { I18n } from "i18n/i18n"; window.I18n = new I18n(); diff --git a/package.json b/package.json index 310d7b04c1..04a771a5ae 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "@babel/preset-typescript": "^7.23.0", "@dodona/papyros": "^1.0.1", "@popperjs/core": "^2.11.8", - "@rails/activestorage": "^7.0.8", - "@rails/ujs": "^7.0.8", + "@rails/activestorage": "^7.1.0", + "@rails/ujs": "^7.1.0", "@types/d3": "^7.4.1", "babel-loader": "^9.1.3", "babel-plugin-macros": "^3.1.0", diff --git a/yarn.lock b/yarn.lock index baede02ccc..4398d6be00 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1630,17 +1630,17 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== -"@rails/activestorage@^7.0.8": - version "7.0.8" - resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-7.0.8.tgz#7ea8a656b5621e0dc57f51e3ad2f06c3af30d3ea" - integrity sha512-CxPyCxTV0HIaZP8qqH11tkESNl8TrQsIAesAgeOXDOl0BkaN6nC0/Mq2/0ngezBu9CZbFzfHtP2g6Yl8BWkV8g== +"@rails/activestorage@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-7.1.0.tgz#6aeea30720f98ea25f790596862ac89251bcc05d" + integrity sha512-TYc3AkBaXgBlavODTHPgyaOMqt0MRkFlPCa7BiQJJyND17GYS7pP0lT0bgcDQgpuKMvsCdVxQaRwl6tzL5AW0g== dependencies: spark-md5 "^3.0.1" -"@rails/ujs@^7.0.8": - version "7.0.8" - resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.0.8.tgz#59853367d0827b3955d2c4bedfd5eba4a79d3422" - integrity sha512-tOQQBVH8LsUpGXqDnk+kaOGVsgZ8maHAhEiw3Git3p88q+c0Slgu47HuDnL6sVxeCfz24zbq7dOjsVYDiTpDIA== +"@rails/ujs@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.1.0.tgz#144ec54b1cc53aa24713cafc29bf8a8d52ac3d24" + integrity sha512-cO8+HREI8hhJDaFyzGCA4AL9/EotHYSTz1v7aQmfZmUdanx/ppXe+MPE4dly2/MtC6Ha6K2Dkzo7bkDGc46y6Q== "@sinonjs/commons@^1.7.0": version "1.8.3"
Head
Head