bnb_blazer 0.4.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/overrides/controllers/blazer/base_controller_override.rb +133 -0
  3. data/app/views/{blazer → bnb_blazer}/_variables.html.haml +0 -0
  4. data/app/views/{blazer → bnb_blazer}/checks/_form.html.haml +0 -0
  5. data/app/views/{blazer → bnb_blazer}/checks/edit.html.haml +0 -0
  6. data/app/views/{blazer → bnb_blazer}/checks/index.html.haml +0 -0
  7. data/app/views/{blazer → bnb_blazer}/checks/new.html.haml +0 -0
  8. data/app/views/{blazer → bnb_blazer}/dashboards/_form.html.haml +0 -0
  9. data/app/views/{blazer → bnb_blazer}/dashboards/edit.html.haml +0 -0
  10. data/app/views/{blazer → bnb_blazer}/dashboards/new.html.haml +0 -0
  11. data/app/views/{blazer → bnb_blazer}/dashboards/show.html.haml +2 -2
  12. data/app/views/{blazer → bnb_blazer}/queries/_form.html.haml +0 -0
  13. data/app/views/{blazer → bnb_blazer}/queries/edit.html.haml +0 -0
  14. data/app/views/{blazer → bnb_blazer}/queries/home.html.haml +0 -0
  15. data/app/views/{blazer → bnb_blazer}/queries/new.html.haml +0 -0
  16. data/app/views/{blazer → bnb_blazer}/queries/run.html.haml +0 -0
  17. data/app/views/{blazer → bnb_blazer}/queries/show.html.haml +2 -2
  18. data/app/views/layouts/{blazer → bnb_blazer}/_footer.html.haml +0 -0
  19. data/app/views/layouts/{blazer → bnb_blazer}/_navbar.html.haml +0 -0
  20. data/app/views/layouts/{blazer → bnb_blazer}/application.html.haml +4 -4
  21. data/lib/bnb_blazer.rb +1 -0
  22. data/lib/bnb_blazer/engine.rb +5 -0
  23. data/lib/bnb_blazer/version.rb +1 -1
  24. metadata +22 -94
  25. data/.docker-development-vars +0 -1
  26. data/.gitignore +0 -34
  27. data/.rspec +0 -3
  28. data/.ruby-version +0 -1
  29. data/.travis.yml +0 -6
  30. data/Gemfile +0 -54
  31. data/Gemfile.lock +0 -233
  32. data/LICENSE.txt +0 -21
  33. data/README.md +0 -35
  34. data/app/assets/config/manifest.js +0 -3
  35. data/app/assets/images/.keep +0 -0
  36. data/app/assets/images/bnb_intel_logo.png +0 -0
  37. data/app/assets/stylesheets/application.css +0 -83
  38. data/app/channels/application_cable/channel.rb +0 -4
  39. data/app/channels/application_cable/connection.rb +0 -4
  40. data/app/controllers/application_controller.rb +0 -2
  41. data/app/controllers/concerns/.keep +0 -0
  42. data/app/helpers/application_helper.rb +0 -2
  43. data/app/jobs/application_job.rb +0 -2
  44. data/app/mailers/application_mailer.rb +0 -4
  45. data/app/models/application_record.rb +0 -3
  46. data/app/models/concerns/.keep +0 -0
  47. data/app/models/user.rb +0 -2
  48. data/bin/bundle +0 -3
  49. data/bin/console +0 -14
  50. data/bin/rails +0 -9
  51. data/bin/rake +0 -9
  52. data/bin/setup +0 -36
  53. data/bin/spring +0 -17
  54. data/bin/update +0 -31
  55. data/bin/yarn +0 -11
  56. data/bnb_blazer.gemspec +0 -28
  57. data/config.ru +0 -5
  58. data/config/application.rb +0 -19
  59. data/config/blazer.yml +0 -79
  60. data/config/boot.rb +0 -4
  61. data/config/cable.yml +0 -10
  62. data/config/credentials.yml.enc +0 -1
  63. data/config/database.yml +0 -19
  64. data/config/environment.rb +0 -5
  65. data/config/environments/development.rb +0 -61
  66. data/config/environments/production.rb +0 -94
  67. data/config/environments/test.rb +0 -46
  68. data/config/initializers/application_controller_renderer.rb +0 -8
  69. data/config/initializers/assets.rb +0 -14
  70. data/config/initializers/backtrace_silencers.rb +0 -7
  71. data/config/initializers/content_security_policy.rb +0 -25
  72. data/config/initializers/cookies_serializer.rb +0 -5
  73. data/config/initializers/filter_parameter_logging.rb +0 -4
  74. data/config/initializers/inflections.rb +0 -16
  75. data/config/initializers/mime_types.rb +0 -4
  76. data/config/initializers/wrap_parameters.rb +0 -14
  77. data/config/locales/en.yml +0 -33
  78. data/config/puma.rb +0 -37
  79. data/config/routes.rb +0 -3
  80. data/config/spring.rb +0 -6
  81. data/config/storage.yml +0 -34
  82. data/db/migrate/20210309231658_install_blazer.rb +0 -47
  83. data/db/migrate/20210309231908_create_users.rb +0 -13
  84. data/db/schema.rb +0 -85
  85. data/db/seeds.rb +0 -45
  86. data/docker-compose.yml +0 -22
  87. data/lib/tasks/.keep +0 -0
  88. data/log/.keep +0 -0
  89. data/package.json +0 -5
  90. data/public/404.html +0 -67
  91. data/public/422.html +0 -67
  92. data/public/500.html +0 -66
  93. data/public/apple-touch-icon-precomposed.png +0 -0
  94. data/public/apple-touch-icon.png +0 -0
  95. data/public/favicon.ico +0 -0
  96. data/public/robots.txt +0 -1
  97. data/tmp/.keep +0 -0
  98. data/vendor/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 437e6d1c035864ecdc01a74748e2845068ea7ce0ef423ccee284389e2c623d6f
