decidim-cdtb 0.5.2 → 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 +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -2
- data/config/initializers/rack_attack.rb +6 -6
- data/lib/decidim/cdtb/users/remover.rb +6 -4
- 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/github_actions/templates/zeitwerk.yml +48 -0
- data/lib/tasks/census.rake +1 -1
- metadata +8 -5
- data/lib/generators/cdtb/USAGE +0 -8
- data/lib/generators/cdtb/validate_migrations_ci_generator.rb +0 -12
- /data/lib/generators/cdtb/{templates → github_actions/templates}/validate_migrations.yml +0 -0
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,12 @@
|
|
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
|
+
|
3
10
|
## [0.5.2] - 2025-05-23 (patch - Sense por ni flotador)
|
4
11
|
|
5
12
|
- Update validate_migrations generator template.
|
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
|
@@ -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,8 +36,6 @@ 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)
|
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
|
@@ -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
|
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
|
@@ -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
|
File without changes
|