Skip to content

Commit 55cf024

Browse files
Raphael WeinerStephan Hagemann
authored andcommitted
convert breach migration plugin to proper gem and fix name
Change-Id: Ie26495b5ea3e09f31b6b80d643679fe94ca9816b Reviewed-on: https://gerrit.instructure.com/29455 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Stephan Hagemann <stephan@pivotallabs.com> Product-Review: Stephan Hagemann <stephan@pivotallabs.com> QA-Review: Stephan Hagemann <stephan@pivotallabs.com>
1 parent 669ba4f commit 55cf024

13 files changed

Lines changed: 131 additions & 8 deletions

File tree

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ gem 'crocodoc-ruby', '0.0.1', :require => 'crocodoc'
144144
# we can go back to the gem once 1.7.8 is released
145145
gem 'regru-premailer', :require => 'premailer', :github => "regru/premailer", :ref => "08a73c70701f5d81bc4a5cf6c959a45ad94db88e"
146146

147-
gem 'canvas_sanitize', path: 'gems/canvas_sanitize'
147+
gem 'canvas_breach_mitigation', path: 'gems/canvas_breach_mitigation'
148148
gem 'canvas_crummy', path: 'gems/canvas_crummy'
149149
gem 'canvas_mimetype_fu', path: 'gems/canvas_mimetype_fu'
150+
gem 'canvas_sanitize', path: 'gems/canvas_sanitize'
150151

151152
group :assets do
152153
gem 'compass-rails', '1.0.3'

app/controllers/application_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,15 +1020,15 @@ def verify_authenticity_token
10201020
redirect_to(login_url(:needs_cookies => '1'))
10211021
return false
10221022
else
1023-
raise(ActionController::InvalidAuthenticityToken) unless BreachMitigation::MaskingSecrets.valid_authenticity_token?(session, form_authenticity_param) ||
1024-
BreachMitigation::MaskingSecrets.valid_authenticity_token?(session, request.headers['X-CSRF-Token'])
1023+
raise(ActionController::InvalidAuthenticityToken) unless CanvasBreachMitigation::MaskingSecrets.valid_authenticity_token?(session, form_authenticity_param) ||
1024+
CanvasBreachMitigation::MaskingSecrets.valid_authenticity_token?(session, request.headers['X-CSRF-Token'])
10251025
end
10261026
end
10271027
Rails.logger.warn("developer_key id: #{@developer_key.id}") if @developer_key
10281028
end
10291029

10301030
def form_authenticity_token
1031-
BreachMitigation::MaskingSecrets.masked_authenticity_token(session)
1031+
CanvasBreachMitigation::MaskingSecrets.masked_authenticity_token(session)
10321032
end
10331033

10341034
API_REQUEST_REGEX = %r{\A/api/v\d}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*.gem
2+
*.rbc
3+
.bundle
4+
.config
5+
.yardoc
6+
Gemfile.lock
7+
InstalledFiles
8+
_yardoc
9+
coverage
10+
doc/
11+
lib/bundler/man
12+
pkg
13+
rdoc
14+
spec/reports
15+
test/tmp
16+
test/version_tmp
17+
tmp
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format progress
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec
File renamed without changes.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# breach-mitigation-rails
1+
# Canvas Breach Mitigation
2+
3+
This is a fork of the breach-mitigation-rails gem: http://rubygems.org/gems/breach-mitigation-rails
4+
5+
TODO: Ideally this should be replaced with the gem
26

37
Makes Rails applications less susceptible to the BREACH /
48
CRIME attacks. See [breachattack.com](http://breachattack.com/) for
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding: utf-8
2+
lib = File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
5+
Gem::Specification.new do |spec|
6+
spec.name = "canvas_breach_mitigation"
7+
spec.version = '0.0.1'
8+
spec.authors = ["Raphael Weiner", "David Julia"]
9+
spec.email = ["rweiner@pivotallabs.com", "djulia@pivotallabs.com"]
10+
spec.summary = %q{Subset of breach-mitigation-rails gem}
11+
12+
spec.files = `git ls-files`.split($/)
13+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15+
spec.require_paths = ["lib"]
16+
17+
spec.add_development_dependency "bundler", "~> 1.5"
18+
spec.add_development_dependency "rspec"
19+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module CanvasBreachMitigation
2+
require "canvas_breach_mitigation/masking_secrets"
3+
end

vendor/plugins/breach_migration/lib/breach_mitigation/masking_secrets.rb renamed to gems/canvas_breach_mitigation/lib/canvas_breach_mitigation/masking_secrets.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module BreachMitigation
1+
module CanvasBreachMitigation
22
class MaskingSecrets
33
class << self
44
AUTHENTICITY_TOKEN_LENGTH = 32

0 commit comments

Comments
 (0)