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

Upload profiles to Chef Compliance via Chef resource #122

Merged
merged 6 commits into from Oct 27, 2016

Conversation

Projects
None yet
4 participants
@vjeffrey
Collaborator

vjeffrey commented Oct 26, 2016

tada! it works @chris-rock .....i have a bunch of requires in the inspec resource....not sure how to get around that?

using this to test it: https://github.com/vjeffrey/testing-audit

@binamov binamov added the in progress label Oct 26, 2016

@vjeffrey vjeffrey changed the title from wip: upload profiles to upload profiles Oct 26, 2016

resources/inspec.rb Outdated
require 'bundles/inspec-compliance/api'
require 'bundles/inspec-compliance/target'
_success, msg, access_token = Compliance::API.get_token_via_refresh_token(server, refresh_token, true)

This comment has been minimized.

@jeremymv2

jeremymv2 Oct 26, 2016

Contributor

The access_token (and inspec lib namespaces) will also be required when sending reports directly to Compliance so the all the lib requires should probably be moved in this resource so that it's as DRY as possible.

This comment has been minimized.

@jeremymv2

jeremymv2 Oct 26, 2016

Contributor

This was solved in the past since there was a compliance library (libraries/compliance.rb). All libraries get compiled and automatically included in the cookbook resources. That would perhaps be a decent place for all the requires and the compliance API methods.

This comment has been minimized.

@vjeffrey

vjeffrey Oct 26, 2016

Collaborator

👍 sounds like a plan!

@vjeffrey vjeffrey referenced this pull request Oct 26, 2016

Closed

Features missing from 2.0.0 #116

3 of 4 tasks complete
recipes/upload.rb Outdated
# upload profile
inspec p do
profile_name p

This comment has been minimized.

@jeremymv2

jeremymv2 Oct 26, 2016

Contributor
inspec p do
   profile_name p

This feels a little strange to me since the resource is inspec - to me that would on the surface mean that it controls the installation and configuration of inspec (gem/tools). This might just be pernickety, but mixing in inspec profiles uploads might make more sense in a separate resource perhaps.

This comment has been minimized.

@vjeffrey

vjeffrey Oct 26, 2016

Collaborator

ya, that makes sense. 👍

@chris-rock

This comment has been minimized.

Collaborator

chris-rock commented Oct 27, 2016

@vjeffrey Do you intend to add the upload example to our example directory?

@chris-rock

I like the simple wrapper for the cookbook that reuses all the InSpec core functionality. Awesome @vjeffrey Just added a minor questions.

resources/upload.rb Outdated
raise "Profile archive file #{path} does not exist." unless ::File.exist?(path)
profile = Inspec::Profile.for_target(path, {})
error_count = 0
lambda { |msg|

This comment has been minimized.

@chris-rock

chris-rock Oct 27, 2016

Collaborator

Is this lamda used somewhere?

This comment has been minimized.

@chris-rock

chris-rock Oct 27, 2016

Collaborator

Would be great to tie this warnings and errors to Chef::Log.error and Chef::Log.warn

This comment has been minimized.

@vjeffrey

vjeffrey Oct 27, 2016

Collaborator

i think that lambda was just cruft leftover. i'll remove and test in a bit. oh ya, good point on the errors. i'll go through and update those! :)

vjeffrey added some commits Oct 26, 2016

upload profiles
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
move upload to its own resource
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
clean up and add comments
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
examples/profile_upload/chefignore Outdated
@@ -0,0 +1,107 @@
# Put files/directories that should be ignored in this file when uploading

This comment has been minimized.

@chris-rock

chris-rock Oct 27, 2016

Collaborator

lets remove this file

This comment has been minimized.

@vjeffrey

vjeffrey Oct 27, 2016

Collaborator

👍

add example cookbook for profile upload
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
@vjeffrey

This comment has been minimized.

Collaborator

vjeffrey commented Oct 27, 2016

@chris-rock: updated!

@chris-rock chris-rock changed the title from upload profiles to Upload profiles to Chef Compliance via Chef resource Oct 27, 2016

@chris-rock chris-rock referenced this pull request Oct 27, 2016

Closed

Add unit tests #128

@chris-rock

This comment has been minimized.

Collaborator

chris-rock commented Oct 27, 2016

Awesome @vjeffrey Lets cover the unit tests in another PR #128

@chris-rock chris-rock merged commit 3296f21 into master Oct 27, 2016

2 checks passed

DCO This commit has a DCO Signed-off-by
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@chris-rock chris-rock deleted the vj/upload-profiles branch Oct 27, 2016

@binamov binamov removed the in progress label Oct 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment