Skip to content

Commit

Permalink
Merge b065416 into 32a8f7a
Browse files Browse the repository at this point in the history
  • Loading branch information
jmortlock committed Jan 4, 2021
2 parents 32a8f7a + b065416 commit e70cb0d
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rake

release:
needs: build
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Generate Changelog
run: |
# Get version from github ref (remove 'refs/tags/' and prefix 'v')
version="${GITHUB_REF#refs/tags/v}"
npx changelog-parser CHANGELOG.md | jq -cr ".versions | .[] | select(.version == \"$version\") | .body" > ${{ github.workflow }}-CHANGELOG.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workflow }}-CHANGELOG.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: [build, release]
name: Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1

- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
16 changes: 16 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build and Test
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
ruby: ["2.6", "2.7", "3.0"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.3
3.0.0
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).

## Unreleased
- [TT-8626] Update to build with github actions / ruby 3.0 / rails 6.1

## [0.5.0]
- [TT-5815] Relax version dependencies and tested on latest ruby versions

Expand Down
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# SensitiveDataFilter

[![Gem Version](https://badge.fury.io/rb/sensitive_data_filter.svg)](http://badge.fury.io/rb/sensitive_data_filter)
[![Build Status](https://travis-ci.org/sealink/sensitive_data_filter.svg?branch=master)](https://travis-ci.org/sealink/sensitive_data_filter)
[![Build Status](https://github.com/sealink/pansophy/workflows/Build%20and%20Test/badge.svg?branch=master)](https://github.com/sealink/pansophy/actions)
[![Coverage Status](https://coveralls.io/repos/sealink/sensitive_data_filter/badge.svg)](https://coveralls.io/r/sealink/sensitive_data_filter)
[![Dependency Status](https://gemnasium.com/sealink/sensitive_data_filter.svg)](https://gemnasium.com/sealink/sensitive_data_filter)
[![Code Climate](https://codeclimate.com/github/sealink/sensitive_data_filter/badges/gpa.svg)](https://codeclimate.com/github/sealink/sensitive_data_filter)

A Rack Middleware filter for sensitive data
Expand Down Expand Up @@ -37,7 +36,7 @@ E.g. for Rails, add the following in application.rb
config.middleware.insert_before 'ActionDispatch::ParamsParser', SensitiveDataFilter::Middleware::Filter
```

To ensure that no sensitive data is accessed at any level of the stack, insert the middleware at the top of the stack.
To ensure that no sensitive data is accessed at any level of the stack, insert the middleware at the top of the stack.

E.g.

Expand All @@ -49,15 +48,15 @@ config.middleware.insert_before 0, SensitiveDataFilter::Middleware::Filter
#### Important note for Rails

Rails logs the URI of the request in ``Rails::Rack::Logger``. At this point of the stack, Rails generally has not yet set the session in the env.
If you insert the sensitive data filtering middleware before this middleware you will prevent sensitive data from appearing in the logs,
If you insert the sensitive data filtering middleware before this middleware you will prevent sensitive data from appearing in the logs,
but you will not have access to the session via the occurrence or the env in the occurrence handling block.

### Configuration

```ruby
SensitiveDataFilter.config do |config|
config.enable_types :credit_card # Already defaults to :credit_card if not specified
config.on_occurrence do |occurrence|
config.on_occurrence do |occurrence|
# Report occurrence
end
config.whitelist pattern1, pattern2 # Allows specifying patterns to whitelist matches
Expand All @@ -83,7 +82,7 @@ An occurrence object has the following properties:
* changeset: the modified rack env variables

It also exposes `to_h` and `to_s` methods for hash and string representation respectively.
Please note that these representations omit sensitive data,
Please note that these representations omit sensitive data,
i.e. `original_query_params`, `original_body_params` and `matches` are not included.

#### Important Notes
Expand All @@ -106,10 +105,10 @@ filtered_body_params = if @occurrence.filtered_body_params.is_a? Hash

#### Whitelisting

A list of whitelisting patterns can be passed to `config.whitelist`.
A list of whitelisting patterns can be passed to `config.whitelist`.
Any sensitive data match which also matches any of these patterns will be ignored.

A list of whitelisting patterns can be passed to `config.whitelist_key`.
A list of whitelisting patterns can be passed to `config.whitelist_key`.
When scanning and matching hashes, any value whose key matches any of these patterns will be ignored.

#### Parameter Parsing
Expand All @@ -119,9 +118,9 @@ The arguments for `config.register_parser` are:
* a pattern to match the content type
* a parser for the parameters
* an unparser to convert parameters back to the encoded format

The parser and unparser must be objects that respond to `call` and accept the parameters as an argument (e.g. procs or lambdas).
The parser should handle parsing exceptions gracefully by returning the arguments.
The parser should handle parsing exceptions gracefully by returning the arguments.
This ensures that sensitive data scanning and masking is applied on the raw parameters.

## Development
Expand All @@ -130,6 +129,18 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Release

To publish a new version of this gem the following steps must be taken.

* Update the version in the following files
```
CHANGELOG.md
lib/sensitive_data_filter/version.rb
````
* Create a tag using the format v0.1.0
* Follow build progress in GitHub actions

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sealink/sensitive_data_filter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
Expand All @@ -138,4 +149,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/sealin
## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

4 changes: 2 additions & 2 deletions sensitive_data_filter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 2.4'
spec.required_ruby_version = '>= 2.6'

spec.add_dependency 'rack'
spec.add_dependency 'facets'
Expand All @@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'simplecov-rcov'
spec.add_development_dependency 'coveralls'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'travis'
spec.add_development_dependency 'pry'
end

0 comments on commit e70cb0d

Please sign in to comment.