dradis-html_export 3.20.0 → 3.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6ac583114b620b0f712eec9d0d4635012a0566e1b6b5bf6e331b708991c223
4
- data.tar.gz: 571a3c231cddac14d08577f6811dd8beab715a0387fc763a99ce57b8340e9110
3
+ metadata.gz: f29710e9f73ca0b7af15e9fbe8c3bd980d549393993c9dc6a801930921d01ceb
4
+ data.tar.gz: 221eb9afccb68af19eedb080964f9e60dca1518f473beaeaee91b7680b92bc7d
5
5
  SHA512:
6
- metadata.gz: 6700179c827068d2810787d028bdc0621f918e86588d7c666547e7ea00be5425e141b15740cab0b0afe359021f13e28e1300c4a03edd87e7e2b86cd0b6adb1b8
7
- data.tar.gz: 36b73d54c2167cf49063882d9521e6954562331a3edc4464ec77b3f951302ad8ebc20ded1b9a7d996acc369e2000364ee916b0d2e6a5b1a2038d43ae6a7b1800
6
+ metadata.gz: b7c8395019a1b5e1eec2ab049ab9c475d6ee57a9d30819cc4023d14dbc78428355e5045c924265e4e3edb25bf7ca2da48af09fcc90e6810f62f0162fd43e3e46
7
+ data.tar.gz: 3f2912502311e65530cca4d8641a3e7d24d921dff1baefd3af118a195aaa90f288974849286d8ea397c17d8f06f51fde2ade20e9ebab6c2fc15279e89898acea
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
+ ## Dradis Framework 3.21 (February, 2021) ##
2
+
3
+ * Add a fix for Rails 6 not allowing HTML rendering outside the view directory.
4
+
1
5
  ## Dradis Framework 3.20 (December, 2020) ##
2
6
 
3
7
  * Add an option in the exporter to pass a controller for rendering.
8
+ * Add views for the export view.
4
9
  * Use NamingService to build export filename.
5
10
 
6
11
  ## Dradis Framework 3.19 (September, 2020) ##
@@ -0,0 +1,23 @@
1
+ <%
2
+ templates_dir = File.join(::Configuration::paths_templates_reports, 'html_export')
3
+ templates = Dir["%s/*" % templates_dir].map { |t| File.basename(t) }.sort
4
+ %>
5
+
6
+ <%= content_tag :div, id: 'plugin-html_export', class: 'tab-pane fade' do %>
7
+ <%= form_tag project_export_manager_path(current_project), target: '_blank' do %>
8
+ <%= hidden_field_tag :plugin, :html_export %>
9
+ <%= hidden_field_tag :route, :root %>
10
+
11
+ <h4 class="header-underline">Choose a template</h4>
12
+ <p>Please choose one of the templates available for this plugin (find them in <code>.<%= templates_dir[Rails.root.to_s.length..-1] %></code>)</p>
13
+
14
+ <% templates.each do |template| %>
15
+ <div class="custom-control custom-radio">
16
+ <%= radio_button_tag :template, template, template == templates.first, :class => 'custom-control-input' %>
17
+ <label class="custom-control-label" for="template_<%= template %>"><%= template %></label>
18
+ </div>
19
+ <% end %>
20
+
21
+ <button id="export-button" class="btn btn-lg btn-primary mt-4">Export</button>
22
+ <% end %>
23
+ <% end%>
@@ -0,0 +1,3 @@
1
+ <li class='nav-item'>
2
+ <a href='#html_export' class='nav-link' data-toggle='tab' data-target='#plugin-html_export'>Generate advanced HTML reports</a>
3
+ </li>
@@ -3,29 +3,30 @@ module Dradis
3
3
  module HtmlExport
4
4
 
5
5
  class Exporter < Dradis::Plugins::Export::Base
6
-
7
6
  def export(args = {})
8
7
  log_report
9
8
 
10
9
  controller = args[:controller] || ApplicationController
11
10
 
