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

json-file, unable to save file on a windows system #173

Closed
username-is-already-taken2 opened this Issue Dec 2, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@username-is-already-taken2

username-is-already-taken2 commented Dec 2, 2016

Cookbook version

2.3.0

Chef-client version

12.16.2

Platform Details

Windows 2012 R2

Scenario:

Trying to save the compliance report to disk using the json-file collector

Steps to Reproduce:

{
  "audit": {
    "collector": [
      "chef-server",
      "json-file"
    ],....

Expected Result:

should write the file

Actual Result:

Client run errors and no file is written to disk

[2016-12-02T12:07:44+00:00] WARN: Writing report to file.
[2016-12-02T12:07:44+00:00] WARN: Filename is c:/chef/cache/cookbooks/audit/inspec-2016-12-02_12:07:44_UTC.json
[2016-12-02T12:07:44+00:00] ERROR: Report handler Chef::Handler::AuditReport raised #<Errno::EINVAL: Invalid argument @rb_sysopen - c:/chef/cache/cookbooks/audit/inspec-2016-12-02_12:07:44_UTC.json>
@chris-rock

This comment has been minimized.

Collaborator

chris-rock commented Dec 2, 2016

@username-is-already-taken2 Great finding. A colon is an invalid character for a windows file name. We need to change the way the filename is generated

@jeremymv2

This comment has been minimized.

Contributor

jeremymv2 commented Dec 3, 2016

I propose we use Time.now.strftime('%Y%m%d%H%M%S')

This will result in a more sort friendly file name, for example:

irb(main):022:0> "inspec-#{Time.now.strftime('%Y%m%d%H%M%S')}.json"
=> "inspec-20161202222307.json"
irb(main):023:0>

@jeremymv2 jeremymv2 referenced this issue Dec 3, 2016

Merged

change json-file filename #177

0 of 4 tasks complete

@binamov binamov added the in progress label Dec 3, 2016

@chris-rock

This comment has been minimized.

Collaborator

chris-rock commented Dec 5, 2016

#177 fixed that issue. @username-is-already-taken2 let us know if the issue continues to persist

@chris-rock chris-rock closed this Dec 5, 2016

@chris-rock chris-rock removed the in progress label Dec 5, 2016

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