app_manager 2.4.3 → 2.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0290bbafdb7d1f3176dc2fa2a81f2826e5ca3fad4438786347b6ad4b075e8c08'
4
- data.tar.gz: 57f949f7c33cf5aa80d1c58fc0d5d30e9d55a91e76907ce194c59e0f846fcb01
3
+ metadata.gz: badbc7307519661c369eb2a5e601018d1da63fb4a6d0640d8a9b45aadf38c1e5
4
+ data.tar.gz: 1baffa7b22a09589b346cd32f5071ff4cb3b3a08fc68bf0956828d0bf86cd877
5
5
  SHA512:
6
- metadata.gz: 25811aad36f0e14134924c08563b56358910e8e47371d040adc9045d0e41fe0aaece9cb7a6346d816d5df0396c987b634e9f7cc0ea646a04fa0774b76d2d2441
7
- data.tar.gz: 6ae46323bb5bcade4371e2142d70148e8b8dfb555e2a79ed2ac145457a42fd525087631e0df5a12cf7c83b75619fd5ece268b73b927ffce4933d4838b57c382d
6
+ metadata.gz: 1b7955219208f4081acd575f971f3bb8b77e21fdc113f603e56e8cd23e08be8a6bfe9dfcd06a8609325cd421889e92e342730a6635d6ab31d24089cca30628ce
7
+ data.tar.gz: 66a155af1b682ba51f94f57c2bffcaa0c38110129bafc86003bd3e7f9280bdf84e6004b324fbb1e1a57da691ce7b934c11303d2be2e7be1b95acee9fa065b85a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_manager (2.4.3)
4
+ app_manager (2.4.4)
5
5
  activerecord-import (~> 1.4)
6
6
  httparty
7
7
  kaminari (>= 0.16.3)
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- action_text-trix (2.1.16)
13
+ action_text-trix (2.1.17)
14
14
  railties
15
15
  actioncable (8.1.2)
16
16
  actionpack (= 8.1.2)
@@ -120,7 +120,7 @@ GEM
120
120
  prism (>= 1.3.0)
121
121
  rdoc (>= 4.0.0)
122
122
  reline (>= 0.4.2)
123
- json (2.18.1)
123
+ json (2.19.1)
124
124
  kaminari (1.2.2)
125
125
  activesupport (>= 4.1.0)
126
126
  kaminari-actionview (= 1.2.2)
@@ -134,7 +134,7 @@ GEM
134
134
  kaminari-core (= 1.2.2)
135
135
  kaminari-core (1.2.2)
136
136
  logger (1.7.0)
137
- loofah (2.25.0)
137
+ loofah (2.25.1)
138
138
  crass (~> 1.0.2)
139
139
  nokogiri (>= 1.12.0)
140
140
  mail (2.9.0)
@@ -244,7 +244,7 @@ GEM
244
244
  securerandom (0.4.1)
245
245
  stringio (3.2.0)
246
246
  thor (1.5.0)
247
- timeout (0.6.0)
247
+ timeout (0.6.1)
248
248
  tsort (0.2.0)
249
249
  tzinfo (2.0.6)
250
250
  concurrent-ruby (~> 1.0)
@@ -6,6 +6,7 @@ module AppManager
6
6
  cache_response_for :index
7
7
  cache_response_for :users
8
8
  skip_before_action :verify_authenticity_token, :only => [:active_without_plan, :burst_cache, :fail_safe_backup]
9
+ ALLOWED_SORTS = %w[name shopify_email created_at].freeze
9
10
 
10
11
  def index
11
12
  render :json => {"features" => AppManager.configuration.plan_features || []}
@@ -110,8 +111,10 @@ module AppManager
110
111
  if model
111
112
 
112
113
  search = params[:search]
113
- sort = params[:sort] || AppManager.configuration.field_names['created_at']
114
- order = params[:order] || 'asc'
114
+ sort_param = params[:sort]&.downcase
115
+ sort = ALLOWED_SORTS.include?(sort_param) ? AppManager.configuration.field_names[sort_param] : 'created_at'
116
+ order_param = params[:order]&.downcase
117
+ order = %w[asc desc].include?(order_param) ? order_param : 'asc'
115
118
  plans = params[:plans] || nil
116
119
  plans = plans.values if !plans.nil?
117
120
  shopify_plans = params[:shopify_plans] || nil
@@ -120,12 +123,12 @@ module AppManager
120
123
  @shopify_email = AppManager.configuration.field_names['shopify_email']
121
124
  @shopify_plan_name_field = AppManager.configuration.field_names['shopify_plan']
122
125
  if params[:search]
123
- data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%").order(sort + " " + order)
126
+ data = model.where("#{@shopify_domain} LIKE :search OR #{@shopify_email} LIKE :search", search: "%#{search}%").order(sort => order)
124
127
  data = data.where(@plan_field => plans) if !plans.nil?
125
128
  data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
126
129
  data = data.page(params[:page]).per(items_per_page)
127
130
  else
128
- data = model.order(sort + " " + order)
131
+ data = model.order(sort => order)
129
132
  data = data.where(@plan_field => plans) if !plans.nil?
130
133
  data = data.where(@shopify_plan_name_field => shopify_plans) if !shopify_plans.nil?
131
134
  data = data.page(params[:page]).per(items_per_page)
