fixed codeclimate errors (partically)

This commit is contained in:
dinsmol 2021-09-09 09:19:09 +03:00
parent 3f41ce4ab4
commit f4e0084895
103 changed files with 339 additions and 367 deletions

View file

@ -1,7 +1,9 @@
version: "2"
prepare:
fetch:
- "https://raw.githubusercontent.com/internetee/style-guide/master/ruby/.rubocop.yml"
- "https://raw.githubusercontent.com/internetee/style-guide/adding-new-rules/.rubocop-ruby.yml"
- url: "https://raw.githubusercontent.com/internetee/style-guide/adding-new-rules/.rubocop-rails.yml"
path: ".rubocop.yml"
plugins:
brakeman:
enabled: true

22
Gemfile
View file

@ -5,8 +5,8 @@ gem 'active_interaction', '~> 4.0'
gem 'apipie-rails', '~> 0.5.19'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'iso8601', '0.13.0' # for dates and times
gem 'mime-types-data'
gem 'mimemagic', '0.4.3'
gem 'mime-types-data'
gem 'puma'
gem 'rails', '~> 6.1.4'
gem 'rest-client'
@ -29,22 +29,22 @@ gem 'nokogiri', '~> 1.12.4'
# style
gem 'bootstrap-sass', '~> 3.4'
gem 'cancancan'
gem 'coderay', '1.1.3' # xml console visualize
gem 'coffee-rails', '>= 5.0'
gem 'devise', '~> 4.8'
gem 'jquery-rails'
gem 'selectize-rails', '0.12.6' # include selectize.js for select
gem 'kaminari'
gem 'sass-rails'
gem 'select2-rails', '4.0.13' # for autocomplete
gem 'cancancan'
gem 'devise', '~> 4.8'
gem 'selectize-rails', '0.12.6' # include selectize.js for select
# registry specfic
gem 'data_migrate', '~> 7.0'
gem 'dnsruby', '~> 1.61'
gem 'isikukood' # for EE-id validation
gem 'simpleidn', '0.2.1' # For punycode
gem 'money-rails'
gem 'simpleidn', '0.2.1' # For punycode
gem 'whenever', '1.0.0', require: false
# country listing
@ -62,22 +62,22 @@ gem 'omniauth-rails_csrf_protection'
gem 'omniauth-tara', github: 'internetee/omniauth-tara'
gem 'airbrake'
gem 'daemons-rails', '1.2.1'
gem 'epp', github: 'internetee/epp', branch: :master
gem 'epp-xml', '1.2.0', github: 'internetee/epp-xml', branch: :master
gem 'jquery-ui-rails', '6.0.1'
gem 'pdfkit'
gem 'que'
gem 'daemons-rails', '1.2.1'
gem 'que-web'
gem 'sidekiq'
gem 'pdfkit'
gem 'jquery-ui-rails', '6.0.1'
gem 'airbrake'
gem 'company_register', github: 'internetee/company_register',
branch: 'master'
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
gem 'lhv', github: 'internetee/lhv', branch: 'master'
gem 'domain_name'
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
gem 'haml', '~> 5.2'
gem 'lhv', github: 'internetee/lhv', branch: 'master'
gem 'rexml'
gem 'wkhtmltopdf-binary', '~> 0.12.5.1'

View file

@ -63,7 +63,12 @@ module Admin
def admin_user_params
params.require(:admin_user).permit(:username,
:password, :password_confirmation, :identity_code, :email, :country_code, { roles: [] })
:password,
:password_confirmation,
:identity_code,
:email,
:country_code,
{ roles: [] })
end
end
end

View file

@ -61,8 +61,8 @@ module Admin
end
def bank_statement_params
params.require(:bank_statement).permit(:bank_code, :iban, bank_transactions_attributes: [
:description, :sum, :currency, :reference_no, :paid_at
params.require(:bank_statement).permit(:bank_code, :iban, bank_transactions_attributes: %i[
description sum currency reference_no paid_at
])
end
end

View file

@ -43,7 +43,6 @@ module Admin
end
end
def blocked_domain_params
params.require(:blocked_domain).permit(:name)
end

View file

@ -11,19 +11,20 @@ module Admin
@versions = @q.result.page(params[:page])
search_params = params[:q].deep_dup
whereS = "1=1"
where_s = "1=1"
search_params.each do |key, value|
next if value.empty?
case key
where_s += case key
when 'event'
whereS += " AND event = '#{value}'"
" AND event = '#{value}'"
else
whereS += create_where_string(key, value)
create_where_string(key, value)
end
end
versions = Version::ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
versions = Version::ContactVersion.includes(:item).where(where_s).order(created_at: :desc, id: :desc)
@q = versions.search(params[:q])
@versions = @q.result.page(params[:page])
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?

View file

@ -9,7 +9,8 @@ module Admin
params[:q] ||= {}
search_params = params[:q].deep_dup
if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant')
if search_params[:domain_contacts_type_in].is_a?(Array) &&
search_params[:domain_contacts_type_in].delete('registrant')
search_params[:registrant_domains_id_not_null] = 1
end

View file

@ -21,26 +21,31 @@ module Admin
search_params.delete(:registrar)
end
whereS = "1=1"
where_s = "1=1"
search_params.each do |key, value|
next if value.empty?
case key
where_s += case key
when 'event'
whereS += " AND event = '#{value}'"
" AND event = '#{value}'"
when 'name'
whereS += " AND (object->>'name' ~* '#{value}' OR object_changes->>'name' ~* '#{value}')"
" AND (object->>'name' ~* '#{value}' OR object_changes->>'name' ~* '#{value}')"
else
whereS += create_where_string(key, value)
create_where_string(key, value)
end
end
whereS += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrants.present?
whereS += " AND 1=0" if registrants == []
whereS += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrars.present?
whereS += " AND 1=0" if registrars == []
if registrants.present?
where_s += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id}'" }.join ','})"
end
where_s += " AND 1=0" if registrants == []
if registrars.present?
where_s += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id}'" }.join ','})"
end
where_s += " AND 1=0" if registrars == []
versions = Version::DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
versions = Version::DomainVersion.includes(:item).where(where_s).order(created_at: :desc, id: :desc)
@q = versions.search(params[:q])
@versions = @q.result.page(params[:page])
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?