4
- data.tar.gz: 8fe7e32b6e9e13a5e6c8965624d053296897a8e37c163985e3880935c5221c31
3
+ metadata.gz: 6c4eeb11855b3ee65cfc2502b2cdab2b23cd90d2288839c4deaa95e91a969656
4
+ data.tar.gz: 067f920d2ad254337973ab555bb8f8e7ec24c2406e5398dc208dcf4860a7f2e1
5
5
  SHA512:
6
- metadata.gz: 6e888e6840446ef55a40bbd21c2bb97ea9f1b7c83b21c402b0862cff5e3449259314c177041f2ca107deddb6643750cc57a1389f3f77774bbec39cd9f0872a6b
7
- data.tar.gz: da26c670aafa02dd626216c17abb30c524adc9b7cd899c34c25f657d326ed35667149e23998f49529236103b52b2aae977459122cd6979c8dce0ec1bdc1d6c23
6
+ metadata.gz: '0891b743b0d8b6335c7aed43b4fb72a67b39e45c1529d05fe21e338294df4ba353885f3bb9cb6e117e5deacfaef9333cd94d65fe54d319d612837867c25cf7b8'
7
+ data.tar.gz: a0842017c74108c065d0c9dde22a912320fa1573a28eb71e1cc2184019ef810552c1fcaa8f7bb1b0305ec09eaa273120a9ecc5f5fc8c09e266c1ce123bbaf026
@@ -0,0 +1,133 @@
1
+ Blazer::BaseController.class_eval do
2
+ # skip filters
3
+ filters = _process_action_callbacks.map(&:filter) - [:activate_authlogic]
4
+ skip_before_action(*filters, raise: false)
5
+ skip_after_action(*filters, raise: false)
6
+ skip_around_action(*filters, raise: false)
7
+
8
+ clear_helpers
9
+
10
+ protect_from_forgery with: :exception
11
+
12
+ if ENV["BLAZER_PASSWORD"]
13
+ http_basic_authenticate_with name: ENV["BLAZER_USERNAME"], password: ENV["BLAZER_PASSWORD"]
14
+ end
15
+
16
+ if Blazer.settings["before_action"]
17
+ raise Blazer::Error, "The docs for protecting Blazer with a custom before_action had an incorrect example from August 2017 to June 2018. The example method had a boolean return value. However, you must render or redirect if a user is unauthorized rather than return a falsy value. Double check that your before_action works correctly for unauthorized users (if it worked when added, there should be no issue). Then, change before_action to before_action_method in config/blazer.yml."
18
+ end
19
+
20
+ if Blazer.before_action
21
+ before_action Blazer.before_action.to_sym
22
+ end
23
+
24
+ if Blazer.override_csp
25
+ after_action do
26
+ response.headers['Content-Security-Policy'] = "default-src 'self' https: 'unsafe-inline' 'unsafe-eval' data:"
27
+ end
28
+ end
29
+
30
+ layout "bnb_blazer/application"
31
+ append_view_path(["views/blazer", "views/bnb_blazer", "views/blazer"])
32
+
33
+ private
34
+
35
+ def process_vars(statement, data_source)
36
+ (@bind_vars ||= []).concat(Blazer.extract_vars(statement)).uniq!
37
+ @bind_vars.each do |var|
38
+ params[var] ||= Blazer.data_sources[data_source].variable_defaults[var]
39
+ end
40
+ @success = @bind_vars.all? { |v| params[v] }
41
+
42
+ if @success
43
+ @bind_vars.each do |var|
44
+ value = params[var].presence
45
+ if value
46
+ if ["start_time", "end_time"].include?(var)
47
+ value = value.to_s.gsub(" ", "+") # fix for Quip bug
48
+ end
49
+
50
+ if var.end_with?("_at")
51
+ begin
52
+ value = Blazer.time_zone.parse(value)
53
+ rescue
54
+ # do nothing
55
+ end
56
+ end
57
+
58
+ if value =~ /\A\d+\z/
59
+ value = value.to_i
60
+ elsif value =~ /\A\d+\.\d+\z/
61
+ value = value.to_f
62
+ end
63
+ end
64
+ value = Blazer.transform_variable.call(var, value) if Blazer.transform_variable
65
+ statement.gsub!("{#{var}}", ActiveRecord::Base.connection.quote(value))
66
+ end
67
+ end
68
+ end
69
+
70
+ def add_cohort_analysis_vars
71
+ @bind_vars << "cohort_period" unless @bind_vars.include?("cohort_period")
72
+ @smart_vars["cohort_period"] = ["day", "week", "month"]
73
+ params[:cohort_period] ||= "week"
74
+ end
75
+
76
+ def parse_smart_variables(var, data_source)
77
+ smart_var_data_source =
78
+ ([data_source] + Array(data_source.settings["inherit_smart_settings"]).map { |ds| Blazer.data_sources[ds] }).find { |ds| ds.smart_variables[var] }
79
+
80
+ if smart_var_data_source
81
+ query = smart_var_data_source.smart_variables[var]
82
+
83
+ if query.is_a? Hash
84
+ smart_var = query.map { |k,v| [v, k] }
85
+ elsif query.is_a? Array
86
+ smart_var = query.map { |v| [v, v] }
87
+ elsif query
88
+ result = smart_var_data_source.run_statement(query)
89
+ smart_var = result.rows.map { |v| v.reverse }
90
+ error = result.error if result.error
91
+ end
92
+ end
93
+
94
+ [smart_var, error]
95
+ end
96
+
97
+ # don't pass to url helpers
98
+ #
99
+ # some are dangerous when passed as symbols
100
+ # root_url({host: "evilsite.com"})
101
+ #
102
+ # certain ones (like host) only affect *_url and not *_path
103
+ #
104
+ # when permitted parameters are passed in Rails 6,
105
+ # they appear to be added as GET parameters
106
+ # root_url(params.permit(:host))
107
+ UNPERMITTED_KEYS = [:controller, :action, :id, :host, :query, :dashboard, :query_id, :query_ids, :table_names, :authenticity_token, :utf8, :_method, :commit, :statement, :data_source, :name, :fork_query_id, :blazer, :run_id, :script_name, :original_script_name]
108
+
109
+ # remove unpermitted keys from both params and permitted keys for better sleep
110
+ def variable_params(resource)
111
+ permitted_keys = resource.variables - UNPERMITTED_KEYS.map(&:to_s)
112
+ params.except(*UNPERMITTED_KEYS).slice(*permitted_keys).permit!
113
+ end
114
+ helper_method :variable_params
115
+
116
+ def blazer_user
117
+ send(Blazer.user_method) if Blazer.user_method && respond_to?(Blazer.user_method, true)
118
+ end
119
+ helper_method :blazer_user
120
+
121
+ def render_errors(resource)
122
+ @errors = resource.errors
123
+ action = resource.persisted? ? :edit : :new
124
+ render action, status: :unprocessable_entity
125
+ end
126
+
127
+ # do not inherit from ApplicationController - #120
128
+ def default_url_options
129
+ {}
130
+ end
131
+ end
132
+
133
+ end
@@ -1,7 +1,7 @@
1
1
  - blazer_title @dashboard.name
