dradis-html_export 3.13.0 → 3.18.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d59a2956d0e60bff6292cc581118db9407d49fb4
4
- data.tar.gz: 5ae8bc781be3e250547de65c397dca9b8d01e558
2
+ SHA256:
3
+ metadata.gz: 44a40f1bc271b8211123ed58ea69212e1bc4c8837da97d76194ebaa1485f29be
4
+ data.tar.gz: f58b4edfa716c6c77b3a7e264684777705cc46da2cf87f9bb02eb660ee6fa70e
5
5
  SHA512:
6
- metadata.gz: dd0c4ab53d98ee4d182a5c5dc47909928bf238d4c939043a86efd1a1208a8d2f88d2b9d9a847da3c3931259f16a6b8d66c4ee1e0345594880b99feb90d751ecb
7
- data.tar.gz: 47e352724497b250e69a9160452385dbd76ccbc9f580f62d87306e95d87a1d7e1dcddd22f00e4e24874f42c75a29c4fcfbd9b1583cd01f8229faa696fb6a701b
6
+ metadata.gz: 4e39c16ea0cdd301e70c106bc815372ff53fb8de163f6d6a5278869532988b6cb50ec6c0ad18f63786f5b6fc4655f1cbb008c1d75dd0f87e2d63cf4304c18d3a
7
+ data.tar.gz: 45a5b725f445b9849d2844124bbdc16604e77169e198eaed1c7e2b29cbb82119246c0026796c7e5091a0d129de4f8f6eccdff605ef21662f8676a591a9527b9d
@@ -0,0 +1,16 @@
1
+ ### Steps to reproduce
2
+
3
+ Help us help you, how can we reproduce the problem?
4
+
5
+ ### Expected behavior
6
+ Tell us what should happen
7
+
8
+ ### Actual behavior
9
+ Tell us what happens instead
10
+
11
+ ### System configuration
12
+ **Dradis version**:
13
+
14
+ **Ruby version**:
15
+
16
+ **OS version**:
@@ -0,0 +1,36 @@
1
+ ### Summary
2
+
3
+ Provide a general description of the code changes in your pull
4
+ request... were there any bugs you had fixed? If so, mention them. If
5
+ these bugs have open GitHub issues, be sure to tag them here as well,
6
+ to keep the conversation linked together.
7
+
8
+
9
+ ### Other Information
10
+
11
+ If there's anything else that's important and relevant to your pull
12
+ request, mention that information here. This could include
13
+ benchmarks, or other information.
14
+
15
+ Thanks for contributing to Dradis!
16
+
17
+
18
+ ### Copyright assignment
19
+
20
+ Collaboration is difficult with commercial closed source but we want
21
+ to keep as much of the OSS ethos as possible available to users
22
+ who want to fix it themselves.
23
+
24
+ In order to unambiguously own and sell Dradis Framework commercial
25
+ products, we must have the copyright associated with the entire
26
+ codebase. Any code you create which is merged must be owned by us.
27
+ That's not us trying to be a jerks, that's just the way it works.
28
+
29
+ Please review the [CONTRIBUTING.md](https://github.com/dradis/dradis-ce/blob/master/CONTRIBUTING.md)
30
+ file for the details.
31
+
32
+ You can delete this section, but the following sentence needs to
33
+ remain in the PR's description:
34
+
35
+ > I assign all rights, including copyright, to any future Dradis
36
+ > work by myself to Security Roots.
@@ -1,3 +1,24 @@
1
+ ## Dradis Framework 3.18 (July, 2020) ##
2
+
3
+ * No changes.
4
+
5
+ ## Dradis Framework 3.17 (May, 2020) ##
6
+
7
+ * Render report using main app's ApplicationController#render.
8
+
9
+ ## Dradis Framework 3.16 (February, 2020) ##
10
+
11
+ * No changes.
12
+
13
+ ## Dradis Framework 3.15 (November, 2019) ##
14
+
15
+ * No changes.
16
+
17
+
18
+ ## Dradis Framework 3.14 (August, 2019) ##
19
+
20
+ * No changes.
21
+
1
22
  ## Dradis Framework 3.13 (June, 2019) ##
2
23
 
3
24
  * No changes.
@@ -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
- template_path = options.fetch(:template)
13
- template_properties = ::ReportTemplateProperties.find_by_template_file(File.basename(template_path)) rescue nil
8
+ log_report
14
9
 
15
- # Build title
16
- title = if Dradis.constants.include?(:Pro)
17
- "Dradis Professional Edition v#{Dradis::Pro.version}"
18
- else
19
- "Dradis Community Edition v#{Dradis::CE.version}"
20
- end
21
- logger.debug{ "Report title: #{title}"}
22
-
23
- # Prepare notes
24
- reporting_cat = content_service.report_category
25
- notes = content_service.all_notes
26
- logger.debug{ "Found #{notes.count} notes assigned to the reporting category."}
27
-
28
- # Prepare issues
29
- issues = content_service.all_issues
30
- if issues
31
- # Sort our issues based on the ReportTemplateProperties rules.
32
- if template_properties && template_properties.sort_field
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
- logger.debug{ "Template properties define a sort field: #{sort_by}. Sorting..." }
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
- # 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
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
- logger.debug{ "Done." }
43
- end
40
+ logger.debug { "Found #{notes.count} notes assigned to the reporting category." }
41
+ end
44
42
 
45
- # FIXME: This is an ugly piece of code and the list of nodes should
46
- # come from the ContentService.
47
- nodes = issues.map(&:evidence).flatten.map(&:node).uniq
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
- logger.debug{ "Found #{issues.count} issues affecting #{nodes.count} nodes" }
50
- else
51
- logger.warning { "No issue library node found in this project" }
52
- end
49
+ def notes
50
+ @notes ||= content_service.all_notes
51
+ end
53
52
 
54
- # Render template
55
- erb = ERB.new( File.read(template_path) )
56
- erb.result( binding )
53
+ def issues
54
+ @issues ||= sort_issues content_service.all_issues.includes(:tags)
57
55
  end
58
56
 
59
- private
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
- # FIXME This method is a behavioural duplicate of ApplicationHelper#markup
62
- # from the main app, it would be better to re-use that code.
63
- def markup(text)
64
- return unless text.present?
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
- # escape HTML 'manually' instead of using RedCloth's "filter_html"
67
- # for security reasons
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
- Hash[ *text.scan(/#\[(.+?)\]#[\r|\n](.*?)(?=#\[|\z)/m).flatten.collect{ |str| str.strip } ].keys.each do |field|
71
- output.gsub!(/#\[#{Regexp.escape(field)}\]#[\r|\n]/, "h4. #{field}\n\n")
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
- auto_link(RedCloth.new(output, [:no_span_caps]).to_html).html_safe
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
@@ -8,7 +8,7 @@ module Dradis
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 3
11
- MINOR = 13
11
+ MINOR = 18
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
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.13.0
4
+ version: 3.18.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: 2019-06-10 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dradis-plugins
@@ -59,6 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/issue_template.md"
63
+ - ".github/pull_request_template.md"
62
64
  - ".gitignore"
63
65
  - ".rspec"
64
66
  - ".travis.yml"
@@ -100,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.6.12
105
+ rubygems_version: 3.1.2
105
106
  signing_key:
106
107
  specification_version: 4
107
108
  summary: Dradis HTML export plugin