From b0cb2c72e98206c42bdd25d6077582362a837f55 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Jul 2024 14:22:12 -0700 Subject: [PATCH] Improved CSP support --- CHANGELOG.md | 4 ++++ app/views/blazer/_variables.html.erb | 16 ++++++++-------- app/views/blazer/checks/_form.html.erb | 16 ++++++++-------- app/views/blazer/checks/index.html.erb | 4 ++-- app/views/blazer/dashboards/_form.html.erb | 4 ++-- app/views/blazer/dashboards/show.html.erb | 4 ++-- app/views/blazer/queries/_form.html.erb | 4 ++-- app/views/blazer/queries/home.html.erb | 4 ++-- app/views/blazer/queries/run.html.erb | 8 ++++---- app/views/blazer/queries/schema.html.erb | 4 ++-- app/views/blazer/queries/show.html.erb | 8 ++++---- app/views/blazer/uploads/index.html.erb | 4 ++-- app/views/layouts/blazer/application.html.erb | 8 ++++---- 13 files changed, 46 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97d077fef..fe342c9f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.4 (unreleased) + +- Improved CSP support + ## 3.0.3 (2024-01-10) - Fixed error with Trilogy, non-ASCII column names, and charts diff --git a/app/views/blazer/_variables.html.erb b/app/views/blazer/_variables.html.erb index a2bc8df1f..9d8af1be3 100644 --- a/app/views/blazer/_variables.html.erb +++ b/app/views/blazer/_variables.html.erb @@ -1,6 +1,6 @@ <% if @bind_vars.any? %> <% var_params = request.query_parameters %> - + <% end %>
<% date_vars = ["start_time", "end_time"] %> <% if (date_vars - @bind_vars).empty? %> @@ -21,11 +21,11 @@ <%= label_tag var, var %> <% if (data = @smart_vars[var]) %> <%= select_tag var, options_for_select([[nil, nil]] + data, selected: var_params[var]), style: "margin-right: 20px; width: 200px; display: none;" %> - + <% end %> <% elsif var.end_with?("_at") || var == "start_time" || var == "end_time" %> <%= hidden_field_tag var, var_params[var] %> @@ -35,7 +35,7 @@ - + <% end %> <% else %> <%= text_field_tag var, var_params[var], style: "width: 120px; margin-right: 20px;", autofocus: i == 0 && !var.end_with?("_at") && !var_params[var], class: "form-control" %> <% end %> @@ -75,7 +75,7 @@ - + <% end %> <% end %> diff --git a/app/views/blazer/checks/_form.html.erb b/app/views/blazer/checks/_form.html.erb index ceaf4e440..3e6020604 100644 --- a/app/views/blazer/checks/_form.html.erb +++ b/app/views/blazer/checks/_form.html.erb @@ -12,12 +12,12 @@
<%= f.select :query_id, [], {include_blank: true} %>
- + <% end %> <% if @check.respond_to?(:check_type) %> @@ -28,9 +28,9 @@ <% check_options << ["Anomaly (most recent data point)", "anomaly"] if Blazer.anomaly_checks %> <%= f.select :check_type, check_options %> - + <% end %> <% elsif @check.respond_to?(:invert) %>
@@ -38,9 +38,9 @@
<%= f.select :invert, [["Any results (bad data)", false], ["No results (missing data)", true]] %>
- + <% end %>
<% end %> @@ -50,9 +50,9 @@
<%= f.select :schedule, Blazer.check_schedules.map { |v| [v, v] } %>
- + <% end %> <% end %> diff --git a/app/views/blazer/checks/index.html.erb b/app/views/blazer/checks/index.html.erb index 5ce7296b8..dd1e3cda4 100644 --- a/app/views/blazer/checks/index.html.erb +++ b/app/views/blazer/checks/index.html.erb @@ -62,11 +62,11 @@ - +<% end %> diff --git a/app/views/blazer/dashboards/_form.html.erb b/app/views/blazer/dashboards/_form.html.erb index af0d3cb2b..4e881dc8d 100644 --- a/app/views/blazer/dashboards/_form.html.erb +++ b/app/views/blazer/dashboards/_form.html.erb @@ -30,7 +30,7 @@

<% end %> - +<% end %> diff --git a/app/views/blazer/dashboards/show.html.erb b/app/views/blazer/dashboards/show.html.erb index 30b716b93..8ba1f2b77 100644 --- a/app/views/blazer/dashboards/show.html.erb +++ b/app/views/blazer/dashboards/show.html.erb @@ -38,7 +38,7 @@

Loading...

- + <% end %> <% end %> diff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erb index 5ad024c25..2cfe7cc59 100644 --- a/app/views/blazer/queries/_form.html.erb +++ b/app/views/blazer/queries/_form.html.erb @@ -68,7 +68,7 @@ - +<% end %> diff --git a/app/views/blazer/queries/home.html.erb b/app/views/blazer/queries/home.html.erb index 80795fd37..051894f55 100644 --- a/app/views/blazer/queries/home.html.erb +++ b/app/views/blazer/queries/home.html.erb @@ -56,7 +56,7 @@

