dradis-plugins 3.6.0 → 3.7.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
2
  SHA1:
3
- metadata.gz: d94fcec6ee192333a702bf277c2f1362d42b388e
4
- data.tar.gz: 8a87e09bee59fed75707f5254492f0f39ca9191c
3
+ metadata.gz: b4465a6abfcfcc1f72c2507db25a1fec1c078539
4
+ data.tar.gz: 451a8b3b7676968c4f2cd9640ed975b02cb31d77
5
5
  SHA512:
6
- metadata.gz: 92eadbdcd4e11ebae0dab886c64bae45b49c55bbbc886cc7af4676a7ab57b2ce8c38dc89fbdb4c528a4c36b1da2bb830b75fd18258e0025f3cf28b41e8043e27
7
- data.tar.gz: f17974a6a3ab0d402314457282a74f98751dc64d20e2b2f4035ca7bc2d57d79515cb6b47d0a948a420bbffa84c6b24f76a51fe38013de9c486d44b33f1e72ead
6
+ metadata.gz: 38544da5415a6f1107a641b549e20b088767a58c040e97842a3f314813d2563fb313ceeaeb0dc2e60060760928d6f6cff23a1d2d55109a49674cbd31261e9b34
7
+ data.tar.gz: 918e42243f03461549f368abf0e2f59ce60a6dcf0428ed56bd3b77645d5c94d41fdbc12e6374c78eb2f38ef44c811e66c3709a888ece8866059b7258c1a992a2
@@ -1,4 +1,12 @@
1
- ## Dradis Framework 3.6 (March XX, 2017) ##
1
+ ## Dradis Framework 3.7 (July, 2017) ##
2
+
3
+ * Add ContentService#all_properties method to access the current project's
4
+ document properties.
5
+
6
+ * Don't lose :plugin and :plugin_id from ContentService#create_issue due to
7
+ excessive input length.
8
+
9
+ ## Dradis Framework 3.6 (April 6, 2017) ##
2
10
 
3
11
  * Split the ContentService into multiple modules.
4
12
 
@@ -5,6 +5,7 @@ require 'dradis/plugins/content_service/evidence'
5
5
  require 'dradis/plugins/content_service/issues'
6
6
  require 'dradis/plugins/content_service/nodes'
7
7
  require 'dradis/plugins/content_service/notes'
8
+ require 'dradis/plugins/content_service/properties'
8
9
 
9
10
  module Dradis::Plugins::ContentService
10
11
  class Base
@@ -16,6 +17,7 @@ module Dradis::Plugins::ContentService
16
17
  include Issues
17
18
  include Nodes
18
19
  include Notes
20
+ include Properties if defined?(Dradis::Pro)
19
21
 
20
22
  ActiveSupport.run_load_hooks(:content_service, self)
21
23
  end
@@ -28,6 +28,7 @@ module Dradis::Plugins::ContentService
28
28
  field = args[:field]
29
29
  text = args[:text]
30
30
  msg = args[:msg]
31
+ tail = "..." + args[:tail].to_s
31
32
 
32
33
  logger.error{ "Trying to rescue from a :length error" }
33
34
 
@@ -36,11 +37,11 @@ module Dradis::Plugins::ContentService
36
37
  msg = "#[Title]#\nTruncation warning!\n\n"
37
38
  msg << "#[Error]#\np(alert alert-error). The plugin tried to store content that was too big for the DB. Review the source to ensure no important data was lost.\n\n"
38
39
  msg << text
39
- model.send("#{field}=", msg.truncate(65300))
40
+ model.send("#{field}=", msg.truncate(65300, omission: tail))
40
41
  else
41
42
  # bail
42
43
  msg = "#[Title]#\n#{msg}\n\n"
43
- msg << "#[Description]#\nbc. #{issue.errors.inspect}\n\n"
44
+ msg << "#[Description]#\nbc. #{model.errors.inspect}\n\n"
44
45
  model.send("#{field}=", msg)
45
46
  end
46
47
  if model.valid?
@@ -19,8 +19,10 @@ module Dradis::Plugins::ContentService
19
19
  return issue_cache[cache_key] if issue_cache.key?(cache_key)
20
20
 
21
21
  # we inject the source Plugin and unique ID into the issue's text
22
- text << "\n\n#[plugin]#\n#{uuid[0]}\n"
23
- text << "\n\n#[plugin_id]#\n#{uuid[1]}\n"
22
+ plugin_details =
23
+ "\n\n#[plugin]#\n#{uuid[0]}\n" \
24
+ "\n\n#[plugin_id]#\n#{uuid[1]}\n"
25
+ text << plugin_details
24
26
 
