trek 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.node-version +1 -1
- data/AGENTS.md +18 -14
- data/CHANGELOG.md +88 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +135 -124
- data/Makefile +9 -1
- data/README.md +17 -21
- data/app/components/trek/dashboard/tile_component/tile_component.css +9 -0
- data/app/components/trek/dashboard/tile_component/tile_component.html.slim +4 -2
- data/app/components/trek/dashboard/tile_component.rb +12 -2
- data/app/components/trek/form/content_editor_component/content_editor_component.css +9 -8
- data/app/components/trek/form/content_editor_component/content_editor_component.html.slim +19 -93
- data/app/components/trek/form/content_editor_component/content_editor_component.js +94 -251
- data/app/components/trek/form/content_editor_component/extensions/block_view.js +40 -0
- data/app/components/trek/form/content_editor_component/extensions/image_block.js +28 -26
- data/app/components/trek/form/content_editor_component/extensions/prompts_block.js +15 -26
- data/app/components/trek/form/content_editor_component/extensions/table_of_contents.js +1 -3
- data/app/components/trek/form/content_editor_component.rb +15 -0
- data/app/components/trek/form/image_field_component/image_field_component.css +40 -1
- data/app/components/trek/form/image_field_component/image_field_component.html.slim +0 -9
- data/app/components/trek/form/image_field_component/image_field_component.js +1 -2
- data/app/components/trek/form/image_field_component.rb +36 -9
- data/app/components/trek/form/password_strength_component/password_strength_component.css +2 -0
- data/app/components/trek/form/sound_field_component/sound_field_component.js +1 -2
- data/app/components/trek/security_check_component/security_check_component.css +69 -0
- data/app/components/trek/security_check_component/security_check_component.html.slim +19 -0
- data/app/components/trek/security_check_component/security_check_component.js +15 -0
- data/app/components/trek/security_check_component.rb +19 -0
- data/app/content/trek/content/cleaner.rb +53 -0
- data/app/content/trek/content/document.rb +2 -2
- data/app/content/trek/content/list_item.rb +1 -1
- data/app/content/trek/content/paragraph.rb +7 -2
- data/app/content/trek/content/prompts_block.rb +1 -2
- data/app/content/trek/content.rb +6 -0
- data/app/controllers/concerns/trek/auditable.rb +5 -2
- data/app/controllers/concerns/trek/localization.rb +6 -2
- data/app/controllers/concerns/trek/reorderable.rb +24 -6
- data/app/controllers/trek/csp_reports_controller.rb +14 -1
- data/app/controllers/trek/panels/prompts_controller.rb +1 -1
- data/app/controllers/trek/resource_controller.rb +5 -5
- data/app/jobs/trek/purge_expired_sessions_job.rb +4 -3
- data/app/jobs/trek/purge_expired_sign_in_codes_job.rb +15 -0
- data/app/models/concerns/trek/contentable.rb +15 -1
- data/app/models/concerns/trek/users/sign_in_code.rb +70 -0
- data/app/models/concerns/trek/users/sign_in_lockout.rb +4 -2
- data/app/policies/trek/security_check_policy.rb +8 -0
- data/app/uploaders/image_uploader.rb +77 -15
- data/app/views/trek/panels/links/_form.html.slim +2 -4
- data/app/views/trek/panels/prompts/create.turbo_stream.slim +0 -1
- data/config/locales/trek.en.yml +97 -11
- data/config/locales/trek.fr.yml +97 -11
- data/docs/.vitepress/config.mjs +5 -1
- data/docs/background-jobs.md +74 -0
- data/docs/content-editor.md +219 -0
- data/docs/customize.md +2 -0
- data/docs/deploy.md +69 -6
- data/docs/getting-started.md +16 -18
- data/docs/index.md +2 -2
- data/docs/personal-data.md +61 -0
- data/docs/proxies.md +2 -2
- data/docs/reference/components.md +4 -4
- data/docs/reference/concerns/contentable.md +10 -4
- data/docs/reference/concerns/formattable.md +1 -1
- data/docs/reference/concerns/fragmentable.md +12 -6
- data/docs/reference/concerns/orderable.md +2 -2
- data/docs/reference/concerns/search-engine-optimizable.md +1 -1
- data/docs/reference/concerns/searchable.md +14 -1
- data/docs/reference/concerns/sectionable.md +7 -3
- data/docs/reference/concerns/versionable.md +1 -1
- data/docs/reference/controllers.md +33 -1
- data/docs/reference/environment-variables.md +3 -2
- data/docs/reference/formatters.md +4 -31
- data/docs/reference/forms.md +7 -4
- data/docs/reference/generators/admin-user.md +1 -1
- data/docs/reference/generators/audit-log.md +12 -13
- data/docs/reference/generators/install.md +23 -11
- data/docs/reference/generators/public-accounts.md +159 -0
- data/docs/reference/generators/scaffold.md +28 -9
- data/docs/reference/generators/security-headers.md +5 -4
- data/docs/reference/generators/taxonomies.md +1 -1
- data/docs/reference/icons.md +5 -3
- data/docs/reference/index.md +10 -7
- data/docs/reference/models/current.md +5 -3
- data/docs/reference/models/page-version.md +1 -1
- data/docs/reference/models/user.md +7 -8
- data/docs/reference/uploaders.md +25 -0
- data/docs/reference/validators.md +1 -1
- data/docs/security.md +30 -9
- data/docs/what-is-trek.md +4 -4
- data/lib/generators/trek/USAGE +1 -1
- data/lib/generators/trek/audit_log_generator.rb +62 -0
- data/lib/generators/trek/helpers.rb +17 -0
- data/lib/generators/trek/install/admin/routes_generator.rb +2 -1
- data/lib/generators/trek/install/admin/security_check_generator.rb +36 -0
- data/lib/generators/trek/install/admin/users_generator.rb +6 -1
- data/lib/generators/trek/install/audit_log_generator.rb +9 -45
- data/lib/generators/trek/install/ci_generator.rb +19 -0
- data/lib/generators/trek/install/good_job_generator.rb +161 -0
- data/lib/generators/trek/install/model_specs_generator.rb +3 -3
- data/lib/generators/trek/install/postcss_generator.rb +1 -2
- data/lib/generators/trek/install/ruby_generator.rb +1 -1
- data/lib/generators/trek/install/scalingo_generator.rb +7 -45
- data/lib/generators/trek/install/translations_generator.rb +1 -2
- data/lib/generators/trek/install_generator.rb +18 -2
- data/lib/generators/trek/public_accounts_generator.rb +294 -0
- data/lib/generators/trek/scaffold_generator.rb +22 -21
- data/lib/generators/trek/scalingo_generator.rb +67 -0
- data/lib/generators/trek/templates/.gitlab-ci.yml +10 -1
- data/lib/generators/trek/templates/AGENTS.md +2 -2
- data/lib/generators/trek/templates/Makefile +1 -0
- data/lib/generators/trek/templates/config/i18n-tasks.yml.erb +0 -8
- data/lib/generators/trek/templates/controllers/admin/password_renewals_controller.rb +11 -0
- data/lib/generators/trek/templates/controllers/admin/security_checks_controller.rb +11 -0
- data/lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb +1 -1
- data/lib/generators/trek/templates/controllers/admin/users_controller.rb +0 -8
- data/lib/generators/trek/templates/controllers/concerns/trek/authentication.rb +13 -4
- data/lib/generators/trek/templates/initializers/content_security_policy.rb +3 -2
- data/lib/generators/trek/templates/initializers/good_job.rb.tt +40 -0
- data/lib/generators/trek/templates/jobs/mail_delivery_job.rb +6 -0
- data/lib/generators/trek/templates/layouts/admin.html.slim +10 -0
- data/lib/generators/trek/templates/mailers/admin_mailer.rb +4 -2
- data/lib/generators/trek/templates/package.json.tt +1 -1
- data/lib/generators/trek/templates/policies/security_check.rb +4 -0
- data/lib/generators/trek/templates/public_accounts/api/authentication.rb.tt +76 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/accounts_controller.rb.tt +22 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/active_sessions_controller.rb.tt +21 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/base_controller.rb.tt +71 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/email_changes_controller.rb.tt +55 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/email_confirmations_controller.rb.tt +19 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/password_resets_controller.rb.tt +28 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/passwords_controller.rb.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/registrations_controller.rb.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/sessions_controller.rb.tt +57 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/sign_in_codes_controller.rb.tt +20 -0
- data/lib/generators/trek/templates/public_accounts/jobs/sign_in_code_job.rb.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/locales/accounts.en.yml.tt +215 -0
- data/lib/generators/trek/templates/public_accounts/locales/accounts.fr.yml.tt +215 -0
- data/lib/generators/trek/templates/public_accounts/mailers/account_mailer.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/migrations/create_accounts.rb.tt +46 -0
- data/lib/generators/trek/templates/public_accounts/models/account/session.rb.tt +47 -0
- data/lib/generators/trek/templates/public_accounts/models/account/sign_in_code.rb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/models/account.rb.tt +87 -0
- data/lib/generators/trek/templates/public_accounts/spec/api/accounts_spec.rb.tt +90 -0
- data/lib/generators/trek/templates/public_accounts/spec/api/sign_ins_spec.rb.tt +188 -0
- data/lib/generators/trek/templates/public_accounts/spec/models/account/sign_in_code_spec.rb.tt +66 -0
- data/lib/generators/trek/templates/public_accounts/spec/models/account_spec.rb.tt +129 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/accounts_spec.rb.tt +126 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/authentication_spec.rb.tt +43 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/sign_ins_spec.rb.tt +237 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.fr.html.slim.tt +13 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.en.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.en.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.fr.html.slim.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.fr.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.fr.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.fr.html.slim.tt +13 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.en.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.en.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.fr.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.fr.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.en.html.slim.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.en.text.erb.tt +14 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.fr.html.slim.tt +24 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.fr.text.erb.tt +14 -0
- data/lib/generators/trek/templates/public_accounts/web/authentication.rb.tt +97 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/accounts_controller.rb.tt +33 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/active_sessions_controller.rb.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/base_controller.rb.tt +52 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/email_changes_controller.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/email_confirmations_controller.rb.tt +19 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/password_resets_controller.rb.tt +41 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/passwords_controller.rb.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/registrations_controller.rb.tt +24 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/sessions_controller.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/sign_in_codes_controller.rb.tt +32 -0
- data/lib/generators/trek/templates/public_accounts/web/views/_flash.html.slim.tt +5 -0
- data/lib/generators/trek/templates/public_accounts/web/views/accounts/show.html.slim.tt +52 -0
- data/lib/generators/trek/templates/public_accounts/web/views/email_changes/edit.html.slim.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/web/views/email_changes/new.html.slim.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/views/password_resets/edit.html.slim.tt +29 -0
- data/lib/generators/trek/templates/public_accounts/web/views/password_resets/new.html.slim.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/views/passwords/edit.html.slim.tt +28 -0
- data/lib/generators/trek/templates/public_accounts/web/views/registrations/new.html.slim.tt +30 -0
- data/lib/generators/trek/templates/public_accounts/web/views/sessions/new.html.slim.tt +40 -0
- data/lib/generators/trek/templates/public_accounts/web/views/sign_in_codes/new.html.slim.tt +17 -0
- data/lib/generators/trek/templates/spec/jobs/mail_delivery_job_spec.rb +11 -0
- data/lib/generators/trek/templates/spec/mailers/admin_mailer_spec.rb +10 -0
- data/lib/generators/trek/templates/spec/requests/admin/fragments_spec.rb +1 -1
- data/lib/generators/trek/templates/spec/requests/admin/good_job_spec.rb +34 -0
- data/lib/generators/trek/templates/spec/requests/admin/pages_spec.rb +12 -1
- data/lib/generators/trek/templates/spec/requests/admin/panels_spec.rb +16 -0
- data/lib/generators/trek/templates/spec/requests/admin/password_renewal_spec.rb +2 -2
- data/lib/generators/trek/templates/spec/requests/admin/security_checks_spec.rb +24 -0
- data/lib/generators/trek/templates/spec/requests/admin/sign_in_lockout_spec.rb +1 -1
- data/lib/generators/trek/templates/spec/requests/admin/sign_in_notices_spec.rb +33 -0
- data/lib/generators/trek/templates/spec/requests/admin/user_sessions_spec.rb +2 -2
- data/lib/generators/trek/templates/views/admin/pages/_form.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/security_checks/show.html.slim +9 -0
- data/lib/generators/trek/templates/views/admin/user_password_resets/edit.html.slim +6 -1
- data/lib/generators/trek/templates/views/admin/user_sessions/new.html.slim +4 -1
- data/lib/generators/trek/templates/views/admin/users/index.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.text.erb +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.text.erb +1 -1
- data/lib/tasks/trek/attachments.rake +12 -0
- data/lib/tasks/trek/security.rake +10 -0
- data/lib/trek/csp_reports.rb +22 -4
- data/lib/trek/disposable_email_domains.rb +9 -20
- data/lib/trek/engine.rb +5 -0
- data/lib/trek/json_compatibility.rb +20 -0
- data/lib/trek/security_check.rb +241 -0
- data/lib/trek/stored_image_metadata.rb +88 -0
- data/lib/trek/typography_formatter.rb +35 -4
- data/lib/trek/version.rb +1 -1
- data/lib/trek.rb +2 -1
- data/package.json +16 -13
- data/postcss.config.js +0 -3
- data/trek.gemspec +6 -7
- data/vitest.config.mjs +24 -0
- data/yarn.lock +1667 -1010
- metadata +122 -33
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Trek
|
|
4
|
+
# Checks a running app's configuration against what docs/security.md recommends, for
|
|
5
|
+
# `bin/rails trek:security:check`: each check gives a status, a message and the docs page to read.
|
|
6
|
+
#
|
|
7
|
+
# check = Trek::SecurityCheck.new
|
|
8
|
+
# check.results.each { |result| puts result.status, result.message }
|
|
9
|
+
# check.failed? # any :failure
|
|
10
|
+
#
|
|
11
|
+
# Run it where the app runs in production, with its configuration and database (the admin accounts
|
|
12
|
+
# are counted). Given the request of an admin page (`request:`), it also checks what only a request
|
|
13
|
+
# tells: that it came over HTTPS, and the address Rails sees behind a CDN.
|
|
14
|
+
class SecurityCheck
|
|
15
|
+
# :ok, :info (a fact, nothing to fix), :warning (a recommendation not followed), :failure (a
|
|
16
|
+
# setting Trek relies on)
|
|
17
|
+
STATUSES = %i[ok info warning failure].freeze
|
|
18
|
+
|
|
19
|
+
Result = Data.define(:check, :status, :message, :docs) do
|
|
20
|
+
STATUSES.each { |status| define_method(:"#{status}?") { self.status == status } }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
DOCS = "https://trek.etamin.studio"
|
|
24
|
+
# Admins who haven't signed in for longer are reported as dormant
|
|
25
|
+
DORMANT_AFTER = 6.months
|
|
26
|
+
|
|
27
|
+
CHECKS = %i[https content_security_policy cache_store trusted_proxies admin_allowed_ips audit_log
|
|
28
|
+
session_purge cron admins encryption].freeze
|
|
29
|
+
REQUEST_CHECKS = %i[request_https remote_ip].freeze
|
|
30
|
+
|
|
31
|
+
# The headers CDNs put the visitor's address in (Cloudflare, Akamai and Cloudflare Enterprise, Fastly)
|
|
32
|
+
CDN_IP_HEADERS = %w[HTTP_CF_CONNECTING_IP HTTP_TRUE_CLIENT_IP HTTP_FASTLY_CLIENT_IP].freeze
|
|
33
|
+
|
|
34
|
+
def initialize(app = Rails.application, user_class: "User", env: ENV, request: nil)
|
|
35
|
+
@app = app
|
|
36
|
+
@user_class = user_class
|
|
37
|
+
@env = env
|
|
38
|
+
@request = request
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def results
|
|
42
|
+
@results ||= [*(REQUEST_CHECKS if @request), *CHECKS].flat_map { |check| send(check) }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def failed?
|
|
46
|
+
results.any?(&:failure?)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
SYMBOLS = { ok: "✓", info: "•", warning: "⚠", failure: "✗" }.freeze
|
|
50
|
+
|
|
51
|
+
# The report the rake task prints, dated, to keep as evidence of the check
|
|
52
|
+
def to_text(time: Time.current)
|
|
53
|
+
header = I18n.t("trek.security_check.header", app: @app.class.module_parent_name, environment: Rails.env,
|
|
54
|
+
time: time.utc.iso8601, trek: Trek::VERSION, rails: Rails.version, ruby: RUBY_VERSION)
|
|
55
|
+
lines = results.map { |result| "#{SYMBOLS.fetch(result.status)} #{result.message}\n #{result.docs}" }
|
|
56
|
+
counts = STATUSES.index_with { |status| results.count { |result| result.status == status } }
|
|
57
|
+
[header, *lines, I18n.t("trek.security_check.summary", **counts)].join("\n\n") + "\n"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
def config = @app.config
|
|
63
|
+
|
|
64
|
+
def https
|
|
65
|
+
return result(:https, :failure, :off, docs: "/reference/generators/security-headers#hsts") unless config.force_ssl
|
|
66
|
+
|
|
67
|
+
hsts = config.ssl_options.fetch(:hsts, {})
|
|
68
|
+
return result(:https, :warning, :no_hsts, docs: "/reference/generators/security-headers#hsts") if hsts == false
|
|
69
|
+
|
|
70
|
+
expires = (hsts.is_a?(Hash) && hsts[:expires]) || ActionDispatch::SSL.default_hsts_options[:expires]
|
|
71
|
+
result(:https, :ok, :on, duration: duration(expires), docs: "/reference/generators/security-headers#hsts")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def request_https
|
|
75
|
+
docs = "/proxies#how-rails-finds-the-address"
|
|
76
|
+
return result(:request_https, :ok, :https, docs:) if @request.ssl?
|
|
77
|
+
|
|
78
|
+
result(:request_https, :failure, :http, docs:)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Behind a CDN missing from trusted_proxies, Rails takes the CDN for the visitor: its own header
|
|
82
|
+
# then names someone else than request.remote_ip
|
|
83
|
+
def remote_ip
|
|
84
|
+
docs = "/proxies#behind-a-cdn-or-a-web-application-firewall"
|
|
85
|
+
ip = @request.remote_ip
|
|
86
|
+
forwarded = CDN_IP_HEADERS.filter_map { |header| @request.headers[header].presence }.first
|
|
87
|
+
return result(:remote_ip, :failure, :cdn, ip:, forwarded:, docs:) if forwarded && forwarded != ip
|
|
88
|
+
|
|
89
|
+
result(:remote_ip, :info, :seen, ip:, docs:)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def content_security_policy
|
|
93
|
+
docs = "/reference/generators/security-headers#report-first-then-enforce"
|
|
94
|
+
return result(:content_security_policy, :failure, :none, docs:) unless config.content_security_policy
|
|
95
|
+
return result(:content_security_policy, :warning, :report_only, docs:) if config.content_security_policy_report_only
|
|
96
|
+
|
|
97
|
+
result(:content_security_policy, :ok, :enforced, docs:)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# The sign-in limits count in the cache: a store each process keeps to itself splits the count
|
|
101
|
+
def cache_store
|
|
102
|
+
store = Rails.cache
|
|
103
|
+
docs = "/reference/models/user#failed-sign-ins"
|
|
104
|
+
case store
|
|
105
|
+
when ActiveSupport::Cache::NullStore, ActiveSupport::Cache::MemoryStore
|
|
106
|
+
result(:cache_store, :failure, :per_process, store: store.class.name, docs:)
|
|
107
|
+
when ActiveSupport::Cache::FileStore
|
|
108
|
+
result(:cache_store, :warning, :per_server, store: store.class.name, docs:)
|
|
109
|
+
else
|
|
110
|
+
result(:cache_store, :ok, :shared, store: store.class.name, docs:)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def trusted_proxies
|
|
115
|
+
proxies = config.action_dispatch.trusted_proxies
|
|
116
|
+
docs = "/proxies#behind-a-cdn-or-a-web-application-firewall"
|
|
117
|
+
return result(:trusted_proxies, :info, :default, docs:) if proxies.nil?
|
|
118
|
+
|
|
119
|
+
result(:trusted_proxies, :info, :set, count: Array(proxies).size, docs:)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def admin_allowed_ips
|
|
123
|
+
allowed = @env["ADMIN_ALLOWED_IPS"].to_s.split(/[\s,]+/).compact_blank
|
|
124
|
+
docs = "/proxies#restricting-the-admin-to-ip-addresses"
|
|
125
|
+
return result(:admin_allowed_ips, :info, :unset, docs:) if allowed.empty?
|
|
126
|
+
|
|
127
|
+
result(:admin_allowed_ips, :ok, :set, count: allowed.size, docs:)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def audit_log
|
|
131
|
+
docs = "/reference/generators/audit-log"
|
|
132
|
+
return result(:audit_log, :warning, :not_installed, docs:) unless audit_log_installed?
|
|
133
|
+
|
|
134
|
+
purge_docs = "/reference/generators/audit-log#purging-old-rows"
|
|
135
|
+
return result(:audit_log, :info, :purge_unknown, docs: purge_docs) unless good_job?
|
|
136
|
+
return result(:audit_log, :ok, :purged, docs: purge_docs) if scheduled?("Trek::AuditLog::PurgeJob")
|
|
137
|
+
|
|
138
|
+
result(:audit_log, :failure, :not_purged, docs: purge_docs)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def session_purge
|
|
142
|
+
docs = "/reference/models/user#sessions"
|
|
143
|
+
return result(:session_purge, :info, :unknown, docs:) unless good_job?
|
|
144
|
+
return result(:session_purge, :ok, :scheduled, docs:) if scheduled?("Trek::PurgeExpiredSessionsJob")
|
|
145
|
+
|
|
146
|
+
result(:session_purge, :warning, :not_scheduled, docs:)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def cron
|
|
150
|
+
docs = "/background-jobs#scheduled-jobs-cron"
|
|
151
|
+
return result(:cron, :info, :other_backend, adapter: queue_adapter, docs:) unless good_job?
|
|
152
|
+
return result(:cron, :ok, :enabled, docs:) if config.good_job.enable_cron
|
|
153
|
+
|
|
154
|
+
result(:cron, :failure, :disabled, docs:)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def admins
|
|
158
|
+
users = @user_class.safe_constantize
|
|
159
|
+
return [] unless users
|
|
160
|
+
|
|
161
|
+
privileged = users.where(role: Trek::Users::Roles::PRIVILEGED_ROLES)
|
|
162
|
+
# In one query: two counts of the same shape are an N+1 for Prosopite, which host apps run in their specs
|
|
163
|
+
by_role = privileged.group(:role).count
|
|
164
|
+
docs = "/reference/models/user#roles"
|
|
165
|
+
[
|
|
166
|
+
result(:admins, :info, :count, admins: by_role.fetch("admin", 0), privileged: by_role.values.sum, docs:),
|
|
167
|
+
passkeys(users, privileged),
|
|
168
|
+
dormant(users, privileged),
|
|
169
|
+
password_expiry(users)
|
|
170
|
+
].compact
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def passkeys(users, privileged)
|
|
174
|
+
return unless users.reflect_on_association(:passkeys) && users.connection.table_exists?(users.reflect_on_association(:passkeys).table_name)
|
|
175
|
+
|
|
176
|
+
count = privileged.where.missing(:passkeys).count
|
|
177
|
+
docs = "/reference/models/user#passkeys"
|
|
178
|
+
return result(:passkeys, :ok, :all, docs:) if count.zero?
|
|
179
|
+
|
|
180
|
+
result(:passkeys, :warning, :password_only, count:, docs:)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# By their latest sign-in (current_sign_in_at: last_sign_in_at is the one before), or since their
|
|
184
|
+
# account was created when they never signed in, so a user invited last week isn't dormant
|
|
185
|
+
def dormant(users, privileged)
|
|
186
|
+
return unless users.column_names.include?("current_sign_in_at")
|
|
187
|
+
|
|
188
|
+
since = DORMANT_AFTER.ago
|
|
189
|
+
count = privileged.where(current_sign_in_at: ...since)
|
|
190
|
+
.or(privileged.where(current_sign_in_at: nil, created_at: ...since)).count
|
|
191
|
+
docs = "/reference/models/user#sign-ins"
|
|
192
|
+
return result(:dormant, :ok, :none, duration: duration(DORMANT_AFTER), docs:) if count.zero?
|
|
193
|
+
|
|
194
|
+
result(:dormant, :warning, :some, count:, duration: duration(DORMANT_AFTER), docs:)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def password_expiry(users)
|
|
198
|
+
return unless users.respond_to?(:password_expires_after)
|
|
199
|
+
|
|
200
|
+
docs = "/reference/models/user#expiry-and-renewal"
|
|
201
|
+
return result(:password_expiry, :info, :never, docs:) unless users.password_expires_after
|
|
202
|
+
|
|
203
|
+
result(:password_expiry, :ok, :after, duration: duration(users.password_expires_after), docs:)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def encryption
|
|
207
|
+
ActiveRecord::Encryption.config.primary_key
|
|
208
|
+
result(:encryption, :ok, :configured, docs: "/security#cryptography")
|
|
209
|
+
rescue ActiveRecord::Encryption::Errors::Configuration
|
|
210
|
+
result(:encryption, :warning, :not_configured, docs: "/security#cryptography")
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def audit_log_installed?
|
|
214
|
+
defined?(::AuditLog) && ::AuditLog.table_exists?
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def good_job?
|
|
218
|
+
queue_adapter.to_s == "good_job"
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def queue_adapter
|
|
222
|
+
adapter = config.active_job.queue_adapter
|
|
223
|
+
adapter.is_a?(Symbol) || adapter.is_a?(String) ? adapter : ActiveJob::Base.queue_adapter_name
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Whether GoodJob's cron runs the job, whatever the entry's name
|
|
227
|
+
def scheduled?(job_class)
|
|
228
|
+
return false unless config.respond_to?(:good_job) && config.good_job.cron
|
|
229
|
+
|
|
230
|
+
config.good_job.cron.values.any? { |entry| entry[:class].to_s == job_class }
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def duration(seconds)
|
|
234
|
+
ActionController::Base.helpers.distance_of_time_in_words(0, seconds.to_i)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def result(check, status, key, docs:, **values)
|
|
238
|
+
Result.new(check:, status:, message: I18n.t("trek.security_check.#{check}.#{key}", **values), docs: DOCS + docs)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
module Trek
|
|
2
|
+
# Strips the metadata (EXIF, with the GPS location and the camera's serial number, XMP, IPTC) of
|
|
3
|
+
# the images stored before ImageUploader stripped it on upload, as it does now. Each file is
|
|
4
|
+
# replaced in place, under the same id, so that every reference to it keeps working: records,
|
|
5
|
+
# page versions, the content editor's image blocks, and files no record references anymore but
|
|
6
|
+
# still published.
|
|
7
|
+
#
|
|
8
|
+
# Goes through the files of a storage (S3, the file system, or in memory): the images by their
|
|
9
|
+
# extension, and the sizes the derivation endpoint stored under derivatives/, which have none.
|
|
10
|
+
class StoredImageMetadata
|
|
11
|
+
Entry = Struct.new(:id, :status, keyword_init: true)
|
|
12
|
+
|
|
13
|
+
IMAGE_ID = %r{\.(jpe?g|png|webp)\z|\Aderivatives/}i
|
|
14
|
+
METADATA_FIELD = /\A(exif|xmp|iptc)-/
|
|
15
|
+
|
|
16
|
+
def initialize(storage = Shrine.storages[:store], uploader: ImageUploader)
|
|
17
|
+
@storage = storage
|
|
18
|
+
@uploader = uploader
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Yields an Entry per image carrying metadata, whose status is :stripped, :strippable (dry
|
|
22
|
+
# run) or :failed (libvips couldn't read or write it, e.g. a truncated file).
|
|
23
|
+
def strip(dry_run: false)
|
|
24
|
+
return enum_for(:strip, dry_run:) unless block_given?
|
|
25
|
+
|
|
26
|
+
# Apps have their own copy of ImageUploader, stripping only once updated
|
|
27
|
+
unless @uploader.private_method_defined?(:strip_metadata)
|
|
28
|
+
raise ArgumentError, "#{@uploader} doesn't strip metadata: update it first (bin/rails g trek:install:uploaders)"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
file_ids.each do |id|
|
|
32
|
+
next unless IMAGE_ID.match?(id)
|
|
33
|
+
|
|
34
|
+
status = strip_file(id, dry_run:)
|
|
35
|
+
yield Entry.new(id:, status:) if status
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def strip_file(id, dry_run:)
|
|
42
|
+
Shrine.with_file(@storage.open(id)) do |file|
|
|
43
|
+
mime_type = @uploader.determine_mime_type(file)
|
|
44
|
+
next unless @uploader::TYPES.include?(mime_type) && metadata?(file)
|
|
45
|
+
next :strippable if dry_run
|
|
46
|
+
|
|
47
|
+
replace(id, file, mime_type)
|
|
48
|
+
:stripped
|
|
49
|
+
end
|
|
50
|
+
rescue Vips::Error
|
|
51
|
+
:failed
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def metadata?(file)
|
|
55
|
+
Vips::Image.new_from_file(file.path).get_fields.any? { METADATA_FIELD.match?(it) }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Re-encoded as ImageUploader does on upload (its private method, so that both always match)
|
|
59
|
+
def replace(id, file, mime_type)
|
|
60
|
+
stripped = @uploader.new(:store).send(:strip_metadata, file, mime_type)
|
|
61
|
+
@storage.upload(stripped, id, **headers(id))
|
|
62
|
+
ensure
|
|
63
|
+
stripped&.close!
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# An S3 object's headers, which a new upload would otherwise lose (the Content-Type, and the
|
|
67
|
+
# Content-Disposition with the original file name)
|
|
68
|
+
def headers(id)
|
|
69
|
+
return {} unless @storage.respond_to?(:object)
|
|
70
|
+
|
|
71
|
+
object = @storage.object(id)
|
|
72
|
+
{ content_type: object.content_type, content_disposition: object.content_disposition,
|
|
73
|
+
cache_control: object.cache_control }.compact
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def file_ids
|
|
77
|
+
case @storage.class.name
|
|
78
|
+
when "Shrine::Storage::Memory" then @storage.store.keys
|
|
79
|
+
when "Shrine::Storage::FileSystem"
|
|
80
|
+
Dir.glob("**/*", base: @storage.directory.to_s).select { @storage.directory.join(it).file? }
|
|
81
|
+
when "Shrine::Storage::S3"
|
|
82
|
+
prefix = @storage.prefix && "#{@storage.prefix}/"
|
|
83
|
+
@storage.bucket.objects(**{ prefix: }.compact).lazy.map { it.key.delete_prefix(prefix.to_s) }
|
|
84
|
+
else raise ArgumentError, "#{@storage.class} can't list its files"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
1
3
|
module Trek
|
|
2
4
|
# `TypographyFormatter` formats strings to enforce French typography rules.
|
|
3
5
|
#
|
|
4
6
|
# Supports both plain strings and ProseMirror JSONB hashes. When given
|
|
5
7
|
# a Hash, it walks the node tree and formats only `text` node values
|
|
6
|
-
# in place, leaving the structure intact.
|
|
8
|
+
# in place, leaving the structure intact. A ProseMirror document given
|
|
9
|
+
# as a JSON string, as the content editor submits it, is parsed first,
|
|
10
|
+
# and returned as a Hash.
|
|
7
11
|
class TypographyFormatter
|
|
8
12
|
NBSP = [160].pack("U*").freeze
|
|
9
13
|
NNBSP = [8239].pack("U*").freeze # U+202F narrow no-break space
|
|
14
|
+
# Signs preceded by a non-breaking space, whether one was typed or not
|
|
10
15
|
SPACE_BEFORE_CHARS = [
|
|
11
|
-
[NBSP, %w[
|
|
16
|
+
[NBSP, %w[» – —]]
|
|
17
|
+
].freeze
|
|
18
|
+
# Signs preceded by a non-breaking space when one was typed, or when they end a word: followed by a
|
|
19
|
+
# space, punctuation or the end of the text. Inside a word, as in a time (10:30), a URL
|
|
20
|
+
# (https://example.com/?a=50%25) or a ratio (3:1), they aren't punctuation, and are left alone.
|
|
21
|
+
SPACE_BEFORE_WORD_ENDING_CHARS = [
|
|
22
|
+
[NBSP, %w[: % € \$]],
|
|
12
23
|
[NNBSP, %w[; ! \?]]
|
|
13
24
|
].freeze
|
|
25
|
+
WORD_ENDING_SIGNS = %w[: ; ! \?].freeze
|
|
14
26
|
NBSP_AFTER_CHARS = %w[« – —].freeze
|
|
15
27
|
NBSP_BEFORE_UNITS = %w[°C °F g h ha kg km Ko ko kW L l m min ml Mo mo s].freeze
|
|
16
28
|
|
|
17
29
|
def initialize(input)
|
|
30
|
+
input = JSON.parse(input) if prosemirror_json?(input)
|
|
18
31
|
@source = input
|
|
19
32
|
@prosemirror = input.is_a?(Hash)
|
|
20
33
|
@output = @prosemirror ? deep_dup_hash(input) : input.dup
|
|
@@ -34,6 +47,11 @@ module Trek
|
|
|
34
47
|
|
|
35
48
|
private
|
|
36
49
|
|
|
50
|
+
# Formatted as plain text, the JSON would get non-breaking spaces before its colons, and no longer parse
|
|
51
|
+
def prosemirror_json?(input)
|
|
52
|
+
input.is_a?(String) && input.start_with?('{"type":"doc"')
|
|
53
|
+
end
|
|
54
|
+
|
|
37
55
|
def format_string!
|
|
38
56
|
remove_double_spaces
|
|
39
57
|
add_nbsp
|
|
@@ -79,6 +97,18 @@ module Trek
|
|
|
79
97
|
regexp = /(?<=\S)(\p{Zs}?(#{chars.join("|")}))/
|
|
80
98
|
@output.gsub!(regexp, "#{space}\\2")
|
|
81
99
|
end
|
|
100
|
+
|
|
101
|
+
word_end = "\\p{Zs}|\\z|[#{WORD_ENDING_SIGNS.join}.,…»”)\\]]"
|
|
102
|
+
# Not after another sign: "Quoi?!" gets one space, before the group
|
|
103
|
+
not_after_sign = "(?<![\\p{Zs}\\s#{WORD_ENDING_SIGNS.join}])"
|
|
104
|
+
|
|
105
|
+
SPACE_BEFORE_WORD_ENDING_CHARS.each do |space, chars|
|
|
106
|
+
signs = chars.join("|")
|
|
107
|
+
# Repairs what earlier versions spaced inside a word: "10 :30", "https ://"
|
|
108
|
+
@output.gsub!(/[#{NBSP}#{NNBSP}](#{signs})(?!#{word_end})/, "\\1")
|
|
109
|
+
@output.gsub!(/(?<=\S)\p{Zs}+(#{signs})(?=#{word_end})/, "#{space}\\1")
|
|
110
|
+
@output.gsub!(/#{not_after_sign}(#{signs})(?=#{word_end})/, "#{space}\\1")
|
|
111
|
+
end
|
|
82
112
|
end
|
|
83
113
|
|
|
84
114
|
def add_nbsp_before_units
|
|
@@ -87,7 +117,7 @@ module Trek
|
|
|
87
117
|
end
|
|
88
118
|
|
|
89
119
|
def add_nbsp_after_chars
|
|
90
|
-
regexp = /((#{NBSP_AFTER_CHARS.join("|")})\p{Zs}?)(
|
|
120
|
+
regexp = /((#{NBSP_AFTER_CHARS.join("|")})\p{Zs}?)(?=[\p{L}\p{N}])/
|
|
91
121
|
@output.gsub!(regexp, "\\2#{NBSP}")
|
|
92
122
|
end
|
|
93
123
|
|
|
@@ -109,7 +139,8 @@ module Trek
|
|
|
109
139
|
end
|
|
110
140
|
|
|
111
141
|
def replace_apostrophes
|
|
112
|
-
|
|
142
|
+
# Letters with accents too (l'\u00e9t\u00e9), which `\w` doesn't match
|
|
143
|
+
@output.gsub!(/(?<=[\p{L}\p{N}])'(?=[\p{L}\p{N}])/, "\u2019")
|
|
113
144
|
end
|
|
114
145
|
|
|
115
146
|
def remove_spaces_before_attached_punctuation
|
data/lib/trek/version.rb
CHANGED
data/lib/trek.rb
CHANGED
|
@@ -4,7 +4,6 @@ require "action_policy"
|
|
|
4
4
|
require "acts_as_list"
|
|
5
5
|
require "blurhash"
|
|
6
6
|
require "closure_tree"
|
|
7
|
-
require "deepl"
|
|
8
7
|
require "dry-initializer"
|
|
9
8
|
require "email_validator"
|
|
10
9
|
require "fastimage"
|
|
@@ -34,9 +33,11 @@ module Trek
|
|
|
34
33
|
require_relative "trek/disposable_email_domains"
|
|
35
34
|
require_relative "trek/engine"
|
|
36
35
|
require_relative "trek/i18n_keys_resolver"
|
|
36
|
+
require_relative "trek/json_compatibility"
|
|
37
37
|
require_relative "trek/passkey_providers"
|
|
38
38
|
require_relative "trek/reverse_dns"
|
|
39
39
|
require_relative "trek/saved_attachments_reload"
|
|
40
|
+
require_relative "trek/stored_image_metadata"
|
|
40
41
|
require_relative "trek/typography_formatter"
|
|
41
42
|
require_relative "trek/version"
|
|
42
43
|
|
data/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trek",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "A modern content management & back-office system for Ruby on Rails",
|
|
5
5
|
"homepage": "https://trek.etamin.studio",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,20 +20,19 @@
|
|
|
20
20
|
},
|
|
21
21
|
"author": "Etamin Studio",
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@floating-ui/dom": "^1.8.0",
|
|
23
24
|
"@fontsource/inter": "^5.3.0",
|
|
24
25
|
"@hotwired/stimulus": "^3.2.2",
|
|
25
26
|
"@hotwired/turbo-rails": "^8.0.20",
|
|
26
27
|
"@radix-ui/colors": "^3.0.0",
|
|
27
|
-
"@tiptap/core": "^
|
|
28
|
-
"@tiptap/extension-floating-menu": "^
|
|
29
|
-
"@tiptap/
|
|
30
|
-
"@tiptap/
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@uppy/
|
|
34
|
-
"@uppy/
|
|
35
|
-
"@uppy/thumbnail-generator": "^3.0.2",
|
|
36
|
-
"@uppy/xhr-upload": "^3.0.4",
|
|
28
|
+
"@tiptap/core": "^3.32.0",
|
|
29
|
+
"@tiptap/extension-floating-menu": "^3.32.0",
|
|
30
|
+
"@tiptap/pm": "^3.32.0",
|
|
31
|
+
"@tiptap/starter-kit": "^3.32.0",
|
|
32
|
+
"@uppy/core": "^6.3.1",
|
|
33
|
+
"@uppy/locales": "^5.3.2",
|
|
34
|
+
"@uppy/thumbnail-generator": "^6.0.1",
|
|
35
|
+
"@uppy/xhr-upload": "^6.0.1",
|
|
37
36
|
"hotkeys-js": "^3.13.15",
|
|
38
37
|
"normalize.css": "^8.0.1",
|
|
39
38
|
"slugify": "^1.6.6",
|
|
@@ -42,26 +41,30 @@
|
|
|
42
41
|
"tom-select": "^2.2.2"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
44
|
+
"@vitest/browser-playwright": "^5.0.5",
|
|
45
45
|
"esbuild": "^0.28.0",
|
|
46
46
|
"esbuild-rails": "^1.0.7",
|
|
47
47
|
"esbuild-style-plugin": "^1.6.3",
|
|
48
48
|
"eslint": "^8.49.0",
|
|
49
49
|
"eslint-config-prettier": "^8.10.2",
|
|
50
|
+
"playwright": "^1.64.1",
|
|
50
51
|
"postcss": "^8.4.30",
|
|
51
52
|
"postcss-flexbugs-fixes": "^5.0.2",
|
|
52
53
|
"postcss-import": "^15.1.0",
|
|
53
|
-
"postcss-inline-svg": "^5.0.0",
|
|
54
54
|
"postcss-modules": "^5.0.0",
|
|
55
55
|
"postcss-preset-env": "^7.8.3",
|
|
56
56
|
"prettier": "2.8.8",
|
|
57
57
|
"stylelint": "^15.11.0",
|
|
58
58
|
"stylelint-config-standard": "^31.0.0",
|
|
59
59
|
"stylelint-order": "^6.0.4",
|
|
60
|
+
"vite": "^8.3.5",
|
|
60
61
|
"vitepress": "^1.6.4",
|
|
61
|
-
"vitepress-plugin-llms": "^1.13.1"
|
|
62
|
+
"vitepress-plugin-llms": "^1.13.1",
|
|
63
|
+
"vitest": "^5.0.5"
|
|
62
64
|
},
|
|
63
65
|
"packageManager": "yarn@4.18.1",
|
|
64
66
|
"scripts": {
|
|
67
|
+
"test": "vitest run",
|
|
65
68
|
"docs:dev": "vitepress dev docs",
|
|
66
69
|
"docs:build": "vitepress build docs",
|
|
67
70
|
"docs:preview": "vitepress preview docs"
|
data/postcss.config.js
CHANGED
data/trek.gemspec
CHANGED
|
@@ -33,24 +33,23 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.add_dependency "aws-sdk-s3", "~> 1.117"
|
|
34
34
|
spec.add_dependency "blurhash", "~> 0.1"
|
|
35
35
|
spec.add_dependency "closure_tree", "~> 9.0"
|
|
36
|
-
spec.add_dependency "deepl-rb", "~> 3.0"
|
|
37
36
|
spec.add_dependency "dry-initializer", "~> 3.1"
|
|
38
37
|
spec.add_dependency "email_validator", "~> 2.2"
|
|
39
38
|
spec.add_dependency "fastimage", "~> 2.2"
|
|
40
39
|
spec.add_dependency "http_accept_language", "~> 2.1"
|
|
41
40
|
spec.add_dependency "i18n-tasks", "~> 1.0"
|
|
42
41
|
spec.add_dependency "image_processing", "~> 1.8"
|
|
43
|
-
# json 3's `JSON.parse` takes keyword options only, but ActiveSupport (up to 8.1.3.1) passes them
|
|
44
|
-
# positionally, which breaks `db/schema.rb` for jsonb columns with a default. Lift once Rails
|
|
45
|
-
# supports json 3 (spec/dummy/generated_files_spec.rb checks the schema dump).
|
|
46
|
-
spec.add_dependency "json", "< 3"
|
|
47
42
|
spec.add_dependency "kaminari"
|
|
48
43
|
spec.add_dependency "listen"
|
|
49
44
|
spec.add_dependency "lookbook", ">= 2.3.13"
|
|
50
45
|
spec.add_dependency "mobility", "~> 1.3.2"
|
|
51
46
|
spec.add_dependency "phonelib", "~> 0.8"
|
|
52
47
|
spec.add_dependency "postmark-rails"
|
|
53
|
-
|
|
48
|
+
# Not used by Trek: refract 1.1.0 (prosemirror → phlex → refract) refers to Prism::MissingNode,
|
|
49
|
+
# which Prism 2 removed, so an app eager loading it (in production, or on CI) fails at boot. Drop it
|
|
50
|
+
# once a refract release has https://github.com/yippee-fun/refract/pull/4 (requested in issue 6).
|
|
51
|
+
spec.add_dependency "prism", "< 2"
|
|
52
|
+
spec.add_dependency "prosemirror", ">= 1.0", "< 2"
|
|
54
53
|
spec.add_dependency "rails", [">= 8.0", "< 8.2"]
|
|
55
54
|
spec.add_dependency "rails-healthcheck"
|
|
56
55
|
spec.add_dependency "rails-i18n", ">= 6.0"
|
|
@@ -60,7 +59,7 @@ Gem::Specification.new do |spec|
|
|
|
60
59
|
spec.add_dependency "strip_attributes", "~> 2.0"
|
|
61
60
|
spec.add_dependency "time_for_a_boolean", "~> 0.3"
|
|
62
61
|
spec.add_dependency "turbo-rails", ">= 1.0"
|
|
63
|
-
spec.add_dependency "valid_email2", "~> 7.
|
|
62
|
+
spec.add_dependency "valid_email2", "~> 7.2"
|
|
64
63
|
spec.add_dependency "view_component", "< 5.0"
|
|
65
64
|
spec.add_dependency "view_component-form", "~> 0.3"
|
|
66
65
|
spec.add_dependency "webauthn", "~> 3.4"
|
data/vitest.config.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import { playwright } from "@vitest/browser-playwright";
|
|
3
|
+
|
|
4
|
+
// JavaScript tests (yarn test): the admin's Stimulus controllers, with their libraries, in a headless Chrome.
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
test: {
|
|
7
|
+
include: ["spec/javascript/**/*.test.js"],
|
|
8
|
+
browser: {
|
|
9
|
+
enabled: true,
|
|
10
|
+
headless: true,
|
|
11
|
+
// The Chrome installed on the machine, as the system specs use: Playwright downloads none. CI's image
|
|
12
|
+
// has Debian's Chromium instead, at CHROME_PATH.
|
|
13
|
+
provider: playwright({
|
|
14
|
+
launchOptions: process.env.CHROME_PATH
|
|
15
|
+
? { executablePath: process.env.CHROME_PATH }
|
|
16
|
+
: { channel: "chrome" },
|
|
17
|
+
}),
|
|
18
|
+
instances: [{ browser: "chromium" }],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
// The components import their CSS, which the tests don't need: without this, Vite would load
|
|
22
|
+
// postcss.config.js, written for the esbuild build.
|
|
23
|
+
css: { postcss: {} },
|
|
24
|
+
});
|