dradis-html_export 4.8.0 → 4.9.1

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: 33775e0ad945bd81755715cbf8e456e5dff150b8c68345b81939ff638e845492
4
- data.tar.gz: ad4c037605dfeddead30d36ee617face34fb654dfff8644d3749406d52b1e8c9
3
+ metadata.gz: ca36e1c731fed6fecd0df85b0f3e4f8d767b8165c683cab6fa1c9f306d61f741
4
+ data.tar.gz: 847247d60414d9ab8c1342318421d15b5e2b1cdf1103f6c061ee03d4b21fba23
5
5
  SHA512:
6
- metadata.gz: 1cf2fba75c376bf10f08b1db6fefe02b924a4f3969400bbb2177f2d2dae0da4db5899c6ebe6cd4f1267564f3633594e29a1cc7d339930863b440cec6f48b3ee0
7
- data.tar.gz: 507a013795af1a52eb554622faf4257f789b6be034169f4bb325c2691b2ffca0ff53dd33bf1610897aedd41d0306aa33fad3c448731444c748a389b4ebbd35be
6
+ metadata.gz: afad897697ffc0473072d1b2bf4b074724c3ec38286a3328eb34c654bff1676543168d3ef5081b1fa51dfaae8c1bd1eb7a754a95e66327399cd284a4c03585dd
7
+ data.tar.gz: ed111b118353cc1419f6d141975275a4982ca910aefd139bf6bf286bbd8372902d98c1d889051883c3242102ce627663b23c4d36fd0a9556fd0de627e2f0ced2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ v4.9.1 (June 2023)
2
+ - Show HTML export tab by default in CE's export view
3
+
4
+ v4.9.0 (June 2023)
5
+ - Update views for compatibility with Bootstrap 5
6
+
1
7
  v4.8.0 (April 2023)
2
8
  - Add feature to select published/all records for export
3
9
 
@@ -1,4 +1,4 @@
1
- <%= content_tag :div, id: 'plugin-html_export', class: 'tab-pane fade' do %>
1
+ <%= content_tag :div, id: 'plugin-html_export', class: class_names('tab-pane', 'fade', 'active show': !defined?(Dradis::Pro)) do %>
2
2
  <%= form_tag project_export_manager_path(current_project), target: '_blank' do %>
3
3
  <%= hidden_field_tag :plugin, :html_export %>
4
4
  <%= hidden_field_tag :route, :root %>
@@ -8,9 +8,9 @@
8
8
 
9
9
  <% Dradis::Plugins::HtmlExport::TemplatePresenter.each_template do |template| %>
10
10
  <% present(template, Dradis::Plugins::HtmlExport::TemplatePresenter) do |template_presenter| %>
11
- <div class="custom-control custom-radio">
12
- <%= radio_button_tag :template, template_presenter.filename, Dradis::Plugins::HtmlExport::TemplatePresenter.templates.first == template , class: 'custom-control-input' %>
13
- <label class="custom-control-label" for="template_<%= template_presenter.filename %>">
11
+ <div class="form-check">
12
+ <%= radio_button_tag :template, template_presenter.filename, Dradis::Plugins::HtmlExport::TemplatePresenter.templates.first == template , class: 'form-check-input' %>
13
+ <label class="form-check-label" for="template_<%= template_presenter.filename %>">
14
14
  <%= template_presenter.title %>
15
15
  </label>
16
16
  </div>
@@ -1,3 +1,3 @@
1
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>
2
+ <a href='#plugin-html_export' class="<%= class_names('nav-link', active: !defined?(Dradis::Pro)) %>" data-bs-toggle='tab'>HTML</a>
3
3
  </li>
@@ -2,7 +2,6 @@ module Dradis
2
2
  module Plugins
3
3
  module HtmlExport
4
4
  class Engine < ::Rails::Engine
5
-
6
5
  # Standard Rails Engine stuff
7
6
  isolate_namespace Dradis::Plugins::HtmlExport
8
7
  engine_name 'dradis_html_export'
@@ -19,12 +18,17 @@ module Dradis
19
18
  provides :export, :rtp
20
19
  description 'Generate advanced HTML reports'
21
20
 
22
-
23
21
  initializer 'dradis-html_export.mount_engine' do
24
22
  Rails.application.routes.append do
25
23
  mount Dradis::Plugins::HtmlExport::Engine => '/export/html'
26
24
  end
27
25
  end
26
+
27
+ initializer 'draids-html_export.include_helper' do
28
+ ActiveSupport.on_load(:action_view) do
29
+ Dradis::Plugins::HtmlExport::Exporter.include(ApplicationHelper)
30
+ end
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -1,31 +1,13 @@
1
1
  module Dradis
2
2
  module Plugins
3
3
  module HtmlExport
4
-
5
4
  class Exporter < Dradis::Plugins::Export::Base
6
5
  def export(args = {})
7
6
  log_report
8
7
 
9
- controller = args[:controller] || ApplicationController
10
-
11
8
  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
- )
9
+ erb = ERB.new(File.read(temporary_template))
10
+ erb.result(binding)
29
11
  end
30
12
  end
31
13
 
@@ -89,11 +71,30 @@ module Dradis
89
71
  end
90
72
 
91
73
  def title
92
- @title ||= if Dradis.constants.include?(:Pro)
93
- "Dradis Professional Edition v#{Dradis::Pro.version}"
94
- else
95
- "Dradis Community Edition v#{Dradis::CE.version}"
96
- end
74
+ @title ||=
75
+ if Dradis.constants.include?(:Pro)
76
+ "Dradis Professional Edition v#{Dradis::Pro.version}"
77
+ else
78
+ "Dradis Community Edition v#{Dradis::CE.version}"
79
+ end
80
+ end
81
+
82
+ def liquid_assigns
83
+ assigns = {
84
+ 'issues' => issues.map { |issue| IssueDrop.new(issue) },
85
+ 'nodes' => nodes.map { |node| NodeDrop.new(node) },
86
+ 'project' => ProjectDrop.new(project),
87
+ 'tags' => tags.map { |tag| TagDrop.new(tag) }
88
+ }
89
+
90
+ if defined?(Dradis::Pro)
91
+ assigns.merge!(
92
+ 'content_blocks' => content_service.all_content_blocks.map { |c| ContentBlockDrop.new(c) },
93
+ 'document_properties' => DocumentPropertiesDrop.new(properties: project.content_library.properties)
94
+ )
95
+ end
96
+
97
+ assigns
97
98
  end
98
99
 
99
100
  def with_temporary_template(original, &block)
@@ -103,7 +104,7 @@ module Dradis
103
104
  FileUtils.mkdir_p(File.dirname(destination_path))
104
105
  FileUtils.cp(original, destination_path)
105
106
 
106
- yield("tmp/#{filename}")
107
+ yield(destination_path)
107
108
  ensure
108
109
  file_path = Rails.root.join("app/views/tmp/#{filename}")
109
110
  File.delete(file_path) if File.exists?(file_path)
@@ -8,8 +8,8 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 8
12
- TINY = 0
11
+ MINOR = 9
12
+ TINY = 1
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -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, liquid: true) %></p>
10
+ <% end %>
11
+ </body>
12
+ </html>
@@ -1,25 +1,108 @@
1
1
  require 'rails_helper'
2
2
 
3
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
4
+ let!(:project) { create(:project, :with_team) }
5
+
6
+ let!(:content_blocks) { create_list(:content_block, 5, project: project) }
7
+ let!(:issues) { create_list(:issue, 5, node: project.issue_library) }
8
+ let!(:nodes) { create_list(:node, 5, project: project) }
9
+ let!(:tags) { create_list(:tag, 5, project: project) }
10
+
11
+ let(:controller) { Dradis::Plugins::HtmlExport::BaseController.new }
15
12
 
16
13
  let(:exporter) { described_class.new(export_options) }
17
14
 
