mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
FIX: Fix bug/todo to handle duplicacy of control ids
Signed-off-by: Sonu Saha <sonu.saha@progress.com>
This commit is contained in:
parent
47c92d8746
commit
46d66e0026
2 changed files with 3 additions and 9 deletions
|
@ -524,8 +524,8 @@ module Inspec
|
|||
# TODO - look at the various source contents
|
||||
# PASS 1: parse them using rubocop-ast
|
||||
# Look for controls, top-level metadata, and inputs
|
||||
# PASS 2: Using the control IDs, deterimine the extents -
|
||||
# line locations - of the coontrol IDs in each file, and
|
||||
# PASS 2: Using the control IDs, deterimine the extents -
|
||||
# line locations - of the coontrol IDs in each file, and
|
||||
# then extract each source code block. Use this to populate the source code
|
||||
# locations and 'code' properties.
|
||||
|
||||
|
@ -537,7 +537,7 @@ module Inspec
|
|||
ctl_id_collector = Inspec::Profile::AstHelper::ControlIDCollector.new(res)
|
||||
# TODO: look for inputs
|
||||
# TODO: look for top-level metadata like title
|
||||
src.ast.each_node { |n| ctl_id_collector.process(n) }
|
||||
src.ast.each_child_node { |n| ctl_id_collector.process(n) }
|
||||
|
||||
# For each control ID
|
||||
# Look for per-control metadata
|
||||
|
|
|
@ -96,10 +96,8 @@ module Inspec
|
|||
end
|
||||
|
||||
class ControlIDCollector < CollectorBase
|
||||
attr_reader :seen_control_ids
|
||||
def initialize(memo)
|
||||
@memo = memo
|
||||
@seen_control_ids = {}
|
||||
end
|
||||
|
||||
def on_block(block_node)
|
||||
|
@ -110,10 +108,6 @@ module Inspec
|
|||
|
||||
# TODO - This assumes the control ID is always a plain string, which we know it is often not!
|
||||
control_id = control_node.children[2].value
|
||||
# TODO - BUG - this keeps seeing the same nodes over and over againa, and so repeating control IDs. We are ignoring duplicate control IDs, which is incorrect.
|
||||
return if seen_control_ids[control_id]
|
||||
|
||||
seen_control_ids[control_id] = true
|
||||
|
||||
control_data = {
|
||||
id: control_id
|
||||
|
|
Loading…
Reference in a new issue