Loading...

- +<% end %> diff --git a/app/views/blazer/queries/run.html.erb b/app/views/blazer/queries/run.html.erb index 2f433e918..82760be1b 100644 --- a/app/views/blazer/queries/run.html.erb +++ b/app/views/blazer/queries/run.html.erb @@ -75,21 +75,21 @@ <% if @markers.any? %> <% map_id = SecureRandom.hex %> <%= content_tag :div, nil, id: map_id, style: "height: #{@only_chart ? 300 : 500}px;" %> - + <% end %> <% elsif @geojson.any? %> <% map_id = SecureRandom.hex %> <%= content_tag :div, nil, id: map_id, style: "height: #{@only_chart ? 300 : 500}px;" %> - + <% end %> <% elsif chart_type == "line" %> <% chart_data = @columns[1..-1].each_with_index.map{ |k, i| {name: blazer_series_name(k), data: @rows.map{ |r| [r[0], r[i + 1]] }, library: series_library[i]} } %> <%= line_chart chart_data, **chart_options %> diff --git a/app/views/blazer/queries/schema.html.erb b/app/views/blazer/queries/schema.html.erb index be3b2897f..764a85773 100644 --- a/app/views/blazer/queries/schema.html.erb +++ b/app/views/blazer/queries/schema.html.erb @@ -28,7 +28,7 @@ <% end %> - +<% end %> diff --git a/app/views/blazer/queries/show.html.erb b/app/views/blazer/queries/show.html.erb index 560b367e8..5a03b5380 100644 --- a/app/views/blazer/queries/show.html.erb +++ b/app/views/blazer/queries/show.html.erb @@ -46,7 +46,7 @@

Loading...

- + <% end %> <% end %> - +<% end %> diff --git a/app/views/blazer/uploads/index.html.erb b/app/views/blazer/uploads/index.html.erb index 18dc1a2b1..96506f808 100644 --- a/app/views/blazer/uploads/index.html.erb +++ b/app/views/blazer/uploads/index.html.erb @@ -45,11 +45,11 @@ - +<% end %> diff --git a/app/views/layouts/blazer/application.html.erb b/app/views/layouts/blazer/application.html.erb index b8a87f70e..93f71cf07 100644 --- a/app/views/layouts/blazer/application.html.erb +++ b/app/views/layouts/blazer/application.html.erb @@ -7,14 +7,14 @@ <%= favicon_link_tag "blazer/favicon.png" %> <% if defined?(Propshaft::Railtie) %> <%= stylesheet_link_tag "blazer/bootstrap-propshaft", "blazer/bootstrap", "blazer/selectize", "blazer/github", "blazer/daterangepicker", "blazer/application" %> - <%= javascript_include_tag "blazer/jquery", "blazer/rails-ujs", "blazer/stupidtable", "blazer/stupidtable-custom-settings", "blazer/jquery.stickytableheaders", "blazer/selectize", "blazer/highlight.min", "blazer/moment", "blazer/moment-timezone-with-data", "blazer/daterangepicker", "blazer/chart.umd", "blazer/chartjs-adapter-date-fns.bundle", "blazer/chartkick", "blazer/mapkick.bundle", "blazer/ace/ace", "blazer/ace/ext-language_tools", "blazer/ace/theme-twilight", "blazer/ace/mode-sql", "blazer/ace/snippets/text", "blazer/ace/snippets/sql", "blazer/Sortable", "blazer/bootstrap", "blazer/vue.global.prod", "blazer/routes", "blazer/queries", "blazer/fuzzysearch", "blazer/application" %> + <%= javascript_include_tag "blazer/jquery", "blazer/rails-ujs", "blazer/stupidtable", "blazer/stupidtable-custom-settings", "blazer/jquery.stickytableheaders", "blazer/selectize", "blazer/highlight.min", "blazer/moment", "blazer/moment-timezone-with-data", "blazer/daterangepicker", "blazer/chart.umd", "blazer/chartjs-adapter-date-fns.bundle", "blazer/chartkick", "blazer/mapkick.bundle", "blazer/ace/ace", "blazer/ace/ext-language_tools", "blazer/ace/theme-twilight", "blazer/ace/mode-sql", "blazer/ace/snippets/text", "blazer/ace/snippets/sql", "blazer/Sortable", "blazer/bootstrap", "blazer/vue.global.prod", "blazer/routes", "blazer/queries", "blazer/fuzzysearch", "blazer/application", nonce: true %> <% else %> <%= stylesheet_link_tag "blazer/application" %> - <%= javascript_include_tag "blazer/application" %> + <%= javascript_include_tag "blazer/application", nonce: true %> <% end %> - + <% end %> <%= csrf_meta_tags %>