Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix add new control #443

Merged
merged 1 commit into from
Jun 27, 2022
Merged
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
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