dradis-html_export 3.19.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/app/views/dradis/plugins/html_export/export/_index-content.html.erb +23 -0
- data/app/views/dradis/plugins/html_export/export/_index-tabs.html.erb +3 -0
- data/dradis-html_export.gemspec +1 -1
- data/lib/dradis/plugins/html_export/exporter.rb +34 -18
- data/lib/dradis/plugins/html_export/gem_version.rb +2 -2
- data/lib/tasks/thorfile.rb +9 -3
- data/spec/fixtures/files/template.html.erb +12 -0
- data/spec/lib/dradis/plugins/html_export/exporter_spec.rb +25 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e30ca0b3eebbe1ddc727fd0b9f9197b25490f545913c9e666282f40508bd858
|
4
|
+
data.tar.gz: 46ab64967389ecd8687c5dbba547ca78b1446bc97ff965f2851983e3ccc168b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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%>
|
data/dradis-html_export.gemspec
CHANGED
@@ -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', '~>
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
data/lib/tasks/thorfile.rb
CHANGED
@@ -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
|
19
|
-
|
20
|
-
|
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,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:
|
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:
|
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:
|
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:
|
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.
|
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
|