25
27
  issue = Issue.new(text: text) do |i|
26
28
  i.author = default_author
@@ -35,7 +37,8 @@ module Dradis::Plugins::ContentService
35
37
  model: issue,
36
38
  field: :text,
37
39
  text: text,
38
- msg: 'Error in create_issue()'
40
+ msg: 'Error in create_issue()',
41
+ tail: plugin_details
39
42
  )
40
43
  end
41
44
 
@@ -2,6 +2,21 @@ module Dradis::Plugins::ContentService
2
2
  module Nodes
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ def reporting_nodes
6
+ nodes = []
7
+
8
+ nodes |= nodes_from_evidence
9
+ nodes |= nodes_from_properties
10
+
11
+ # Note that the below sorting would the non-IP nodes first, then the IP
12
+ # nodes, and will sort them by each octet.
13
+ #
14
+ # See:
15
+ # http://stackoverflow.com/questions/13996033/sorting-an-array-in-ruby-special-case
16
+ # http://tech.maynurd.com/archives/124
17
+ nodes.sort_by! { |node| node.label.split('.').map(&:to_i) }
18
+ end
19
+
5
20
  def create_node(args={})
6
21
  label = args[:label] || default_node_label
7
22
  parent = args[:parent] || default_node_parent
@@ -35,5 +50,31 @@ module Dradis::Plugins::ContentService
35
50
  def default_node_type
36
51
  @default_node_type ||= Node::Types::DEFAULT
37
52
  end
53
+
54
+
55
+ # Private: this method returns a list of nodes associated with Evidence
56
+ # instances. When a node is affected by multiple issues, or multiple pieces
57
+ # of evidence, we just want a single reference to it.
58
+ #
59
+ # Returns and Array with a unique collection of Nodes.
60
+ def nodes_from_evidence
61
+ all_issues.
62
+ includes(:evidence, evidence: :node).
63
+ collect(&:evidence).
64
+ # Each Issue can have 0, 1 or more Evidence
65
+ map { |evidence_collection| evidence_collection.collect(&:node) }.
66
+ flatten.
67
+ uniq
68
+ end
69
+
70
+ # Private: this method returns a list of nodes in the project that have some
71
+ # properties associated with them. Typically properties are used for HOST
72
+ # type nodes, and even if they have no issues / evidence associated, we want
73
+ # to include them in the report.
74
+ #
75
+ # Returns and Array with a unique collection of Nodes.
76
+ def nodes_from_properties
77
+ Node.user_nodes.where('properties IS NOT NULL AND properties != \'{}\'')
78
+ end
38
79
  end
39
80
  end
@@ -0,0 +1,9 @@
1
+ module Dradis::Plugins::ContentService
2
+ module Properties
3
+ extend ActiveSupport::Concern
4
+
5
+ def all_properties
6
+ Node.content_library.properties
7
+ end
8
+ end
9
+ end
@@ -7,11 +7,11 @@ module Dradis
7
7
 
8
8
  module VERSION
9
9
  MAJOR = 3
10
- MINOR = 6
10
+ MINOR = 7
11
11
  TINY = 0
12
12
  PRE = nil
13
13
 
14
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
15
15
  end
16
16
  end
17
17
  end
@@ -2,9 +2,28 @@ module Dradis
2
2
  module Plugins
3
3
  # Helper methods for plugin Thor tasks
4
4
  module ThorHelper
5
+ attr_accessor :task_options, :logger
6
+
5
7
  def detect_and_set_project_scope
6
8
  ;
7
9
  end
10
+
11
+ def task_options
12
+ @task_options ||= { logger: logger }
13
+ end
14
+
15
+ def logger
16
+ @logger ||= default_logger
17
+ end
18
+
19
+
20
+ private
21
+ def default_logger
22
+ STDOUT.sync = true
23
+ logger = Logger.new(STDOUT)
24
+ logger.level = Logger::DEBUG
25
+ logger
26
+ end
8
27
  end
9
28
  end
10
- end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dradis-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.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: 2017-04-06 00:00:00.000000000 Z
11
+ date: 2017-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - lib/dradis/plugins/content_service/issues.rb
82
82
  - lib/dradis/plugins/content_service/nodes.rb
83
83
  - lib/dradis/plugins/content_service/notes.rb
84
+ - lib/dradis/plugins/content_service/properties.rb
84
85
  - lib/dradis/plugins/engine.rb
85
86
  - lib/dradis/plugins/export.rb
86
87
  - lib/dradis/plugins/export/base.rb
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  requirements: []
125
126
  rubyforge_project:
126
- rubygems_version: 2.4.5
127
+ rubygems_version: 2.6.8
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Plugin manager for the Dradis Framework project.