redaction 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/redaction/railtie.rb +12 -0
- data/lib/redaction/redactable.rb +2 -0
- data/lib/redaction/redactor.rb +2 -0
- data/lib/redaction/types/email.rb +5 -1
- data/lib/redaction/version.rb +1 -1
- data/lib/redaction.rb +8 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c7c1ab9e4c83779e70bd6cc332671fd69a007281c34b4c64ea4ce309ca1eb49
|
4
|
+
data.tar.gz: b2c8ef0998df228f1062b91e6a3d4cff740071c3d41cb5082d34431254e2b446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec8127de732264971eef233c3ee8366db0eb660e84b427901180729c0f5d7c253d227c3591c6a3ab403b1e930dbcf709935d224382dd4cdc79b2736fee9056e
|
7
|
+
data.tar.gz: 0fb500148ce2f328f96d59bf0ff497bc908a6d2641e363d9fa5e7f9d6301cc0c2a1ba429025c6986c91103d0ae70036b11198c20225921cb9b5628389ab1c853
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Redaction
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/redaction.svg)](https://badge.fury.io/rb/redaction)
|
2
3
|
[![Tests](https://github.com/DRBragg/redaction/actions/workflows/ci.yml/badge.svg)](https://github.com/DRBragg/redaction/actions/workflows/ci.yml)
|
3
4
|
|
4
5
|
Easily redact your ActiveRecord Models. Great for use when you use production data in staging or dev. Simply set the redaction type of the attributes you want to redact and run via the [console](#via-the-rails-console) or the included [rake task](#via-rake-task).
|
@@ -6,17 +7,17 @@ Easily redact your ActiveRecord Models. Great for use when you use production da
|
|
6
7
|
`redaction` uses [Faker](https://github.com/faker-ruby/faker) under the hood to generate redacted data.
|
7
8
|
|
8
9
|
## Installation
|
9
|
-
**NOTE:** This is currently
|
10
|
+
**NOTE:** This is currently very much in beta. Use at your own risk.
|
10
11
|
|
11
12
|
Add this line to your application's Gemfile:
|
12
13
|
|
13
14
|
```ruby
|
14
|
-
gem "redaction"
|
15
|
+
gem "redaction"
|
15
16
|
```
|
16
17
|
|
17
18
|
And then execute:
|
18
19
|
```bash
|
19
|
-
$ bundle
|
20
|
+
$ bundle install
|
20
21
|
```
|
21
22
|
|
22
23
|
## Usage
|
data/lib/redaction/railtie.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
module Redaction
|
2
|
+
class << self
|
3
|
+
def config
|
4
|
+
@config ||= Railtie.config.redaction
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
2
8
|
class Railtie < ::Rails::Railtie
|
9
|
+
config.redaction = ActiveSupport::OrderedOptions.new
|
10
|
+
|
3
11
|
initializer "redaction.initialize" do
|
12
|
+
options = config.redaction
|
13
|
+
|
14
|
+
options.email_domain = options.email_domain
|
15
|
+
|
4
16
|
ActiveSupport.on_load(:active_record) do
|
5
17
|
include Redaction::Redactable
|
6
18
|
end
|
data/lib/redaction/redactable.rb
CHANGED
data/lib/redaction/redactor.rb
CHANGED
@@ -4,7 +4,11 @@ module Redaction
|
|
4
4
|
module Types
|
5
5
|
class Email < Base
|
6
6
|
def content
|
7
|
-
|
7
|
+
if Redaction.config.email_domain.present?
|
8
|
+
Faker::Internet.email(domain: Redaction.config.email_domain)
|
9
|
+
else
|
10
|
+
Faker::Internet.safe_email
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
data/lib/redaction/version.rb
CHANGED
data/lib/redaction.rb
CHANGED
@@ -16,6 +16,14 @@ module Redaction
|
|
16
16
|
autoload :Redactable, "redaction/redactable"
|
17
17
|
autoload :Redactor, "redaction/redactor"
|
18
18
|
|
19
|
+
class ProductionEnvironmentError < StandardError
|
20
|
+
DEFAULT_MESSAGE = "Data cannot be redacted in production!"
|
21
|
+
|
22
|
+
def initialize(message = DEFAULT_MESSAGE)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
def self.find(redactor_type)
|
20
28
|
if redactor_type.respond_to?(:call)
|
21
29
|
redactor_type
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drew Bragg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -111,7 +111,7 @@ metadata:
|
|
111
111
|
homepage_uri: https://github.com/drbragg/redaction
|
112
112
|
source_code_uri: https://github.com/drbragg/redaction
|
113
113
|
changelog_uri: https://github.com/drbragg/redaction/blob/main/CHANGELOG.md
|
114
|
-
post_install_message:
|
114
|
+
post_install_message:
|
115
115
|
rdoc_options: []
|
116
116
|
require_paths:
|
117
117
|
- lib
|
@@ -119,15 +119,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
119
|
requirements:
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
122
|
+
version: 2.5.0
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
125
|
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
130
|
-
signing_key:
|
129
|
+
rubygems_version: 3.3.3
|
130
|
+
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: Easily redact your ActiveRecord Models.
|
133
133
|
test_files: []
|