Skip to content

Commit

Permalink
Merge pull request #220 from chef-cookbooks/chris-rock/fix-cc-reporting
Browse files Browse the repository at this point in the history
fix cc token and ensure we create a new string for a url
  • Loading branch information
arlimus authored May 3, 2017
2 parents 78b2eff + 22de2b8 commit cbf8ee8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions files/default/handler/audit_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,8 @@ def send_report(reporter, server, user, source_location, report)
raise_if_unreachable = node['audit']['raise_if_unreachable']
url = construct_url(server, File.join('/owners', user, 'inspec'))

# @config = Compliance::Configuration.new
# Chef::Log.info "Report to Chef Compliance: #{@config['server']}/owners/#{@config['user']}/inspec"
# @url = URI("#{@config['server']}/owners/#{@config['user']}/inspec")
token = @config['token']
config = Compliance::Configuration.new
token = config['token']

opts = {
url: url,
Expand Down
10 changes: 6 additions & 4 deletions libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ def tests_for_runner(profiles)
end

def construct_url(server, path)
# ensure we do not modify a frozen String
srv = server.dup
# sanitize inputs
server << '/' unless server =~ %r{/\z}
srv << '/' unless server =~ %r{/\z}
path.sub!(%r{^/}, '')
server = URI(server)
server.path = server.path + path if path
server
srv = URI(srv)
srv.path = srv.path + path if path
srv
end

def with_http_rescue(*)
Expand Down

0 comments on commit cbf8ee8

Please sign in to comment.