View file

@ -5,20 +5,19 @@ module Admin
def index
params[:q] ||= {}
if params[:statuses_contains]
domains = Domain.includes(:registrar, :registrant).where(
domains = if params[:statuses_contains]
Domain.includes(:registrar, :registrant).where(
"domains.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
)
else
domains = Domain.includes(:registrar, :registrant)
Domain.includes(:registrar, :registrant)
end
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
if @domains.count == 1 && params[:q][:name_matches].present?
redirect_to [:admin, @domains.first] and return
elsif @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
(redirect_to [:admin, @domains.first] and return if @domains.count == 1 && params[:q][:name_matches].present?)
if @domains.count.zero? && params[:q][:name_matches] !~ /^%.+%$/
# if we do not get any results, add wildcards to the name field and search again
n_cache = params[:q][:name_matches]
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
@ -51,7 +50,7 @@ module Admin
redirect_to [:admin, @domain]
else
build_associations
flash.now[:alert] = I18n.t('failed_to_update_domain') + ' ' + @domain.errors.full_messages.join(", ")
flash.now[:alert] = "#{I18n.t('failed_to_update_domain')} #{@domain.errors.full_messages.join(', ')}"
render 'edit'
end
end

View file

@ -8,8 +8,14 @@ module Admin
@q.sorts = 'id desc' if @q.sorts.empty?
@epp_logs = @q.result
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
@epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
if params[:q][:created_at_gteq].present?
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
Time.parse(params[:q][:created_at_gteq]))
end
if params[:q][:created_at_lteq].present?
@epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)",
Time.parse(params[:q][:created_at_lteq]))
end
@epp_logs = @epp_logs.page(params[:page])
render_by_format('admin/epp_logs/index', 'epp_logs')

View file

@ -8,8 +8,14 @@ module Admin
@q.sorts = 'id desc' if @q.sorts.empty?
@repp_logs = @q.result
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
if params[:q][:created_at_gteq].present?
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
Time.parse(params[:q][:created_at_gteq]))
end
if params[:q][:created_at_lteq].present?
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)",
Time.parse(params[:q][:created_at_lteq]))
end
@repp_logs = @repp_logs.page(params[:page])
@count = @q.result.count
@repp_logs = @repp_logs.per(params[:results_per_page]) if paginate?

View file

@ -45,8 +45,7 @@ module Api
def create_token(user)
token_creator = AuthTokenCreator.create_with_defaults(user)
hash = token_creator.token_in_hash
hash
token_creator.token_in_hash
end
def check_ip_whitelist

View file

@ -103,9 +103,10 @@ module Api
end
def verify_action
action = if params[:template] == 'change'
action = case params[:template]
when 'change'
@domain.registrant_update_confirmable?(verify_params[:token])
elsif params[:template] == 'delete'
when 'delete'
@domain.registrant_delete_confirmable?(verify_params[:token])
end

View file

@ -77,9 +77,7 @@ module Api
render json: { errors: [{ address: [error_msg] }] }, status: :bad_request and return
end
if ENV['fax_enabled'] == 'true'
contact.fax = params[:fax] if params[:fax].present?
end
contact.fax = params[:fax] if ENV['fax_enabled'] == 'true' && params[:fax].present?
logger.debug "ENV['fax_enabled'] is set to #{ENV['fax_enabled']}"
if ENV['fax_enabled'] != 'true' && params[:fax]

View file

@ -303,7 +303,10 @@ module Epp
if request_command == 'login' && frame.present?
frame.gsub!(/pw>.+<\//, 'pw>[FILTERED]</')
end
trimmed_request = frame.gsub(/<eis:legalDocument([^>]+)>([^<])+<\/eis:legalDocument>/, "<eis:legalDocument>[FILTERED]</eis:legalDocument>") if frame.present?
if frame.present?
trimmed_request = frame.gsub(/<eis:legalDocument([^>]+)>([^<])+<\/eis:legalDocument>/,
"<eis:legalDocument>[FILTERED]</eis:legalDocument>")
end
ApiLog::EppLog.create({
request: trimmed_request,
@ -312,7 +315,8 @@ module Epp
request_object: resource ? "#{params[:epp_object_type]}: #{resource.class} - #{resource.id} - #{resource.name}" : params[:epp_object_type],
response: @response,
api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public',
api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_user.try(:registrar).try(:to_s),
api_user_registrar: @api_user.try(:registrar).try(:to_s) ||
current_user.try(:registrar).try(:to_s),
ip: request.ip,
uuid: request.uuid
})

View file

@ -155,8 +155,8 @@ module Epp
end
def validate_update
if element_count('update > chg > registrant') > 0
requires 'extension > extdata > legalDocument' if current_user.legaldoc_mandatory?
if element_count('update > chg > registrant').positive? && current_user.legaldoc_mandatory?
requires 'extension > extdata > legalDocument'
end
@prefix = 'update > update >'

View file

@ -51,6 +51,7 @@ module Epp
end
handle_errors(@notification) and return unless @notification.mark_as_read
render_epp_response 'epp/poll/poll_ack'
end

View file

@ -29,23 +29,19 @@ module Epp
end
end
if !Rails.env.development? && (!webclient_request && @api_user)
unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
request.env['HTTP_SSL_CLIENT_S_DN_CN'])
if !Rails.env.development? && (!webclient_request && @api_user) &&
!@api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
msg = 'Authentication error; server closing connection (certificate is not valid)'
epp_errors.add(:epp_errors,
msg: msg,
code: '2501')
msg: msg,code: '2501')
success = false
end
end
if success && !@api_user
msg = 'Authentication error; server closing connection (API user not found)'
epp_errors.add(:epp_errors,
msg: msg,
code: '2501')
msg: msg, code: '2501')
success = false
end
@ -53,8 +49,7 @@ module Epp
if success && !@api_user.try(:active)
msg = 'Authentication error; server closing connection (API user is not active)'
epp_errors.add(:epp_errors,
msg: msg,
code: '2501')
msg: msg, code: '2501')
success = false
end
@ -62,8 +57,7 @@ module Epp
if success && @api_user.cannot?(:create, :epp_login)
msg = 'Authentication error; server closing connection (API user does not have epp role)'
epp_errors.add(:epp_errors,
msg: msg,
code: '2501')
msg: msg, code: '2501')
success = false
end
@ -71,8 +65,7 @@ module Epp
if success && !ip_white?
msg = 'Authentication error; server closing connection (IP is not whitelisted)'
epp_errors.add(:epp_errors,
msg: msg,
code: '2501')
msg: msg, code: '2501')
success = false
end
@ -80,8 +73,7 @@ module Epp
if success && EppSession.limit_reached?(@api_user.registrar)
msg = 'Session limit exceeded; server closing connection (connection limit reached)'
epp_errors.add(:epp_errors,
msg: msg,
code: '2502')
msg: msg, code: '2502')
success = false
end
@ -99,8 +91,7 @@ module Epp
if already_authenticated
epp_errors.add(:epp_errors,
msg: 'Command use error; Already authenticated',
code: 2002)
msg: 'Command use error; Already authenticated', code: 2002)
handle_errors
return
end
@ -118,8 +109,8 @@ module Epp
def ip_white?
webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip)
return true if webclient_request
if @api_user
return false unless @api_user.registrar.api_ip_white?(request.ip)
if @api_user && !@api_user.registrar.api_ip_white?(request.ip)
return false
end
true
end
@ -127,8 +118,7 @@ module Epp
def logout
unless signed_in?
epp_errors.add(:epp_errors,
code: 2201,
msg: 'Authorization error')
code: 2201, msg: 'Authorization error')
handle_errors
return
end

