decidim-cdtb 0.5.0 → 0.5.3
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/CHANGELOG.md +17 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -2
- data/config/initializers/rack_attack.rb +6 -6
- data/lib/decidim/cdtb/participatory_spaces/add_content_blocks.rb +1 -0
- data/lib/decidim/cdtb/spam/{user_spam_detector.rb → spam_users_detector.rb} +3 -3
- data/lib/decidim/cdtb/tasks.rb +1 -1
- data/lib/decidim/cdtb/users/remover.rb +19 -18
- data/lib/decidim/cdtb/version.rb +1 -1
- data/lib/generators/cdtb/github_actions/USAGE +14 -0
- data/lib/generators/cdtb/github_actions/github_actions_generator.rb +30 -0
- data/lib/generators/cdtb/github_actions/templates/ci_app.yml +92 -0
- data/lib/generators/cdtb/github_actions/templates/linters.yml +48 -0
- data/lib/generators/cdtb/{templates → github_actions/templates}/validate_migrations.yml +4 -4
- data/lib/generators/cdtb/github_actions/templates/zeitwerk.yml +48 -0
- data/lib/tasks/census.rake +1 -1
- data/lib/tasks/spam.rake +2 -2
- metadata +9 -6
- data/lib/generators/cdtb/USAGE +0 -8
- data/lib/generators/cdtb/validate_migrations_ci_generator.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6241713e113ab066abfe43c43d7262929e758583440148ef3410d12c3a4375b7
|
4
|
+
data.tar.gz: 15ff2f42ce709a998482e7790259f645be2ea914bef19298f09f30ba907e3272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4092451ddead10f5af1f2f298258f99ba1b1ebf8e0844d8707be6471a042986042da6a7483ed42145f23c8cdc316d8d15110bc201d4e23e9cdfe139efc8174d5
|
7
|
+
data.tar.gz: 8ae262af44f440fdeeae32e0f4c664d724e8d51eb5241f617a05da92e1604e6734ba4d5a74ed5c06f209c303c712153193565e7128bba598efa873fd7ebbcdee
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.5.3] - 2025-07-10 (patch - Aperitius explosius)
|
4
|
+
|
5
|
+
- Add "cdtb" in RackAttack logs to ease finding them.
|
6
|
+
- Optimize Users::Remover task, retrieve reporter_user only once
|
7
|
+
- Update way of retrieving manifest form attributes on census task
|
8
|
+
- Check zeitwerk class loading.
|
9
|
+
|
10
|
+
## [0.5.2] - 2025-05-23 (patch - Sense por ni flotador)
|
11
|
+
|
12
|
+
- Update validate_migrations generator template.
|
13
|
+
- Add last_sign_in_at to spam users detector.
|
14
|
+
|
15
|
+
## [0.5.1] - 2025-04-14 (minor - Diferents però igual)
|
16
|
+
|
17
|
+
- Add remove ActionLogs of users on remove users task.
|
18
|
+
- Fix error on add content blocks task.
|
19
|
+
|
3
20
|
## [0.5.0] - 2025-04-28 (minor - Unes roques molt gracioses)
|
4
21
|
|
5
22
|
- Add task to export the list of admins.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,8 +12,10 @@ Install the gem and add to the application's Gemfile by executing:
|
|
12
12
|
|
13
13
|
Install CI tests on your app with:
|
14
14
|
|
15
|
-
$ bin/rails
|
16
|
-
|
15
|
+
$ bin/rails g cdtb:github_actions:github_actions ci_app
|
16
|
+
$ bin/rails g cdtb:github_actions:github_actions linters
|
17
|
+
$ bin/rails g cdtb:github_actions:github_actions validate_migrations
|
18
|
+
$ bin/rails g cdtb:github_actions:github_actions zeitwerk
|
17
19
|
|
18
20
|
## Usage
|
19
21
|
|
@@ -17,17 +17,17 @@ unless ENV["CDTB_RACK_ATTACK_DISABLED"].to_i.positive? || %w[development test].i
|
|
17
17
|
limit= ENV.fetch("RACK_ATTACK_THROTTLE_LIMIT", 30)
|
18
18
|
period= ENV.fetch("RACK_ATTACK_THROTTLE_PERIOD", 60)
|
19
19
|
Rails.logger.info("Configuring Rack::Attack.throttle with limit: #{limit}, period: #{period}")
|
20
|
-
Rack::Attack.throttle("requests by ip", limit: limit.to_i, period: period.to_i) do |request|
|
20
|
+
Rack::Attack.throttle("cdtb: requests by ip", limit: limit.to_i, period: period.to_i) do |request|
|
21
21
|
# ignore requests to assets
|
22
22
|
next if request.path.start_with?("/rails/active_storage")
|
23
23
|
|
24
24
|
extract_ip(request)
|
25
25
|
end
|
26
26
|
|
27
|
-
limit= ENV.fetch("RACK_ATTACK_THROTTLE_RANGE_LIMIT",
|
28
|
-
period= ENV.fetch("RACK_ATTACK_THROTTLE_RANGE_PERIOD",
|
27
|
+
limit= ENV.fetch("RACK_ATTACK_THROTTLE_RANGE_LIMIT", 30)
|
28
|
+
period= ENV.fetch("RACK_ATTACK_THROTTLE_RANGE_PERIOD", 60)
|
29
29
|
Rails.logger.info("Configuring Rack::Attack.throttle with limits for IP Ranges: #{limit}, period: #{period}")
|
30
|
-
Rack::Attack.throttle("requests by ip range", limit: limit.to_i, period: period.to_i) do |request|
|
30
|
+
Rack::Attack.throttle("cdtb: requests by ip range", limit: limit.to_i, period: period.to_i) do |request|
|
31
31
|
# ignore requests to assets
|
32
32
|
next if request.path.start_with?("/rails/active_storage")
|
33
33
|
|
@@ -37,13 +37,13 @@ unless ENV["CDTB_RACK_ATTACK_DISABLED"].to_i.positive? || %w[development test].i
|
|
37
37
|
# rubocop: enable Lint/UselessAssignment
|
38
38
|
end
|
39
39
|
|
40
|
-
Rack::Attack.blocklist("block all /.well-known/traffic-advice") do |request|
|
40
|
+
Rack::Attack.blocklist("cdtb: block all /.well-known/traffic-advice") do |request|
|
41
41
|
request.path.start_with?("/.well-known/traffic-advice")
|
42
42
|
end
|
43
43
|
|
44
44
|
if ENV["RACK_ATTACK_BLOCKED_IPS"].present?
|
45
45
|
blocked_ips_and_subnets= ENV["RACK_ATTACK_BLOCKED_IPS"].split(",")
|
46
|
-
Rack::Attack.blocklist("block all unaccepted IPs") do |request|
|
46
|
+
Rack::Attack.blocklist("cdtb:block all unaccepted IPs") do |request|
|
47
47
|
ip= extract_ip(request)
|
48
48
|
blocked_ips_and_subnets.any? { |ip_or_subnet| ip.start_with?(ip_or_subnet) }
|
49
49
|
end
|
@@ -73,6 +73,7 @@ module Decidim
|
|
73
73
|
|
74
74
|
current_content_blocks.each do |content_block|
|
75
75
|
# hero is usually the first content block
|
76
|
+
next if content_block.nil?
|
76
77
|
next if content_block == extra_data_content_block || content_block.manifest_name == "hero"
|
77
78
|
|
78
79
|
content_block.update(weight: content_block.weight + 10)
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
module Spam
|
8
8
|
# Detect spam behavior in users
|
9
9
|
#
|
10
|
-
class
|
10
|
+
class SpamUsersDetector < ::Decidim::Cdtb::Task
|
11
11
|
# rubocop:disable Style/RedundantRegexpEscape
|
12
12
|
URL_REGEX = %r{(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|
|
13
13
|
www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|
|
@@ -44,7 +44,7 @@ module Decidim
|
|
44
44
|
filepath= Rails.env.test? ? "tmp/#{filename}" : filename
|
45
45
|
CSV.open(filepath, "w") do |csv|
|
46
46
|
csv_headers = ["ID", "Is suspicious?", "Name", "Email", "Nickname", "Personal URL", "About",
|
47
|
-
"Organization ID", "Organization Name"]
|
47
|
+
"Organization ID", "Organization Name", "Last Sign In At"]
|
48
48
|
csv << csv_headers
|
49
49
|
|
50
50
|
@users.find_each do |user|
|
@@ -56,7 +56,7 @@ module Decidim
|
|
56
56
|
end
|
57
57
|
|
58
58
|
csv << [user.id, suspicious, user.name, user.email, user.nickname, user.personal_url, user.about,
|
59
|
-
user.organization.id, user.organization.name]
|
59
|
+
user.organization.id, user.organization.name, user.last_sign_in_at&.strftime(Decidim::Cdtb::STRFTIME_FORMAT)]
|
60
60
|
|
61
61
|
progress_bar.increment
|
62
62
|
end
|
data/lib/decidim/cdtb/tasks.rb
CHANGED
@@ -8,7 +8,7 @@ require "decidim/cdtb/users/remover"
|
|
8
8
|
require "decidim/cdtb/multitenants/org_by_host_like"
|
9
9
|
require "decidim/cdtb/participatory_spaces/add_content_blocks"
|
10
10
|
require "decidim/cdtb/participatory_spaces/move_images_to_content_block"
|
11
|
-
require "decidim/cdtb/spam/
|
11
|
+
require "decidim/cdtb/spam/spam_users_detector"
|
12
12
|
require "decidim/cdtb/storage/local_sharding"
|
13
13
|
require "decidim/cdtb/storage/set_local_on_blobs"
|
14
14
|
require "decidim/cdtb/upgrades/validate_migrations_task"
|
@@ -7,7 +7,8 @@ module Decidim
|
|
7
7
|
#
|
8
8
|
# rubocop:disable Metrics/ClassLength
|
9
9
|
class Remover < ::Decidim::Cdtb::Task
|
10
|
-
def initialize(csv_path, reporter_user_email)
|
10
|
+
def initialize(organization, csv_path, reporter_user_email)
|
11
|
+
@organization= organization
|
11
12
|
@csv_path = csv_path
|
12
13
|
@reporter_user_email = reporter_user_email
|
13
14
|
progress_bar = { title: "Decidim::User" }
|
@@ -24,7 +25,10 @@ module Decidim
|
|
24
25
|
def do_execution(context)
|
25
26
|
progress_bar = context[:progress_bar]
|
26
27
|
|
27
|
-
|
28
|
+
reporter_user = @organization.users.find_by(email: @reporter_user_email,
|
29
|
+
organization: user.organization)
|
30
|
+
|
31
|
+
emails_on_moderations = @organization.users.where(email_on_moderations: true).pluck(:email)
|
28
32
|
|
29
33
|
disable_email_moderations(emails_on_moderations)
|
30
34
|
|
@@ -32,11 +36,12 @@ module Decidim
|
|
32
36
|
user = Decidim::User.find_by(id: row[0])
|
33
37
|
next unless user.present?
|
34
38
|
|
35
|
-
reporter_user = Decidim::User.find_by(email: @reporter_user_email,
|
36
|
-
organization: user.organization)
|
37
39
|
comments = Decidim::Comments::Comment.where(decidim_author_id: user.id)
|
38
40
|
manage_comments(comments, user, reporter_user) unless comments.empty?
|
39
|
-
|
41
|
+
if block_user(user, reporter_user)
|
42
|
+
remove_action_logs_by(user)
|
43
|
+
destroy_user(user)
|
44
|
+
end
|
40
45
|
progress_bar.increment
|
41
46
|
end
|
42
47
|
ensure
|
@@ -53,28 +58,18 @@ module Decidim
|
|
53
58
|
def disable_email_moderations(users_emails)
|
54
59
|
log_task_step("Disabling email on moderations...")
|
55
60
|
|
56
|
-
|
57
|
-
|
58
|
-
users.find_each do |user|
|
59
|
-
user.email_on_moderations = false
|
60
|
-
user.save(validate: false)
|
61
|
-
end
|
61
|
+
Decidim::User.where(email: users_emails).update_all(email_on_moderations: false)
|
62
62
|
end
|
63
63
|
|
64
64
|
def enable_email_moderations(users_emails)
|
65
65
|
log_task_step("Enabling email on moderations...")
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
users.find_each do |user|
|
70
|
-
user.email_on_moderations = true
|
71
|
-
user.save(validate: false)
|
72
|
-
end
|
67
|
+
Decidim::User.where(email: users_emails).update_all(email_on_moderations: true)
|
73
68
|
end
|
74
69
|
|
75
70
|
def manage_comments(comments, user, reporter_user)
|
76
71
|
comments.find_each do |comment|
|
77
|
-
report_comment(comment, user, reporter_user)
|
72
|
+
report_comment(comment, user, reporter_user) unless comment.reported?
|
78
73
|
hide_comment(comment, user, reporter_user) unless comment.hidden?
|
79
74
|
end
|
80
75
|
end
|
@@ -163,6 +158,12 @@ module Decidim
|
|
163
158
|
current_participatory_space: comment.participatory_space
|
164
159
|
}
|
165
160
|
end
|
161
|
+
|
162
|
+
def remove_action_logs_by(user)
|
163
|
+
puts "Removing ActionLog from user #{user.id}..."
|
164
|
+
|
165
|
+
ActiveRecord::Base.connection.execute("DELETE FROM decidim_action_logs WHERE decidim_user_id = #{user.id}")
|
166
|
+
end
|
166
167
|
end
|
167
168
|
# rubocop:enable Metrics/ClassLength
|
168
169
|
end
|
data/lib/decidim/cdtb/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
Description:
|
2
|
+
Installs a GitHub workflow to validate that all migrations from all engines have been installed
|
3
|
+
|
4
|
+
Available workflows:
|
5
|
+
- linters: Analizes app artifacts with Rubocop.
|
6
|
+
- ci_app: Runs Rspec specs for the Rails app.
|
7
|
+
- validate_migrations: Validates that the app has the migrations from all gems already installed.
|
8
|
+
- zeitwerk: Cheks that all artifacts accomplish with Zeitwerk's loading rules.
|
9
|
+
|
10
|
+
Example:
|
11
|
+
rails generate cdtb:github_actions:github_actions validate_migrations
|
12
|
+
|
13
|
+
This will create:
|
14
|
+
.github/workflows/validate_migrations.yml
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cdtb
|
4
|
+
module GithubActions
|
5
|
+
# Generates the given GitHub workflow that validates that the app has the migrations from all gems already installed
|
6
|
+
class GithubActionsGenerator < Rails::Generators::NamedBase
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
|
+
|
9
|
+
def copy_github_workflow_file
|
10
|
+
copy_file "#{file_name}.yml", ".github/workflows/#{file_name}.yml"
|
11
|
+
end
|
12
|
+
|
13
|
+
def replace_ruby_version
|
14
|
+
path= File.join(Rails.root, ".ruby-version")
|
15
|
+
return unless File.exist?(path)
|
16
|
+
|
17
|
+
ruby_version= File.read(path).strip
|
18
|
+
gsub_file ".github/workflows/#{file_name}.yml", /RUBY_VERSION: \d+\.\d+\.\d+/, "RUBY_VERSION: #{ruby_version}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def replace_node_version
|
22
|
+
path= File.join(Rails.root, ".node-version")
|
23
|
+
return unless File.exist?(path)
|
24
|
+
|
25
|
+
node_version= File.read(path).strip
|
26
|
+
gsub_file ".github/workflows/#{file_name}.yml", /NODE_VERSION: \d+\.\d+\.\d+/, "NODE_VERSION: #{node_version}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
name: "[CI] App"
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- release/*
|
8
|
+
- "*-stable"
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
env:
|
12
|
+
RUBY_VERSION: 3.1.7
|
13
|
+
NODE_VERSION: 16.9.1
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
test:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
services:
|
19
|
+
postgres:
|
20
|
+
image: postgres:11
|
21
|
+
ports: ["5432:5432"]
|
22
|
+
options: >-
|
23
|
+
--health-cmd pg_isready
|
24
|
+
--health-interval 10s
|
25
|
+
--health-timeout 5s
|
26
|
+
--health-retries 5
|
27
|
+
env:
|
28
|
+
POSTGRES_PASSWORD: postgres
|
29
|
+
redis:
|
30
|
+
image: redis:3.2-alpine
|
31
|
+
ports: ["6379:6379"]
|
32
|
+
env:
|
33
|
+
DB_TEST_DATABASE: app-test
|
34
|
+
DB_DATABASE: app
|
35
|
+
DB_USERNAME: postgres
|
36
|
+
DB_PASSWORD: postgres
|
37
|
+
DB_HOST: localhost
|
38
|
+
SECRET_KEY_BASE: "secret_key_base"
|
39
|
+
|
40
|
+
steps:
|
41
|
+
- uses: actions/checkout@v4
|
42
|
+
with:
|
43
|
+
fetch-depth: 1
|
44
|
+
- uses: ruby/setup-ruby@master
|
45
|
+
with:
|
46
|
+
ruby-version: ${{ env.RUBY_VERSION }}
|
47
|
+
bundler-cache: true
|
48
|
+
|
49
|
+
# Workaround https://github.com/decidim/decidim/issues/12369
|
50
|
+
- uses: nanasess/setup-chromedriver@v2
|
51
|
+
with:
|
52
|
+
chromedriver-version: 119.0.6045.105
|
53
|
+
|
54
|
+
- name: List Chrome
|
55
|
+
run: apt list --installed | grep chrome
|
56
|
+
|
57
|
+
- name: Remove Chrome
|
58
|
+
run: sudo apt remove google-chrome-stable
|
59
|
+
|
60
|
+
- uses: browser-actions/setup-chrome@v1
|
61
|
+
with:
|
62
|
+
chrome-version: 119.0.6045.105
|
63
|
+
|
64
|
+
- name: Recover Ruby dependency cache
|
65
|
+
uses: actions/cache@v4
|
66
|
+
with:
|
67
|
+
path: ./vendor/bundle
|
68
|
+
key: ${{ runner.OS }}-app-rubydeps-${{ hashFiles('Gemfile.lock') }}
|
69
|
+
restore-keys: |
|
70
|
+
${{ runner.OS }}-app-rubydeps-${{ env.cache-name }}-
|
71
|
+
${{ runner.OS }}-app-rubydeps-
|
72
|
+
|
73
|
+
- name: Set bundle local config vendor/bundle path
|
74
|
+
run: bundle config set --local path 'vendor/bundle'
|
75
|
+
|
76
|
+
- name: Install Ruby deps
|
77
|
+
uses: nick-fields/retry@v3
|
78
|
+
with:
|
79
|
+
timeout_minutes: 10
|
80
|
+
max_attempts: 3
|
81
|
+
retry_on: error
|
82
|
+
command: bundle install --jobs 4 --retry 3
|
83
|
+
|
84
|
+
- uses: actions/setup-node@v4
|
85
|
+
with:
|
86
|
+
node-version: ${{ env.NODE_VERSION }}
|
87
|
+
cache: 'npm'
|
88
|
+
- run: npm install
|
89
|
+
- run: bundle exec rake db:test:prepare
|
90
|
+
name: Setup database
|
91
|
+
- run: bundle exec rspec
|
92
|
+
name: Run specs
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: "[CI] Lint / Lint code"
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- release/*
|
8
|
+
- "*-stable"
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
env:
|
12
|
+
RUBY_VERSION: 3.1.7
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
test-report:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v4
|
20
|
+
with:
|
21
|
+
fetch-depth: 1
|
22
|
+
|
23
|
+
- uses: ruby/setup-ruby@master
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ env.RUBY_VERSION }}
|
26
|
+
|
27
|
+
- name: Recover Ruby dependency cache
|
28
|
+
uses: actions/cache@v4
|
29
|
+
with:
|
30
|
+
path: ./vendor/bundle
|
31
|
+
key: ${{ runner.OS }}-rubydeps-${{ hashFiles('Gemfile.lock') }}
|
32
|
+
restore-keys: |
|
33
|
+
${{ runner.OS }}-rubydeps-${{ env.cache-name }}-
|
34
|
+
${{ runner.OS }}-rubydeps-
|
35
|
+
${{ runner.OS }}-
|
36
|
+
|
37
|
+
- name: Set bundle local config configvendor/bundle path
|
38
|
+
run: bundle config set --local path 'vendor/bundle'
|
39
|
+
|
40
|
+
- name: Install Ruby deps
|
41
|
+
uses: nick-fields/retry@v3
|
42
|
+
with:
|
43
|
+
timeout_minutes: 10
|
44
|
+
max_attempts: 3
|
45
|
+
command: bundle install --jobs 4 --retry 3
|
46
|
+
|
47
|
+
- name: Rubocop
|
48
|
+
run: bundle exec rubocop -P
|
@@ -19,7 +19,7 @@ jobs:
|
|
19
19
|
runs-on: ubuntu-latest
|
20
20
|
services:
|
21
21
|
postgres:
|
22
|
-
image: postgres:
|
22
|
+
image: postgres:16
|
23
23
|
ports: ["5432:5432"]
|
24
24
|
options: >-
|
25
25
|
--health-cmd pg_isready
|
@@ -36,7 +36,7 @@ jobs:
|
|
36
36
|
SECRET_KEY_BASE: "secret_key_base"
|
37
37
|
|
38
38
|
steps:
|
39
|
-
- uses: actions/checkout@
|
39
|
+
- uses: actions/checkout@v4
|
40
40
|
with:
|
41
41
|
fetch-depth: 1
|
42
42
|
- uses: ruby/setup-ruby@master
|
@@ -44,7 +44,7 @@ jobs:
|
|
44
44
|
ruby-version: ${{ env.RUBY_VERSION }}
|
45
45
|
bundler-cache: true
|
46
46
|
- name: Recover Ruby dependency cache
|
47
|
-
uses: actions/cache@
|
47
|
+
uses: actions/cache@v4
|
48
48
|
with:
|
49
49
|
path: ./vendor/bundle
|
50
50
|
key: ${{ runner.OS }}-app-rubydeps-${{ hashFiles('Gemfile.lock') }}
|
@@ -56,7 +56,7 @@ jobs:
|
|
56
56
|
run: bundle config set --local path 'vendor/bundle'
|
57
57
|
|
58
58
|
- name: Install Ruby deps
|
59
|
-
uses: nick-
|
59
|
+
uses: nick-fields/retry@v3
|
60
60
|
with:
|
61
61
|
timeout_minutes: 10
|
62
62
|
max_attempts: 3
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: "[CI] Check Zeitwerk Class Loading"
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- release/*
|
8
|
+
- "*-stable"
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
env:
|
12
|
+
RUBY_VERSION: 3.1.7
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
test-report:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v4
|
20
|
+
with:
|
21
|
+
fetch-depth: 1
|
22
|
+
|
23
|
+
- uses: ruby/setup-ruby@master
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ env.RUBY_VERSION }}
|
26
|
+
|
27
|
+
- name: Recover Ruby dependency cache
|
28
|
+
uses: actions/cache@v4
|
29
|
+
with:
|
30
|
+
path: ./vendor/bundle
|
31
|
+
key: ${{ runner.OS }}-rubydeps-${{ hashFiles('Gemfile.lock') }}
|
32
|
+
restore-keys: |
|
33
|
+
${{ runner.OS }}-rubydeps-${{ env.cache-name }}-
|
34
|
+
${{ runner.OS }}-rubydeps-
|
35
|
+
${{ runner.OS }}-
|
36
|
+
|
37
|
+
- name: Set bundle local config configvendor/bundle path
|
38
|
+
run: bundle config set --local path 'vendor/bundle'
|
39
|
+
|
40
|
+
- name: Install Ruby deps
|
41
|
+
uses: nick-fields/retry@v3
|
42
|
+
with:
|
43
|
+
timeout_minutes: 10
|
44
|
+
max_attempts: 3
|
45
|
+
command: bundle install --jobs 4 --retry 3
|
46
|
+
|
47
|
+
- name: Check zeitwerk class loading
|
48
|
+
run: bundle exec rails zeitwerk:check
|
data/lib/tasks/census.rake
CHANGED
@@ -11,7 +11,7 @@ namespace :cdtb do
|
|
11
11
|
puts "Verification Handlers in this Decidim application:"
|
12
12
|
Decidim.authorization_handlers.each do |manifest|
|
13
13
|
attrs= if manifest.form.present?
|
14
|
-
manifest.form.constantize.
|
14
|
+
manifest.form.constantize.attribute_names.excluding("id", "user", "handler_name").join(", ")
|
15
15
|
else
|
16
16
|
"No form."
|
17
17
|
end
|
data/lib/tasks/spam.rake
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
namespace :cdtb do
|
4
4
|
namespace :spam do
|
5
|
-
desc "Show a list with users
|
5
|
+
desc "Show a list with users suspicious of being spammers"
|
6
6
|
task :users, %i[org_id] => :environment do |_task, args|
|
7
7
|
organization = args.org_id.present? ? Decidim::Organization.find(args.org_id) : nil
|
8
8
|
|
9
|
-
detector = Decidim::Cdtb::Spam::
|
9
|
+
detector = Decidim::Cdtb::Spam::SpamUsersDetector.new(organization)
|
10
10
|
detector.execute!
|
11
11
|
end
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-cdtb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Valls
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim
|
@@ -96,7 +96,7 @@ files:
|
|
96
96
|
- lib/decidim/cdtb/participatory_spaces/add_content_blocks.rb
|
97
97
|
- lib/decidim/cdtb/participatory_spaces/manages_content_blocks.rb
|
98
98
|
- lib/decidim/cdtb/participatory_spaces/move_images_to_content_block.rb
|
99
|
-
- lib/decidim/cdtb/spam/
|
99
|
+
- lib/decidim/cdtb/spam/spam_users_detector.rb
|
100
100
|
- lib/decidim/cdtb/storage/local_sharding.rb
|
101
101
|
- lib/decidim/cdtb/storage/set_local_on_blobs.rb
|
102
102
|
- lib/decidim/cdtb/task.rb
|
@@ -107,9 +107,12 @@ files:
|
|
107
107
|
- lib/decidim/cdtb/upgrades/validate_migrations_task.rb
|
108
108
|
- lib/decidim/cdtb/users/remover.rb
|
109
109
|
- lib/decidim/cdtb/version.rb
|
110
|
-
- lib/generators/cdtb/USAGE
|
111
|
-
- lib/generators/cdtb/
|
112
|
-
- lib/generators/cdtb/
|
110
|
+
- lib/generators/cdtb/github_actions/USAGE
|
111
|
+
- lib/generators/cdtb/github_actions/github_actions_generator.rb
|
112
|
+
- lib/generators/cdtb/github_actions/templates/ci_app.yml
|
113
|
+
- lib/generators/cdtb/github_actions/templates/linters.yml
|
114
|
+
- lib/generators/cdtb/github_actions/templates/validate_migrations.yml
|
115
|
+
- lib/generators/cdtb/github_actions/templates/zeitwerk.yml
|
113
116
|
- lib/tasks/anonymize.rake
|
114
117
|
- lib/tasks/census.rake
|
115
118
|
- lib/tasks/fix_youtube_embeds.rake
|
data/lib/generators/cdtb/USAGE
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Cdtb
|
4
|
-
# Generates the GitHub workflow that validates that the app has the migrations from all gems already installed
|
5
|
-
class ValidateMigrationsCiGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path("templates", __dir__)
|
7
|
-
|
8
|
-
def copy_github_workflow_file
|
9
|
-
copy_file "validate_migrations.yml", ".github/workflows/validate_migrations.yml"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|