2
2
  %nav.navbar.navbar-default.navbar-fixed-top
3
3
  .container
4
- = render layout: "layouts/blazer/navbar" do
4
+ = render layout: "layouts/bnb_blazer/navbar" do
5
5
  %li= link_to "Edit", edit_dashboard_path(@dashboard, variable_params(@dashboard))
6
6
 
7
7
  %div{:style => "margin-bottom: 70px;"}
@@ -11,7 +11,7 @@
11
11
  Some queries may be cached
12
12
  \#{link_to "Refresh", refresh_dashboard_path(@dashboard, variable_params(@dashboard)), method: :post}
13
13
  - if @bind_vars.any?
14
- = render partial: "blazer/variables", locals: {action: dashboard_path(@dashboard)}
14
+ = render partial: "bnb_blazer/variables", locals: {action: dashboard_path(@dashboard)}
15
15
  - else
16
16
  %div{:style => "padding-bottom: 15px;"}
17
17
  - @queries.each_with_index do |query, i|
@@ -1,7 +1,7 @@
1
1
  - blazer_title @query.name
2
2
  %nav.navbar.navbar-default.navbar-fixed-top
3
3
  .container
4
- = render layout: "layouts/blazer/navbar" do
4
+ = render layout: "layouts/bnb_blazer/navbar" do
5
5
  %li= link_to "Edit", edit_query_path(@query, variable_params(@query)), class: "text-muted font-weight-bold px-1", disabled: !@query.editable?(blazer_user)
