dradis-html_export 3.19.0 → 4.0.0

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: 5fcb7bc8d38264378015cd4c8e1685e44a7cd09e1253a01ef073fe9c27069cb7
4
- data.tar.gz: 1dd26e8483b3613c68148c0b0ad0707dafa925219ee4e32192096860a11fa42a
3
+ metadata.gz: 0e30ca0b3eebbe1ddc727fd0b9f9197b25490f545913c9e666282f40508bd858
4
+ data.tar.gz: 46ab64967389ecd8687c5dbba547ca78b1446bc97ff965f2851983e3ccc168b6
5
5
  SHA512:
6
- metadata.gz: 98d58bc1d770bf388e73946bbd76cda56ca9fec22f5f1505ff24c9ac8dd71005462ca7bc75fc5b0146402258f683680d32790b2e7f6524d5176bd1b9a81bb7e5
7
- data.tar.gz: a387b6edd7adab12deba1868970b03f9c7a02e2fa5f75cff7add7ad37c9bdf2b19f0a1e7cccd2560c3bb1feae1c02db20415b045b476efcab37d076db0ab3dc7
6
+ metadata.gz: ff0405750e4525d3e9b2cfcaf434dabff1df3d3523fc398e2eaaf7764007e0b0b51c3c8a789e57bebb2f232e660e9ae3dad772985c3efe73ea0a5f8913bdafff
7
+ data.tar.gz: d52abe89584e52491e3edee462d788ec7d52e14ff38657c1553b624902fe9435882dbba99d4ff2a9909d639a5f9fd76b5dbe758746f752f23c5dcb85df954b7b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## Dradis Framework 4.0.0 (July, 2021) ##
2
+
3
+ * No changes.
4
+
5
+ ## Dradis Framework 3.22 (April, 2021) ##
6
+
7
+ * No changes.
8
+
9
+ ## Dradis Framework 3.21 (February, 2021) ##
10
+
11
+ * Add a fix for Rails 6 not allowing HTML rendering outside the view directory.
12
+
13
+ ## Dradis Framework 3.20 (December, 2020) ##
14
+
15
+ * Add an option in the exporter to pass a controller for rendering.
16
+ * Add views for the export view.
17
+ * Use NamingService to build export filename.
18
+
1
19
  ## Dradis Framework 3.19 (September, 2020) ##
2
20
 
3
21
  * No changes.
@@ -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>
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  # gem.add_dependency 'dradis_core', version
24
- spec.add_dependency 'dradis-plugins', '~> 3.6'
24
+ spec.add_dependency 'dradis-plugins', '~> 4.0.0'
25
25
 
26
26
  # Note markup
27
27
  spec.add_dependency 'rails_autolink', '~> 1.1'
@@ -3,27 +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
- # Render template
11
- ApplicationController.render(
12
- file: options.fetch(:template),
13
- layout: false,
14
- locals: {
15
- categorized_issues: categorized_issues,
16
- content_service: content_service,
17
- issues: issues,
18
- nodes: nodes,
19
- notes: notes,
20
- project: project,
21
- reporting_cat: content_service.report_category,
22
- tags: tags,
23
- title: title,
24
- user: options[:user]
25
- }
26
- )
9
+ controller = args[:controller] || ApplicationController
10
+
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
27
30
  end
28
31
 
29
32
  private
@@ -92,6 +95,19 @@ module Dradis
92
95
  "Dradis Community Edition v#{Dradis::CE.version}"
93
96
  end
94
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
95
111
  end
96
112
  end
97
113
  end
@@ -7,8 +7,8 @@ module Dradis
7
7
  end
8
8
 
9
9
  module VERSION
10
- MAJOR = 3
11
- MINOR = 19
10
+ MAJOR = 4
11
+ MINOR = 0
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
@@ -15,9 +15,15 @@ class HtmlExportTasks < Thor
15
15
 
16
16
  report_path = options.output || Rails.root
17
17
  unless report_path.to_s =~ /\.html\z/
18
- date = DateTime.now.strftime("%Y-%m-%d")
19
- sequence = Dir.glob(File.join(report_path, "dradis-report_#{date}_*.html")).collect { |a| a.match(/_([0-9]+)\.html\z/)[1].to_i }.max || 0
20
- report_path = File.join(report_path, "dradis-report_#{date}_#{sequence + 1}.html")
18
+ date = DateTime.now.strftime("%Y-%m-%d")
19
+ base_filename = "dradis-report_#{date}.html"
20
+
21
+ report_filename = NamingService.name_file(
22
+ original_filename: base_filename,
23
+ pathname: Pathname.new(report_path)
24
+ )
25
+
26
+ report_path = File.join(report_path, report_filename)
21
27
  end
22
28
 
23
29
  if template = options.template
@@ -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.19.0
4
+ version: 4.0.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: 2020-09-04 00:00:00.000000000 Z
11
+ date: 2021-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dradis-plugins
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.6'
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.6'
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails_autolink
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -102,10 +106,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
106
  - !ruby/object:Gem::Version
103
107
  version: '0'
104
108
  requirements: []
105
- rubygems_version: 3.0.1
109
+ rubygems_version: 3.1.4
106
110
  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