View file

@ -89,7 +89,7 @@ class Registrar
end
def domain_ids_for_bulk_renew
params.dig('domain_ids')&.reject { |id| id.blank? }
params['domain_ids']&.reject { |id| id.blank? }
end
def renew_task(domains)

View file

@ -13,7 +13,8 @@ class Registrar
search_params = params[:q].deep_dup
if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant')
if search_params[:domain_contacts_type_in].is_a?(Array) &&
search_params[:domain_contacts_type_in].delete('registrant')
search_params[:registrant_domains_id_not_null] = 1
end

View file

@ -16,9 +16,7 @@ class Registrar
end
def destroy
@data = depp_current_user.request(@ex.poll(poll: {
value: '', attrs: { op: 'ack', msgID: params[:id] }
}))
@data = depp_current_user.request(@ex.poll(poll: { value: '', attrs: { op: 'ack', msgID: params[:id] } }))
@results = @data.css('result')

View file

@ -30,12 +30,10 @@ class Registrar
show_error and return
end
if @depp_user.pki
unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
if @depp_user.pki && !@api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
request.env['HTTP_SSL_CLIENT_S_DN_CN'], api: false)
@depp_user.errors.add(:base, :invalid_cert)
end
end
if @depp_user.errors.none?
if @api_user.active?

View file

@ -22,7 +22,7 @@ class Registrar
def load_xml
cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}"
xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests'
xml_dir_path = "#{Rails.root}/app/views/registrar/xml_consoles/epp_requests"
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml = prepare_payload(xml, cl_trid)
@ -54,7 +54,7 @@ class Registrar
end
def insert_prefix_and_version(xml, pref, version)
xml.gsub!('"' + pref.to_s + '"',
xml.gsub!("\"#{pref.to_s}\"",
"\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
xml
end

View file

@ -89,13 +89,11 @@ module Repp
return contacts.pluck(:code) unless details
contacts = contacts.map do |contact|
contacts.map do |contact|
serializer = ::Serializers::Repp::Contact.new(contact,
show_address: Contact.address_processing?)
serializer.to_json
end
contacts
end
def opt_addr?

View file

@ -53,7 +53,7 @@ module Repp
end
def nameserver_params
params.permit(:domain_id, nameservers: [[:hostname, :action, ipv4: [], ipv6: []]])
params.permit(:domain_id, nameservers: [[:hostname, :action, { ipv4: [], ipv6: [] }]])
end
end
end

View file

@ -223,7 +223,7 @@ module Repp
params.require(:domain).permit(:name, :registrant, :period, :period_unit, :registrar,
:transfer_code, :reserved_pw,
dnskeys_attributes: [%i[flags alg protocol public_key]],
nameservers_attributes: [[:hostname, ipv4: [], ipv6: []]],
nameservers_attributes: [[:hostname, { ipv4: [], ipv6: [] }]],
admin_contacts: [], tech_contacts: [])
end
end

View file

@ -6,7 +6,7 @@ module ApplicationHelper
def env_style
return '' if unstable_env.nil?
"background-image: url(#{image_path(unstable_env.to_s + '.png')});"
"background-image: url(#{image_path("#{unstable_env.to_s}.png")});"
end
def ident_for(contact)

View file

@ -1,10 +1,6 @@
module Actions
class ContactDelete
attr_reader :contact
attr_reader :new_attributes
attr_reader :legal_document
attr_reader :ident
attr_reader :user
attr_reader :contact, :new_attributes, :legal_document, :ident, :user
def initialize(contact, legal_document = nil)
@legal_document = legal_document

View file

@ -1,10 +1,6 @@
module Actions
class ContactUpdate
attr_reader :contact
attr_reader :new_attributes
attr_reader :legal_document
attr_reader :ident
attr_reader :user
attr_reader :contact, :new_attributes, :legal_document, :ident, :user
def initialize(contact, new_attributes, legal_document, ident, user)
@contact = contact

View file

@ -6,14 +6,14 @@ module Actions
end
def call
response = if Rails.env.test?
if Rails.env.test?
do_test_request(@request, @uri)
elsif Rails.env.development?
do_dev_request(@request, @uri)
else
do_live_request(@request, @uri)
end
response
rescue StandardError, OpenURI::HTTPError => e
Rails.logger.debug e.message
end

View file

@ -1,8 +1,6 @@
module Actions
class DomainDelete
attr_reader :domain
attr_reader :params
attr_reader :user
attr_reader :domain, :params, :user
def initialize(domain, params, user)
@domain = domain

View file

@ -1,8 +1,6 @@
module Actions
class DomainRenew
attr_reader :domain
attr_reader :params
attr_reader :user
attr_reader :domain, :params, :user
def initialize(domain, params, user)
@domain = domain

View file

@ -1,10 +1,6 @@
module Actions
class DomainTransfer
attr_reader :domain
attr_reader :transfer_code
attr_reader :legal_document
attr_reader :ident
attr_reader :user
attr_reader :domain, :transfer_code, :legal_document, :ident, :user
def initialize(domain, transfer_code, user)
@domain = domain

View file

@ -70,7 +70,8 @@ module Domains
max_reg_time = 11.years.from_now
if renewed_expire_time >= max_reg_time
domain.add_epp_error('2105', nil, nil, I18n.t('epp.domains.object_is_not_eligible_for_renewal',
domain.add_epp_error('2105', nil, nil,
I18n.t('epp.domains.object_is_not_eligible_for_renewal',
max_date: max_reg_time.to_date.to_s(:db)))
end
renewed_expire_time

View file

@ -3,7 +3,7 @@ module Domains
class Base < ActiveInteraction::Base
def to_stdout(message)
time = Time.zone.now.utc
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
$stdout << "#{time} - #{message}\n" unless Rails.env.test?
end
end
end

View file

@ -3,7 +3,7 @@ module Domains
class Base < ActiveInteraction::Base
def to_stdout(message)
time = Time.zone.now.utc
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
$stdout << "#{time} - #{message}\n" unless Rails.env.test?
end
def logger

View file

@ -3,7 +3,7 @@ module Domains
class Base < ActiveInteraction::Base
def to_stdout(message)
time = Time.zone.now.utc
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
$stdout << "#{time} - #{message}\n" unless Rails.env.test?
end
end
end

View file

@ -9,6 +9,7 @@ module Domains
count = 0
expired_pending_domains.each do |domain|
log_error(domain) && next unless need_to_be_cleared?(domain)
count += 1
Domains::ExpiredPendings::ProcessClean.run(domain: domain)
end

View file

@ -37,7 +37,7 @@ module Domains
def added_additional_email_into_notes(domain)
return if domain.status_notes[DomainStatus::FORCE_DELETE].include? email
domain.status_notes[DomainStatus::FORCE_DELETE].concat(' ' + email)
domain.status_notes[DomainStatus::FORCE_DELETE].concat(" #{email}")
domain.save(validate: false)
end

View file

@ -3,7 +3,7 @@ module Domains
class Base < ActiveInteraction::Base
def to_stdout(message)
time = Time.zone.now.utc
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
$stdout << "#{time} - #{message}\n" unless Rails.env.test?
end
end
end

View file

@ -5,7 +5,7 @@ class CsyncJob < ApplicationJob
@store = {}
@input_store = { secure: {}, insecure: {} }
@results = {}
@logger = Rails.env.test? ? Rails.logger : Logger.new(STDOUT)
@logger = Rails.env.test? ? Rails.logger : Logger.new($stdout)
generate ? generate_scanner_input : process_scanner_results
@logger.info 'CsyncJob: Finished.'
@ -121,7 +121,7 @@ class CsyncJob < ApplicationJob
end
out_file.close
@logger.info 'CsyncJob Generate: Finished writing output to ' + ENV['cdns_scanner_input_file']
@logger.info "CsyncJob Generate: Finished writing output to #{ENV['cdns_scanner_input_file']}"
end
def check_directory

View file

@ -1,5 +1,5 @@
class DisputeStatusUpdateJob < ApplicationJob
def perform(logger: Logger.new(STDOUT))
def perform(logger: Logger.new($stdout))
@logger = logger
@backlog = { 'activated': 0, 'closed': 0, 'activate_fail': [], 'close_fail': [] }

View file

@ -13,7 +13,8 @@ class RegistrantChangeConfirmEmailJob < ApplicationJob
private
def log(domain)
message = "Send RegistrantChangeMailer#confirm email for domain #{domain.name} (##{domain.id}) to #{domain.registrant.email}"
message = 'Send RegistrantChangeMailer#confirm email for domain '\
"#{domain.name} (##{domain.id}) to #{domain.registrant.email}"
logger.info(message)
end

View file

@ -12,7 +12,8 @@ class RegistrantChangeNoticeEmailJob < ApplicationJob
private
def log(domain, new_registrant)
message = "Send RegistrantChangeMailer#notice email for domain #{domain.name} (##{domain.id}) to #{new_registrant.email}"
message = 'Send RegistrantChangeMailer#notice email for domain '\
"#{domain.name} (##{domain.id}) to #{new_registrant.email}"
logger.info(message)
end

View file

@ -1,6 +1,6 @@
class ToStdout
def self.msg(message)
time = Time.zone.now.utc
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
$stdout << "#{time} - #{message}\n" unless Rails.env.test?
end
end

View file

@ -39,4 +39,3 @@ class AccountActivity < ApplicationRecord
end
end
end

View file

@ -1,10 +1,6 @@
module Actions
class ContactDelete
attr_reader :contact
attr_reader :new_attributes
attr_reader :legal_document
attr_reader :ident
attr_reader :user
attr_reader :contact, :new_attributes, :legal_document, :ident, :user
def initialize(contact, legal_document = nil)
@legal_document = legal_document

View file

@ -1,10 +1,6 @@
module Actions
class ContactUpdate
attr_reader :contact
attr_reader :new_attributes
attr_reader :legal_document
attr_reader :ident
attr_reader :user
attr_reader :contact, :new_attributes, :legal_document, :ident, :user
def initialize(contact, new_attributes, legal_document, ident, user)
@contact = contact

View file

@ -1,10 +1,6 @@
module Actions
class DomainTransfer
attr_reader :domain
attr_reader :transfer_code
attr_reader :legal_document
attr_reader :ident
attr_reader :user
attr_reader :domain, :transfer_code, :legal_document, :ident, :user
def initialize(domain, transfer_code, user)
@domain = domain

View file

@ -2,8 +2,7 @@ module BalanceAutoReloadTypes
class Threshold
include ActiveModel::Model
attr_accessor :amount
attr_accessor :threshold
attr_accessor :amount, :threshold
validates :amount, numericality: { greater_than_or_equal_to: :min_amount }
validates :threshold, numericality: { greater_than_or_equal_to: 0 }

View file

@ -9,7 +9,8 @@ module Billing
validates :price, :valid_from, :operation_category, :duration, presence: true
validates :operation_category, inclusion: { in: Proc.new { |price| price.class.operation_categories } }
validates :duration, inclusion: { in: Proc.new { |price| price.class.durations.values } }, if: :should_validate_duration?
validates :duration, inclusion: { in: Proc.new { |price| price.class.durations.values } },
if: :should_validate_duration?
alias_attribute :effect_time, :valid_from
alias_attribute :expire_time, :valid_to

View file

@ -83,7 +83,8 @@ class Certificate < ApplicationRecord
csr_file.rewind
crt_file = Tempfile.new('client_crt')
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} -keyfile #{ENV['ca_key_path']} \
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} \
-keyfile #{ENV['ca_key_path']} \
-cert #{ENV['ca_cert_path']} \
-extensions usr_cert -notext -md sha256 \
-in #{csr_file.path} -out #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
@ -112,7 +113,8 @@ class Certificate < ApplicationRecord
crt_file.write(crt)
crt_file.rewind
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} -keyfile #{ENV['ca_key_path']} \
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} \
-keyfile #{ENV['ca_key_path']} \
-cert #{ENV['ca_cert_path']} \
-revoke #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
@ -134,7 +136,7 @@ class Certificate < ApplicationRecord
class << self
def tostdout(message)
time = Time.zone.now.utc
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
$stdout << "#{time} - #{message}\n" unless Rails.env.test?
end
def update_crl