6
6
  %li= link_to "Fork", new_query_path(variable_params(@query).merge(fork_query_id: @query.id, data_source: @query.data_source, name: @query.name)), class: "text-muted font-weight-bold px-1"
7
7
  - if !@error && @success
@@ -17,7 +17,7 @@
17
17
  %h3.text-center=@query.name
18
18
  - if @query.description.present?
19
19
  %p= @query.description
20
- = render partial: "blazer/variables", locals: {action: query_path(@query)}
20
+ = render partial: "bnb_blazer/variables", locals: {action: query_path(@query)}
21
21
  %pre#code
22
22
  %code= @statement
23
23
  - if @success
@@ -5,10 +5,10 @@
5
5
  %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
6
6
  %title= blazer_title ? blazer_title : "Blazer"
7
7
  %meta{:charset => "utf-8"}/
8
- = favicon_link_tag "blazer/favicon.png"
9
- = stylesheet_link_tag "blazer/application"
8
+ = favicon_link_tag "bnb_blazer/favicon.png"
9
+ = stylesheet_link_tag "bnb_blazer/application"
10
10
  = stylesheet_link_tag "application"
11
- = javascript_include_tag "blazer/application"
11
+ = javascript_include_tag "bnb_blazer/application"
12
12
  :javascript
13
13
  #{blazer_js_var "rootPath", root_path}
