dradis-html_export 3.15.0 → 3.20.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 +4 -4
- data/CHANGELOG.md +20 -2
- data/lib/dradis/plugins/html_export/exporter.rb +76 -55
- data/lib/dradis/plugins/html_export/gem_version.rb +1 -1
- data/lib/tasks/thorfile.rb +9 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f6ac583114b620b0f712eec9d0d4635012a0566e1b6b5bf6e331b708991c223
|
4
|
+
data.tar.gz: 571a3c231cddac14d08577f6811dd8beab715a0387fc763a99ce57b8340e9110
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6700179c827068d2810787d028bdc0621f918e86588d7c666547e7ea00be5425e141b15740cab0b0afe359021f13e28e1300c4a03edd87e7e2b86cd0b6adb1b8
|
7
|
+
data.tar.gz: 36b73d54c2167cf49063882d9521e6954562331a3edc4464ec77b3f951302ad8ebc20ded1b9a7d996acc369e2000364ee916b0d2e6a5b1a2038d43ae6a7b1800
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,29 @@
|
|
1
|
-
## Dradis Framework 3.
|
1
|
+
## Dradis Framework 3.20 (December, 2020) ##
|
2
|
+
|
3
|
+
* Add an option in the exporter to pass a controller for rendering.
|
4
|
+
* Use NamingService to build export filename.
|
5
|
+
|
6
|
+
## Dradis Framework 3.19 (September, 2020) ##
|
2
7
|
|
3
8
|
* No changes.
|
4
9
|
|
5
|
-
## Dradis Framework 3.
|
10
|
+
## Dradis Framework 3.18 (July, 2020) ##
|
6
11
|
|
7
12
|
* No changes.
|
8
13
|
|
14
|
+
## Dradis Framework 3.17 (May, 2020) ##
|
15
|
+
|
16
|
+
* Render report using main app's ApplicationController#render.
|
17
|
+
|
18
|
+
## Dradis Framework 3.16 (February, 2020) ##
|
19
|
+
|
20
|
+
* No changes.
|
21
|
+
|
22
|
+
## Dradis Framework 3.15 (November, 2019) ##
|
23
|
+
|
24
|
+
* No changes.
|
25
|
+
|
26
|
+
|
9
27
|
## Dradis Framework 3.14 (August, 2019) ##
|
10
28
|
|
11
29
|
* No changes.
|
@@ -3,75 +3,96 @@ module Dradis
|
|
3
3
|
module HtmlExport
|
4
4
|
|
5
5
|
class Exporter < Dradis::Plugins::Export::Base
|
6
|
-
# Add auto_link support to the ERB processor (see rails_autolink)
|
7
|
-
include ::ActionView::Helpers::TextHelper
|
8
|
-
# For auto_link feature (requires #mail_to)
|
9
|
-
include ::ActionView::Helpers::UrlHelper
|
10
6
|
|
11
7
|
def export(args = {})
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
logger.debug{ "Template properties define a sort field: #{sort_by}. Sorting..." }
|
36
|
-
|
37
|
-
# FIXME: Assume the Field :type is :number, so cast .to_f and sort
|
38
|
-
issues.to_a.sort! do |a, b|
|
39
|
-
b.fields.fetch(sort_by, '0').to_f <=> a.fields.fetch(sort_by, '0').to_f
|
40
|
-
end
|
41
|
-
|
42
|
-
logger.debug{ "Done." }
|
43
|
-
end
|
8
|
+
log_report
|
9
|
+
|
10
|
+
controller = args[:controller] || ApplicationController
|
11
|
+
|
12
|
+
# Render template
|
13
|
+
controller.render(
|
14
|
+
file: options.fetch(: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
|
44
30
|
|
45
|
-
|
46
|
-
|
47
|
-
|
31
|
+
private
|
32
|
+
def log_report
|
33
|
+
logger.debug { "Report title: #{title}" }
|
34
|
+
logger.debug { "Template properties define a sort field: #{sort_field}" }
|
48
35
|
|
49
|
-
|
36
|
+
if issues&.any?
|
37
|
+
logger.debug { "Found #{issues.count} issues affecting #{nodes.count} nodes" }
|
50
38
|
else
|
51
|
-
logger.
|
39
|
+
logger.warn { 'No issue library node found in this project' }
|
52
40
|
end
|
53
41
|
|
54
|
-
#
|
55
|
-
erb = ERB.new( File.read(template_path) )
|
56
|
-
erb.result( binding )
|
42
|
+
logger.debug { "Found #{notes.count} notes assigned to the reporting category." }
|
57
43
|
end
|
58
44
|
|
59
|
-
|
45
|
+
def nodes
|
46
|
+
# FIXME: This is an ugly piece of code and the list of nodes should
|
47
|
+
# come from the ContentService.
|
48
|
+
@nodes ||= issues.map(&:evidence).flatten.map(&:node).uniq
|
49
|
+
end
|
50
|
+
|
51
|
+
def notes
|
52
|
+
@notes ||= content_service.all_notes
|
53
|
+
end
|
60
54
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
return unless text.present?
|
55
|
+
def issues
|
56
|
+
@issues ||= sort_issues content_service.all_issues.includes(:tags)
|
57
|
+
end
|
65
58
|
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
def categorized_issues
|
60
|
+
@categorized_issues ||= tags
|
61
|
+
.each_with_object({}) do |tag, hash|
|
62
|
+
hash[tag.id] = issues.select { |issue| issue.tags.include?(tag) }
|
63
|
+
end
|
64
|
+
.tap do |hash|
|
65
|
+
hash[:untagged] = issues.select { |issue| issue.tags.empty? }
|
66
|
+
end
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
|
69
|
+
def sort_field
|
70
|
+
@sort_field ||= begin
|
71
|
+
template_path = options.fetch(:template)
|
72
|
+
properties = ::ReportTemplateProperties.find_by_template_file(File.basename(template_path)) rescue nil
|
73
|
+
properties&.sort_field
|
72
74
|
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def sort_issues(unsorted_issues)
|
78
|
+
return unsorted_issues unless unsorted_issues.any? && sort_field
|
79
|
+
|
80
|
+
# FIXME: Assume the Field :type is :number, so cast .to_f and sort
|
81
|
+
unsorted_issues.sort do |a, b|
|
82
|
+
b.fields.fetch(sort_field, '0').to_f <=> a.fields.fetch(sort_field, '0').to_f
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def tags
|
87
|
+
@tags ||= project.tags
|
88
|
+
end
|
73
89
|
|
74
|
-
|
90
|
+
def title
|
91
|
+
@title ||= if Dradis.constants.include?(:Pro)
|
92
|
+
"Dradis Professional Edition v#{Dradis::Pro.version}"
|
93
|
+
else
|
94
|
+
"Dradis Community Edition v#{Dradis::CE.version}"
|
95
|
+
end
|
75
96
|
end
|
76
97
|
end
|
77
98
|
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
|
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.
|
4
|
+
version: 3.20.0
|
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:
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dradis-plugins
|
@@ -87,7 +87,7 @@ homepage: http://dradisframework.org
|
|
87
87
|
licenses:
|
88
88
|
- GPL-2
|
89
89
|
metadata: {}
|
90
|
-
post_install_message:
|
90
|
+
post_install_message:
|
91
91
|
rdoc_options: []
|
92
92
|
require_paths:
|
93
93
|
- lib
|
@@ -102,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
106
|
-
signing_key:
|
105
|
+
rubygems_version: 3.2.4
|
106
|
+
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Dradis HTML export plugin
|
109
109
|
test_files:
|