-
Notifications
You must be signed in to change notification settings - Fork 682
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
In ApacheConf#include_files, check for abs paths #1042
In ApacheConf#include_files, check for abs paths #1042
Conversation
@@ -105,7 +105,7 @@ def include_files(params) | |||
|
|||
includes = [] | |||
(include_files + include_files_optional).each do |f| | |||
id = File.join(@conf_dir, f) | |||
id = Pathname.new(f).absolute? ? f : File.join(@conf_dir, f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use File.expand_path here?
irb(main):027:0> File.expand_path("foo", "/bar/baz")
=> "/bar/baz/foo"
irb(main):028:0> File.expand_path("/foo", "/bar/baz")
=> "/foo"
The tests appear to be working now. Left a minor comment, otherwise this looks reasonable to me. 👍 |
@stevendanna oops, yeah I made a typo in the first commit that was resulting in the test failure and I forgot to comment that I had fixed it after doing so. Also, good thought with |
AppVeyor does indeed run the test suite on Windows. What I think may be happening (but haven't confirmed yet) is that |
Not tested it, but I looks like we need to mock the files for Windows as well with c:. I can help on that later this week |
@chris-rock @stevendanna do you know of a good windows server box I can use locally so I don't have to test by pushing here every time I change something? I didn't see a bento windows box |
I have really good experiences with the boxes from @mwrock https://atlas.hashicorp.com/mwrock |
@chris-rock @stevendanna am I understanding correctly that for this to work all of the mock files would need duplicates prepended with |
@chris-rock @stevendanna any thought on my last comment? |
I feel like that is the best path.
I think that path is fraught with peril because we might be passed paths that end up pointing at other drives and then we'll get into trying to parse it out correctly, whereas I'd prefer we just sort out any problems we hit with using expand_path on windows as we find them. |
@stevendanna @chris-rock my most recent commit (duplicating mock files and prepending with
Any idea what exactly AppVeyor is complaining about? Is there something else I should add? I went with the windows-style backslash instead of forward slash b/c of linux filenames and forward slashes (though assuming that Windows may be having a problem with the backslash?). |
@davidcpell I apologize for the late response, we are quite busy with InSpec 1.0 preparation. I took a look on your PR:
We cannot use |
@chris-rock thanks for the feedback. I don't think
So far the only solution that has handled absolute paths coming in from the conf file and is also multi-platform was my original submission (that used
|
@davidcpell lets go for this solution then |
If the path is absolute, just use what was passed, otherwise build an absolute path using `@conf_dir`. Fixes inspec#1013
67ea418
to
155995a
Compare
@chris-rock I rebased with master and squashed my commits to implement the solution using
Not sure what that test is or whether it could've been affected by the change. Do you have any insight? |
Let me double-check... |
💯 Thanks @davidcpell this is a great improvement! |
If the path is absolute, just use what was passed, otherwise build an
absolute path using
@conf_dir
.Fixes #1013