dradis-html_export 4.2.0 → 4.5.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
- SHA256:
3
- metadata.gz: 3ea91825f0e0e103783e3d00268f924ca7a48eb7a6dee9328ba7566ba308b8e2
4
- data.tar.gz: df85040ddc235ad054ba657e947c7181daa0c877fc986beb5168d107f9dd64f3
2
+ SHA1:
3
+ metadata.gz: 7d690770a75919dbe976633d353e384b6afd54bf
4
+ data.tar.gz: 3d0e9dbe221f3a5383dd205c52bdaa350625eb7c
5
5
  SHA512:
6
- metadata.gz: b456de048f00e40bbdc594d705e1d486bf02e28470a9a701fa9e381e6c4ae10f52f3cf76283a91b65918a3786ab6215ab2cbe54a7d6cc9d76ece048aa725423c
7
- data.tar.gz: 23c4872736d4713ce8f13037305843eb475ded540782b9d56193faaff1c5ac0faa091367ca059885a958acc12149b98d91adc543bc1be345b579dd2d80b969b8
6
+ metadata.gz: c43f713508ba10e0ab2827cfc0de8bb41e7d1826bdc6f45302c1b7438e41bfdf4b8ada40354747095ecbbd894e8775dfbcb64dbf6cae9ec42b5e4b8df83e1074
7
+ data.tar.gz: 41a590d97cb1b25d7a2da590aa23a09e0aae62f47a607e6f4cc72d6bb87c44d42b9a96f926a25d84ebf7d3bbf74fde819eef261a749a9d6fbb0642301a984d2f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ v4.5.0 (August 2022)
2
+ - Add :rtp plugins feature
3
+
4
+ v4.4.0 (June 2022)
5
+ - No changes
6
+
7
+ v4.3.0 (April 2022)
8
+ - Add the RTP report title on export page in DradisPro
9
+
1
10
  v4.2.0 (February 2022)
2
11
  - No changes
3
12
 
@@ -0,0 +1,38 @@
1
+ module Dradis
2
+ module Plugins
3
+ module HtmlExport
4
+ class TemplatePresenter < BasePresenter
5
+ presents :template
6
+
7
+ def self.each_template(&block)
8
+ templates.each(&block)
9
+ end
10
+
11
+ def self.templates
12
+ if defined?(Dradis::Pro)
13
+ ReportTemplateProperties.all.where(plugin_name: :html_export).order(:title)
14
+ else
15
+ Dir["%s/*" % templates_dir].map { |t| File.basename(t) }.sort
16
+ end
17
+ end
18
+
19
+ def self.templates_dir
20
+ File.join(::Configuration::paths_templates_reports, 'html_export')
21
+ end
22
+
23
+ def title
24
+ return template if template.is_a?(String)
25
+
26
+ content_tag(:span, "#{template.title} - ") +
27
+ content_tag(:small, template.template_file)
28
+ end
29
+
30
+ def filename
31
+ return template if template.is_a?(String)
32
+
33
+ template.template_file
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,21 +1,20 @@
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
1
  <%= content_tag :div, id: 'plugin-html_export', class: 'tab-pane fade' do %>
7
2
  <%= form_tag project_export_manager_path(current_project), target: '_blank' do %>
8
3
  <%= hidden_field_tag :plugin, :html_export %>
9
4
  <%= hidden_field_tag :route, :root %>
10
5
 
11
6
  <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>
7
+ <p>Please choose one of the templates available for this plugin (find them in <code>.<%= Dradis::Plugins::HtmlExport::TemplatePresenter.templates_dir[Rails.root.to_s.length..-1] %></code>)</p>
13
8
 
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>
9
+ <% Dradis::Plugins::HtmlExport::TemplatePresenter.each_template do |template| %>
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 %>">
14
+ <%= template_presenter.title %>
15
+ </label>
16
+ </div>
17
+ <% end %>
19
18
  <% end %>
20
19
 
21
20
  <button id="export-button" class="btn btn-lg btn-primary mt-4">Export</button>
@@ -16,7 +16,7 @@ module Dradis
16
16
  include Dradis::Plugins::Base
17
17
 
18
18
  # plugin_name 'HTML export'
19
- provides :export
19
+ provides :export, :rtp
20
20
  description 'Generate advanced HTML reports'
21
21
 
22
22
 
@@ -8,7 +8,7 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 2
11
+ MINOR = 5
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
@@ -0,0 +1,47 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Dradis::Plugins::HtmlExport::TemplatePresenter do
4
+ class FakeView
5
+ include ActionView::Helpers::TextHelper
6
+ end
7
+
8
+ let(:template_presenter) { described_class.new(template, FakeView.new) }
9
+
10
+ describe '#title' do
11
+ context 'when template is a string' do
12
+ let(:template) { 'basic.html.erb' }
13
+
14
+ it 'returns the string' do
15
+ expect(template_presenter.title).to eq template
16
+ end
17
+ end
18
+
19
+ context 'when template is a RTP' do
20
+ let(:template) do
21
+ double(
22
+ 'ReportTemplateProperties',
23
+ title: 'Basic',
24
+ template_file: 'basic.html.erb'
25
+ )
26
+ end
27
+
28
+ it 'returns a formatted title' do
29
+ expect(template_presenter.title).to eq "<span>#{template.title} - </span><small>#{template.template_file}</small>"
30
+ end
31
+
32
+ context 'when title contains javascript' do
33
+ let(:template) do
34
+ double(
35
+ 'ReportTemplateProperties',
36
+ title: '<script>alert("hello world")</script>',
37
+ template_file: 'basic.html.erb'
38
+ )
39
+ end
40
+
41
+ it 'prevents cross site scriptiing' do
42
+ expect(template_presenter.title).to eq "<span>&lt;script&gt;alert(&quot;hello world&quot;)&lt;/script&gt; - </span><small>#{template.template_file}</small>"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ 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.2.0
4
+ version: 4.5.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: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dradis-plugins
@@ -70,6 +70,7 @@ files:
70
70
  - README.md
71
71
  - Rakefile
72
72
  - app/controllers/dradis/plugins/html_export/base_controller.rb
73
+ - app/presenters/dradis/plugins/html_export/template_presenter.rb
73
74
  - app/views/dradis/plugins/html_export/export/_index-content.html.erb
74
75
  - app/views/dradis/plugins/html_export/export/_index-tabs.html.erb
75
76
  - config/routes.rb
@@ -83,6 +84,7 @@ files:
83
84
  - lib/tasks/thorfile.rb
84
85
  - spec/fixtures/files/template.html.erb
85
86
  - spec/lib/dradis/plugins/html_export/exporter_spec.rb
87
+ - spec/presenters/dradis/plugins/html_export/template_presenter_spec.rb
86
88
  - spec/requests/html_export_spec.rb
87
89
  - spec/spec_helper.rb
88
90
  - templates/basic.html.erb
@@ -106,12 +108,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  - !ruby/object:Gem::Version
107
109
  version: '0'
108
110
  requirements: []
109
- rubygems_version: 3.1.4
111
+ rubyforge_project:
112
+ rubygems_version: 2.6.11
110
113
  signing_key:
111
114
  specification_version: 4
112
115
  summary: Dradis HTML export plugin
113
116
  test_files:
114
117
  - spec/fixtures/files/template.html.erb
115
118
  - spec/lib/dradis/plugins/html_export/exporter_spec.rb
119
+ - spec/presenters/dradis/plugins/html_export/template_presenter_spec.rb
116
120
  - spec/requests/html_export_spec.rb
117
121
  - spec/spec_helper.rb