Skip to content

Commit

Permalink
Support call destination redirect based on LNP response (#1078)
Browse files Browse the repository at this point in the history
* Support call destination redirect based on LNP response
* Minor rails upgrade to 6.1.4.4 - fix CVE-2021-44528
  • Loading branch information
dmitry-sinina authored Dec 20, 2021
1 parent b982b3c commit 85ac320
Show file tree
Hide file tree
Showing 22 changed files with 5,695 additions and 133 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ swagger/yeti.json
vendor/bundle
vendor/bundler
db/schema_cache.yml
db/cdr_schema_cache.yml
.byebug_history
config/database.yml
config/pkgr.yml
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem 'pg'
gem 'pg_advisory_lock', git: 'https://github.com/didww/pg_advisory_lock.git'
gem 'pg_sql_caller', git: 'https://github.com/didww/pg_sql_caller.git'
gem 'rack', '2.1.4' # https://github.com/rack/rack/issues/1628
gem 'rails', '~> 6.1.4.1'
gem 'rails', '~> 6.1.4.4'
gem 'responders'

# Authentication
Expand Down
130 changes: 65 additions & 65 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,40 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.4.1)
actionpack (= 6.1.4.1)
activesupport (= 6.1.4.1)
actioncable (6.1.4.4)
actionpack (= 6.1.4.4)
activesupport (= 6.1.4.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.4.1)
actionpack (= 6.1.4.1)
activejob (= 6.1.4.1)
activerecord (= 6.1.4.1)
activestorage (= 6.1.4.1)
activesupport (= 6.1.4.1)
actionmailbox (6.1.4.4)
actionpack (= 6.1.4.4)
activejob (= 6.1.4.4)
activerecord (= 6.1.4.4)
activestorage (= 6.1.4.4)
activesupport (= 6.1.4.4)
mail (>= 2.7.1)
actionmailer (6.1.4.1)
actionpack (= 6.1.4.1)
actionview (= 6.1.4.1)
activejob (= 6.1.4.1)
activesupport (= 6.1.4.1)
actionmailer (6.1.4.4)
actionpack (= 6.1.4.4)
actionview (= 6.1.4.4)
activejob (= 6.1.4.4)
activesupport (= 6.1.4.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.4.1)
actionview (= 6.1.4.1)
activesupport (= 6.1.4.1)
actionpack (6.1.4.4)
actionview (= 6.1.4.4)
activesupport (= 6.1.4.4)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.4.1)
actionpack (= 6.1.4.1)
activerecord (= 6.1.4.1)
activestorage (= 6.1.4.1)
activesupport (= 6.1.4.1)
actiontext (6.1.4.4)
actionpack (= 6.1.4.4)
activerecord (= 6.1.4.4)
activestorage (= 6.1.4.4)
activesupport (= 6.1.4.4)
nokogiri (>= 1.8.5)
actionview (6.1.4.1)
activesupport (= 6.1.4.1)
actionview (6.1.4.4)
activesupport (= 6.1.4.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand Down Expand Up @@ -159,34 +159,34 @@ GEM
kaminari (~> 1.0, >= 1.2.1)
railties (>= 5.2, < 6.2)
ransack (~> 2.1, >= 2.1.1)
activejob (6.1.4.1)
activesupport (= 6.1.4.1)
activejob (6.1.4.4)
activesupport (= 6.1.4.4)
globalid (>= 0.3.6)
activeldap (5.1.1)
activemodel (> 4.0.0)
builder
gettext
gettext_i18n_rails
locale
activemodel (6.1.4.1)
activesupport (= 6.1.4.1)
activemodel (6.1.4.4)
activesupport (= 6.1.4.4)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (6.1.4.1)
activemodel (= 6.1.4.1)
activesupport (= 6.1.4.1)
activerecord (6.1.4.4)
activemodel (= 6.1.4.4)
activesupport (= 6.1.4.4)
activerecord-import (1.0.4)
activerecord (>= 3.2)
activestorage (6.1.4.1)
actionpack (= 6.1.4.1)
activejob (= 6.1.4.1)
activerecord (= 6.1.4.1)
activesupport (= 6.1.4.1)
activestorage (6.1.4.4)
actionpack (= 6.1.4.4)
activejob (= 6.1.4.4)
activerecord (= 6.1.4.4)
activesupport (= 6.1.4.4)
marcel (~> 1.0.0)
mini_mime (>= 1.1.0)
activesupport (6.1.4.1)
activesupport (6.1.4.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -308,13 +308,13 @@ GEM
text (>= 1.3.0)
gettext_i18n_rails (1.8.0)
fast_gettext (>= 0.9.0)
globalid (0.5.2)
globalid (1.0.0)
activesupport (>= 5.0)
has_scope (0.8.0)
actionpack (>= 5.2)
activesupport (>= 5.2)
hashdiff (0.3.8)
i18n (1.8.10)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
inherited_resources (1.13.0)
actionpack (>= 5.2, < 6.2)
Expand Down Expand Up @@ -355,16 +355,16 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
locale (2.1.2)
loofah (2.12.0)
loofah (2.13.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.1)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
minitest (5.14.4)
minitest (5.15.0)
msgpack (1.4.2)
multipart-post (2.1.1)
mustache (1.0.5)
Expand Down Expand Up @@ -396,33 +396,33 @@ GEM
pundit (1.1.0)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.5.2)
racc (1.6.0)
rack (2.1.4)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.4.1)
actioncable (= 6.1.4.1)
actionmailbox (= 6.1.4.1)
actionmailer (= 6.1.4.1)
actionpack (= 6.1.4.1)
actiontext (= 6.1.4.1)
actionview (= 6.1.4.1)
activejob (= 6.1.4.1)
activemodel (= 6.1.4.1)
activerecord (= 6.1.4.1)
activestorage (= 6.1.4.1)
activesupport (= 6.1.4.1)
rails (6.1.4.4)
actioncable (= 6.1.4.4)
actionmailbox (= 6.1.4.4)
actionmailer (= 6.1.4.4)
actionpack (= 6.1.4.4)
actiontext (= 6.1.4.4)
actionview (= 6.1.4.4)
activejob (= 6.1.4.4)
activemodel (= 6.1.4.4)
activerecord (= 6.1.4.4)
activestorage (= 6.1.4.4)
activesupport (= 6.1.4.4)
bundler (>= 1.15.0)
railties (= 6.1.4.1)
railties (= 6.1.4.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (6.1.4.1)
actionpack (= 6.1.4.1)
activesupport (= 6.1.4.1)
railties (6.1.4.4)
actionpack (= 6.1.4.4)
activesupport (= 6.1.4.4)
method_source
rake (>= 0.13)
thor (~> 1.0)
Expand Down Expand Up @@ -533,9 +533,9 @@ GEM
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
syslog-logger (1.6.8)
text (1.3.1)
Expand Down Expand Up @@ -576,7 +576,7 @@ GEM
rails (>= 3.2.16)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.2)
zeitwerk (2.5.1)
zip-zip (0.3)
rubyzip (>= 1.0.0)