14
14
  - if blazer_maps?
@@ -18,4 +18,4 @@
18
18
  %body
19
19
  .container.blazer-content
20
20
  = yield
21
- = render "layouts/blazer/footer"
21
+ = render "layouts/bnb_blazer/footer"
data/lib/bnb_blazer.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require "blazer"
3
3
 
4
4
  # modules
5
+ # require "bnb_blazer/engine"
5
6
  require "bnb_blazer/version"
6
7
 
7
8
  module BnbBlazer
@@ -0,0 +1,5 @@
1
+ module BnbBlazer
2
+ class Enginer < ::Rails::Engine
3
+ isolate_namespace BnbBlazer
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module BnbBlazer
2
- VERSION = "0.4.0"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bnb_blazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2021-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blazer
@@ -31,101 +31,29 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".docker-development-vars"
35
- - ".gitignore"
36
- - ".rspec"
37
- - ".ruby-version"
38
- - ".travis.yml"
39
- - Gemfile
40
- - Gemfile.lock
41
- - LICENSE.txt
42
- - README.md
43
34
  - Rakefile
44
- - app/assets/config/manifest.js
45
- - app/assets/images/.keep
46
- - app/assets/images/bnb_intel_logo.png
47
- - app/assets/stylesheets/application.css
48
- - app/channels/application_cable/channel.rb
49
- - app/channels/application_cable/connection.rb
50
- - app/controllers/application_controller.rb
51
- - app/controllers/concerns/.keep
52
- - app/helpers/application_helper.rb
53
- - app/jobs/application_job.rb
54
- - app/mailers/application_mailer.rb
55
- - app/models/application_record.rb
56
- - app/models/concerns/.keep
57
- - app/models/user.rb
58
- - app/views/blazer/_variables.html.haml
59
- - app/views/blazer/checks/_form.html.haml
60
- - app/views/blazer/checks/edit.html.haml
61
- - app/views/blazer/checks/index.html.haml
62
- - app/views/blazer/checks/new.html.haml
63
- - app/views/blazer/dashboards/_form.html.haml
64
- - app/views/blazer/dashboards/edit.html.haml
65
- - app/views/blazer/dashboards/new.html.haml
66
- - app/views/blazer/dashboards/show.html.haml
67
- - app/views/blazer/queries/_form.html.haml
68
- - app/views/blazer/queries/edit.html.haml
69
- - app/views/blazer/queries/home.html.haml
70
- - app/views/blazer/queries/new.html.haml
71
- - app/views/blazer/queries/run.html.haml
72
- - app/views/blazer/queries/show.html.haml
73
- - app/views/layouts/blazer/_footer.html.haml
74
- - app/views/layouts/blazer/_navbar.html.haml
75
- - app/views/layouts/blazer/application.html.haml
76
- - bin/bundle
77
- - bin/console
78
- - bin/rails
79
- - bin/rake
80
- - bin/setup
81
- - bin/spring
82
- - bin/update
83
- - bin/yarn
84
- - bnb_blazer.gemspec
85
- - config.ru
86
- - config/application.rb
87
- - config/blazer.yml
88
- - config/boot.rb
89
- - config/cable.yml
90
- - config/credentials.yml.enc
91
- - config/database.yml
92
- - config/environment.rb
93
- - config/environments/development.rb
94
- - config/environments/production.rb
95
- - config/environments/test.rb
96
- - config/initializers/application_controller_renderer.rb
97
- - config/initializers/assets.rb
98
- - config/initializers/backtrace_silencers.rb
99
- - config/initializers/content_security_policy.rb
100
- - config/initializers/cookies_serializer.rb
101
- - config/initializers/filter_parameter_logging.rb
102
- - config/initializers/inflections.rb
103
- - config/initializers/mime_types.rb
104
- - config/initializers/wrap_parameters.rb
105
- - config/locales/en.yml
106
- - config/puma.rb
107
- - config/routes.rb
108
- - config/spring.rb
109
- - config/storage.yml
110
- - db/migrate/20210309231658_install_blazer.rb
111
- - db/migrate/20210309231908_create_users.rb
112
- - db/schema.rb
113
- - db/seeds.rb
114
- - docker-compose.yml
35
+ - app/overrides/controllers/blazer/base_controller_override.rb
36
+ - app/views/bnb_blazer/_variables.html.haml
37
+ - app/views/bnb_blazer/checks/_form.html.haml
38
+ - app/views/bnb_blazer/checks/edit.html.haml
39
+ - app/views/bnb_blazer/checks/index.html.haml
40
+ - app/views/bnb_blazer/checks/new.html.haml
41
+ - app/views/bnb_blazer/dashboards/_form.html.haml
42
+ - app/views/bnb_blazer/dashboards/edit.html.haml
43
+ - app/views/bnb_blazer/dashboards/new.html.haml
44
+ - app/views/bnb_blazer/dashboards/show.html.haml
45
+ - app/views/bnb_blazer/queries/_form.html.haml
46
+ - app/views/bnb_blazer/queries/edit.html.haml
47
+ - app/views/bnb_blazer/queries/home.html.haml
48
+ - app/views/bnb_blazer/queries/new.html.haml
49
+ - app/views/bnb_blazer/queries/run.html.haml
50
+ - app/views/bnb_blazer/queries/show.html.haml
51
+ - app/views/layouts/bnb_blazer/_footer.html.haml
52
+ - app/views/layouts/bnb_blazer/_navbar.html.haml
53
+ - app/views/layouts/bnb_blazer/application.html.haml
115
54
  - lib/bnb_blazer.rb