View file

@ -47,7 +47,7 @@ module Contact::Archivable
end
def log(msg)
@log ||= Logger.new(STDOUT)
@log ||= Logger.new($stdout)
@log.info(msg)
end

View file

@ -68,13 +68,10 @@ module Registrar::BookKeeping
def finalize_invoice_line(line, price:, activity:, duration:)
yearly = price.duration.in_years.to_i >= 1
line['price'] = yearly ? (price.price.amount / price.duration.in_years.to_i) : price.price.amount
line['description'] = description_in_language(price: price, yearly: yearly)
if duration.present?
add_product_timeframe(line: line, activity: activity, duration: duration) if duration > 1
end
add_product_timeframe(line: line, activity: activity, duration: duration) if duration.present? && (duration > 1)
line
end

View file

@ -164,7 +164,9 @@ class Contact < ApplicationRecord
scope = all
# all contacts has state ok, so no need to filter by it
scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}") if states.delete(OK)
if states.delete(OK)
scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}")
end
scope = scope.linked if states.delete(LINKED)
scope = scope.where("contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any?
scope
@ -385,7 +387,6 @@ class Contact < ApplicationRecord
self.email = email.to_s.strip
end
# what we can do load firstly by registrant
# if total is smaller than needed, the load more
# we also need to sort by valid_to

View file

@ -1,10 +1,6 @@
class Contact
class Address
attr_reader :street
attr_reader :zip
attr_reader :city
attr_reader :state
attr_reader :country_code
attr_reader :street, :zip, :city, :state, :country_code
def initialize(street, zip, city, state, country_code)
@street = street

View file

@ -1,9 +1,7 @@
class Contact::Ident
include ActiveModel::Model
attr_accessor :code
attr_accessor :type
attr_accessor :country_code
attr_accessor :code, :type, :country_code
validates :code, presence: true
validates :code, national_id: true, if: :national_id?

View file

@ -122,7 +122,7 @@ class CsyncRecord < ApplicationRecord
end
def self.log
Rails.env.test? ? logger : Logger.new(STDOUT)
Rails.env.test? ? logger : Logger.new($stdout)
end
def validate_csync_action

View file

@ -116,10 +116,11 @@ module Depp
xml.with_indifferent_access
end
def extract_disclosure_hash(cpd) # cpd = contact_params[:disclose]
# cpd = contact_params[:disclose]
def extract_disclosure_hash(cpd)
return {} unless cpd
cpd = cpd.delete_if { |k, v| v if v != '1' && k == 'flag' }
cpd
cpd.delete_if { |k, v| v if v != '1' && k == 'flag' }
end
def extract_info_disclosure(data)
@ -240,7 +241,7 @@ module Depp
ident = ident_xml[:_anonymus].try(:first)
when :update
# detect if any ident has changed, nb! ident and self.ident is not always same
if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code)
unless ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code
ident = ident_xml[:_anonymus].try(:first)
end
end

View file

@ -109,11 +109,9 @@ module Depp
period = params[:period].to_i.to_s
period_unit = params[:period][-1].to_s
current_user.request(epp_xml.renew(
name: { value: params[:domain_name] },
current_user.request(epp_xml.renew(name: { value: params[:domain_name] },
curExpDate: { value: params[:cur_exp_date] },
period: { value: period, attrs: { unit: period_unit } }
))
period: { value: period, attrs: { unit: period_unit } }))
end
def transfer(params)

View file

@ -11,7 +11,7 @@ module Depp
validate :validate_existance_in_server
def initialize(args = {})
args.each { |k, v| send(k.to_s + '=', v) }
args.each { |k, v| send("#{k.to_s}=", v) }
end
def server

View file

@ -20,7 +20,7 @@ module DNS
def self.generate_zonefile(origin)
filename = "#{origin}.zone"
STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
$stdout << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
zf = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{origin}')"
@ -28,7 +28,7 @@ module DNS
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
$stdout << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
end
def self.origins

View file

@ -24,7 +24,8 @@ class Dnskey < ApplicationRecord
end
}
ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze # IANA numbers, single authority list
# IANA numbers, single authority list
ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze
PROTOCOLS = %w(3)
FLAGS = %w(0 256 257) # 256 = ZSK, 257 = KSK
DS_DIGEST_TYPE = [1,2]
@ -81,7 +82,9 @@ class Dnskey < ApplicationRecord
def generate_digest
return unless flags == 257 || flags == 256 # require ZoneFlag, but optional SecureEntryPoint
self.ds_alg = alg
self.ds_digest_type = Setting.ds_digest_type if self.ds_digest_type.blank? || !DS_DIGEST_TYPE.include?(ds_digest_type)
if self.ds_digest_type.blank? || !DS_DIGEST_TYPE.include?(ds_digest_type)
self.ds_digest_type = Setting.ds_digest_type
end
flags_hex = self.class.int_to_hex(flags)
protocol_hex = self.class.int_to_hex(protocol)
@ -90,9 +93,10 @@ class Dnskey < ApplicationRecord
hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join
bin = self.class.hex_to_bin(hex)
if self.ds_digest_type == 1
case self.ds_digest_type
when 1
self.ds_digest = Digest::SHA1.hexdigest(bin).upcase
elsif self.ds_digest_type == 2
when 2
self.ds_digest = Digest::SHA256.hexdigest(bin).upcase
end
end