Expand Down Expand Up @@ -641,7 +641,7 @@ DEPENDENCIES
puma_worker_killer
pundit
rack (= 2.1.4)
rails (~> 6.1.4.1)
rails (~> 6.1.4.4)
rails-html-sanitizer (~> 1.0)
ransack
responders
Expand Down
9 changes: 7 additions & 2 deletions app/admin/equipment/lnp_databases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
actions
column :name
column :type, :database_type_name, sortable: :database_type
column :cache_ttl
column :created_at
end

Expand Down Expand Up @@ -78,6 +79,7 @@
attributes_table do
row :id
row :name
row :cache_ttl
row :created_at
end
end
Expand All @@ -93,6 +95,7 @@
row :username
row :token
when Lnp::Database::CONST::TYPE_SIP_REDIRECT
row :format
row :host
row :port
row :timeout
Expand All @@ -118,7 +121,7 @@
end

permit_params do
attrs = %i[name database_type]
attrs = %i[name database_type cache_ttl]
database_attrs = [:type]
database_type = params[:lnp_database].try!(:[], :database_type) ||
params[:lnp_database].try!(:[], :database_attributes).try!(:[], :type)
Expand All @@ -127,7 +130,7 @@
when Lnp::Database::CONST::TYPE_THINQ
database_attrs += %i[host port username token timeout]
when Lnp::Database::CONST::TYPE_SIP_REDIRECT
database_attrs += %i[host port timeout]
database_attrs += %i[host port timeout format_id]
when Lnp::Database::CONST::TYPE_CSV
database_attrs += [:csv_file_path]
when Lnp::Database::CONST::TYPE_ALCAZAR
Expand All @@ -145,6 +148,7 @@

f.inputs name: 'Main' do
f.input :name
f.input :cache_ttl
end

database = f.object.database || f.object.database_type.constantize.new
Expand All @@ -159,6 +163,7 @@
o.input :token
o.input :timeout
when Lnp::Database::CONST::TYPE_SIP_REDIRECT
o.input :format, as: :select, include_blank: false
o.input :host
o.input :port
o.input :timeout
Expand Down
13 changes: 10 additions & 3 deletions app/admin/routing/routing_plan_lnp_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

permit_params :routing_plan_id, :database_id, :dst_prefix,
:req_dst_rewrite_rule, :req_dst_rewrite_result,
:lrn_rewrite_rule, :lrn_rewrite_result
:lrn_rewrite_rule, :lrn_rewrite_result,
:drop_call_on_error, :rewrite_call_destination

includes :routing_plan, :database

Expand All @@ -30,6 +31,8 @@
column :database
column :lrn_rewrite_rule
column :lrn_rewrite_result
column :drop_call_on_error
column :rewrite_call_destination
column :created_at
end

Expand All @@ -49,19 +52,23 @@
row :database
row :lrn_rewrite_rule
row :lrn_rewrite_result
row :drop_call_on_error
row :rewrite_call_destination
row :created_at
end
end

form do |f|
f.inputs do
f.input :routing_plan
f.input :routing_plan, input_html: { class: 'chosen' }
f.input :dst_prefix
f.input :req_dst_rewrite_rule
f.input :req_dst_rewrite_result
f.input :database
f.input :database, input_html: { class: 'chosen' }
f.input :lrn_rewrite_rule
f.input :lrn_rewrite_result
f.input :drop_call_on_error
f.input :rewrite_call_destination
end
actions
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/lnp/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Table name: class4.lnp_databases
#
# id :integer(2) not null, primary key
# cache_ttl :integer(4) default(10800), not null
# database_type(One of Lnp::DatabaseThinq, Lnp::DatabaseSipRedirect, Lnp::DatabaseCsv) :string
# name :string not null
# created_at :datetime
Expand Down Expand Up @@ -65,6 +66,7 @@ def database_attributes=(attrs)
end

validates :database, presence: true
validates :cache_ttl, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: PG_MAX_INT, allow_nil: false, only_integer: true }
validates :name, presence: true, uniqueness: true
validates :database_id, uniqueness: { scope: :database_type }

Expand Down
Loading

0 comments on commit 85ac320

Please sign in to comment.