Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions lib/dradis/plugins/content_service/nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ def reporting_nodes
nodes.sort_by! { |node| node.label.split('.').map(&:to_i) }
end

# This method returns a list of nodes associated with Evidence
# instances. When a node is affected by multiple issues, or multiple pieces
# of evidence, we just want a single reference to it.
#
# Returns and Array with a unique collection of Nodes.
def nodes_from_evidence
all_issues.
includes(:evidence, evidence: :node).
collect(&:evidence).
# Each Issue can have 0, 1 or more Evidence
map { |evidence_collection| evidence_collection.collect(&:node) }.
flatten.
uniq
end

def create_node(args={})
label = args[:label] || default_node_label
parent = args[:parent] || default_node_parent
Expand Down Expand Up @@ -59,22 +74,6 @@ def default_node_type
@default_node_type ||= Node::Types::DEFAULT
end


# Private: this method returns a list of nodes associated with Evidence
# instances. When a node is affected by multiple issues, or multiple pieces
# of evidence, we just want a single reference to it.
#
# Returns and Array with a unique collection of Nodes.
def nodes_from_evidence
all_issues.
includes(:evidence, evidence: :node).
collect(&:evidence).
# Each Issue can have 0, 1 or more Evidence
map { |evidence_collection| evidence_collection.collect(&:node) }.
flatten.
uniq
end

# Private: this method returns a list of nodes in the project that have some
# properties associated with them. Typically properties are used for HOST
# type nodes, and even if they have no issues / evidence associated, we want
Expand Down