View file

@ -13,9 +13,14 @@ class Domain < ApplicationRecord
include Domain::Disputable
include Domain::BulkUpdatable
attr_accessor :roles
attr_accessor :legal_document_id
attr_accessor :roles,
:legal_document_id,
:is_admin,
:registrant_typeahead,
:update_me,
:epp_pending_update,
:epp_pending_delete,
:reserved_pw
alias_attribute :on_hold_time, :outzone_at
alias_attribute :outzone_time, :outzone_at
@ -27,16 +32,18 @@ class Domain < ApplicationRecord
:admin_store_statuses_history
# 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: most inputs should be trimmed before validation, probably some global logic?
belongs_to :registrar, required: true
belongs_to :registrant, required: true
# TODO: should we user validates_associated :registrant here?
has_many :admin_domain_contacts
accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: true, reject_if: :admin_change_prohibited?
accepts_nested_attributes_for :admin_domain_contacts,
allow_destroy: true, reject_if: :admin_change_prohibited?
has_many :tech_domain_contacts
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true, reject_if: :tech_change_prohibited?
accepts_nested_attributes_for :tech_domain_contacts,
allow_destroy: true, reject_if: :tech_change_prohibited?
def registrant_change_prohibited?
statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED
@ -122,8 +129,6 @@ class Domain < ApplicationRecord
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
end
attr_accessor :is_admin
# Removed to comply new ForceDelete procedure
# at https://github.com/internetee/registry/issues/1428#issuecomment-570561967
#
@ -204,12 +209,10 @@ class Domain < ApplicationRecord
def statuses_uniqueness
return if statuses.uniq == statuses
errors.add(:statuses, :taken)
end
attr_accessor :registrant_typeahead, :update_me,
:epp_pending_update, :epp_pending_delete, :reserved_pw
self.ignored_columns = %w[legacy_id legacy_registrar_id legacy_registrant_id]
def subordinate_nameservers
@ -423,9 +426,11 @@ class Domain < ApplicationRecord
def pending_update!
return true if pending_update?
self.epp_pending_update = true # for epp
return true unless registrant_verification_asked?
pending_json_cache = pending_json
token = registrant_verification_token
asked_at = registrant_verification_asked_at
@ -582,7 +587,6 @@ class Domain < ApplicationRecord
# special handling for admin changing status
def admin_status_update(update)
update_unless_locked_by_registrant(update)
update_not_by_locked_statuses(update)
# check for deleted status
statuses.each do |s|

View file

