anony 1.6.0 → 1.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/.github/workflows/test.yml +6 -2
- data/.rubocop.yml +2 -5
- data/.rubocop_todo.yml +16 -11
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +10 -0
- data/README.md +22 -0
- data/anony.gemspec +0 -10
- data/lib/anony/anonymisable.rb +1 -1
- data/lib/anony/config.rb +10 -1
- data/lib/anony/version.rb +1 -1
- metadata +3 -105
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10df947501d12fc04d77ba8133487801dae18bc0bba4d13c5f08c8e68b4852c4
|
4
|
+
data.tar.gz: 822685bc6968e72119bbc9ee497e16e5a59d3859763372e8162cef5cd838387d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d69bb5e5e66f43731c4be96eb9dbc5922979fcff55d39e839dd78a294c5d28c75e3e51ca87c9747c5f550a4bba0feaa4697882756c06520740b2efbd5fbe8676
|
7
|
+
data.tar.gz: d93945a2bb1556229ae9c7ca68b613acb198b15e6440342403ea7f6cfaf740f02bb6d5810a03a2c8a10574aeaab021ef93dc54fa037650743449237e1080cf78
|
data/.github/workflows/test.yml
CHANGED
@@ -2,6 +2,10 @@ name: tests
|
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types: [opened, reopened, synchronize]
|
5
9
|
|
6
10
|
jobs:
|
7
11
|
rubocop:
|
@@ -19,8 +23,8 @@ jobs:
|
|
19
23
|
tests:
|
20
24
|
strategy:
|
21
25
|
matrix:
|
22
|
-
ruby-version: [3.1, 3.2, 3.3]
|
23
|
-
rails-version: [7.0, 7.1, 7.2, 8.0]
|
26
|
+
ruby-version: ["3.1", "3.2", "3.3", "3.4"]
|
27
|
+
rails-version: ["7.0", "7.1", "7.2", "8.0"]
|
24
28
|
exclude:
|
25
29
|
- ruby-version: 3.1
|
26
30
|
rails-version: 8.0
|
data/.rubocop.yml
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
|
+
|
2
3
|
inherit_gem:
|
3
4
|
gc_ruboconfig: rubocop.yml
|
4
5
|
|
5
6
|
AllCops:
|
6
|
-
TargetRubyVersion: 3.
|
7
|
+
TargetRubyVersion: 3.1
|
7
8
|
NewCops: enable
|
8
9
|
|
9
10
|
Layout/LineLength:
|
10
11
|
Max: 100
|
11
12
|
|
12
|
-
Gemspec/DevelopmentDependencies:
|
13
|
-
EnforcedStyle: gemspec
|
14
|
-
|
15
13
|
Gemspec/RequiredRubyVersion:
|
16
14
|
Enabled: false
|
17
15
|
|
@@ -20,4 +18,3 @@ RSpec/MultipleExpectations:
|
|
20
18
|
|
21
19
|
RSpec/ExampleLength:
|
22
20
|
Max: 15
|
23
|
-
|
data/.rubocop_todo.yml
CHANGED
@@ -1,24 +1,29 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2025-02-05 14:52:30 UTC using RuboCop version 1.71.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: IgnoredMetadata.
|
11
|
+
RSpec/DescribeClass:
|
10
12
|
Exclude:
|
11
|
-
- 'spec/
|
12
|
-
- 'spec/
|
13
|
+
- '**/spec/features/**/*'
|
14
|
+
- '**/spec/requests/**/*'
|
15
|
+
- '**/spec/routing/**/*'
|
16
|
+
- '**/spec/system/**/*'
|
17
|
+
- '**/spec/views/**/*'
|
18
|
+
- 'spec/anony/rspec_shared_examples_spec.rb'
|
13
19
|
|
14
|
-
|
20
|
+
# Offense count: 3
|
21
|
+
RSpec/LeakyConstantDeclaration:
|
15
22
|
Exclude:
|
16
23
|
- 'spec/anony/anonymisable_spec.rb'
|
24
|
+
- 'spec/anony/strategies/overwrite_spec.rb'
|
17
25
|
|
26
|
+
# Offense count: 4
|
27
|
+
# Configuration parameters: AllowedGroups.
|
18
28
|
RSpec/NestedGroups:
|
19
|
-
|
20
|
-
- 'spec/anony/anonymisable_spec.rb'
|
21
|
-
|
22
|
-
RSpec/DescribeClass:
|
23
|
-
Exclude:
|
24
|
-
- 'spec/anony/rspec_shared_examples_spec.rb'
|
29
|
+
Max: 4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.1
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -6,3 +6,13 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
7
7
|
# Specify your gem's dependencies in anony.gemspec
|
8
8
|
gemspec
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem "bundler", "~> 2"
|
12
|
+
gem "database_cleaner-active_record", "~> 2.2"
|
13
|
+
gem "gc_ruboconfig", "~> 5.0.0"
|
14
|
+
gem "rspec", "~> 3.9"
|
15
|
+
gem "rspec-github", "~> 3.0.0"
|
16
|
+
gem "sqlite3", "~> 2.6.0"
|
17
|
+
gem "yard", "~> 0.9.20"
|
18
|
+
end
|
data/README.md
CHANGED
@@ -410,6 +410,28 @@ Anony::Config.ignore_fields(:id, :created_at, :updated_at)
|
|
410
410
|
By default, `Config.ignore_fields` is an empty array and all fields are considered
|
411
411
|
anonymisable.
|
412
412
|
|
413
|
+
### Preventing model validation before anonymisation
|
414
|
+
|
415
|
+
There are cases where models may contain data that is not valid according to the validations defined on the model, and
|
416
|
+
the default behaviour of Anony is to validate the model before anonymisation.
|
417
|
+
|
418
|
+
If it is necessary to be able to anonymise models even if they contain invalid data, Anony can be configured to skip this
|
419
|
+
validation, in which case the validations will only be run when using strategies that modify the model data, and will run
|
420
|
+
after anonymisation when the model is saved.
|
421
|
+
|
422
|
+
To configure this behaviour, you can set the following configuration option in an initializer:
|
423
|
+
|
424
|
+
```ruby
|
425
|
+
# config/initializers/anony.rb
|
426
|
+
|
427
|
+
Anony::Config.validate_before_anonymisation = false
|
428
|
+
```
|
429
|
+
|
430
|
+
> Note: If you set this configuration option to `false`, be aware that a model that is invalid before anonymisation and continues
|
431
|
+
to be invalid after anonymisation may have new validation failures caused by the anonymisation if a strategy is incorrectly
|
432
|
+
defined for the model. It is recommended that you perform the anonymisation in a database transaction and roll it back if there
|
433
|
+
are validation errors after anonymisation.
|
434
|
+
|
413
435
|
## Testing
|
414
436
|
|
415
437
|
This library ships with a set of useful RSpec examples for your specs. Just require them
|
data/anony.gemspec
CHANGED
@@ -24,16 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_ruby_version = ">= 3.1"
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler", "~> 2"
|
28
|
-
spec.add_development_dependency "database_cleaner-active_record", "~> 2.2"
|
29
|
-
spec.add_development_dependency "gc_ruboconfig", "~> 5.0.0"
|
30
|
-
spec.add_development_dependency "rspec", "~> 3.9"
|
31
|
-
spec.add_development_dependency "rspec-github", "~> 2.4.0"
|
32
|
-
spec.add_development_dependency "yard", "~> 0.9.20"
|
33
|
-
|
34
|
-
# For integration testing
|
35
|
-
spec.add_development_dependency "sqlite3", "~> 2.2.0"
|
36
|
-
|
37
27
|
if ENV["RAILS_VERSION"]
|
38
28
|
spec.add_dependency "activerecord", "~> #{ENV['RAILS_VERSION']}"
|
39
29
|
spec.add_dependency "activesupport", "~> #{ENV['RAILS_VERSION']}"
|
data/lib/anony/anonymisable.rb
CHANGED
@@ -99,7 +99,7 @@ module Anony
|
|
99
99
|
raise ArgumentError, "#{self.class.name} does not have an Anony configuration"
|
100
100
|
end
|
101
101
|
|
102
|
-
self.class.anonymise_config.validate!
|
102
|
+
self.class.anonymise_config.validate! if Config.validate_before_anonymisation
|
103
103
|
self.class.anonymise_config.apply(self)
|
104
104
|
rescue ActiveRecord::RecordNotSaved, ActiveRecord::RecordNotDestroyed => e
|
105
105
|
Result.failed(e, self)
|
data/lib/anony/config.rb
CHANGED
@@ -12,7 +12,7 @@ module Anony
|
|
12
12
|
#
|
13
13
|
# Anony::Config.ignore_fields(:id)
|
14
14
|
module Config
|
15
|
-
mattr_accessor :ignores
|
15
|
+
mattr_accessor :ignores, :validate_before_anonymisation
|
16
16
|
|
17
17
|
# @!visibility private
|
18
18
|
def self.ignore?(field)
|
@@ -38,5 +38,14 @@ module Anony
|
|
38
38
|
end
|
39
39
|
|
40
40
|
self.ignores = []
|
41
|
+
|
42
|
+
# Config option to change behaviour so that validations on models being anonymised
|
43
|
+
# are not run before anonymisation has been performed. This means that if an invalid model
|
44
|
+
# would become valid after anonymisation, it will not raise an error when being anonymised.
|
45
|
+
#
|
46
|
+
# Validations are still run for the overwrite strategy when the changes to the model are saved
|
47
|
+
#
|
48
|
+
# By default this is set to true, to maintain existing behaviour
|
49
|
+
self.validate_before_anonymisation = true
|
41
50
|
end
|
42
51
|
end
|
data/lib/anony/version.rb
CHANGED
metadata
CHANGED
@@ -1,113 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless Engineering
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-05-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: database_cleaner-active_record
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.2'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.2'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: gc_ruboconfig
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 5.0.0
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 5.0.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.9'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.9'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec-github
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.4.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.4.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: yard
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.9.20
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.9.20
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: sqlite3
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.2.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 2.2.0
|
111
12
|
- !ruby/object:Gem::Dependency
|
112
13
|
name: activerecord
|
113
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,7 +49,6 @@ dependencies:
|
|
148
49
|
- - "<"
|
149
50
|
- !ruby/object:Gem::Version
|
150
51
|
version: '9'
|
151
|
-
description:
|
152
52
|
email:
|
153
53
|
- engineering@gocardless.com
|
154
54
|
executables: []
|
@@ -190,7 +90,6 @@ licenses:
|
|
190
90
|
- MIT
|
191
91
|
metadata:
|
192
92
|
rubygems_mfa_required: 'true'
|
193
|
-
post_install_message:
|
194
93
|
rdoc_options: []
|
195
94
|
require_paths:
|
196
95
|
- lib
|
@@ -205,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
104
|
- !ruby/object:Gem::Version
|
206
105
|
version: '0'
|
207
106
|
requirements: []
|
208
|
-
rubygems_version: 3.
|
209
|
-
signing_key:
|
107
|
+
rubygems_version: 3.6.2
|
210
108
|
specification_version: 4
|
211
109
|
summary: A small library that defines how ActiveRecord models should be anonymised
|
212
110
|
for deletion purposes.
|