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

Create rake task for cfn_nag_rules from VSCode Container #376

Open
thegonch opened this issue Feb 19, 2020 · 2 comments
Open

Create rake task for cfn_nag_rules from VSCode Container #376

thegonch opened this issue Feb 19, 2020 · 2 comments
Projects

Comments

@thegonch
Copy link
Contributor

Currently none of the cfn_nag commands (e.g. cfn_nag, cfn_nag_rules, cfn_nag_scan) will work from directly within the VSCode Remote Development container. Being able to execute these from within the container would be useful to keep all actions siloed. One way we could get around this (as suggested by @phelewski) is to add them as rake commands. We can start off by trying to create a rake task for cfn_nag_rules.

@ghost ghost added this to To do in cfn_nag Feb 26, 2020
@pshelby
Copy link
Contributor

pshelby commented Feb 28, 2020

@thegonch Another workaround is to call those commands using bundle exec .... That will execute them from the locally installed cfn_nag gem, which is from the source.

Here are some examples of calling those commands with bundle exec within the VS Code remote dev container:

cfn_nag

cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ cfn_nag --version
Traceback (most recent call last):
        2: from /usr/local/bundle/bin/cfn_nag:23:in `<main>'
        1: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem cfn-nag (>= 0.a) with executable cfn_nag (Gem::GemNotFoundException)
cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ bundle exec cfn_nag --version
0.0.0
cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ cfn_nag spec/test_templates/yaml/sam/globals.yml 
Traceback (most recent call last):
        2: from /usr/local/bundle/bin/cfn_nag:23:in `<main>'
        1: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem cfn-nag (>= 0.a) with executable cfn_nag (Gem::GemNotFoundException)
cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ bundle exec cfn_nag spec/test_templates/yaml/sam/globals.yml 
------------------------------------------------------------
spec/test_templates/yaml/sam/globals.yml
------------------------------------------------------------
Failures count: 0
Warnings count: 0

cfn_nag_rules

cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ cfn_nag_rules
Traceback (most recent call last):
        2: from /usr/local/bundle/bin/cfn_nag_rules:23:in `<main>'
        1: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem cfn-nag (>= 0.a) with executable cfn_nag_rules (Gem::GemNotFoundException)
cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ bundle exec cfn_nag_rules
WARNING VIOLATIONS:
W1 Specifying credentials in the template itself is probably not the safest thing
W2 Security Groups found with cidr open to world on ingress.  This should never be true on instance.  Permissible on ELB
W5 Security Groups found with cidr open to world on egress
W9 Security Groups found with ingress cidr that is not /32

cfn_nag_scan

cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ cfn_nag_scan --input-path spec/test_templates/yaml/sam/globals.yml 
Traceback (most recent call last):
        2: from /usr/local/bundle/bin/cfn_nag_scan:23:in `<main>'
        1: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem cfn-nag (>= 0.a) with executable cfn_nag_scan (Gem::GemNotFoundException)
cfn_nag_dev@caefac1f2dd9:/workspaces/cfn_nag$ bundle exec cfn_nag_scan --input-path spec/test_templates/yaml/sam/globals.yml 
------------------------------------------------------------
spec/test_templates/yaml/sam/globals.yml
------------------------------------------------------------
Failures count: 0
Warnings count: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
cfn_nag
  
To do
Development

No branches or pull requests

3 participants