@ -80,9 +80,10 @@ class DomainStatus < ApplicationRecord
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_DELETE_CONFIRMATION, PENDING_RENEW, PENDING_TRANSFER,
PENDING_UPDATE, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED,
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE,
INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_DELETE_CONFIRMATION,
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, DISPUTED, SERVER_RELEASE_PROHIBITED
].freeze
@ -106,7 +107,7 @@ class DomainStatus < ApplicationRecord
DomainStatus::PENDING_DELETE,
DomainStatus::PENDING_RENEW,
DomainStatus::PENDING_TRANSFER
]
].freeze
DELETE_PROHIBIT_STATES = [
DomainStatus::CLIENT_DELETE_PROHIBITED,
@ -148,7 +149,6 @@ class DomainStatus < ApplicationRecord
admin_statuses_map.map(&:second)
end
def admin_statuses_map
[
['Hold', SERVER_HOLD],

View file

@ -15,7 +15,8 @@ class Epp::Domain < Domain
return true if is_transfer || is_renewal
return unless update_prohibited?
stat = (statuses & (DomainStatus::UPDATE_PROHIBIT_STATES + DomainStatus::DELETE_PROHIBIT_STATES)).first
stat = (statuses &
(DomainStatus::UPDATE_PROHIBIT_STATES + DomainStatus::DELETE_PROHIBIT_STATES)).first
add_epp_error('2304', 'status', stat, I18n.t(:object_status_prohibits_operation))
throw(:abort)
end
@ -307,10 +308,12 @@ class Epp::Domain < Domain
begin
return if cur_exp_date.to_date == valid_to.to_date
rescue
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
add_epp_error('2306', 'curExpDate', cur_exp_date,
I18n.t('errors.messages.epp_exp_dates_do_not_match'))
return
end
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
add_epp_error('2306', 'curExpDate', cur_exp_date,
I18n.t('errors.messages.epp_exp_dates_do_not_match'))
end
### ABILITIES ###
@ -325,7 +328,8 @@ class Epp::Domain < Domain
begin
errors.add(:base, :domain_status_prohibits_operation)
return false
end if (statuses & [DomainStatus::CLIENT_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED]).any?
end if (statuses &
[DomainStatus::CLIENT_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED]).any?
true
end

View file

@ -14,7 +14,7 @@ class InactiveContacts
end
def log(msg)
@log ||= Logger.new(STDOUT)
@log ||= Logger.new($stdout)
@log.info(msg)
end
end

View file

@ -12,22 +12,22 @@ class Invoice < ApplicationRecord
has_many :payment_orders
accepts_nested_attributes_for :items
scope :all_columns, ->{select("invoices.*")}
scope :sort_due_date_column, ->{all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN
# rubocop:disable Layout/LineLength
scope :all_columns, -> { select("invoices.*") }
scope :sort_due_date_column, -> { all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN
(invoices.cancelled_at + interval '100 year') ELSE
invoices.due_date END AS sort_due_date")}
scope :sort_by_sort_due_date_asc, ->{sort_due_date_column.order("sort_due_date ASC")}
scope :sort_by_sort_due_date_desc, ->{sort_due_date_column.order("sort_due_date DESC")}
scope :sort_receipt_date_column, ->{all_columns.includes(:account_activity).references(:account_activity).select(%Q{
scope :sort_by_sort_due_date_asc, -> { sort_due_date_column.order("sort_due_date ASC") }
scope :sort_by_sort_due_date_desc, -> { sort_due_date_column.order("sort_due_date DESC") }
scope :sort_receipt_date_column, -> { all_columns.includes(:account_activity).references(:account_activity).select(%Q{
CASE WHEN account_activities.created_at is not null THEN account_activities.created_at
WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year'
ELSE NULL END AS sort_receipt_date })}
scope :sort_by_sort_receipt_date_asc, ->{sort_receipt_date_column.order("sort_receipt_date ASC")}
scope :sort_by_sort_receipt_date_desc, ->{sort_receipt_date_column.order("sort_receipt_date DESC")}
scope :sort_by_sort_receipt_date_asc, -> { sort_receipt_date_column.order("sort_receipt_date ASC") }
scope :sort_by_sort_receipt_date_desc, -> { sort_receipt_date_column.order("sort_receipt_date DESC") }
scope :overdue, -> { unpaid.non_cancelled.where('due_date < ?', Time.zone.today) }
# rubocop:enable Layout/LineLength
validates :due_date, :currency, :seller_name,
:seller_iban, :buyer_name, :items, presence: true

View file

@ -1,7 +1,6 @@
class Invoice
class EInvoiceGenerator
attr_reader :invoice
attr_reader :payable
attr_reader :invoice, :payable
def initialize(invoice, payable)
@invoice = invoice

View file

@ -1,7 +1,6 @@
class Invoice
class VatRateCalculator
attr_reader :registry
attr_reader :registrar
attr_reader :registry, :registrar
def initialize(registry: Registry.current, registrar:)
@registry = registry

View file

@ -65,7 +65,6 @@ class LegalDocument < ApplicationRecord
true
end
def self.remove_duplicates
start = Time.zone.now.to_f
Rails.logger.info '-----> Removing legal documents duplicates'
@ -84,7 +83,8 @@ class LegalDocument < ApplicationRecord
File.delete(new_legal.path) if File.exist?(new_legal.path)
new_legal.update(path: orig_legal.path)
count += 1
Rails.logger.info "File #{new_legal.path} has been removed by Domain #{new_legal.documentable_id}. Document id: #{new_legal.id}"
Rails.logger.info "File #{new_legal.path} has been removed by Domain "\
"#{new_legal.documentable_id}. Document id: #{new_legal.id}"
end
end
@ -107,7 +107,8 @@ class LegalDocument < ApplicationRecord
File.delete(new_legal.path) if File.exist?(new_legal.path)
new_legal.update(path: orig_legal.path)
count += 1
Rails.logger.info "File #{new_legal.path} has been removed by Contact #{new_legal.documentable_id}. Document id: #{new_legal.id}"
Rails.logger.info "File #{new_legal.path} has been removed by Contact "\
"#{new_legal.documentable_id}. Document id: #{new_legal.id}"
end
end
end

View file

@ -39,7 +39,7 @@ class Nameserver < ApplicationRecord
def epp_code_map
{
'2302' => [
[:hostname, :taken, { value: { obj: 'hostAttr', val: {'hostName': hostname} } }]
[:hostname, :taken, { value: { obj: 'hostAttr', val: { 'hostName': hostname } } }]
],
'2005' => [
[:hostname, :invalid, { value: { obj: 'hostAttr', val: hostname } }],
@ -63,11 +63,10 @@ class Nameserver < ApplicationRecord
end
class << self
def from_hash_params params
def from_hash_params(params)
params = params.with_indifferent_access
rel = all
rel = rel.where(hostname: params[:hostname])
rel
rel.where(hostname: params[:hostname])
end
def hostnames

View file

@ -23,7 +23,7 @@ class PaymentOrder < ApplicationRecord
supported = []
PAYMENT_METHODS.each do |method|
class_name = ('PaymentOrders::' + method.camelize).constantize
class_name = "PaymentOrders::#{method.camelize}".constantize
raise(NoMethodError, class_name) unless class_name < PaymentOrder
supported << class_name
@ -33,7 +33,7 @@ class PaymentOrder < ApplicationRecord
end
def self.new_with_type(type:, invoice:)
channel = ('PaymentOrders::' + type.camelize).constantize
channel = "PaymentOrders::#{type.camelize}".constantize
PaymentOrder.new(type: channel, invoice: invoice)
end
@ -55,7 +55,7 @@ class PaymentOrder < ApplicationRecord
def self.supported_method?(name, shortname: false)
some_class = if shortname
('PaymentOrders::' + name.camelize).constantize
"PaymentOrders::#{name.camelize}".constantize
else
name.constantize
end

View file

@ -104,9 +104,8 @@ module PaymentOrders
def sign(data)
private_key = OpenSSL::PKey::RSA.new(File.read(seller_certificate))
signed_data = private_key.sign(OpenSSL::Digest::SHA1.new, data)
signed_data = Base64.encode64(signed_data).gsub(/\n|\r/, '')
signed_data
signed_data = private_key.sign(OpenSSL::Digest.new('SHA1'), data)
Base64.encode64(signed_data).gsub(/\n|\r/, '')
end
def calc_mac(fields)
@ -122,7 +121,7 @@ module PaymentOrders
def verify_mac(data, mac)
bank_public_key = OpenSSL::X509::Certificate.new(File.read(bank_certificate)).public_key
bank_public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(mac), data)
bank_public_key.verify(OpenSSL::Digest.new('SHA1'), Base64.decode64(mac), data)
end
def prepend_size(value)

View file

@ -1,8 +1,7 @@
class Registry
include ActiveModel::Model
attr_accessor :vat_rate
attr_accessor :vat_country
attr_accessor :vat_rate, :vat_country
def self.current
vat_rate = Setting.registry_vat_prc.to_d * 100

View file

@ -75,7 +75,7 @@ class WhoisRecord < ApplicationRecord
h[:nameservers] = domain.nameservers.hostnames.uniq.select(&:present?)
h[:nameservers_changed] = domain.nameservers.pluck(:updated_at).max.try(:to_s, :iso8601)
h[:dnssec_keys] = domain.dnskeys.map{|key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
h[:dnssec_keys] = domain.dnskeys.map { |key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
h[:dnssec_changed] = domain.dnskeys.pluck(:updated_at).max.try(:to_s, :iso8601) rescue nil

View file

@ -103,6 +103,5 @@ class DomainPresenter
class: 'dropdown-item'
end
attr_reader :domain
attr_reader :view
attr_reader :domain, :view
end

View file

@ -37,6 +37,5 @@ class RegistrantPresenter
private
attr_reader :registrant
attr_reader :view
attr_reader :registrant, :view
end

View file

@ -42,6 +42,5 @@ class Registrar::DomainListCsvPresenter
CSV::Row.new([], row)
end
attr_reader :domains
attr_reader :view
attr_reader :domains, :view
end

View file

@ -26,6 +26,5 @@ class RegistrarPresenter
private
attr_reader :registrar
attr_reader :view
attr_reader :registrar, :view
end

View file

@ -14,6 +14,5 @@ class UserPresenter
user.roles.first
end
attr_reader :user
attr_reader :view
attr_reader :user, :view
end

View file

@ -1,6 +1,5 @@
class OverdueInvoiceCanceller
attr_reader :invoices
attr_reader :delay
attr_reader :invoices, :delay
def initialize(invoices: Invoice.overdue, delay: self.class.delay)
@invoices = invoices

View file

@ -15,6 +15,5 @@ class RegistrantChange
RegistrantChangeMailer.accepted(domain: domain, old_registrant: old_registrant).deliver_now
end
attr_reader :domain
attr_reader :old_registrant
attr_reader :domain, :old_registrant
end

View file

@ -65,9 +65,9 @@ xml.epp_head do
xml.tag!('contact:crDate', @contact.created_at.try(:iso8601))
if @contact.updated_at > @contact.created_at
upID = @contact.updator.try(:registrar)
upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar?
xml.tag!('contact:upID', upID) if upID.present? # optional upID
up_id = @contact.updator.try(:registrar)
up_id = up_id.code if up_id.present? # Did updator return a kind of User that has a registrar?
xml.tag!('contact:upID', up_id) if up_id.present? # optional upID
xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601))
end
if can? :view_password, @contact, @password

View file

@ -7,7 +7,7 @@ xml.epp_head do
xml.result('code' => x[:code]) do
xml.msg(x[:msg], 'lang' => 'en')
model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize
prefix = model_name == 'poll' ? 'changePoll' : model_name + '-ee'
prefix = model_name == 'poll' ? 'changePoll' : "#{model_name}-ee"
xml.value("xmlns:#{model_name}" => Xsd::Schema.filename(for_prefix: prefix)) do
value = x[:value][:val]

View file

@ -9,10 +9,10 @@ xml.epp_head do
xml.msg @notification.text
end
if @notification.attached_obj_type == 'DomainTransfer'
if @notification.attached_obj_type == 'DomainTransfer' && @object
xml.resData do
xml << render('epp/domains/partials/transfer', builder: xml, dt: @object)
end if @object
end
end
if @notification.action&.contact || @notification.registry_lock?

View file

@ -1,9 +1,7 @@
class AuthTokenCreator
DEFAULT_VALIDITY = 2.hours
attr_reader :user
attr_reader :key
attr_reader :expires_at
attr_reader :user, :key, :expires_at
def self.create_with_defaults(user)
new(user, Rails.application.config.secret_key_base, Time.now + DEFAULT_VALIDITY)
@ -24,7 +22,7 @@ class AuthTokenCreator
end
def encrypted_token
encryptor = OpenSSL::Cipher::AES.new(256, :CBC)
encryptor = OpenSSL::Cipher.new('aes-256-cbc')
encryptor.encrypt
# OpenSSL used to automatically shrink oversized keys, it does not do that any longer.

View file

@ -1,8 +1,5 @@
class AuthTokenDecryptor
attr_reader :decrypted_data
attr_reader :token
attr_reader :key
attr_reader :user
attr_reader :decrypted_data, :token, :key, :user
def self.create_with_defaults(token)
new(token, Rails.application.config.secret_key_base)
@ -14,7 +11,7 @@ class AuthTokenDecryptor
end
def decrypt_token
decipher = OpenSSL::Cipher::AES.new(256, :CBC)
decipher = OpenSSL::Cipher.new('aes-256-cbc')
decipher.decrypt
# OpenSSL used to automatically shrink oversized keys, it does not do that any longer.

View file

@ -5,8 +5,7 @@ require 'deserializers/xml/dnssec'
module Deserializers
module Xml
class DomainCreate
attr_reader :frame
attr_reader :registrar
attr_reader :frame, :registrar
def initialize(frame, registrar)
@frame = frame

View file

@ -81,13 +81,12 @@ module Serializers
end
def contacts(type)
contact_pool = begin
if type == :tech
contact_pool = case type
when :tech
domain.tech_contacts
elsif type == :admin
when :admin
domain.admin_contacts
end
end
array_of_contacts = []
contact_pool.map do |contact|

View file

@ -26,7 +26,7 @@ namespace :contacts do
end
def log(msg)
@log ||= Logger.new(STDOUT)
@log ||= Logger.new($stdout)
@log.info(msg)
end
end

View file

@ -26,7 +26,7 @@ namespace :dev do
http.ca_file = ENV['lhv_ca_file']
http.start do
response = http.post(api_base_uri.path + '/payment', request_body, request_headers)
response = http.post("#{api_base_uri.path}/payment", request_body, request_headers)
if response.is_a?(Net::HTTPSuccess)
puts 'Success'

View file

@ -41,7 +41,7 @@ namespace :invoices do
end
def log(msg)
@log ||= Logger.new(STDOUT)
@log ||= Logger.new($stdout)
@log.info(msg)
end

View file

@ -1,8 +1,6 @@
class Iso8601Validator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if options[:date_only]
record.errors.add(attribute, :invalid_iso8601_date) unless value =~ date_format
end
record.errors.add(attribute, :invalid_iso8601_date) if options[:date_only] && value !~ date_format
end
private