55
+ - lib/bnb_blazer/engine.rb
116
56
  - lib/bnb_blazer/version.rb
117
- - lib/tasks/.keep
118
- - log/.keep
119
- - package.json
120
- - public/404.html
121
- - public/422.html
122
- - public/500.html
123
- - public/apple-touch-icon-precomposed.png
124
- - public/apple-touch-icon.png
125
- - public/favicon.ico
126
- - public/robots.txt
127
- - tmp/.keep
128
- - vendor/.keep
129
57
  homepage: https://github.com/brandnewbox/bnb_blazer
130
58
  licenses:
131
59
  - MIT
@@ -1 +0,0 @@
1
- DATABASE_URL=postgresql://postgres:password@postgresql:5432
data/.gitignore DELETED
@@ -1,34 +0,0 @@
1
- # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
- #
3
- # If you find yourself ignoring temporary files generated by your text editor
4
- # or operating system, you probably want to add a global ignore instead:
5
- # git config --global core.excludesfile '~/.gitignore_global'
6
-
7
- # Ignore bundler config.
8
- /.bundle
9
-
10
- # Ignore all logfiles and tempfiles.
11
- /log/*
12
- /tmp/*
13
- !/log/.keep
14
- !/tmp/.keep
15
-
16
- # Ignore uploaded files in development
17
- /storage/*
18
- !/storage/.keep
19
-
20
- /node_modules
21
- /yarn-error.log
22
-
23
- /public/assets
24
- .byebug_history
25
-
26
- .DS_Store
27
- /pgdata
28
- /vendor/bundle
29
-
30
- # Ignore master key for decrypting credentials and more.
31
- /config/master.key
32
-
33
- # Ignore built versions
34
- bnb_blazer-*
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper