dradis-html_export 4.7.0 → 4.9.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: ae758e02f855542073277aa3b444e2d3fce2bbfd9272597b38432c83ca0d87f0
4
- data.tar.gz: ae4ed11607ecf26f9f098d223119033815099d1605acec28bb4a19ff3f1c2db5
3
+ metadata.gz: 4f159a418d2f4dea8f4b57772360b8bb3d687c1df4f311a5277da61135532984
4
+ data.tar.gz: fef4201229f3d73ea441747f072d25b411709cefcd27e9423b2b7ab9af82b310
5
5
  SHA512:
6
- metadata.gz: 02063660baee8928849fd5a36ae24f73e5661cf96ba6305d551921e34456e894304ed98e36337e095a4ff7438cbfa2e1bc51fb5174645d96ee94707d2e5af51c
7
- data.tar.gz: 62ec459d7a00ab9d849a8966a10c42a73695cc7c07920bb5cecaa79093758de5767721b11f1715ec4eea5a5e942f7b87b59411e1f17ec12de3ed9c08fee06a75
6
+ metadata.gz: 799c8f3fc2a9a8209b12c307ce0fa544497b38825fe669002e56e4986050a85ba7aaaa5f0dcffe6da27cd1057f52c6eabe3e2efac8f96f69794f8f0eb02fcb06
7
+ data.tar.gz: af728f464fc65494da24da642b173434dbd7d31146438a96bd2690a166f266324f4fe6867f3bd509b8a743acebef4293f34a38c647c9552dbb8e806d5c7bc95e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ v4.9.0 (June 2023)
2
+ - Update views for compatibility with Bootstrap 5
3
+
4
+ v4.8.0 (April 2023)
5
+ - Add feature to select published/all records for export
6
+
1
7
  v4.7.0 (February 2023)
2
8
  - No changes
3
9
 
@@ -7,13 +7,12 @@ module Dradis
7
7
  #
8
8
  # It uses the template at: ./vendor/plugins/html_export/template.html.erb
9
9
  def index
10
- exporter = Dradis::Plugins::HtmlExport::Exporter.new(export_options)
11
- html = exporter.export
10
+ exporter = Dradis::Plugins::HtmlExport::Exporter.new(export_params)
11
+ html = exporter.export
12
12
 
13
13
  render html: html.html_safe
14
14
  end
15
15
  end
16
-
17
16
  end
18
17
  end
19
18
  end
@@ -8,15 +8,17 @@
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>
17
17
  <% end %>
18
18
  <% end %>
19
19
 
20
- <button id="export-button" class="btn btn-lg btn-primary mt-4">Export</button>
20
+ <div class="mt-4">
21
+ <%= render partial: 'export/submit_button', locals: { plugin_name: Dradis::Plugins::HtmlExport::Engine.plugin_name } %>
22
+ </div>
21
23
  <% end %>
22
24
  <% end%>
@@ -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='nav-link' data-bs-toggle='tab'>HTML</a>
3
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', '~> 4.0'
24
+ spec.add_dependency 'dradis-plugins', '>= 4.8.0'
25
25
 
26
26
  # Note markup
27
27
  spec.add_dependency 'rails_autolink', '~> 1.1'
@@ -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,7 +8,7 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 7
11
+ MINOR = 9
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, 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,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dradis-html_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 4.9.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: 2023-02-20 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dradis-plugins
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 4.8.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: '4.0'
26
+ version: 4.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails_autolink
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -113,6 +114,7 @@ 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