Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream #1

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d92e8c2
Modern Ruby + ActiveRecord, Update Travis Config (#416)
joshbranham Oct 19, 2022
4ec77d3
Add support for Ruby 2.7 and its kwargs (#383)
igor-drozdov Oct 19, 2022
e2c7d31
Fixed bug where we were comparing versions as strings (#419)
mvastola Oct 21, 2022
15b47b6
Fixed a typo in README.md (#421)
joshbranham Oct 21, 2022
1b0c912
Fix typo in README (#422)
joshbranham Oct 21, 2022
f3355d4
Add (failable) tests to Travis for RoR 6/6.1/7
mvastola Dec 22, 2022
67bcfa2
Restrict set_attribute_was patch to Rails versions >= 5.2, < 6
joshbranham Dec 16, 2022
a70d87b
Don't use Gem requirement comparison with frozen Gem::Version
Dec 16, 2022
e369e61
Disallow failures for RoR 6.0+ tests on travis
mvastola Dec 22, 2022
a2db662
Use #write_cast_value to register the original value before change fo…
vimalvnair Mar 17, 2023
da75c9b
Prefix 'attr_encrypted' to encrypted_attributes method to avoid clash…
vimalvnair Mar 17, 2023
de318e0
Hardcoding sqlite3 gem version to 1.5.4 since newer sqlite3 versions …
vimalvnair Mar 18, 2023
b565876
Release 4.0.0
Mar 28, 2023
7e857a5
Drop gem signing (#436)
joshbranham Apr 6, 2023
0462d56
Drop support for DataMapper (#439)
mlarraz Apr 24, 2023
b802253
Update README.md (#441)
joshbranham Apr 29, 2023
799d60b
Start testing ruby 3 (#440)
joshbranham Apr 29, 2023
dee8d41
Use ActiveRecord.deprecator when available (#437)
etiennebarrie Apr 29, 2023
6bab9de
Use Github Actions for CI (#442)
mlarraz May 26, 2023
d93c017
Fix minitest guard for rails 4 breaking specs (#448)
joshbranham Jan 22, 2024
502d44e
Add Josh and Mike to authors (#447)
joshbranham Jan 22, 2024
83f52d4
Add GitHub Actions badge to README (#449)
joshbranham Jan 22, 2024
81e3e4f
Deprecate testing with travis (#450)
joshbranham Jan 27, 2024
17ac2f0
Add rails7.1 and Ruby3.3 to CI matrix (#453)
willnet May 2, 2024
efe06f3
Release v4.1.0 (#455)
joshbranham May 30, 2024
e96f4ad
Fix SystemStackError when extending the reload method with Module#pre…
willnet Sep 16, 2024
18ef8b6
Release 4.1.1 (#458)
joshbranham Sep 20, 2024
96bf315
Add Rails7.2, 8.0 and Ruby 3.4 to CI matrix
willnet Jan 23, 2025
71b5862
Fix CI failures for Rails 6.0 to 7.0.
willnet Jan 23, 2025
bf354d3
Set the sqlite3 version to 2.1.0 or higher for Rails 8.0.
willnet Jan 23, 2025
515f862
Remove the unused dm-sqlite-adapter
willnet Jan 23, 2025
86aed8a
Merge pull request #462 from willnet/add-ruby-3-4-and-rails-7-2-and-8-0
joshbranham Jan 23, 2025
38b2e85
Set required_ruby_version >= 2.7.0 (#464)
joshbranham Jan 23, 2025
49bc41d
Release 4.2.0
joshbranham Jan 23, 2025
c2aa160
Release 4.2.0 (#465)
joshbranham Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches:
- master
pull_request:

jobs:
test:
name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.active_record }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { active_record: '5.1', ruby: '2.7' }
- { active_record: '5.2', ruby: '2.7' }
- { active_record: '6.0', ruby: '2.7' }
- { active_record: '6.0', ruby: '3.0' }
- { active_record: '6.0', ruby: '3.1' }
- { active_record: '6.0', ruby: '3.2' }
- { active_record: '6.1', ruby: '2.7' }
- { active_record: '6.1', ruby: '3.0' }
- { active_record: '6.1', ruby: '3.1' }
- { active_record: '6.1', ruby: '3.2' }
- { active_record: '7.0', ruby: '2.7' }
- { active_record: '7.0', ruby: '3.0' }
- { active_record: '7.0', ruby: '3.1' }
- { active_record: '7.0', ruby: '3.2' }
- { active_record: '7.1', ruby: '2.7' }
- { active_record: '7.1', ruby: '3.0' }
- { active_record: '7.1', ruby: '3.1' }
- { active_record: '7.1', ruby: '3.2' }
- { active_record: '7.1', ruby: '3.3' }
- { active_record: '7.2', ruby: '3.1' }
- { active_record: '7.2', ruby: '3.2' }
- { active_record: '7.2', ruby: '3.3' }
- { active_record: '7.2', ruby: '3.4' }
- { active_record: '8.0', ruby: '3.2' }
- { active_record: '8.0', ruby: '3.3' }
- { active_record: '8.0', ruby: '3.4' }
env:
ACTIVERECORD: ${{ matrix.active_record }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: |
bundle exec rake test
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

75 changes: 57 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# attr_encrypted #
# attr_encrypted

## 4.2.0

* Changed: Set minimum Ruby version as 2.7.
* Added: Rails 7.2 and 8.0 support.
* Fixed: Further removal of `datamapper` support.

## 4.1.1

* Fixed: Fix SystemStackError when extending the reload method with Module#prepend.

## 4.1.0

* Changed: Dropped support for `datamapper` which has not had a release since October 2011. This is in an attempt to make
maintenance and testing easier moving forward.

## 4.0.0

* Added: Support for Ruby >= 3.0.
* Added: Rails 7 support.
* Changed: Using `#encrypted_attributes` is no longer supported. Instead, use `#attr_encrypted_encrypted_attributes` to avoid
collision with Active Record 7 native encryption.

## 3.1.0

## 3.1.0 ##
* Added: Abitilty to encrypt empty values. (@tamird)
* Added: MIT license
* Added: MRI 2.5.x support (@saghaulor)
Expand All @@ -11,23 +34,28 @@
* Fixed: Only check empty on strings, allows for encrypting non-string type objects
* Fixed: Fixed how accessors for db columns are defined in the ActiveRecord adapter, preventing premature definition. (@nagachika)

## 3.0.3 ##
## 3.0.3

* Fixed: attr_was would decrypt the attribute upon every call. This is inefficient and introduces problems when the options change between decrypting an old value and encrypting a new value; for example, when rotating the encryption key. As such, the new approach caches the decrypted value of the old encrypted value such that the old options are no longer needed. (@johnny-lai) (@saghaulor)

## 3.0.2 ##
## 3.0.2

* Changed: Removed alias_method_chain for compatibility with Rails v5.x (@grosser)
* Changed: Updated Travis build matrix to include Rails 5. (@saghaulor) (@connorshea)
* Changed: Removed `.silence_stream` from tests as it has been removed from Rails 5. (@sblackstone)

## 3.0.1 ##
## 3.0.1

* Fixed: attr_was method no longer calls undefined methods. (@saghaulor)

## 3.0.0 ##
## 3.0.0

* Changed: Updated gemspec to use Encryptor v3.0.0. (@saghaulor)
* Changed: Updated README with instructions related to moving from v2.0.0 to v3.0.0. (@saghaulor)
* Fixed: ActiveModel::Dirty methods in the ActiveRecord adapter. (@saghaulor)

## 2.0.0 ##
## 2.0.0

* Added: Now using Encryptor v2.0.0 (@saghaulor)
* Added: Options are copied to the instance. (@saghaulor)
* Added: Operation option is set during encryption/decryption to allow options to be evaluated in the context of the current operation. (@saghaulor)
Expand All @@ -48,51 +76,62 @@
* Removed: Support for Rails < 3.x (@saghaulor)
* Removed: Unnecessary use of `alias_method` from ActiveRecord adapter. (@saghaulor)

## 1.4.0 ##
## 1.4.0

* Added: ActiveModel::Dirty#attribute_was (@saghaulor)
* Added: ActiveModel::Dirty#attribute_changed? (@mwean)

## 1.3.5 ##
## 1.3.5

* Changed: Fixed gemspec to explicitly depend on Encryptor v1.3.0 (@saghaulor)
* Fixed: Evaluate `:mode` option as a symbol or proc. (@cheynewallace)

## 1.3.4 ##
## 1.3.4

* Added: ActiveRecord::Base.reload support. (@rcook)
* Fixed: ActiveRecord adapter no longer forces attribute hashes to be string-keyed. (@tamird)
* Fixed: Mass assignment protection in ActiveRecord 4. (@tamird)
* Changed: Now using rubygems over https. (@tamird)
* Changed: Let ActiveRecord define attribute methods. (@saghaulor)

## 1.3.3 ##
## 1.3.3

* Added: Alias attr_encryptor and attr_encrpted. (@Billy Monk)

## 1.3.2 ##
## 1.3.2

* Fixed: Bug regarding strong parameters. (@S. Brent Faulkner)
* Fixed: Bug regarding loading per instance IV and salt. (@S. Brent Faulkner)
* Fixed: Bug regarding assigning nil. (@S. Brent Faulkner)
* Added: Support for protected attributes. (@S. Brent Faulkner)
* Added: Support for ActiveRecord 4. (@S. Brent Faulkner)

## 1.3.1 ##
## 1.3.1

* Added: Support for Rails 2.3.x and 3.1.x. (@S. Brent Faulkner)

## 1.3.0 ##
## 1.3.0

* Fixed: Serialization bug. (@Billy Monk)
* Added: Support for :per_attribute_iv_and_salt mode. (@rcook)
* Fixed: Added dependencies to gemspec. (@jmazzi)

## 1.2.1 ##
## 1.2.1

* Added: Force encoding when not marshaling. (@mosaicxm)
* Fixed: Issue specifying multiple attributes on the same line. (@austintaylor)
* Added: Typecasting to String before encryption (@shuber)
* Added: `"#{attribute}?"` method. (@shuber)

## 1.2.0 ##
## 1.2.0

* Changed: General code refactoring (@shuber)

## 1.1.2 ##
## 1.1.2

* No significant changes

## 1.1.1 ##
## 1.1.1

* Changled: Updated README. (@shuber)
* Added: `before_type_cast` alias to ActiveRecord adapter. (@shuber)
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source 'https://rubygems.org'

gemspec

gem "concurrent-ruby", "< 1.3.5"
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
## Maintainer(s) wanted!!!

**If you have an interest in maintaining this project... please see https://github.com/attr-encrypted/attr_encrypted/issues/379**

# attr_encrypted

[![Build Status](https://secure.travis-ci.org/attr-encrypted/attr_encrypted.svg)](https://travis-ci.org/attr-encrypted/attr_encrypted) [![Test Coverage](https://codeclimate.com/github/attr-encrypted/attr_encrypted/badges/coverage.svg)](https://codeclimate.com/github/attr-encrypted/attr_encrypted/coverage) [![Code Climate](https://codeclimate.com/github/attr-encrypted/attr_encrypted/badges/gpa.svg)](https://codeclimate.com/github/attr-encrypted/attr_encrypted) [![Gem Version](https://badge.fury.io/rb/attr_encrypted.svg)](https://badge.fury.io/rb/attr_encrypted) [![security](https://hakiri.io/github/attr-encrypted/attr_encrypted/master.svg)](https://hakiri.io/github/attr-encrypted/attr_encrypted/master)
![workflow](https://github.com/attr-encrypted/attr_encrypted/actions/workflows/CI.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/attr_encrypted.svg)](https://badge.fury.io/rb/attr_encrypted)

Generates attr_accessors that transparently encrypt and decrypt attributes.

It works with ANY class, however, you get a few extra features when you're using it with `ActiveRecord`, `DataMapper`, or `Sequel`.

It works with ANY class, however, you get a few extra features when you're using it with `ActiveRecord` or `Sequel`.

## Installation

Add attr_encrypted to your gemfile:

```ruby
gem "attr_encrypted", "~> 3.1.0"
gem "attr_encrypted"
```

Then install the gem:
Expand All @@ -27,7 +22,7 @@ Then install the gem:

## Usage

If you're using an ORM like `ActiveRecord`, `DataMapper`, or `Sequel`, using attr_encrypted is easy:
If you're using an ORM like `ActiveRecord` or `Sequel`, using attr_encrypted is easy:

```ruby
class User
Expand Down Expand Up @@ -368,7 +363,7 @@ NOTE: This only works if all records are encrypted with the same encryption key
__NOTE: This feature is deprecated and will be removed in the next major release.__


### DataMapper and Sequel
### Sequel

#### Default options

Expand Down Expand Up @@ -414,7 +409,7 @@ Then modify your models using attr\_encrypted to account for the changes in defa

## Upgrading from attr_encrypted v2.x to v3.x

A bug was discovered in Encryptor v2.0.0 that inccorectly set the IV when using an AES-\*-GCM algorithm. Unfornately fixing this major security issue results in the inability to decrypt records encrypted using an AES-*-GCM algorithm from Encryptor v2.0.0. Please see [Upgrading to Encryptor v3.0.0](https://github.com/attr-encrypted/encryptor#upgrading-from-v200-to-v300) for more info.
A bug was discovered in Encryptor v2.0.0 that incorrectly set the IV when using an AES-\*-GCM algorithm. Unfornately fixing this major security issue results in the inability to decrypt records encrypted using an AES-*-GCM algorithm from Encryptor v2.0.0. Please see [Upgrading to Encryptor v3.0.0](https://github.com/attr-encrypted/encryptor#upgrading-from-v200-to-v300) for more info.

It is strongly advised that you re-encrypt your data encrypted with Encryptor v2.0.0. However, you'll have to take special care to re-encrypt. To decrypt data encrypted with Encryptor v2.0.0 using an AES-\*-GCM algorithm you can use the `:v2_gcm_iv` option.

Expand All @@ -425,7 +420,7 @@ It is recommended that you implement a strategy to insure that you do not mix th
attr_encrypted :ssn, key: :encryption_key, v2_gcm_iv: is_decrypting?(:ssn)

def is_decrypting?(attribute)
encrypted_attributes[attribute][:operation] == :decrypting
attr_encrypted_encrypted_attributes[attribute][:operation] == :decrypting
end
end

Expand All @@ -442,7 +437,7 @@ It is recommended that you implement a strategy to insure that you do not mix th
While choosing to encrypt at the attribute level is the most secure solution, it is not without drawbacks. Namely, you cannot search the encrypted data, and because you can't search it, you can't index it either. You also can't use joins on the encrypted data. Data that is securely encrypted is effectively noise. So any operations that rely on the data not being noise will not work. If you need to do any of the aforementioned operations, please consider using database and file system encryption along with transport encryption as it moves through your stack.

#### Data leaks
Please also consider where your data leaks. If you're using attr_encrypted with Rails, it's highly likely that this data will enter your app as a request parameter. You'll want to be sure that you're filtering your request params from you logs or else your data is sitting in the clear in your logs. [Parameter Filtering in Rails](http://apidock.com/rails/ActionDispatch/Http/FilterParameters) Please also consider other possible leak points.
Please also consider where your data leaks. If you're using attr_encrypted with Rails, it's highly likely that this data will enter your app as a request parameter. You'll want to be sure that you're filtering your request params from your logs or else your data is sitting in the clear in your logs. [Parameter Filtering in Rails](http://apidock.com/rails/ActionDispatch/Http/FilterParameters) Please also consider other possible leak points.

#### Storage requirements
When storing your encrypted data, please consider the length requirements of the db column that you're storing the cipher text in. Older versions of Mysql attempt to 'help' you by truncating strings that are too large for the column. When this happens, you will not be able to decrypt your data. [MySQL Strict Trans](http://www.davidpashley.com/2009/02/15/silently-truncated/)
Expand Down
Loading