@@ -4,9 +4,11 @@ require 'time'
4
4
  require "fileutils"
5
5
  require 'active_record'
6
6
  require 'activerecord-import'
7
+ require_relative 'fail_safe_helper'
7
8
  module AppManager
8
9
 
9
10
  class FailSafe
11
+ include AppManager::FailSafeHelper
10
12
 
11
13
  def initialize(db_name = 'app_manager_local')
12
14
  # begin
@@ -321,7 +323,7 @@ module AppManager
321
323
  app_structure = AppManager::AppStructure.first
322
324
  app_structure_computed = {}
323
325
  if app_structure.present?
324
- app_structure_computed["banners"] = eval(app_structure.banners)
326
+ app_structure_computed["banners"] = safe_parse_json(app_structure.banners)
325
327
  end
326
328
  return app_structure_computed
327
329
  end
@@ -374,20 +376,20 @@ module AppManager
374
376
  new_plan = {}
375
377
  plan.as_json.each_with_index do |(key, value)|
376
378
  if ['interval'].include?(key)
377
- val = eval(value)
379
+ val = safe_parse_json(value)
378
380
  new_plan[key] = val
379
381
  new_plan[key] = val['value'] if val rescue {}
380
382
  elsif ['shopify_plans'].include?(key)
381
- val = eval(value)
383
+ val = safe_parse_json(value)
382
384
  new_plan[key] = val.collect { |e| e['value'] }
383
385
  elsif ['affiliate'].include?(key)
384
- new_plan[key] = eval(value)
386
+ new_plan[key] = safe_parse_json(value)
385
387
  elsif ['is_custom', 'public', 'store_base_plan', 'choose_later_plan'].include?(key)
386
388
  new_plan[key] = (value == 0 || value == false ? false : true)
387
389
  elsif ['test'].include?(key)
388
390
  new_plan[key] = (value == 0 || value == false ? nil : true)
389
391
  elsif ['features'].include?(key)
390
- value = eval(value)
392
+ value = safe_parse_json(value)
391
393
  value = value.each { |e| e.delete("id") }.each { |e| e.delete("created_at") }.each { |e| e.delete("updated_at") }
392
394
  new_plan[key] = value
393
395
  elsif ['plan_id'].include?(key)
@@ -473,10 +475,10 @@ module AppManager
473
475
  new_plan = {}
474
476
  plan.as_json.each_with_index do |(key, value), index|
475
477
  if ['interval'].include?(key)
476
- val = eval(value)
478
+ val = safe_parse_json(value)
477
479
  new_plan[key] = val
478
480
  elsif ['shopify_plans', 'affiliate', 'features'].include?(key)
479
- new_plan[key] = eval(value)
481
+ new_plan[key] = safe_parse_json(value)
480
482
  elsif ['is_custom', 'public', 'store_base_plan', 'choose_later_plan'].include?(key)
481
483
  new_plan[key] = (value == 0 || value == false ? false : true)
482
484
  elsif ['test'].include?(key)
@@ -678,7 +680,7 @@ module AppManager
678
680
  message = {"message" => 'fail'}
679
681
  if options
680
682
  options.gsub!('null', 'nil') rescue nil
681
- charge = eval(options) rescue nil
683
+ charge = safe_parse_json(options)
682
684
  if charge
683
685
  charge = charge.as_json if charge.class == Hash
684
686
  test_value = charge["test"]
@@ -0,0 +1,33 @@
1
+ module AppManager
2
+ module FailSafeHelper
3
+ def convert_ruby_hash_to_json(ruby_string)
4
+ return nil if ruby_string.nil? || ruby_string.empty?
5
+
6
+ json_string = ruby_string.dup
7
+
8
+ json_string.gsub!(/([^:])=>([^:])/, '\1:\2')
9
+
10
+ json_string.gsub!(/\bnil\b/, 'null')
11
+
12
+ json_string.gsub!(/\btrue\b/, 'true')
13
+ json_string.gsub!(/\bfalse\b/, 'false')
14
+
15
+ json_string.gsub!(/,(\s*[}\]])/, '\1')
16
+
17
+ json_string
18
+ rescue => e
19
+ nil
20
+ end
21
+
22
+ def safe_parse_json(value)
23
+ return nil if value.nil? || value.empty?
24
+
25
+ begin
26
+ json_string = convert_ruby_hash_to_json(value)
27
+ return JSON.parse(json_string) if json_string
28
+ rescue JSON::ParserError => e
29
+ return nil
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppManager
4
- VERSION = "2.4.3"
4
+ VERSION = "2.4.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Tiwari @ Hulkapps
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-03-02 00:00:00.000000000 Z
11
+ date: 2026-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -114,6 +114,7 @@ files:
114
114
  - lib/app_manager/engine.rb
115
115
  - lib/app_manager/exceptions.rb
116
116
  - lib/app_manager/fail_safe.rb
117
+ - lib/app_manager/fail_safe_helper.rb
117
118
  - lib/app_manager/graphql_helper.rb
118
119
  - lib/app_manager/model.rb
119
120
  - lib/app_manager/protection.rb
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubygems_version: 3.4.10
151
+ rubygems_version: 3.5.13
151
152
  signing_key:
152
153
  specification_version: 4
153
154
  summary: An API wrapper of Hulkapps AppManager portal