dradis-html_export 3.16.0 → 3.17.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 +4 -3
- data/lib/dradis/plugins/html_export/exporter.rb +72 -53
- data/lib/dradis/plugins/html_export/gem_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ff810f1056abb025188e810af787950b710ed140b919a3c4c8e28750bbdb757
|
4
|
+
data.tar.gz: 0bf32f0708e38397d807df364ac6a781f23c2cf4a2aaeaf930830e2745c98f8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b85f5c997dbe5664c007ef8b1c40010cf38e123bf57360a5ddf32b6686d33b79ae9d5dc411913945fa5c97f18f8c259c960a1710cb414ee2dea117519234d177
|
7
|
+
data.tar.gz: 6a60cacc47c5fbe64431a9f47865dff2f3fa645e53c1d2b13fb733a279b63794cd9e7f6c610bfe996083dc6d3ecb8e9caf723b5f8a77206e8a73a60eaf4cce52
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## Dradis Framework 3.17 (May, 2020) ##
|
2
|
+
|
3
|
+
* Render report using main app's ApplicationController#render.
|
4
|
+
|
1
5
|
## Dradis Framework 3.16 (February, 2020) ##
|
2
6
|
|
3
7
|
* No changes.
|
@@ -6,9 +10,6 @@
|
|
6
10
|
|
7
11
|
* No changes.
|
8
12
|
|
9
|
-
## Dradis Framework 3.15 (August, 2019) ##
|
10
|
-
|
11
|
-
* No changes.
|
12
13
|
|
13
14
|
## Dradis Framework 3.14 (August, 2019) ##
|
14
15
|
|
@@ -3,75 +3,94 @@ 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
|
-
template_properties = ::ReportTemplateProperties.find_by_template_file(File.basename(template_path)) rescue nil
|
8
|
+
log_report
|
14
9
|
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
sort_by = template_properties.sort_field
|
10
|
+
# Render template
|
11
|
+
ApplicationController.render(
|
12
|
+
file: options.fetch(:template),
|
13
|
+
layout: false,
|
14
|
+
locals: {
|
15
|
+
categorized_issues: categorized_issues,
|
16
|
+
content_service: content_service,
|
17
|
+
issues: issues,
|
18
|
+
nodes: nodes,
|
19
|
+
notes: notes,
|
20
|
+
project: project,
|
21
|
+
reporting_cat: content_service.report_category,
|
22
|
+
tags: tags,
|
23
|
+
title: title,
|
24
|
+
user: options[:user]
|
25
|
+
}
|
26
|
+
)
|
27
|
+
end
|
34
28
|
|
35
|
-
|
29
|
+
private
|
30
|
+
def log_report
|
31
|
+
logger.debug { "Report title: #{title}" }
|
32
|
+
logger.debug { "Template properties define a sort field: #{sort_field}" }
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
if issues&.any?
|
35
|
+
logger.debug { "Found #{issues.count} issues affecting #{nodes.count} nodes" }
|
36
|
+
else
|
37
|
+
logger.warn { 'No issue library node found in this project' }
|
38
|
+
end
|
41
39
|
|
42
|
-
|
43
|
-
|
40
|
+
logger.debug { "Found #{notes.count} notes assigned to the reporting category." }
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
def nodes
|
44
|
+
# FIXME: This is an ugly piece of code and the list of nodes should
|
45
|
+
# come from the ContentService.
|
46
|
+
@nodes ||= issues.map(&:evidence).flatten.map(&:node).uniq
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
49
|
+
def notes
|
50
|
+
@notes ||= content_service.all_notes
|
51
|
+
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
erb.result( binding )
|
53
|
+
def issues
|
54
|
+
@issues ||= sort_issues content_service.all_issues.includes(:tags)
|
57
55
|
end
|
58
56
|
|
59
|
-
|
57
|
+
def categorized_issues
|
58
|
+
@categorized_issues ||= tags
|
59
|
+
.each_with_object({}) do |tag, hash|
|
60
|
+
hash[tag.id] = issues.select { |issue| issue.tags.include?(tag) }
|
61
|
+
end
|
62
|
+
.tap do |hash|
|
63
|
+
hash[:untagged] = issues.select { |issue| issue.tags.empty? }
|
64
|
+
end
|
65
|
+
end
|
60
66
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
67
|
+
def sort_field
|
68
|
+
@sort_field ||= begin
|
69
|
+
template_path = options.fetch(:template)
|
70
|
+
properties = ::ReportTemplateProperties.find_by_template_file(File.basename(template_path)) rescue nil
|
71
|
+
properties&.sort_field
|
72
|
+
end
|
73
|
+
end
|
65
74
|
|
66
|
-
|
67
|
-
|
68
|
-
output = ERB::Util.html_escape(text.dup)
|
75
|
+
def sort_issues(unsorted_issues)
|
76
|
+
return unsorted_issues unless unsorted_issues.any? && sort_field
|
69
77
|
|
70
|
-
|
71
|
-
|
78
|
+
# FIXME: Assume the Field :type is :number, so cast .to_f and sort
|
79
|
+
unsorted_issues.sort do |a, b|
|
80
|
+
b.fields.fetch(sort_field, '0').to_f <=> a.fields.fetch(sort_field, '0').to_f
|
72
81
|
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def tags
|
85
|
+
@tags ||= project.tags
|
86
|
+
end
|
73
87
|
|
74
|
-
|
88
|
+
def title
|
89
|
+
@title ||= if Dradis.constants.include?(:Pro)
|
90
|
+
"Dradis Professional Edition v#{Dradis::Pro.version}"
|
91
|
+
else
|
92
|
+
"Dradis Community Edition v#{Dradis::CE.version}"
|
93
|
+
end
|
75
94
|
end
|
76
95
|
end
|
77
96
|
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: 3.
|
4
|
+
version: 3.17.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: 2020-02
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dradis-plugins
|