Skip to content

Commit

Permalink
Merge pull request #443 from mitre/fix-add-control
Browse files Browse the repository at this point in the history
fix add new control
  • Loading branch information
Tim Wong authored Jun 27, 2022
2 parents d71f828 + a6fef31 commit ebbb88a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/controllers/rules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,18 @@ def create_or_duplicate
rule.rule_id = nil
rule
elsif authorize_admin_project.nil?
Rule.new(rule_create_params.except(:duplicate).merge({
component: @component,
status: 'Not Yet Determined',
rule_severity: 'unknown'
}))
srg = SecurityRequirementsGuide.find_by(id: @component.security_requirements_guide_id)
srg_rule = srg.parsed_benchmark.rule.find { |r| r.ident.reject(&:legacy).first.ident == 'CCI-000366' }

rule = BaseRule.from_mapping(Rule, srg_rule)
rule.audits.build(Audited.audit_class.create_initial_rule_audit_from_mapping(@component.id))
rule.component = @component
rule.srg_rule = srg.srg_rules.find_by(ident: 'CCI-000366')
rule.rule_id = (@component.rules.order(:rule_id).pluck(:rule_id).last.to_i + 1)&.to_s&.rjust(6, '0')
rule.status = 'Not Yet Determined'
rule.rule_severity = 'unknown'

rule
end
end

Expand Down

0 comments on commit ebbb88a

Please sign in to comment.