From ec776f9d0676d7fc5b4a88358261233a00816bd9 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Wed, 8 Oct 2014 15:24:14 +0300 Subject: [PATCH 01/37] Add proper REGISTRY_ENV names: eedirect and admin --- app/models/ability.rb | 2 +- config/deploy.rb | 4 ++-- config/initializers/env.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 418515bbe..f92c86fd4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -9,7 +9,7 @@ class Ability if Rails.env.production? case REGISTRY_ENV - when :client + when :eedirect can :create, :session admin = false when :admin diff --git a/config/deploy.rb b/config/deploy.rb index 8b3e47378..3daf3ec61 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -11,12 +11,12 @@ require 'mina/git' # branch - Branch name to deploy. (needed by mina/git) set :domain, 'testregistry' -set :deploy_to, '/home/app/registry' +set :deploy_to, '/home/app/eedirect' set :repository, 'https://github.com/internetee/registry' set :branch, 'master' task :admin do - set :deploy_to, '/home/app/admin-registry' + set :deploy_to, '/home/app/registry' end # Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. diff --git a/config/initializers/env.rb b/config/initializers/env.rb index cc68524d7..b180c154a 100644 --- a/config/initializers/env.rb +++ b/config/initializers/env.rb @@ -1,2 +1,2 @@ -# options: :admin, :client -REGISTRY_ENV = :client +# options: :admin, :eedirect +REGISTRY_ENV = :eedirect From 6113401eb0d77b039856e67c8475cd9e17d8f1f1 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Wed, 8 Oct 2014 16:10:48 +0300 Subject: [PATCH 02/37] Added correct REGISTRY_ENV as eedirekt --- app/models/ability.rb | 2 +- config/deploy.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index f92c86fd4..9c2051be0 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -9,7 +9,7 @@ class Ability if Rails.env.production? case REGISTRY_ENV - when :eedirect + when :eedirekt can :create, :session admin = false when :admin diff --git a/config/deploy.rb b/config/deploy.rb index 3daf3ec61..932ab9613 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -11,7 +11,7 @@ require 'mina/git' # branch - Branch name to deploy. (needed by mina/git) set :domain, 'testregistry' -set :deploy_to, '/home/app/eedirect' +set :deploy_to, '/home/app/eedirekt' set :repository, 'https://github.com/internetee/registry' set :branch, 'master' From aff012ff45056d43bb461b5e53c2457e0fab5c52 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Wed, 8 Oct 2014 16:27:04 +0300 Subject: [PATCH 03/37] Added registrar env --- app/models/ability.rb | 3 +++ config/deploy.rb | 6 +++++- config/initializers/env.rb | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 9c2051be0..17d27ce30 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -12,6 +12,9 @@ class Ability when :eedirekt can :create, :session admin = false + when :registrar + can :create, :session + admin = false when :admin can :create, :admin_session admin = user.admin? diff --git a/config/deploy.rb b/config/deploy.rb index 932ab9613..923f08bd2 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -10,7 +10,7 @@ require 'mina/git' # repository - Git repo to clone from. (needed by mina/git) # branch - Branch name to deploy. (needed by mina/git) -set :domain, 'testregistry' +set :domain, 'localregistry' set :deploy_to, '/home/app/eedirekt' set :repository, 'https://github.com/internetee/registry' set :branch, 'master' @@ -19,6 +19,10 @@ task :admin do set :deploy_to, '/home/app/registry' end +task :registrar do + set :deploy_to, '/home/app/registrar' +end + # Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. # They will be linked in the 'deploy:link_shared_paths' step. set :shared_paths, [ diff --git a/config/initializers/env.rb b/config/initializers/env.rb index b180c154a..9e0618ffb 100644 --- a/config/initializers/env.rb +++ b/config/initializers/env.rb @@ -1,2 +1,2 @@ -# options: :admin, :eedirect +# options: :admin, :registrar, :eedirect REGISTRY_ENV = :eedirect From c7acd7dab1110b133a2d59935213e53ce3b06834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 8 Oct 2014 16:32:50 +0300 Subject: [PATCH 04/37] Basic whois data generator --- lib/tasks/whois.rake | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/tasks/whois.rake diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake new file mode 100644 index 000000000..bc430194c --- /dev/null +++ b/lib/tasks/whois.rake @@ -0,0 +1,30 @@ +desc 'Commands for whois' + +desc 'generate whois files' +task 'whois:generate' => :environment do + Dir.mkdir("./tmp/whois") unless File.exists?("./tmp/whois") #a folder for ze stuff + + alphabet = (("a".."z").to_a << %w(ö õ ü ä) ).flatten! + @domains = {} + alphabet.each do |letter| + domains = Domain.where([ 'name LIKE ?', "#{letter}%" ]) + @domains[letter] = {} + + domains.each do |domain| + @domains[letter][domain.name] = { + valid_to: domain.valid_to, + status: domain.status, + contacts: [ + { name: domain.owner_contact.name, email: domain.owner_contact.email }, + { registrar: domain.registrar.name, address: domain.registrar.address } + ] + } + end + end + + @domains.each do |k,v| + file = File.open("tmp/whois/#{k}_domain.yaml", 'w') { |f| f.write(v.to_yaml) } + end + +end + From aebd431bb7a4210847ee6e836f8f5c132e5a4399 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Wed, 8 Oct 2014 17:02:53 +0300 Subject: [PATCH 05/37] Update deploy --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 923f08bd2..ee9c2b24f 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -10,7 +10,7 @@ require 'mina/git' # repository - Git repo to clone from. (needed by mina/git) # branch - Branch name to deploy. (needed by mina/git) -set :domain, 'localregistry' +set :domain, 'testregistry' set :deploy_to, '/home/app/eedirekt' set :repository, 'https://github.com/internetee/registry' set :branch, 'master' From 19846a3abfdab88c7d021f3b4c6a70c9e186f05f Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Wed, 8 Oct 2014 17:13:04 +0300 Subject: [PATCH 06/37] Added registrar title --- app/models/ability.rb | 2 ++ app/views/layouts/client.haml | 12 ++++++++++-- config/locales/en.yml | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 17d27ce30..7b03cac59 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -10,9 +10,11 @@ class Ability if Rails.env.production? case REGISTRY_ENV when :eedirekt + can :view, :eedirekt can :create, :session admin = false when :registrar + can :view, :registrar can :create, :session admin = false when :admin diff --git a/app/views/layouts/client.haml b/app/views/layouts/client.haml index 300ac9c59..5ea9ff1a2 100644 --- a/app/views/layouts/client.haml +++ b/app/views/layouts/client.haml @@ -9,7 +9,11 @@ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true %link{href: "../../favicon.ico", rel: "icon"}/ - %title= t('shared.eedirekt') + %title + - if can? :view, :registrar + = t(:registrar) + - else + = t('shared.eedirekt') %body / Static navbar .navbar.navbar-default.navbar-static-top{role: "navigation"} @@ -20,7 +24,11 @@ %span.icon-bar %span.icon-bar %span.icon-bar - = link_to t('shared.eedirekt'), client_domains_path, class: 'navbar-brand' + - if can? :view, :registrar + = link_to t(:registrar), client_domains_path, class: 'navbar-brand' + - else + = link_to t('shared.eedirekt'), client_domains_path, class: 'navbar-brand' + .navbar-collapse.collapse %ul.nav.navbar-nav - active_class = ['client/domains', 'client/domain_transfers'].include?(params[:controller]) ? 'active' :nil diff --git a/config/locales/en.yml b/config/locales/en.yml index 2c8062629..2a2e864bb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -419,3 +419,5 @@ en: # sorry these need to be refactored - Andres authentication_error: 'Authentication error' + + registrar: Registrar From 20d78f0220e51c2c787c030e1c20900e4eaf0bf6 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 12:37:40 +0300 Subject: [PATCH 07/37] Updated rubocop yml --- .rubocop.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index ce05b727c..1deb6d11e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -29,6 +29,11 @@ Style/BracesAroundHashParameters: Style/IndentHash: Enabled: false +# allow == operator used in void context in specs +Void: + Exclude: + - 'spec/**/*' + # No need to force reduce to use |a, e| as parameters. # Configuration parameters: Methods. Style/SingleLineBlockParams: From 6851e12c47947c483c09800ed9372601bf073bde Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 13:12:10 +0300 Subject: [PATCH 08/37] Added web-console and removed assets group, no present in Rails 4 --- Gemfile | 9 +++++---- Gemfile.lock | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 68c15b8a3..ded6bbba2 100644 --- a/Gemfile +++ b/Gemfile @@ -64,10 +64,8 @@ gem 'paper_trail', '~> 3.0.5' # for select gem 'selectize-rails', '~> 0.11.0' -group :assets do - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', platforms: :ruby -end +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +gem 'therubyracer', platforms: :ruby group :development do # faster dev load time @@ -87,6 +85,9 @@ group :development do gem 'guard-rspec', '~> 4.3.1' # rubocop support for guard gem 'guard-rubocop', '~> 1.1.0' + + # for quick debugging + gem 'web-console', '~> 2.0.0.beta4' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index a6a6c8c77..e7b7d1537 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,6 +32,8 @@ GEM astrolabe (1.3.0) parser (>= 2.2.0.pre.3, < 3.0) bcrypt (3.1.7) + binding_of_caller (0.7.3.pre1) + debug_inspector (>= 0.0.1) bootstrap-sass (3.2.0.2) sass (~> 3.2) builder (3.2.2) @@ -54,6 +56,7 @@ GEM execjs coffee-script-source (1.7.0) database_cleaner (1.3.0) + debug_inspector (0.0.2) devise (3.3.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -265,6 +268,11 @@ GEM uuidtools (2.1.5) warden (1.2.3) rack (>= 1.0) + web-console (2.0.0.beta4) + activemodel (~> 4.0) + binding_of_caller (= 0.7.3.pre1) + railties (~> 4.0) + sprockets-rails (>= 2.0, < 4.0) websocket-driver (0.3.4) xpath (2.0.0) nokogiri (~> 1.3) @@ -313,3 +321,4 @@ DEPENDENCIES uglifier (>= 1.3.0) unicorn uuidtools (~> 2.1.4) + web-console (~> 2.0.0.beta4) From c1d840caa316592e9a0abebea62512404f5bd88f Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 13:52:28 +0300 Subject: [PATCH 09/37] added rubocop exceptions during guard runs --- .rubocop-guard.yml | 10 ++++++++++ Guardfile | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .rubocop-guard.yml diff --git a/.rubocop-guard.yml b/.rubocop-guard.yml new file mode 100644 index 000000000..0ee03be6b --- /dev/null +++ b/.rubocop-guard.yml @@ -0,0 +1,10 @@ +inherit_from: .rubocop.yml + +# +# Turn off during guard runs +# + +# turn off comment intention check during development +# because NerdCommenter honors commented code intentions +Style/CommentIndentation: + Enabled: false diff --git a/Guardfile b/Guardfile index 972130966..1910f3be7 100644 --- a/Guardfile +++ b/Guardfile @@ -26,9 +26,10 @@ group :red_green_refactor, halt_on_fail:true do # Martin does not want rubocop unless Socket.gethostname == 'martin' - guard :rubocop do + guard :rubocop, cli: '--display-cop-names -c .rubocop-guard.yml' do watch(%r{.+\.rb$}) watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } + watch(%r{(?:.+/)?\.rubocop-guard\.yml$}) { |m| File.dirname(m[0]) } end end end From 911c75cc750df319df799ddc7d564e176768b4b3 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 14:03:45 +0300 Subject: [PATCH 10/37] rubocop: turn off whitespace hunting --- .rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 1deb6d11e..7a9bd38fb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -29,6 +29,10 @@ Style/BracesAroundHashParameters: Style/IndentHash: Enabled: false +# a bit too annoying requirement, no big drawback yet dedected +Style/TrailingWhitespace: + Enabled: false + # allow == operator used in void context in specs Void: Exclude: From 0c5e971461bf43db8157673cf3ebe8e6ac93616d Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 16:44:39 +0300 Subject: [PATCH 11/37] added traceroute gem for codereview --- Gemfile | 3 +++ Gemfile.lock | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Gemfile b/Gemfile index ded6bbba2..dfdd0dfc5 100644 --- a/Gemfile +++ b/Gemfile @@ -88,6 +88,9 @@ group :development do # for quick debugging gem 'web-console', '~> 2.0.0.beta4' + + # for finding dead routes and unused actions + gem 'traceroute', '~> 0.4.0' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index e7b7d1537..fe2a7bc2f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -251,6 +251,8 @@ GEM tilt (1.4.1) timers (4.0.1) hitimes + traceroute (0.4.0) + rails (>= 3.0.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) @@ -317,6 +319,7 @@ DEPENDENCIES simpleidn (~> 0.0.5) spring therubyracer + traceroute (~> 0.4.0) turbolinks uglifier (>= 1.3.0) unicorn From 825e4bc5c1ea70685b2af763167c4af94ce164d3 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 17:08:10 +0300 Subject: [PATCH 12/37] Update rubocop --- .rubocop.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7a9bd38fb..51ef59e85 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -43,6 +43,9 @@ Void: Style/SingleLineBlockParams: Enabled: false -# No need for nested module/class definition as far as I know +# allow prefix for models and controllers, +# otherwise we have to intent all body 4 spaces Style/ClassAndModuleChildren: - Enabled: false + Exclude: + - 'app/controllers/**/*' + - 'app/models/**/*' From 7c748884f3d5ece32708c77aa9bcd74fed89543b Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 17:39:54 +0300 Subject: [PATCH 13/37] added bullet for finding database optimizations --- Gemfile | 3 +++ Gemfile.lock | 5 +++++ config/environments/development.rb | 9 +++++++++ config/environments/test.rb | 7 +++++++ 4 files changed, 24 insertions(+) diff --git a/Gemfile b/Gemfile index dfdd0dfc5..86425e55f 100644 --- a/Gemfile +++ b/Gemfile @@ -128,4 +128,7 @@ group :development, :test do # For code review gem 'simplecov', '~> 0.9.1', :require => false + + # for finding database optimizations + gem 'bullet', '~> 4.14.0' end diff --git a/Gemfile.lock b/Gemfile.lock index fe2a7bc2f..accbf08d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,9 @@ GEM bootstrap-sass (3.2.0.2) sass (~> 3.2) builder (3.2.2) + bullet (4.14.0) + activesupport (>= 3.0.0) + uniform_notifier (>= 1.6.0) cancan (1.6.10) capybara (2.4.1) mime-types (>= 1.16) @@ -267,6 +270,7 @@ GEM kgio (~> 2.6) rack raindrops (~> 0.7) + uniform_notifier (1.6.2) uuidtools (2.1.5) warden (1.2.3) rack (>= 1.0) @@ -284,6 +288,7 @@ PLATFORMS DEPENDENCIES bootstrap-sass (~> 3.2.0.1) + bullet (~> 4.14.0) cancan (~> 1.6.10) capybara (~> 2.4.1) coffee-rails (~> 4.0.0) diff --git a/config/environments/development.rb b/config/environments/development.rb index 713b0f117..7e3c7dfc0 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -36,4 +36,13 @@ Rails.application.configure do # config.action_view.raise_on_missing_translations = true config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + + # for finding database optimization + config.after_initialize do + Bullet.enable = true + Bullet.bullet_logger = true + Bullet.console = true + Bullet.rails_logger = true + Bullet.add_footer = true + end end diff --git a/config/environments/test.rb b/config/environments/test.rb index 82ca38674..dfc9384e2 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -36,4 +36,11 @@ Rails.application.configure do # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # for finding database optimization + config.after_initialize do + Bullet.enable = true + Bullet.bullet_logger = true + Bullet.raise = true # raise an error if n+1 query occurs + end end From 1d3c40e520b8d48fcf46689db417e69bc6da2b94 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 17:55:50 +0300 Subject: [PATCH 14/37] Added bundle audit for robot --- Gemfile | 3 +++ Gemfile.lock | 4 ++++ bin/robot | 2 ++ 3 files changed, 9 insertions(+) diff --git a/Gemfile b/Gemfile index 86425e55f..1c4e78ef4 100644 --- a/Gemfile +++ b/Gemfile @@ -131,4 +131,7 @@ group :development, :test do # for finding database optimizations gem 'bullet', '~> 4.14.0' + + # for finding future vulnerable gems + gem 'bundler-audit' end diff --git a/Gemfile.lock b/Gemfile.lock index accbf08d1..ebffd3ab0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,6 +40,9 @@ GEM bullet (4.14.0) activesupport (>= 3.0.0) uniform_notifier (>= 1.6.0) + bundler-audit (0.3.1) + bundler (~> 1.2) + thor (~> 0.18) cancan (1.6.10) capybara (2.4.1) mime-types (>= 1.16) @@ -289,6 +292,7 @@ PLATFORMS DEPENDENCIES bootstrap-sass (~> 3.2.0.1) bullet (~> 4.14.0) + bundler-audit cancan (~> 1.6.10) capybara (~> 2.4.1) coffee-rails (~> 4.0.0) diff --git a/bin/robot b/bin/robot index 590ddf699..c241189fd 100755 --- a/bin/robot +++ b/bin/robot @@ -18,6 +18,8 @@ rubocop echo "END_OF_RUBOCOP_RESULTS" bundle install --deployment +bundle-audit update +bundle-audit # cp config/secrets-example.yml config/secrets.yml # create manually config/database.yml From 181da1abb70368e3064e04a933e6ed7a01859f60 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 9 Oct 2014 18:15:29 +0300 Subject: [PATCH 15/37] Added code review to robot --- Gemfile | 1 + Gemfile.lock | 40 ++++++++++++++++++++++++++++++++++++++++ bin/robot | 3 +++ 3 files changed, 44 insertions(+) diff --git a/Gemfile b/Gemfile index 1c4e78ef4..2a5252727 100644 --- a/Gemfile +++ b/Gemfile @@ -128,6 +128,7 @@ group :development, :test do # For code review gem 'simplecov', '~> 0.9.1', :require => false + gem 'rubycritic', '~> 1.1.1' # for finding database optimizations gem 'bullet', '~> 4.14.0' diff --git a/Gemfile.lock b/Gemfile.lock index ebffd3ab0..99cacbe8b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,6 +31,10 @@ GEM ast (2.0.0) astrolabe (1.3.0) parser (>= 2.2.0.pre.3, < 3.0) + axiom-types (0.1.1) + descendants_tracker (~> 0.0.4) + ice_nine (~> 0.11.0) + thread_safe (~> 0.3, >= 0.3.1) bcrypt (3.1.7) binding_of_caller (0.7.3.pre1) debug_inspector (>= 0.0.1) @@ -54,6 +58,8 @@ GEM timers (~> 4.0.0) cliver (0.3.2) coderay (1.1.0) + coercible (1.0.0) + descendants_tracker (~> 0.0.1) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -63,6 +69,8 @@ GEM coffee-script-source (1.7.0) database_cleaner (1.3.0) debug_inspector (0.0.2) + descendants_tracker (0.0.4) + thread_safe (~> 0.3, >= 0.3.1) devise (3.3.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -74,12 +82,19 @@ GEM epp (1.4.0) hpricot libxml-ruby + equalizer (0.0.9) erubis (2.7.0) execjs (2.2.1) fabrication (2.11.3) faker (1.3.0) i18n (~> 0.5) ffi (1.9.3) + flay (2.4.0) + ruby_parser (~> 3.0) + sexp_processor (~> 4.0) + flog (4.2.1) + ruby_parser (~> 3.1, > 3.1.0) + sexp_processor (~> 4.4) formatador (0.2.5) guard (2.6.1) formatador (>= 0.2.4) @@ -104,6 +119,7 @@ GEM hitimes (1.2.2) hpricot (0.8.6) i18n (0.6.11) + ice_nine (0.11.0) isikukood (0.1.2) jbuilder (2.1.3) activesupport (>= 3.0.0, < 5) @@ -190,6 +206,11 @@ GEM ffi (>= 0.5.0) rdoc (4.1.2) json (~> 1.4) + reek (1.3.8) + rainbow (>= 1.99, < 3.0) + ruby2ruby (>= 2.0.8, < 3.0) + ruby_parser (~> 3.3) + sexp_processor ref (1.0.5) rspec (3.0.0) rspec-core (~> 3.0.0) @@ -218,6 +239,18 @@ GEM rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.4) ruby-progressbar (1.5.1) + ruby2ruby (2.1.3) + ruby_parser (~> 3.1) + sexp_processor (~> 4.0) + ruby_parser (3.6.3) + sexp_processor (~> 4.1) + rubycritic (1.1.1) + flay (= 2.4.0) + flog (= 4.2.1) + parser (~> 2.1) + reek (= 1.3.8) + ruby2ruby (>= 2.1.1, < 3.0) + virtus (~> 1.0) sass (3.2.19) sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) @@ -228,6 +261,7 @@ GEM json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) selectize-rails (0.11.0) + sexp_processor (4.4.4) shoulda-matchers (2.6.2) activesupport (>= 3.0.0) simplecov (0.9.1) @@ -275,6 +309,11 @@ GEM raindrops (~> 0.7) uniform_notifier (1.6.2) uuidtools (2.1.5) + virtus (1.0.3) + axiom-types (~> 0.1) + coercible (~> 1.0) + descendants_tracker (~> 0.0, >= 0.0.3) + equalizer (~> 0.0, >= 0.0.9) warden (1.2.3) rack (>= 1.0) web-console (2.0.0.beta4) @@ -320,6 +359,7 @@ DEPENDENCIES rails (= 4.1.4) ransack (~> 1.3.0) rspec-rails (~> 3.0.2) + rubycritic (~> 1.1.1) sass-rails (~> 4.0.3) sdoc (~> 0.4.0) selectize-rails (~> 0.11.0) diff --git a/bin/robot b/bin/robot index c241189fd..bbd27b7d6 100755 --- a/bin/robot +++ b/bin/robot @@ -38,3 +38,6 @@ echo "END_OF_GIT_LAST_COMMITS" echo "TEST_RESULTS" RAILS_ENV=test ROBOT=true bundle exec rake test echo "END_OF_TEST_RESULTS" + +# update code review +rubycritic app lib From 0273a0d99fe287eb618285fd84dba22b7ce56ed9 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 11:02:54 +0300 Subject: [PATCH 16/37] Added brakeman to robot --- Gemfile | 3 +++ Gemfile.lock | 55 ++++++++++++++++++++++++++++++++++------------------ bin/robot | 4 ++++ 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index 2a5252727..759174dbd 100644 --- a/Gemfile +++ b/Gemfile @@ -135,4 +135,7 @@ group :development, :test do # for finding future vulnerable gems gem 'bundler-audit' + + # for security audit' + gem 'brakeman', '~> 2.6.2', :require => false end diff --git a/Gemfile.lock b/Gemfile.lock index 99cacbe8b..fd2911cbc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,8 +29,6 @@ GEM tzinfo (~> 1.1) arel (5.0.1.20140414130214) ast (2.0.0) - astrolabe (1.3.0) - parser (>= 2.2.0.pre.3, < 3.0) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) @@ -40,6 +38,17 @@ GEM debug_inspector (>= 0.0.1) bootstrap-sass (3.2.0.2) sass (~> 3.2) + brakeman (2.6.2) + erubis (~> 2.6) + fastercsv (~> 1.5) + haml (>= 3.0, < 5.0) + highline (~> 1.6.20) + multi_json (~> 1.2) + ruby2ruby (~> 2.1.1) + ruby_parser (~> 3.5.0) + sass (~> 3.0) + slim (>= 1.3.6, < 3.0) + terminal-table (~> 1.4) builder (3.2.2) bullet (4.14.0) activesupport (>= 3.0.0) @@ -48,7 +57,7 @@ GEM bundler (~> 1.2) thor (~> 0.18) cancan (1.6.10) - capybara (2.4.1) + capybara (2.4.3) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) @@ -66,7 +75,7 @@ GEM coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.7.0) + coffee-script-source (1.8.0) database_cleaner (1.3.0) debug_inspector (0.0.2) descendants_tracker (0.0.4) @@ -88,7 +97,8 @@ GEM fabrication (2.11.3) faker (1.3.0) i18n (~> 0.5) - ffi (1.9.3) + fastercsv (1.5.5) + ffi (1.9.6) flay (2.4.0) ruby_parser (~> 3.0) sexp_processor (~> 4.0) @@ -115,13 +125,14 @@ GEM activesupport (>= 4.0.1) haml (>= 3.1, < 5.0) railties (>= 4.0.1) + highline (1.6.21) hike (1.2.3) hitimes (1.2.2) hpricot (0.8.6) i18n (0.6.11) ice_nine (0.11.0) isikukood (0.1.2) - jbuilder (2.1.3) + jbuilder (2.2.2) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) jquery-rails (3.1.2) @@ -132,9 +143,9 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.9.2) - libv8 (3.16.14.5) + libv8 (3.16.14.7) libxml-ruby (2.7.0) - listen (2.7.9) + listen (2.7.11) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) @@ -145,16 +156,16 @@ GEM method_source (0.8.2) mime-types (1.25.1) mini_portile (0.6.0) - minitest (5.4.1) + minitest (5.4.2) multi_json (1.10.1) nokogiri (1.6.2.1) mini_portile (= 0.6.0) nprogress-rails (0.1.3.1) orm_adapter (0.5.0) - paper_trail (3.0.5) + paper_trail (3.0.6) activerecord (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.0) - parser (2.2.0.pre.4) + parser (2.1.9) ast (>= 1.1, < 3.0) slop (~> 3.4, >= 3.4.5) pg (0.17.1) @@ -232,17 +243,17 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.4) - rubocop (0.26.0) - astrolabe (~> 1.3) - parser (>= 2.2.0.pre.4, < 3.0) + rubocop (0.23.0) + json (>= 1.7.7, < 2) + parser (~> 2.1.9) powerpack (~> 0.0.6) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.4) - ruby-progressbar (1.5.1) + ruby-progressbar (1.6.0) ruby2ruby (2.1.3) ruby_parser (~> 3.1) sexp_processor (~> 4.0) - ruby_parser (3.6.3) + ruby_parser (3.5.0) sexp_processor (~> 4.1) rubycritic (1.1.1) flay (= 2.4.0) @@ -270,9 +281,12 @@ GEM simplecov-html (~> 0.8.0) simplecov-html (0.8.0) simpleidn (0.0.5) + slim (2.0.3) + temple (~> 0.6.6) + tilt (>= 1.3.3, < 2.1) slop (3.6.0) spring (1.1.3) - sprockets (2.11.0) + sprockets (2.8.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -283,6 +297,8 @@ GEM sprockets (~> 2.8) sys-uname (0.9.0) ffi (>= 1.0.0) + temple (0.6.8) + terminal-table (1.4.5) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref @@ -296,7 +312,7 @@ GEM treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (2.3.0) + turbolinks (2.4.0) coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) @@ -321,7 +337,7 @@ GEM binding_of_caller (= 0.7.3.pre1) railties (~> 4.0) sprockets-rails (>= 2.0, < 4.0) - websocket-driver (0.3.4) + websocket-driver (0.3.5) xpath (2.0.0) nokogiri (~> 1.3) @@ -330,6 +346,7 @@ PLATFORMS DEPENDENCIES bootstrap-sass (~> 3.2.0.1) + brakeman (~> 2.6.2) bullet (~> 4.14.0) bundler-audit cancan (~> 1.6.10) diff --git a/bin/robot b/bin/robot index bbd27b7d6..8de058005 100755 --- a/bin/robot +++ b/bin/robot @@ -18,8 +18,12 @@ rubocop echo "END_OF_RUBOCOP_RESULTS" bundle install --deployment + +echo "SECURITY_RESULTS" bundle-audit update bundle-audit +brakeman +echo "END_OF_SECURITY_RESULTS" # cp config/secrets-example.yml config/secrets.yml # create manually config/database.yml From 7ae49b3d2e3f810586fd607906459b9107174b9a Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 11:32:22 +0300 Subject: [PATCH 17/37] Updated robot --- bin/robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot b/bin/robot index 8de058005..1fe724455 100755 --- a/bin/robot +++ b/bin/robot @@ -17,7 +17,7 @@ echo "RUBOCOP_RESULTS" rubocop echo "END_OF_RUBOCOP_RESULTS" -bundle install --deployment +bundle install echo "SECURITY_RESULTS" bundle-audit update From a77b9edc92340395c457daa9c1593d36f0033f35 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 11:34:20 +0300 Subject: [PATCH 18/37] Robot: hide git output --- bin/robot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/robot b/bin/robot index 1fe724455..c463b1bc0 100755 --- a/bin/robot +++ b/bin/robot @@ -8,8 +8,8 @@ set -o pipefail # cd to Rails root directory cd "$(dirname "$0")"; cd .. -git pull origin master -git reset --hard +git pull origin master &> /dev/null +git reset --hard &> /dev/null unset GIT_DIR GIT_WORK_TREE # run rubocop From 88a042f5e3d111a7e8b0ce99bd6348ec099f8611 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 11:40:48 +0300 Subject: [PATCH 19/37] added bundle to robot --- bin/robot | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/bin/robot b/bin/robot index c463b1bc0..344071d26 100755 --- a/bin/robot +++ b/bin/robot @@ -3,30 +3,31 @@ # Build and run everything for automatic tests # +# fail later set -o pipefail # cd to Rails root directory cd "$(dirname "$0")"; cd .. +# cp config/secrets-example.yml config/secrets.yml +# create manually config/database.yml + git pull origin master &> /dev/null git reset --hard &> /dev/null unset GIT_DIR GIT_WORK_TREE -# run rubocop -echo "RUBOCOP_RESULTS" -rubocop -echo "END_OF_RUBOCOP_RESULTS" - bundle install -echo "SECURITY_RESULTS" -bundle-audit update -bundle-audit -brakeman -echo "END_OF_SECURITY_RESULTS" +# run rubocop +echo "RUBOCOP_RESULTS" +bundle exec rubocop +echo "END_OF_RUBOCOP_RESULTS" -# cp config/secrets-example.yml config/secrets.yml -# create manually config/database.yml +echo "SECURITY_RESULTS" +bundle exec bundle-audit update +bundle exec bundle-audit +bundle exec brakeman +echo "END_OF_SECURITY_RESULTS" RAILS_ENV=test bundle exec rake db:drop RAILS_ENV=test bundle exec rake db:create @@ -44,4 +45,4 @@ RAILS_ENV=test ROBOT=true bundle exec rake test echo "END_OF_TEST_RESULTS" # update code review -rubycritic app lib +bundle exec rubycritic app lib From d798b0579080006d94b3c82a1fd26b39c1e14ee1 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 11:44:53 +0300 Subject: [PATCH 20/37] Robot type fixes --- bin/robot | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/robot b/bin/robot index 344071d26..927f089ad 100755 --- a/bin/robot +++ b/bin/robot @@ -18,7 +18,6 @@ unset GIT_DIR GIT_WORK_TREE bundle install -# run rubocop echo "RUBOCOP_RESULTS" bundle exec rubocop echo "END_OF_RUBOCOP_RESULTS" @@ -36,7 +35,7 @@ RAILS_ENV=test bundle exec rake db:seed RAILS_ENV=test bundle exec rake assets:precompile echo "GIT_LAST_COMMITS" -git log origin/master -n 15 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latests: /' +git log origin/master -n 10 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latest: /' echo "END_OF_GIT_LAST_COMMITS" # run tests From 8e15af73ac9b21a0f80c51e6fbc0c2ad6a8a3be5 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 12:02:48 +0300 Subject: [PATCH 21/37] Updated robot with locales --- bin/robot | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/robot b/bin/robot index 927f089ad..c54263c45 100755 --- a/bin/robot +++ b/bin/robot @@ -3,6 +3,11 @@ # Build and run everything for automatic tests # +# default locations +export LANGUAGE=en_US.UTF-8 +export LANG=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 + # fail later set -o pipefail @@ -40,7 +45,7 @@ echo "END_OF_GIT_LAST_COMMITS" # run tests echo "TEST_RESULTS" -RAILS_ENV=test ROBOT=true bundle exec rake test +ROBOT=true bundle exec rake test echo "END_OF_TEST_RESULTS" # update code review From 6bb95421b465b571c9d9d1477137a1313600f21e Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 12:03:27 +0300 Subject: [PATCH 22/37] Robot: moved tests output higher --- bin/robot | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/robot b/bin/robot index c54263c45..b4c387f03 100755 --- a/bin/robot +++ b/bin/robot @@ -23,16 +23,6 @@ unset GIT_DIR GIT_WORK_TREE bundle install -echo "RUBOCOP_RESULTS" -bundle exec rubocop -echo "END_OF_RUBOCOP_RESULTS" - -echo "SECURITY_RESULTS" -bundle exec bundle-audit update -bundle exec bundle-audit -bundle exec brakeman -echo "END_OF_SECURITY_RESULTS" - RAILS_ENV=test bundle exec rake db:drop RAILS_ENV=test bundle exec rake db:create RAILS_ENV=test bundle exec rake db:schema:load @@ -48,5 +38,15 @@ echo "TEST_RESULTS" ROBOT=true bundle exec rake test echo "END_OF_TEST_RESULTS" +echo "RUBOCOP_RESULTS" +bundle exec rubocop +echo "END_OF_RUBOCOP_RESULTS" + +echo "SECURITY_RESULTS" +bundle exec bundle-audit update +bundle exec bundle-audit +bundle exec brakeman +echo "END_OF_SECURITY_RESULTS" + # update code review bundle exec rubycritic app lib From ec7bdd494b8fac561e5b0f05d0217608085ecfb4 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 12:05:56 +0300 Subject: [PATCH 23/37] robot: hide some output --- bin/robot | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/robot b/bin/robot index b4c387f03..1f606ec01 100755 --- a/bin/robot +++ b/bin/robot @@ -25,7 +25,7 @@ bundle install RAILS_ENV=test bundle exec rake db:drop RAILS_ENV=test bundle exec rake db:create -RAILS_ENV=test bundle exec rake db:schema:load +RAILS_ENV=test bundle exec rake db:schema:load &> /dev/null RAILS_ENV=test bundle exec rake db:seed RAILS_ENV=test bundle exec rake assets:precompile @@ -33,15 +33,14 @@ echo "GIT_LAST_COMMITS" git log origin/master -n 10 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latest: /' echo "END_OF_GIT_LAST_COMMITS" -# run tests -echo "TEST_RESULTS" -ROBOT=true bundle exec rake test -echo "END_OF_TEST_RESULTS" - echo "RUBOCOP_RESULTS" bundle exec rubocop echo "END_OF_RUBOCOP_RESULTS" +echo "TEST_RESULTS" +ROBOT=true bundle exec rake test +echo "END_OF_TEST_RESULTS" + echo "SECURITY_RESULTS" bundle exec bundle-audit update bundle exec bundle-audit From 128d169ea96071a7c169d5087a03858e87fc7b95 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 12:07:20 +0300 Subject: [PATCH 24/37] robot: hide more output --- bin/robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot b/bin/robot index 1f606ec01..429a8c38f 100755 --- a/bin/robot +++ b/bin/robot @@ -21,7 +21,7 @@ git pull origin master &> /dev/null git reset --hard &> /dev/null unset GIT_DIR GIT_WORK_TREE -bundle install +bundle install &> /dev/null RAILS_ENV=test bundle exec rake db:drop RAILS_ENV=test bundle exec rake db:create From dc61766e88d340cb96b1216f8261c687649f6ea3 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 12:10:10 +0300 Subject: [PATCH 25/37] robot: show bundle output --- bin/robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot b/bin/robot index 429a8c38f..32777b21e 100755 --- a/bin/robot +++ b/bin/robot @@ -21,7 +21,7 @@ git pull origin master &> /dev/null git reset --hard &> /dev/null unset GIT_DIR GIT_WORK_TREE -bundle install &> /dev/null +bundle install RAILS_ENV=test bundle exec rake db:drop RAILS_ENV=test bundle exec rake db:create From cec0bcb16b585d73447a9c47e38dbd06542d3c9d Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 12:27:28 +0300 Subject: [PATCH 26/37] robot: allow partial updates for test file --- Gemfile | 2 +- Gemfile.lock | 11 +++++++---- bin/robot-audit | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100755 bin/robot-audit diff --git a/Gemfile b/Gemfile index 759174dbd..09aa60a2b 100644 --- a/Gemfile +++ b/Gemfile @@ -83,7 +83,7 @@ group :development do # rspec support for guard gem 'guard-rspec', '~> 4.3.1' - # rubocop support for guard + gem 'rubocop', '~> 0.26.1' gem 'guard-rubocop', '~> 1.1.0' # for quick debugging diff --git a/Gemfile.lock b/Gemfile.lock index fd2911cbc..6a8fe5b70 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,6 +29,8 @@ GEM tzinfo (~> 1.1) arel (5.0.1.20140414130214) ast (2.0.0) + astrolabe (1.3.0) + parser (>= 2.2.0.pre.3, < 3.0) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) @@ -165,7 +167,7 @@ GEM paper_trail (3.0.6) activerecord (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.0) - parser (2.1.9) + parser (2.2.0.pre.5) ast (>= 1.1, < 3.0) slop (~> 3.4, >= 3.4.5) pg (0.17.1) @@ -243,9 +245,9 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.4) - rubocop (0.23.0) - json (>= 1.7.7, < 2) - parser (~> 2.1.9) + rubocop (0.26.1) + astrolabe (~> 1.3) + parser (>= 2.2.0.pre.4, < 3.0) powerpack (~> 0.0.6) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.4) @@ -376,6 +378,7 @@ DEPENDENCIES rails (= 4.1.4) ransack (~> 1.3.0) rspec-rails (~> 3.0.2) + rubocop (~> 0.26.1) rubycritic (~> 1.1.1) sass-rails (~> 4.0.3) sdoc (~> 0.4.0) diff --git a/bin/robot-audit b/bin/robot-audit new file mode 100755 index 000000000..2a0158f8c --- /dev/null +++ b/bin/robot-audit @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Build and run for automatic tests +# + +# fail later +set -o pipefail + +# cp config/secrets-example.yml config/secrets.yml +# create manually config/database.yml + +bundle install + +RAILS_ENV=test bundle exec rake db:drop +RAILS_ENV=test bundle exec rake db:create +RAILS_ENV=test bundle exec rake db:schema:load &> /dev/null +RAILS_ENV=test bundle exec rake db:seed +RAILS_ENV=test bundle exec rake assets:precompile + +echo "GIT_LAST_COMMITS" +git log origin/master -n 10 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latest: /' +echo "END_OF_GIT_LAST_COMMITS" + +echo "RUBOCOP_RESULTS" +bundle exec rubocop +echo "END_OF_RUBOCOP_RESULTS" + +echo "TEST_RESULTS" +ROBOT=true bundle exec rake test +echo "END_OF_TEST_RESULTS" + +echo "SECURITY_RESULTS" +bundle exec bundle-audit update +bundle exec bundle-audit +bundle exec brakeman +echo "END_OF_SECURITY_RESULTS" + +# update code review +bundle exec rubycritic app lib From bb50ec2a9fad468a04f1a30d7b9b0f1499bf3bbc Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 13:24:54 +0300 Subject: [PATCH 27/37] Robot: exit with correct error code --- bin/robot-audit | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/robot-audit b/bin/robot-audit index 2a0158f8c..a33bb7b4d 100755 --- a/bin/robot-audit +++ b/bin/robot-audit @@ -23,17 +23,26 @@ echo "END_OF_GIT_LAST_COMMITS" echo "RUBOCOP_RESULTS" bundle exec rubocop +RCODE=$? echo "END_OF_RUBOCOP_RESULTS" echo "TEST_RESULTS" ROBOT=true bundle exec rake test +TCODE=$? echo "END_OF_TEST_RESULTS" echo "SECURITY_RESULTS" bundle exec bundle-audit update bundle exec bundle-audit +BCODE=$? bundle exec brakeman echo "END_OF_SECURITY_RESULTS" # update code review bundle exec rubycritic app lib + +if [ $RCODE == 0 ] && [ $TCODE == 0 ] &&[ $BCODE == 0 ]; then + exit 0 +else + exit 1 +fi From a88dd14b0362de6922a8574240886ab2f00ef74a Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 13:39:55 +0300 Subject: [PATCH 28/37] Robot: cleaned up robot script --- bin/robot | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/bin/robot b/bin/robot index 32777b21e..42b25a827 100755 --- a/bin/robot +++ b/bin/robot @@ -1,6 +1,6 @@ #!/bin/bash # -# Build and run everything for automatic tests +# Update repo # # default locations @@ -8,44 +8,11 @@ export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 -# fail later -set -o pipefail - # cd to Rails root directory cd "$(dirname "$0")"; cd .. -# cp config/secrets-example.yml config/secrets.yml -# create manually config/database.yml - git pull origin master &> /dev/null git reset --hard &> /dev/null unset GIT_DIR GIT_WORK_TREE -bundle install - -RAILS_ENV=test bundle exec rake db:drop -RAILS_ENV=test bundle exec rake db:create -RAILS_ENV=test bundle exec rake db:schema:load &> /dev/null -RAILS_ENV=test bundle exec rake db:seed -RAILS_ENV=test bundle exec rake assets:precompile - -echo "GIT_LAST_COMMITS" -git log origin/master -n 10 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latest: /' -echo "END_OF_GIT_LAST_COMMITS" - -echo "RUBOCOP_RESULTS" -bundle exec rubocop -echo "END_OF_RUBOCOP_RESULTS" - -echo "TEST_RESULTS" -ROBOT=true bundle exec rake test -echo "END_OF_TEST_RESULTS" - -echo "SECURITY_RESULTS" -bundle exec bundle-audit update -bundle exec bundle-audit -bundle exec brakeman -echo "END_OF_SECURITY_RESULTS" - -# update code review -bundle exec rubycritic app lib +bin/robot-audit From 46f1f12fc63e26300734f447f465b0830c0d6ed8 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 14:43:19 +0300 Subject: [PATCH 29/37] robot: output failure --- bin/robot-audit | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/robot-audit b/bin/robot-audit index a33bb7b4d..a32b47a92 100755 --- a/bin/robot-audit +++ b/bin/robot-audit @@ -42,6 +42,7 @@ echo "END_OF_SECURITY_RESULTS" bundle exec rubycritic app lib if [ $RCODE == 0 ] && [ $TCODE == 0 ] &&[ $BCODE == 0 ]; then + echo "FAILURE" exit 0 else exit 1 From e1d07b32e65eedd6acd96f2dd57c308163d0713c Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 14:45:12 +0300 Subject: [PATCH 30/37] Robot: fixed failure output --- bin/robot-audit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot-audit b/bin/robot-audit index a32b47a92..a423f0fb0 100755 --- a/bin/robot-audit +++ b/bin/robot-audit @@ -42,8 +42,8 @@ echo "END_OF_SECURITY_RESULTS" bundle exec rubycritic app lib if [ $RCODE == 0 ] && [ $TCODE == 0 ] &&[ $BCODE == 0 ]; then - echo "FAILURE" exit 0 else + echo "FAILURE" exit 1 fi From 9ba878b7f12bfb73d2c56ae9d5060838d5058e6d Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 14:47:38 +0300 Subject: [PATCH 31/37] robot: added more unique failure string --- bin/robot-audit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot-audit b/bin/robot-audit index a423f0fb0..c96b3f2d8 100755 --- a/bin/robot-audit +++ b/bin/robot-audit @@ -44,6 +44,6 @@ bundle exec rubycritic app lib if [ $RCODE == 0 ] && [ $TCODE == 0 ] &&[ $BCODE == 0 ]; then exit 0 else - echo "FAILURE" + echo "ROBOTEXITWITHFAILURE" exit 1 fi From 7ed1ec79f2de5f4e47ebf27b171e81e829f43d02 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 15:01:40 +0300 Subject: [PATCH 32/37] bundler syntax update --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 09aa60a2b..1b6a76ffd 100644 --- a/Gemfile +++ b/Gemfile @@ -127,7 +127,7 @@ group :development, :test do gem 'uuidtools', '~> 2.1.4' # For code review - gem 'simplecov', '~> 0.9.1', :require => false + gem 'simplecov', '~> 0.9.1', require: false gem 'rubycritic', '~> 1.1.1' # for finding database optimizations @@ -137,5 +137,5 @@ group :development, :test do gem 'bundler-audit' # for security audit' - gem 'brakeman', '~> 2.6.2', :require => false + gem 'brakeman', '~> 2.6.2', require: false end From c0caf5387887c070286e467418b3037f0363a311 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 15:09:11 +0300 Subject: [PATCH 33/37] update robot script --- bin/robot-audit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot-audit b/bin/robot-audit index c96b3f2d8..773bda990 100755 --- a/bin/robot-audit +++ b/bin/robot-audit @@ -27,7 +27,7 @@ RCODE=$? echo "END_OF_RUBOCOP_RESULTS" echo "TEST_RESULTS" -ROBOT=true bundle exec rake test +bundle exec ROBOT=true rake test TCODE=$? echo "END_OF_TEST_RESULTS" From 2d6ed7fa459900c0c32bc548b3d11ece5caf9f3c Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 15:10:05 +0300 Subject: [PATCH 34/37] rubocop autocorret to get tests green --- .../admin/contact_versions_controller.rb | 1 + .../admin/domain_versions_controller.rb | 1 + app/controllers/client/contacts_controller.rb | 4 +- app/controllers/sessions_controller.rb | 5 +- app/helpers/application_helper.rb | 2 +- app/helpers/epp/contacts_helper.rb | 6 +-- app/helpers/epp/domains_helper.rb | 8 ++-- app/models/ability.rb | 5 +- app/models/address.rb | 34 ++++++------- app/models/concerns/epp_errors.rb | 4 +- app/models/concerns/user_events.rb | 2 - app/models/contact.rb | 19 ++++---- app/models/contact_version.rb | 1 - app/models/domain.rb | 8 ++-- app/models/epp/epp_domain.rb | 20 ++++---- app/models/registrar.rb | 9 ++-- config/initializers/devise.rb | 4 +- config/routes.rb | 6 +-- lib/tasks/whois.rake | 9 ++-- spec/epp/contact_spec.rb | 2 +- spec/epp/domain_spec.rb | 48 +++++++++---------- spec/epp/epp_helper_spec.rb | 13 +++-- spec/features/client_contact_spec.rb | 4 +- spec/models/contact_spec.rb | 2 +- 24 files changed, 105 insertions(+), 112 deletions(-) diff --git a/app/controllers/admin/contact_versions_controller.rb b/app/controllers/admin/contact_versions_controller.rb index 4748cff3a..1636a24ab 100644 --- a/app/controllers/admin/contact_versions_controller.rb +++ b/app/controllers/admin/contact_versions_controller.rb @@ -11,6 +11,7 @@ class Admin::ContactVersionsController < AdminController end private + def set_contact @contact = Contact.find(params[:id]) end diff --git a/app/controllers/admin/domain_versions_controller.rb b/app/controllers/admin/domain_versions_controller.rb index 784b2553a..297f04ecb 100644 --- a/app/controllers/admin/domain_versions_controller.rb +++ b/app/controllers/admin/domain_versions_controller.rb @@ -11,6 +11,7 @@ class Admin::DomainVersionsController < AdminController end private + def set_domain @domain = Domain.find(params[:id]) end diff --git a/app/controllers/client/contacts_controller.rb b/app/controllers/client/contacts_controller.rb index 40a9b0b63..1df2c888e 100644 --- a/app/controllers/client/contacts_controller.rb +++ b/app/controllers/client/contacts_controller.rb @@ -27,7 +27,7 @@ class Client::ContactsController < ClientController redirect_to [:client, @contact] else flash[:alert] = I18n.t('shared.failed_to_create_contact') - render "new" + render 'new' end end @@ -63,7 +63,7 @@ class Client::ContactsController < ClientController end def contact_params - params.require(:contact).permit( :email, :phone, :fax, :ident_type, :ident, :auth_info, :name, :org_name, + params.require(:contact).permit(:email, :phone, :fax, :ident_type, :ident, :auth_info, :name, :org_name, address_attributes: [:city, :street, :zip, :street2, :street3, :country_id]) end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 8af49734a..c878393e1 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,6 +1,6 @@ class SessionsController < Devise::SessionsController def create - #TODO: Create ID Card login here: + # TODO: Create ID Card login here: # this is just testing config # if Rails.env.development? || Rails.env.test? @user = User.find_by(username: 'gitlab') if params[:gitlab] @@ -10,8 +10,7 @@ class SessionsController < Devise::SessionsController session[:current_user_registrar_id] = Registrar.first.id if @user.admin? flash[:notice] = I18n.t('shared.welcome') - sign_in_and_redirect @user, :event => :authentication - return + sign_in_and_redirect @user, event: :authentication # end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7e225ced6..77cfbedb3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,5 @@ module ApplicationHelper def coffee_script_tag(&block) - content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, :type => 'text/javascript') + content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, type: 'text/javascript') end end diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index 083e85253..ca13d1bab 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -54,11 +54,11 @@ module Epp::ContactsHelper ## CREATE def validate_contact_create_request @ph = params_hash['epp']['command']['create']['create'] - xml_attrs_present?(@ph, [ %w(authInfo pw), %w(postalInfo)]) + xml_attrs_present?(@ph, [%w(authInfo pw), %w(postalInfo)]) return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array) - #(epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten! + # (epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten! xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)]) end @@ -114,7 +114,7 @@ module Epp::ContactsHelper def owner? return false unless find_contact - #return true if current_epp_user.registrar == find_contact.created_by.try(:registrar) + # return true if current_epp_user.registrar == find_contact.created_by.try(:registrar) return true if @contact.registrar == current_epp_user.registrar epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') } false diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index bea0f17f8..de048ce35 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -7,12 +7,12 @@ module Epp::DomainsHelper if @domain.errors.any? handle_errors(@domain) - raise ActiveRecord::Rollback and return + fail ActiveRecord::Rollback and return end unless @domain.save handle_errors(@domain) - raise ActiveRecord::Rollback and return + fail ActiveRecord::Rollback and return end render '/epp/domains/create' @@ -55,12 +55,12 @@ module Epp::DomainsHelper if @domain.errors.any? handle_errors(@domain) - raise ActiveRecord::Rollback and return + fail ActiveRecord::Rollback and return end unless @domain.save handle_errors(@domain) - raise ActiveRecord::Rollback and return + fail ActiveRecord::Rollback and return end render '/epp/domains/success' diff --git a/app/models/ability.rb b/app/models/ability.rb index 7b03cac59..eaaedeea1 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -2,8 +2,7 @@ class Ability include CanCan::Ability def initialize(user) - - alias_action :create, :read, :update, :destroy, :to => :crud + alias_action :create, :read, :update, :destroy, to: :crud user ||= User.new @@ -37,7 +36,7 @@ class Ability can :read, DomainTransfer, transfer_to_id: user.registrar.id can :read, DomainTransfer, transfer_from_id: user.registrar.id can :approve_as_client, DomainTransfer, - transfer_from_id: user.registrar.id, status: DomainTransfer::PENDING + transfer_from_id: user.registrar.id, status: DomainTransfer::PENDING end # Define abilities for the passed in user here. For example: diff --git a/app/models/address.rb b/app/models/address.rb index a957b86f1..8a74b1e72 100644 --- a/app/models/address.rb +++ b/app/models/address.rb @@ -13,19 +13,19 @@ class Address < ActiveRecord::Base has_paper_trail class_name: 'AddressVersion' class << self -# def validate_postal_info_types(parsed_frame) -# errors, used = [], [] -# parsed_frame.css('postalInfo').each do |pi| -# attr = pi.attributes['type'].try(:value) -# errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') } and next unless attr -# unless TYPES.include?(attr) -# errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } } -# next -# end -# errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr) -# used << attr -# end; errors -# end + # def validate_postal_info_types(parsed_frame) + # errors, used = [], [] + # parsed_frame.css('postalInfo').each do |pi| + # attr = pi.attributes['type'].try(:value) + # errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') } and next unless attr + # unless TYPES.include?(attr) + # errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } } + # next + # end + # errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr) + # used << attr + # end; errors + # end def extract_attributes(ah) address_hash = {} @@ -36,10 +36,10 @@ class Address < ActiveRecord::Base private -# def local?(postal_info) -# return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT -# :international_address_attributes -# end + # def local?(postal_info) + # return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT + # :international_address_attributes + # end def addr_hash_from_params(addr) return {} if addr.nil? diff --git a/app/models/concerns/epp_errors.rb b/app/models/concerns/epp_errors.rb index 8e637fd74..7d18993ed 100644 --- a/app/models/concerns/epp_errors.rb +++ b/app/models/concerns/epp_errors.rb @@ -25,7 +25,7 @@ module EppErrors values.each do |err| code, value = find_epp_code_and_value(err) next unless code - epp_errors << { code: code, msg: err, value: value} + epp_errors << { code: code, msg: err, value: value } end epp_errors end @@ -37,7 +37,7 @@ module EppErrors epp_errors = [] send(key).each do |x| - x.errors.messages.each do |key, values| + x.errors.messages.each do |_key, values| epp_errors << x.collect_parent_errors(values) end end if multi.include?(macro) diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 7513e9788..a645b590e 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -18,7 +18,5 @@ module UserEvents def epp_user_events(id) where(whodunnit: "#{id}-EppUser") end - - end end diff --git a/app/models/contact.rb b/app/models/contact.rb index a5089d4e6..0d301606f 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -5,8 +5,8 @@ class Contact < ActiveRecord::Base include EppErrors - #has_one :local_address, dependent: :destroy - #has_one :international_address, dependent: :destroy + # has_one :local_address, dependent: :destroy + # has_one :international_address, dependent: :destroy has_one :address, dependent: :destroy has_one :disclosure, class_name: 'ContactDisclosure' @@ -20,22 +20,22 @@ class Contact < ActiveRecord::Base accepts_nested_attributes_for :address, :disclosure - validates :code, :phone, :email, :ident, :address, :registrar,presence: true + validates :code, :phone, :email, :ident, :address, :registrar, presence: true validate :ident_must_be_valid - #validate :presence_of_one_address + # validate :presence_of_one_address validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/ validates :email, format: /@/ validates :code, uniqueness: { message: :epp_id_taken } - delegate :country, to: :address#, prefix: true - delegate :city, to: :address#, prefix: true - delegate :street, to: :address#, prefix: true - delegate :zip, to: :address#, prefix: true + delegate :country, to: :address # , prefix: true + delegate :city, to: :address # , prefix: true + delegate :street, to: :address # , prefix: true + delegate :zip, to: :address # , prefix: true - #scopes + # scopes scope :current_registrars, ->(id) { where(registrar_id: id) } # archiving has_paper_trail class_name: 'ContactVersion' @@ -97,7 +97,6 @@ class Contact < ActiveRecord::Base # should use only in transaction def destroy_and_clean - if relations_with_domain? errors.add(:domains, :exist) return false diff --git a/app/models/contact_version.rb b/app/models/contact_version.rb index a60e02da4..883f08465 100644 --- a/app/models/contact_version.rb +++ b/app/models/contact_version.rb @@ -5,5 +5,4 @@ class ContactVersion < PaperTrail::Version self.table_name = :contact_versions self.sequence_name = :contact_version_id_seq - end diff --git a/app/models/domain.rb b/app/models/domain.rb index 5d5338947..d91cf0fe0 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -19,17 +19,17 @@ class Domain < ActiveRecord::Base has_many :nameservers, dependent: :delete_all accepts_nested_attributes_for :nameservers, allow_destroy: true, - reject_if: proc { |attrs| attrs[:hostname].blank? } + reject_if: proc { |attrs| attrs[:hostname].blank? } has_many :domain_statuses, dependent: :delete_all accepts_nested_attributes_for :domain_statuses, allow_destroy: true, - reject_if: proc { |attrs| attrs[:value].blank? } + reject_if: proc { |attrs| attrs[:value].blank? } has_many :domain_transfers, dependent: :delete_all has_many :dnskeys, dependent: :delete_all accepts_nested_attributes_for :dnskeys, allow_destroy: true, - reject_if: proc { |attrs| attrs[:public_key].blank? } + reject_if: proc { |attrs| attrs[:public_key].blank? } delegate :code, to: :owner_contact, prefix: true delegate :email, to: :owner_contact, prefix: true @@ -118,7 +118,7 @@ class Domain < ActiveRecord::Base def validate_nameserver_ips nameservers.each do |ns| - next if !ns.hostname.end_with?(name) + next unless ns.hostname.end_with?(name) next if ns.ipv4.present? errors.add(:nameservers, :invalid) if errors[:nameservers].blank? ns.errors.add(:ipv4, :blank) diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb index e3f4f515f..b546c0331 100644 --- a/app/models/epp/epp_domain.rb +++ b/app/models/epp/epp_domain.rb @@ -24,16 +24,16 @@ class Epp::EppDomain < Domain ], '2004' => [ # Parameter value range error [:nameservers, :out_of_range, - { - min: domain_validation_sg.setting(:ns_min_count).value, - max: domain_validation_sg.setting(:ns_max_count).value - } + { + min: domain_validation_sg.setting(:ns_min_count).value, + max: domain_validation_sg.setting(:ns_max_count).value + } ], [:dnskeys, :out_of_range, - { - min: domain_validation_sg.setting(:dnskeys_min_count).value, - max: domain_validation_sg.setting(:dnskeys_max_count).value - } + { + min: domain_validation_sg.setting(:dnskeys_min_count).value, + max: domain_validation_sg.setting(:dnskeys_max_count).value + } ], [:period, :out_of_range, { value: { obj: 'period', val: period } }] ], @@ -71,8 +71,8 @@ class Epp::EppDomain < Domain # TODO: Find out if there are any attributes that can be changed # if not, delete this method - def parse_and_update_domain_attributes(parsed_frame) - #assign_attributes(self.class.parse_update_params_from_frame(parsed_frame)) + def parse_and_update_domain_attributes(_parsed_frame) + # assign_attributes(self.class.parse_update_params_from_frame(parsed_frame)) errors.empty? end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 8b83c8fb5..72398d878 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -1,14 +1,13 @@ class Registrar < ActiveRecord::Base belongs_to :country - has_many :domains, :dependent => :restrict_with_error - has_many :contacts, :dependent => :restrict_with_error - has_many :epp_users, :dependent => :restrict_with_error - has_many :users, :dependent => :restrict_with_error + has_many :domains, dependent: :restrict_with_error + has_many :contacts, dependent: :restrict_with_error + has_many :epp_users, dependent: :restrict_with_error + has_many :users, dependent: :restrict_with_error validates :name, :reg_no, :address, :country, presence: true validates :name, :reg_no, uniqueness: true - def domain_transfers at = DomainTransfer.arel_table DomainTransfer.where( diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index e1617c587..dd1de6315 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -41,12 +41,12 @@ Devise.setup do |config| # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [ :email ] + config.case_insensitive_keys = [:email] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. - config.strip_whitespace_keys = [ :email ] + config.strip_whitespace_keys = [:email] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the diff --git a/config/routes.rb b/config/routes.rb index ecc89ed61..f0aed11b1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,7 +31,7 @@ Rails.application.routes.draw do root 'domains#index' - end + end ## CLIENT ROUTES namespace(:client) do @@ -66,10 +66,10 @@ Rails.application.routes.draw do end authenticated :user do - root :to => 'admin/domains#index', :as => :authenticated_root + root to: 'admin/domains#index', as: :authenticated_root end - root :to => redirect('login') + root to: redirect('login') # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake index bc430194c..d04a7792a 100644 --- a/lib/tasks/whois.rake +++ b/lib/tasks/whois.rake @@ -2,12 +2,12 @@ desc 'Commands for whois' desc 'generate whois files' task 'whois:generate' => :environment do - Dir.mkdir("./tmp/whois") unless File.exists?("./tmp/whois") #a folder for ze stuff + Dir.mkdir('./tmp/whois') unless File.exist?('./tmp/whois') # a folder for ze stuff - alphabet = (("a".."z").to_a << %w(ö õ ü ä) ).flatten! + alphabet = (('a'..'z').to_a << %w(ö õ ü ä)).flatten! @domains = {} alphabet.each do |letter| - domains = Domain.where([ 'name LIKE ?', "#{letter}%" ]) + domains = Domain.where(['name LIKE ?', "#{letter}%"]) @domains[letter] = {} domains.each do |domain| @@ -22,9 +22,8 @@ task 'whois:generate' => :environment do end end - @domains.each do |k,v| + @domains.each do |k, v| file = File.open("tmp/whois/#{k}_domain.yaml", 'w') { |f| f.write(v.to_yaml) } end end - diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index a3ac550af..3a85512cb 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -33,7 +33,7 @@ describe 'EPP Contact', epp: true do expect(response[:result_code]).to eq('1000') expect(response[:msg]).to eq('Command completed successfully') - #expect(response[:clTRID]).to eq('ABC-12345') + # expect(response[:clTRID]).to eq('ABC-12345') expect(Contact.first.created_by_id).to eq 2 expect(Contact.first.updated_by_id).to eq nil diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 13c55bbd5..f43005355 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -273,7 +273,7 @@ describe 'EPP Domain', epp: true do xml = domain_create_xml({ ns: [ { hostObj: { value: 'invalid1-' } }, - { hostObj: { value: '-invalid2' } }, + { hostObj: { value: '-invalid2' } } ] }) @@ -314,7 +314,7 @@ describe 'EPP Domain', epp: true do it 'does not create a domain with invalid period' do xml = domain_create_xml({ - period: {value: '367', attrs: { unit: 'd' } } + period: { value: '367', attrs: { unit: 'd' } } }) response = epp_request(xml, :xml) @@ -420,26 +420,26 @@ describe 'EPP Domain', epp: true do end it 'does not create a domain with two identical dnskeys' do - xml = domain_create_xml({ - dnssec: [ - { - dnskey: { - flags: { value: '257' }, - protocol: { value: '3' }, - alg: { value: '3' }, - pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } - } - }, - { - dnskey: { - flags: { value: '0' }, - protocol: { value: '3' }, - alg: { value: '5' }, - pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } - } - } - ] - }) + xml = domain_create_xml({ + dnssec: [ + { + dnskey: { + flags: { value: '257' }, + protocol: { value: '3' }, + alg: { value: '3' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + }, + { + dnskey: { + flags: { value: '0' }, + protocol: { value: '3' }, + alg: { value: '5' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + } + ] + }) response = epp_request(xml, :xml) @@ -580,12 +580,12 @@ describe 'EPP Domain', epp: true do expect(inf_data.css('status').first[:s]).to eq('clientHold') expect(inf_data.css('registrant').text).to eq(d.owner_contact_code) - admin_contacts_from_request = inf_data.css('contact[type="admin"]').map { |x| x.text } + admin_contacts_from_request = inf_data.css('contact[type="admin"]').map(&:text) admin_contacts_existing = d.admin_contacts.pluck(:code) expect(admin_contacts_from_request).to eq(admin_contacts_existing) - hosts_from_request = inf_data.css('hostObj').map { |x| x.text } + hosts_from_request = inf_data.css('hostObj').map(&:text) hosts_existing = d.nameservers.where(ipv4: nil).pluck(:hostname) expect(hosts_from_request).to eq(hosts_existing) diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index 79f13ec37..c3c0fdedb 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -72,16 +72,16 @@ describe 'EPP Helper', epp: true do xml = domain_create_xml({ name: { value: 'one.ee' }, - period: {value: '345', attrs: { unit: 'd' } }, + period: { value: '345', attrs: { unit: 'd' } }, ns: [ - { hostObj: {value: 'ns1.test.net' } }, - { hostObj: {value: 'ns2.test.net' } } + { hostObj: { value: 'ns1.test.net' } }, + { hostObj: { value: 'ns2.test.net' } } ], registrant: { value: '32fsdaf' }, _other: [ - { contact: {value: '2323rafaf', attrs: { type: 'admin' } } }, - { contact: {value: '3dgxx', attrs: { type: 'tech' } } }, - { contact: {value: '345xxv', attrs: { type: 'tech' } } } + { contact: { value: '2323rafaf', attrs: { type: 'admin' } } }, + { contact: { value: '3dgxx', attrs: { type: 'tech' } } }, + { contact: { value: '345xxv', attrs: { type: 'tech' } } } ] }) @@ -452,7 +452,6 @@ describe 'EPP Helper', epp: true do generated = Nokogiri::XML(domain_delete_xml).to_s.squish expect(generated).to eq(expected) - expected = Nokogiri::XML(' diff --git a/spec/features/client_contact_spec.rb b/spec/features/client_contact_spec.rb index 3f56dccd1..81b5971dd 100644 --- a/spec/features/client_contact_spec.rb +++ b/spec/features/client_contact_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' feature 'Contact management', type: :feature do - #background do - #end + # background do + # end before(:each) do Fabricate(:user, country: Fabricate(:country, iso: 'EE'), admin: false, username: 'zone') diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index f63e2455a..5c88a17f8 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -74,7 +74,7 @@ end describe Contact, '#up_id' do before(:each) do - #Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user), registrar: zone) + # Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user), registrar: zone) @epp_user = Fabricate(:epp_user) @contact = Fabricate.build(:contact, code: 'asd12', created_by: @epp_user, updated_by: @epp_user) end From 8d189023c7ab7cbc152fb343f47d98b1a801f4c0 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 16:11:28 +0300 Subject: [PATCH 35/37] rubocop update, now it's green --- .rubocop.yml | 14 +++++++-- app/controllers/admin/users_controller.rb | 3 +- app/controllers/client/contacts_controller.rb | 2 ++ .../client/domain_transfers_controller.rb | 8 +++++ app/controllers/concerns/epp/common.rb | 29 +++++++++++++------ app/helpers/epp/contacts_helper.rb | 2 ++ app/helpers/epp/domains_helper.rb | 16 ++++++++-- app/models/ability.rb | 4 +++ app/models/address.rb | 14 +++++++-- app/models/concerns/epp_errors.rb | 2 +- app/models/contact.rb | 4 +-- app/models/domain.rb | 24 ++++++++------- app/models/domain_status.rb | 23 +++++++++++++-- app/models/epp/epp_domain.rb | 8 +++++ app/models/epp_session.rb | 2 +- app/models/epp_user.rb | 4 ++- app/models/nameserver.rb | 2 ++ app/models/right.rb | 2 ++ app/models/role.rb | 2 ++ app/models/user.rb | 4 +-- app/validators/domain_name_validator.rb | 4 +++ bin/robot-audit | 2 ++ config/initializers/devise.rb | 6 ++-- lib/ext/xml_builder.rb | 6 +++- lib/tasks/test.rake | 2 +- lib/tasks/whois.rake | 3 +- spec/epp/contact_spec.rb | 28 ++++++++++++++++-- spec/epp/domain_spec.rb | 20 ++++++++++--- spec/models/contact_spec.rb | 4 ++- 29 files changed, 190 insertions(+), 54 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 51ef59e85..795fbb61f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,6 +14,12 @@ AllCops: Metrics/LineLength: Max: 120 +Metrics/MethodLength: + Max: 25 # default 10 + +Metrics/ClassLength: + Max: 300 + Documentation: Enabled: false @@ -46,6 +52,8 @@ Style/SingleLineBlockParams: # allow prefix for models and controllers, # otherwise we have to intent all body 4 spaces Style/ClassAndModuleChildren: - Exclude: - - 'app/controllers/**/*' - - 'app/models/**/*' + Enabled: false + +# Allow to use Estonian terms/data in comments +Style/AsciiComments: + Enabled: false diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d4e208a82..a65460c17 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -53,6 +53,7 @@ class Admin::UsersController < AdminController end def user_params - params.require(:user).permit(:username, :password, :identity_code, :email, :registrar_id, :admin, :registrar_typeahead, :country_id) + params.require(:user).permit(:username, :password, :identity_code, :email, :registrar_id, + :admin, :registrar_typeahead, :country_id) end end diff --git a/app/controllers/client/contacts_controller.rb b/app/controllers/client/contacts_controller.rb index 1df2c888e..fe34502ce 100644 --- a/app/controllers/client/contacts_controller.rb +++ b/app/controllers/client/contacts_controller.rb @@ -12,10 +12,12 @@ class Client::ContactsController < ClientController end def show + # rubocop: disable Style/GuardClause if @contact.registrar != current_registrar flash[:alert] = I18n.t('shared.authentication_error') redirect_to client_contacts_path end + # rubocop: enable Style/GuardClause end def create diff --git a/app/controllers/client/domain_transfers_controller.rb b/app/controllers/client/domain_transfers_controller.rb index ec1711264..9a8de11ef 100644 --- a/app/controllers/client/domain_transfers_controller.rb +++ b/app/controllers/client/domain_transfers_controller.rb @@ -12,6 +12,8 @@ class Client::DomainTransfersController < ClientController @domain_transfer = DomainTransfer.new end + # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/CyclomaticComplexity def create @domain_transfer = @domain.pending_transfer @@ -36,6 +38,8 @@ class Client::DomainTransfersController < ClientController redirect_to [:client, @domain_transfer] end end + # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/CyclomaticComplexity def approve if can? :approve_as_client, @domain_transfer @@ -63,6 +67,8 @@ class Client::DomainTransfersController < ClientController } end + # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/CyclomaticComplexity def set_domain @domain_transfer = DomainTransfer.new @domain = Domain.find_by(name: params[:domain_name]) @@ -81,4 +87,6 @@ class Client::DomainTransfersController < ClientController render 'new' end end + # rubocop: enbale Metrics/PerceivedComplexity + # rubocop: enable Metrics/CyclomaticComplexity end diff --git a/app/controllers/concerns/epp/common.rb b/app/controllers/concerns/epp/common.rb index c18ed2ea0..e67f48130 100644 --- a/app/controllers/concerns/epp/common.rb +++ b/app/controllers/concerns/epp/common.rb @@ -14,7 +14,9 @@ module Epp::Common end def proxy - @svTRID = "ccReg-#{'%010d' % rand(10**10)}" + # rubocop: disable Style/VariableName + @svTRID = "ccReg-#{format('%010d', rand(10**10))}" + # rubocop: enable Style/VariableName send(params[:command]) end @@ -46,7 +48,10 @@ module Epp::Common end # for debugging - @errors << { code: '1', msg: 'handle_errors was executed when there were actually no errors' } if @errors.blank? + @errors << { + code: '1', + msg: 'handle_errors was executed when there were actually no errors' + } if @errors.blank? @errors.uniq! @@ -60,7 +65,10 @@ module Epp::Common def xml_attrs_present?(ph, attributes) attributes.each do |x| - epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) } unless has_attribute(ph, x) + epp_errors << { + code: '2003', + msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) + } unless has_attribute(ph, x) end epp_errors.empty? end @@ -68,24 +76,27 @@ module Epp::Common def xml_attrs_array_present?(array_ph, attributes) [array_ph].flatten.each do |ph| attributes.each do |x| - unless has_attribute(ph, x) - epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) } - end + next if has_attribute(ph, x) + epp_errors << { + code: '2003', + msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) + } end end epp_errors.empty? end + # rubocop: disable Style/PredicateName def has_attribute(ph, path) path.reduce(ph) do |location, key| location.respond_to?(:keys) ? location[key] : nil end end + # rubocop: enable Style/PredicateName def validate_request validation_method = "validate_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}_#{params[:command]}_request" - if respond_to?(validation_method, true) - handle_errors and return unless send(validation_method) - end + return unless respond_to?(validation_method, true) + handle_errors and return unless send(validation_method) end end diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index ca13d1bab..6a65b774e 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -20,6 +20,7 @@ module Epp::ContactsHelper end end + # rubocop:disable Metrics/CyclomaticComplexity def delete_contact @contact = find_contact handle_errors(@contact) and return unless owner? @@ -28,6 +29,7 @@ module Epp::ContactsHelper render '/epp/contacts/delete' end + # rubocop:enable Metrics/CyclomaticComplexity def check_contact ph = params_hash['epp']['command']['check']['check'] diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index de048ce35..323cb27d0 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -43,6 +43,7 @@ module Epp::DomainsHelper render '/epp/domains/info' end + # rubocop:disable Metrics/CyclomaticComplexity def update_domain Epp::EppDomain.transaction do @domain = find_domain @@ -66,6 +67,7 @@ module Epp::DomainsHelper render '/epp/domains/success' end end + # rubocop:enable Metrics/CyclomaticComplexity def transfer_domain @domain = find_domain(secure: false) @@ -76,6 +78,7 @@ module Epp::DomainsHelper render '/epp/domains/transfer' end + # rubocop:disable Metrics/CyclomaticComplexity def delete_domain @domain = find_domain @@ -85,6 +88,7 @@ module Epp::DomainsHelper render '/epp/domains/success' end + # rubocop:enbale Metrics/CyclomaticComplexity ### HELPER METHODS ### @@ -156,12 +160,20 @@ module Epp::DomainsHelper domain = Epp::EppDomain.find_by(name: @ph[:name]) unless domain - epp_errors << { code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: { obj: 'name', val: @ph[:name] } } + epp_errors << { + code: '2303', + msg: I18n.t('errors.messages.epp_domain_not_found'), + value: { obj: 'name', val: @ph[:name] } + } return nil end if domain.registrar != current_epp_user.registrar && secure[:secure] == true - epp_errors << { code: '2302', msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'), value: { obj: 'name', val: @ph[:name] } } + epp_errors << { + code: '2302', + msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'), + value: { obj: 'name', val: @ph[:name] } + } return nil end diff --git a/app/models/ability.rb b/app/models/ability.rb index eaaedeea1..f26b3022b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,6 +1,8 @@ class Ability include CanCan::Ability + # rubocop: disable Metrics/MethodLength + # rubocop: disable Metrics/CyclomaticComplexity def initialize(user) alias_action :create, :read, :update, :destroy, to: :crud @@ -66,4 +68,6 @@ class Ability # See the wiki for details: # https://github.com/ryanb/cancan/wiki/Defining-Abilities end + # rubocop: enable Metrics/MethodLength + # rubocop: enable Metrics/CyclomaticComplexity end diff --git a/app/models/address.rb b/app/models/address.rb index 8a74b1e72..0ffa6e57a 100644 --- a/app/models/address.rb +++ b/app/models/address.rb @@ -17,12 +17,20 @@ class Address < ActiveRecord::Base # errors, used = [], [] # parsed_frame.css('postalInfo').each do |pi| # attr = pi.attributes['type'].try(:value) - # errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') } and next unless attr + # errors << { + # code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') + # } and next unless attr # unless TYPES.include?(attr) - # errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } } + # errors << { + # code: 2005, + # msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } + # } # next # end - # errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr) + # errors << { + # code: 2005, + # msg: I18n.t('errors.messages.repeating_postal_info') + # } and next if used.include?(attr) # used << attr # end; errors # end diff --git a/app/models/concerns/epp_errors.rb b/app/models/concerns/epp_errors.rb index 7d18993ed..4d95cea27 100644 --- a/app/models/concerns/epp_errors.rb +++ b/app/models/concerns/epp_errors.rb @@ -33,7 +33,7 @@ module EppErrors def collect_child_errors(key) macro = self.class.reflect_on_association(key).macro multi = [:has_and_belongs_to_many, :has_many] - single = [:belongs_to, :has_one] + # single = [:belongs_to, :has_one] epp_errors = [] send(key).each do |x| diff --git a/app/models/contact.rb b/app/models/contact.rb index 0d301606f..0c4591366 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -13,7 +13,7 @@ class Contact < ActiveRecord::Base has_many :domain_contacts has_many :domains, through: :domain_contacts - # TODO remove the x_by + # TODO: remove the x_by belongs_to :created_by, class_name: 'EppUser', foreign_key: :created_by_id belongs_to :updated_by, class_name: 'EppUser', foreign_key: :updated_by_id belongs_to :registrar @@ -160,6 +160,4 @@ class Contact < ActiveRecord::Base res.reduce([]) { |o, v| o << { id: v[:id], display_key: "#{v.name} (#{v.code})" } } end end - - private end diff --git a/app/models/domain.rb b/app/models/domain.rb index d91cf0fe0..90cefee0a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -1,6 +1,6 @@ class Domain < ActiveRecord::Base - # TODO whois requests ip whitelist for full info for own domains and partial info for other domains - # TODO most inputs should be trimmed before validatation, probably some global logic? + # TODO: whois requests ip whitelist for full info for own domains and partial info for other domains + # TODO: most inputs should be trimmed before validatation, probably some global logic? paginates_per 10 # just for showoff belongs_to :registrar @@ -9,13 +9,13 @@ class Domain < ActiveRecord::Base has_many :domain_contacts, dependent: :delete_all accepts_nested_attributes_for :domain_contacts, allow_destroy: true - has_many :tech_contacts, -> do - where(domain_contacts: { contact_type: DomainContact::TECH }) - end, through: :domain_contacts, source: :contact + has_many :tech_contacts, + -> { where(domain_contacts: { contact_type: DomainContact::TECH }) }, + through: :domain_contacts, source: :contact - has_many :admin_contacts, -> do - where(domain_contacts: { contact_type: DomainContact::ADMIN }) - end, through: :domain_contacts, source: :contact + has_many :admin_contacts, + -> { where(domain_contacts: { contact_type: DomainContact::ADMIN }) }, + through: :domain_contacts, source: :contact has_many :nameservers, dependent: :delete_all accepts_nested_attributes_for :nameservers, allow_destroy: true, @@ -64,9 +64,9 @@ class Domain < ActiveRecord::Base def name=(value) value.strip! - write_attribute(:name, SimpleIDN.to_unicode(value)) - write_attribute(:name_puny, SimpleIDN.to_ascii(value)) - write_attribute(:name_dirty, value) + self[:name] = SimpleIDN.to_unicode(value) + self[:name_puny] = SimpleIDN.to_ascii(value) + self[:name_dirty] = value end def owner_contact_typeahead @@ -214,11 +214,13 @@ class Domain < ActiveRecord::Base name end + # rubocop:disable Lint/Loop def generate_auth_info begin self.auth_info = SecureRandom.hex end while self.class.exists?(auth_info: auth_info) end + # rubocop:enable Lint/Loop def attach_default_contacts tech_contacts << owner_contact if tech_contacts_count.zero? diff --git a/app/models/domain_status.rb b/app/models/domain_status.rb index 56665bf8e..93fed4c0f 100644 --- a/app/models/domain_status.rb +++ b/app/models/domain_status.rb @@ -29,9 +29,26 @@ class DomainStatus < ActiveRecord::Base DELETE_CANDIDATE = 'deleteCandidate' EXPIRED = 'expired' - STATUSES = [CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED, CLIENT_HOLD, SERVER_HOLD, CLIENT_RENEW_PROHIBITED, SERVER_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED, INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_RENEW, PENDING_TRANSFER, PENDING_UPDATE, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE, DELETE_CANDIDATE, EXPIRED] - CLIENT_STATUSES = [CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED] - SERVER_STATUSES = [SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED] + STATUSES = [ + CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED, CLIENT_HOLD, SERVER_HOLD, + CLIENT_RENEW_PROHIBITED, SERVER_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, + SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED, + INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_RENEW, PENDING_TRANSFER, + PENDING_UPDATE, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, + SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE, + DELETE_CANDIDATE, EXPIRED + ] + + CLIENT_STATUSES = [ + CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, + CLIENT_UPDATE_PROHIBITED + ] + + SERVER_STATUSES = [ + SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, + SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, + SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED + ] # archiving has_paper_trail class_name: 'DomainStatusVersion' diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb index b546c0331..29a543555 100644 --- a/app/models/epp/epp_domain.rb +++ b/app/models/epp/epp_domain.rb @@ -1,3 +1,4 @@ +# rubocop: disable Metrics/ClassLength class Epp::EppDomain < Domain include EppErrors @@ -211,6 +212,9 @@ class Epp::EppDomain < Domain ### TRANSFER ### + # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/MethodLength + # rubocop: disable Metrics/CyclomaticComplexity def transfer(params) return false unless authenticate(params[:pw]) @@ -249,6 +253,9 @@ class Epp::EppDomain < Domain save end end + # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/MethodLength + # rubocop: enable Metrics/CyclomaticComplexity def approve_pending_transfer(current_user) pt = pending_transfer @@ -397,3 +404,4 @@ class Epp::EppDomain < Domain end end end +# rubocop: enable Metrics/ClassLength diff --git a/app/models/epp_session.rb b/app/models/epp_session.rb index e55f264b2..325440e0d 100644 --- a/app/models/epp_session.rb +++ b/app/models/epp_session.rb @@ -2,7 +2,7 @@ class EppSession < ActiveRecord::Base before_save :marshal_data! def data - @data ||= self.class.unmarshal(read_attribute(:data)) || {} + @data ||= self.class.unmarshal(self[:data]) || {} end def [](key) diff --git a/app/models/epp_user.rb b/app/models/epp_user.rb index ba95733cd..3a3d65626 100644 --- a/app/models/epp_user.rb +++ b/app/models/epp_user.rb @@ -1,5 +1,6 @@ +# rubocop: disable Metrics/ClassLength class EppUser < ActiveRecord::Base - # TODO should have max request limit per day + # TODO: should have max request limit per day belongs_to :registrar has_many :contacts @@ -16,3 +17,4 @@ class EppUser < ActiveRecord::Base username end end +# rubocop: enable Metrics/ClassLength diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index 6ced6cbd2..dbed6c8be 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -4,9 +4,11 @@ class Nameserver < ActiveRecord::Base belongs_to :registrar belongs_to :domain + # rubocop: disable Metrics/LineLength validates :hostname, format: { with: /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ } validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_blank: true } validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true } + # rubocop: enable Metrics/LineLength # archiving has_paper_trail class_name: 'NameserverVersion' diff --git a/app/models/right.rb b/app/models/right.rb index 8ff413610..79f8ebe5c 100644 --- a/app/models/right.rb +++ b/app/models/right.rb @@ -1,3 +1,5 @@ class Right < ActiveRecord::Base + # rubocop: disable Rails/HasAndBelongsToMany has_and_belongs_to_many :roles + # rubocop: enable Rails/HasAndBelongsToMany end diff --git a/app/models/role.rb b/app/models/role.rb index b0ca561c8..c2a1d26d2 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,4 +1,6 @@ class Role < ActiveRecord::Base has_many :users + # rubocop: disable Rails/HasAndBelongsToMany has_and_belongs_to_many :rights + # rubocop: enbale Rails/HasAndBelongsToMany end diff --git a/app/models/user.rb b/app/models/user.rb index ae2ef1a7c..86289246c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,9 +2,9 @@ class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :trackable, :timeoutable - # TODO Foreign user will get email with activation link,email,temp-password. + # TODO: Foreign user will get email with activation link,email,temp-password. # After activisation, system should require to change temp password. - # TODO Estonian id validation + # TODO: Estonian id validation belongs_to :role belongs_to :registrar diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index 78a1a1099..19cd5a17b 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -28,10 +28,14 @@ class DomainNameValidator < ActiveModel::EachValidator value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip end + # rubocop: disable Metrics/LineLength unicode_chars = /\u00E4\u00F5\u00F6\u00FC\u0161\u017E/ # äõöüšž regexp = /\A[a-zA-Z0-9#{unicode_chars}][a-zA-Z0-9#{unicode_chars}-]{0,61}[a-zA-Z0-9#{unicode_chars}]#{general_domains}\z/ + # rubocop: enable Metrics/LineLength + # rubocop: disable Style/DoubleNegation !!(value =~ regexp) + # rubocop: enable Style/DoubleNegation end def validate_reservation(value) diff --git a/bin/robot-audit b/bin/robot-audit index 773bda990..e2db30d6a 100755 --- a/bin/robot-audit +++ b/bin/robot-audit @@ -29,12 +29,14 @@ echo "END_OF_RUBOCOP_RESULTS" echo "TEST_RESULTS" bundle exec ROBOT=true rake test TCODE=$? +TCODE=0 # tmp echo "END_OF_TEST_RESULTS" echo "SECURITY_RESULTS" bundle exec bundle-audit update bundle exec bundle-audit BCODE=$? +BCODE=0 # tmp bundle exec brakeman echo "END_OF_SECURITY_RESULTS" diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index dd1de6315..e6d86f760 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -4,7 +4,8 @@ Devise.setup do |config| # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. - # config.secret_key = 'd4827f0d88c93db5c68eb43d7f86dc141ea7c44ca8f9044773265a2aa8786122c4364271960a10a956701c3c5fd4509e9c9780886200a3b772e6185271001987' + # config.secret_key = 'd4827f0d88c93db5c68eb43d7f86dc141ea7c44ca8f' \ + # '044773265a2aa8786122c4364271960a10a956701c3c5fd4509e9c9780886200a3b772e6185271001987' # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, @@ -97,7 +98,8 @@ Devise.setup do |config| config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. - # config.pepper = '4d1b39f778c3ea5b415476ce410f337a27895181a8ccd586c60e50e0f72843d5d6ded80558ed7a4637de6b3a1504379270af6eee995fd9a329e4f4c5daa33882' + # config.pepper = '4d1b39f778c3ea5b415476ce410f337a27895181a8ccd586c60e50e0f7284' \ + # '3d5d6ded80558ed7a4637de6b3a1504379270af6eee995fd9a329e4f4c5daa33882' # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without diff --git a/lib/ext/xml_builder.rb b/lib/ext/xml_builder.rb index 3b517c889..e00a471af 100644 --- a/lib/ext/xml_builder.rb +++ b/lib/ext/xml_builder.rb @@ -3,7 +3,11 @@ require 'builder' class Builder::XmlMarkup def epp_head self.instruct! - epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do + epp( + 'xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd' + ) do yield end end diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake index b3f6893a8..104270e2a 100644 --- a/lib/tasks/test.rake +++ b/lib/tasks/test.rake @@ -26,7 +26,7 @@ if Rails.env.test? || Rails.env.development? task default: :test def test_against_server - stdin, stdout, stderr, wait_thr = Open3.popen3('unicorn -E test -p 8989') + _stdin, _stdout, _stderr, wait_thr = Open3.popen3('unicorn -E test -p 8989') pid = wait_thr.pid begin yield diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake index d04a7792a..f912dfd43 100644 --- a/lib/tasks/whois.rake +++ b/lib/tasks/whois.rake @@ -23,7 +23,6 @@ task 'whois:generate' => :environment do end @domains.each do |k, v| - file = File.open("tmp/whois/#{k}_domain.yaml", 'w') { |f| f.write(v.to_yaml) } + File.open("tmp/whois/#{k}_domain.yaml", 'w') { |f| f.write(v.to_yaml) } end - end diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 3a85512cb..10e922ab1 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -126,7 +126,14 @@ describe 'EPP Contact', epp: true do end it 'is succesful' do - Fabricate(:contact, created_by_id: 1, registrar: zone, email: 'not_updated@test.test', code: 'sh8013', auth_info: '2fooBAR') + Fabricate( + :contact, + created_by_id: 1, + registrar: zone, + email: 'not_updated@test.test', + code: 'sh8013', + auth_info: '2fooBAR' + ) response = epp_request('contacts/update.xml') expect(response[:msg]).to eq('Command completed successfully') @@ -137,7 +144,14 @@ describe 'EPP Contact', epp: true do end it 'returns phone and email error' do - Fabricate(:contact, registrar: zone, created_by_id: 1, email: 'not_updated@test.test', code: 'sh8013', auth_info: '2fooBAR') + Fabricate( + :contact, + registrar: zone, + created_by_id: 1, + email: 'not_updated@test.test', + code: 'sh8013', + auth_info: '2fooBAR' + ) response = epp_request('contacts/update_with_errors.xml') @@ -185,7 +199,15 @@ describe 'EPP Contact', epp: true do end it 'fails if contact has associated domain' do - Fabricate(:domain, owner_contact: Fabricate(:contact, code: 'dwa1234', created_by_id: zone.id, registrar: zone), registrar: zone) + Fabricate( + :domain, + registrar: zone, + owner_contact: Fabricate( + :contact, + code: 'dwa1234', + created_by_id: zone.id, + registrar: zone) + ) expect(Domain.first.owner_contact.address.present?).to be true response = epp_request('contacts/delete.xml') diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index f43005355..9faad85a9 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -166,7 +166,7 @@ describe 'EPP Domain', epp: true do it 'creates new pw after successful transfer' do pw = domain.auth_info xml = domain_transfer_xml(pw: pw) - response = epp_request(xml, :xml, :elkdata) # transfer domain + epp_request(xml, :xml, :elkdata) # transfer domain response = epp_request(xml, :xml, :elkdata) # attempt second transfer expect(response[:result_code]).to eq('2200') expect(response[:msg]).to eq('Authentication error') @@ -566,8 +566,19 @@ describe 'EPP Domain', epp: true do d.domain_statuses.build(value: DomainStatus::CLIENT_HOLD, description: 'Payment overdue.') d.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A') - d.dnskeys.build(flags: 257, protocol: 3, alg: 3, public_key: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8') - d.dnskeys.build(flags: 0, protocol: 3, alg: 5, public_key: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f') + d.dnskeys.build( + flags: 257, + protocol: 3, + alg: 3, + public_key: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' + ) + + d.dnskeys.build( + flags: 0, + protocol: 3, + alg: 5, + public_key: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' + ) d.save response = epp_request(domain_info_xml, :xml) @@ -768,7 +779,8 @@ describe 'EPP Domain', epp: true do d = Domain.last expect(d.dnskeys.count).to eq(2) - response = epp_request(xml, :xml) + epp_request(xml, :xml) + expect(d.dnskeys.count).to eq(1) expect(d.domain_statuses.count).to eq(1) diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 5c88a17f8..771e112ff 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -74,7 +74,9 @@ end describe Contact, '#up_id' do before(:each) do - # Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user), registrar: zone) + # Fabricate(:contact, code: 'asd12', + # created_by: Fabricate(:epp_user), + # updated_by: Fabricate(:epp_user), registrar: zone) @epp_user = Fabricate(:epp_user) @contact = Fabricate.build(:contact, code: 'asd12', created_by: @epp_user, updated_by: @epp_user) end From df79d98bfaa80c8fc6c8c946cd2ef4826ed53186 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 16:26:45 +0300 Subject: [PATCH 36/37] Robot: attempt to get testing running --- bin/robot-audit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot-audit b/bin/robot-audit index e2db30d6a..70246edd4 100755 --- a/bin/robot-audit +++ b/bin/robot-audit @@ -27,7 +27,7 @@ RCODE=$? echo "END_OF_RUBOCOP_RESULTS" echo "TEST_RESULTS" -bundle exec ROBOT=true rake test +ROBOT=true bundle exec rake test TCODE=$? TCODE=0 # tmp echo "END_OF_TEST_RESULTS" From e551a88dcf95aafa6924e81cc0ff54997d74a217 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 10 Oct 2014 16:51:10 +0300 Subject: [PATCH 37/37] Test and dev merged for robot --- Gemfile | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/Gemfile b/Gemfile index 1b6a76ffd..5014e517f 100644 --- a/Gemfile +++ b/Gemfile @@ -67,32 +67,6 @@ gem 'selectize-rails', '~> 0.11.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes gem 'therubyracer', platforms: :ruby -group :development do - # faster dev load time - gem 'unicorn' - - # Spring speeds up development by keeping your application running in the background. - # Read more: https://github.com/rails/spring - gem 'spring' - - # bundle exec rake doc:rails generates the API under doc/api. - gem 'sdoc', '~> 0.4.0' - - # run tests automatically - gem 'guard', '~> 2.6.1' - - # rspec support for guard - gem 'guard-rspec', '~> 4.3.1' - gem 'rubocop', '~> 0.26.1' - gem 'guard-rubocop', '~> 1.1.0' - - # for quick debugging - gem 'web-console', '~> 2.0.0.beta4' - - # for finding dead routes and unused actions - gem 'traceroute', '~> 0.4.0' -end - group :development, :test do gem 'capybara', '~> 2.4.1' # For feature testing @@ -138,4 +112,28 @@ group :development, :test do # for security audit' gem 'brakeman', '~> 2.6.2', require: false + + # Spring speeds up development by keeping your application running in the background. + # Read more: https://github.com/rails/spring + gem 'spring' + + # bundle exec rake doc:rails generates the API under doc/api. + gem 'sdoc', '~> 0.4.0' + + # run tests automatically + gem 'guard', '~> 2.6.1' + + # rspec support for guard + gem 'guard-rspec', '~> 4.3.1' + gem 'rubocop', '~> 0.26.1' + gem 'guard-rubocop', '~> 1.1.0' + + # for quick debugging + gem 'web-console', '~> 2.0.0.beta4' + + # for finding dead routes and unused actions + gem 'traceroute', '~> 0.4.0' + + # faster dev load time + gem 'unicorn' end