12
- # Render template
13
- controller.render(
14
- file: options.fetch(:template),
15
- layout: false,
16
- locals: {
17
- categorized_issues: categorized_issues,
18
- content_service: content_service,
19
- issues: issues,
20
- nodes: nodes,
21
- notes: notes,
22
- project: project,
23
- reporting_cat: content_service.report_category,
24
- tags: tags,
25
- title: title,
26
- user: options[:user]
27
- }
28
- )
11
+ with_temporary_template(options[:template]) do |temporary_template|
12
+ # Render template
13
+ controller.render(
14
+ template: temporary_template,
15
+ layout: false,
16
+ locals: {
17
+ categorized_issues: categorized_issues,
18
+ content_service: content_service,
19
+ issues: issues,
20
+ nodes: nodes,
21
+ notes: notes,
22
+ project: project,
23
+ reporting_cat: content_service.report_category,
24
+ tags: tags,
25
+ title: title,
26
+ user: options[:user]
27
+ }
28
+ )
29
+ end
29
30
  end
30
31
 
31
32
  private
@@ -94,6 +95,19 @@ module Dradis
94
95
  "Dradis Community Edition v#{Dradis::CE.version}"
95
96
  end
96
97
  end
98
+
99
+ def with_temporary_template(original, &block)
100
+ filename = File.basename(Dir::Tmpname.create(['', '.html.erb']) {})
101
+ destination_path = Rails.root.join('app', 'views', 'tmp', filename)
102
+
103
+ FileUtils.mkdir_p(File.dirname(destination_path))
104
+ FileUtils.cp(original, destination_path)
105
+
106
+ yield("tmp/#{filename}")
107
+ ensure
108
+ file_path = Rails.root.join("app/views/tmp/#{filename}")
109
+ File.delete(file_path) if File.exists?(file_path)
110
+ end
97
111
  end
98
112
  end
99
113
  end
@@ -8,7 +8,7 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 3
11
- MINOR = 20
11
+ MINOR = 21
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>My Title</title>
5
+ </head>
6
+ <body>
7
+ <h2>Issues</h2>
8
+ <% issues.each do |issue| %>
9
+ <p><%= markup(issue.text) %></p>
10
+ <% end %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,25 @@
1
+ require 'rails_helper'
2
+
3
+ describe Dradis::Plugins::HtmlExport::Exporter do
4
+ let!(:project) { create(:project) }
5
+ let!(:issues) { create_list(:issue, 3, node: project.issue_library) }
6
+
7
+ let(:export_options) do
8
+ {
9
+ project_id: project.id,
10
+ template: Dradis::Plugins::HtmlExport::Engine.root.join(
11
+ 'spec/fixtures/files/template.html.erb'
12
+ )
13
+ }
14
+ end
15
+
16
+ let(:exporter) { described_class.new(export_options) }
17
+
18
+ it 'exports html' do
19
+ html = exporter.export
20
+
21
+ issues.each do |issue|
22
+ expect(html.include?(issue.title))
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dradis-html_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.20.0
4
+ version: 3.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dradis-plugins
@@ -70,6 +70,8 @@ files:
70
70
  - README.md
71
71
  - Rakefile
72
72
  - app/controllers/dradis/plugins/html_export/base_controller.rb
73
+ - app/views/dradis/plugins/html_export/export/_index-content.html.erb
74
+ - app/views/dradis/plugins/html_export/export/_index-tabs.html.erb
73
75
  - config/routes.rb
74
76
  - dradis-html_export.gemspec
75
77
  - lib/dradis-html_export.rb
@@ -79,6 +81,8 @@ files:
79
81
  - lib/dradis/plugins/html_export/gem_version.rb
80
82
  - lib/dradis/plugins/html_export/version.rb
81
83
  - lib/tasks/thorfile.rb
84
+ - spec/fixtures/files/template.html.erb
85
+ - spec/lib/dradis/plugins/html_export/exporter_spec.rb
82
86
  - spec/requests/html_export_spec.rb
83
87
  - spec/spec_helper.rb
84
88
  - templates/basic.html.erb
@@ -107,5 +111,7 @@ signing_key:
107
111
  specification_version: 4
108
112
  summary: Dradis HTML export plugin
109
113
  test_files:
114
+ - spec/fixtures/files/template.html.erb
115
+ - spec/lib/dradis/plugins/html_export/exporter_spec.rb
110
116
  - spec/requests/html_export_spec.rb
111
117
  - spec/spec_helper.rb