18
- it 'exports html' do
19
- html = exporter.export
15
+ context 'html' do
16
+ let(:export_options) do
17
+ {
18
+ project_id: project.id,
19
+ template: Dradis::Plugins::HtmlExport::Engine.root.join(
20
+ 'spec/fixtures/files/template.html.erb'
21
+ )
22
+ }
23
+ end
24
+
25
+ it 'exports html' do
26
+ html = exporter.export
27
+
28
+ issues.each do |issue|
29
+ expect(html.include?(issue.title))
30
+ end
31
+ end
32
+ end
33
+
34
+ context 'liquid' do
35
+ let(:export_options) do
36
+ {
37
+ project_id: project.id,
38
+ template: Dradis::Plugins::HtmlExport::Engine.root.join(
39
+ 'spec/fixtures/files/liquid.html.erb'
40
+ )
41
+ }
42
+ end
43
+
44
+ before do
45
+ report_content = project.content_library
46
+ report_content.properties = {
47
+ 'dradis.project' => project.name,
48
+ 'dradis.version' => 'v1.0'
49
+ }
50
+ report_content.save
51
+
52
+ nodes.each do |node|
53
+ create(:evidence, node: node, issue: issues.first)
54
+ end
55
+
56
+ create(:issue,
57
+ node: project.issue_library,
58
+ text: <<-TEXT
59
+ #[Title]#
60
+ Test Issue
61
+
62
+ #[Description]#
63
+ *Project:* {{ project.name }}
64
+ *Document Properties:*
65
+ * {{ document_properties.dradis.project }}
66
+ * {{ document_properties.dradis.version }}
67
+
68
+ *Nodes:*
69
+ {% for node in nodes %}
70
+ * {{ node.label }}
71
+ {% endfor %}
72
+
73
+ *Content blocks:*
74
+ {% for content_block in content_blocks %}
75
+ * {{ content_block.fields['Title'] }}
76
+ {% endfor %}
77
+
78
+ *Tags:*
79
+ {% for tag in tags %}
80
+ * {{ tag.name }}
81
+ {% endfor %}
82
+ TEXT
83
+ )
84
+ end
85
+
86
+ it 'parses liquid syntax' do
87
+ html = exporter.export
88
+
89
+ expect(html).to include project.name
90
+
91
+ project.content_library.properties.each do |_, value|
92
+ expect(html).to include value
93
+ end
94
+
95
+ nodes.each do |node|
96
+ expect(html).to include node.label
97
+ end
98
+
99
+ content_blocks.each do |content_block|
100
+ expect(html).to include content_block.title
101
+ end
20
102
 
21
- issues.each do |issue|
22
- expect(html.include?(issue.title))
103
+ tags.each do |tag|
104
+ expect(html).to include tag.name
105
+ end
23
106
  end
24
107
  end
25
108
  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: 4.8.0
4
+ version: 4.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Martin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-12 00:00:00.000000000 Z
11
+ date: 2023-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dradis-plugins
@@ -82,6 +82,7 @@ files:
82
82
  - lib/dradis/plugins/html_export/gem_version.rb
83
83
  - lib/dradis/plugins/html_export/version.rb
84
84
  - lib/tasks/thorfile.rb
85
+ - spec/fixtures/files/liquid.html.erb
85
86
  - spec/fixtures/files/template.html.erb
86
87
  - spec/lib/dradis/plugins/html_export/exporter_spec.rb
87
88
  - spec/presenters/dradis/plugins/html_export/template_presenter_spec.rb
@@ -93,7 +94,7 @@ homepage: http://dradisframework.org
93
94
  licenses:
94
95
  - GPL-2
95
96
  metadata: {}
96
- post_install_message:
97
+ post_install_message:
97
98
  rdoc_options: []
98
99
  require_paths:
99
100
  - lib
@@ -108,11 +109,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.3.7
112
- signing_key:
112
+ rubygems_version: 3.0.3.1
113
+ signing_key:
113
114
  specification_version: 4
114
115
  summary: Dradis HTML export plugin
115
116
  test_files:
117
+ - spec/fixtures/files/liquid.html.erb
116
118
  - spec/fixtures/files/template.html.erb
117
119
  - spec/lib/dradis/plugins/html_export/exporter_spec.rb
118
120
  - spec/presenters/dradis/plugins/html_export/template_presenter_spec.rb