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

SARIF output support #573

Merged
merged 6 commits into from
Oct 25, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Resolve todo
  • Loading branch information
arothian committed Oct 15, 2021
commit 6c9d5969496d86216049878ef5430da1ca6813bc
3 changes: 1 addition & 2 deletions lib/cfn-nag/result_view/sarif_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def driver(rules)
semanticVersion: Gem.loaded_specs['cfn-nag'].version.to_s,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to do checks for when this is nil or using .& format because rake:test-all is coming back with failures in these cases:

Failures:

  1) SarifResults#driver with four rules should contain name, informationUri, semanticVersion and rules attributes
     Failure/Error: semanticVersion: Gem.loaded_specs['cfn-nag'].version.to_s,

     NoMethodError:
       undefined method `version' for nil:NilClass
     # ./lib/cfn-nag/result_view/sarif_results.rb:38:in `driver'
     # ./spec/result_view/sarif_results_spec.rb:36:in `block (4 levels) in <top (required)>'

  2) SarifResults#driver with four rules should contain a driver with four rules
     Failure/Error: semanticVersion: Gem.loaded_specs['cfn-nag'].version.to_s,

     NoMethodError:
       undefined method `version' for nil:NilClass
     # ./lib/cfn-nag/result_view/sarif_results.rb:38:in `driver'
     # ./spec/result_view/sarif_results_spec.rb:44:in `block (4 levels) in <top (required)>'

  3) SarifResults#driver with four rules should contain a rule with id, name, fullDescription
     Failure/Error: semanticVersion: Gem.loaded_specs['cfn-nag'].version.to_s,

     NoMethodError:
       undefined method `version' for nil:NilClass
     # ./lib/cfn-nag/result_view/sarif_results.rb:38:in `driver'
     # ./spec/result_view/sarif_results_spec.rb:50:in `block (4 levels) in <top (required)>'

Finished in 12.88 seconds (files took 11.49 seconds to load)
871 examples, 3 failures

Failed examples:

rspec ./spec/result_view/sarif_results_spec.rb:35 # SarifResults#driver with four rules should contain name, informationUri, semanticVersion and rules attributes
rspec ./spec/result_view/sarif_results_spec.rb:43 # SarifResults#driver with four rules should contain a driver with four rules
rspec ./spec/result_view/sarif_results_spec.rb:49 # SarifResults#driver with four rules should contain a rule with id, name, fullDescription

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thegonch Addressed by setting up a version.rb file and updating several code references to use that instead.

rules: rules.map do |rule_definition|
{
# TODO: prefix rule id with CFN_NAG_
id: rule_definition.id,
id: "CFN_NAG_#{rule_definition.id}",
name: rule_definition.name,
fullDescription: {
text: rule_definition.message
Expand Down