Skip to content

io.js support for null byte path#20

Closed
pierreinglebert wants to merge 2 commits intohapijs:masterfrom
pierreinglebert:iojs-support
Closed

io.js support for null byte path#20
pierreinglebert wants to merge 2 commits intohapijs:masterfrom
pierreinglebert:iojs-support

Conversation

@pierreinglebert
Copy link
Copy Markdown
Contributor

The null byte path traversal is fixed for io.js in nodejs/node#517 and returns an ENOENT.
We have a different behavior between node and io here, maybe it should be homogenized by returning a 404 instead of 403.

@kanongil
Copy link
Copy Markdown
Contributor

kanongil commented Feb 7, 2015

I am not sure about official iojs support yet, as hapi itself doesn't target it. I am however willing to accept a patch that simply reverts the response code to 404 to more closely align with iojs development.

@kanongil kanongil added the bug Bug or defect label Feb 7, 2015
@hueniverse
Copy link
Copy Markdown
Contributor

Given the current state of io.js adoption, the official node distribution wins whenever there is conflict in implementation.

@pierreinglebert
Copy link
Copy Markdown
Contributor Author

Sorry for not being clear enough.

The null byte path issue is not fixed in node.js so you fixed it in inert (https://github.com/hapijs/inert/blob/master/lib/file.js#L216) by returning a 403.
io.js fixed that issue (nodejs/node#517) by returning an ENOENT error leading to a 404 in inert.

So the implementation conflict is between inert and io.js not node.js.

The other part of this pr is for coverage failure because that fix is not being executed in io.js.

@kanongil
Copy link
Copy Markdown
Contributor

kanongil commented Feb 8, 2015

@hueniverse Even without iojs I think that a 404 response is more appropriate than 403, which I initially implemented. The error should be a 404.

@pierreinglebert
Copy link
Copy Markdown
Contributor Author

I created another PR for 404, i'll rebase this one after and then there will only be specific fixes for io.js tests to pass.

@hueniverse
Copy link
Copy Markdown
Contributor

@kanongil I don't have an opinion on that part of the discussion.

@kanongil kanongil removed the bug Bug or defect label Feb 9, 2015
@kanongil
Copy link
Copy Markdown
Contributor

kanongil commented Feb 9, 2015

@hueniverse Is $lab:coverage:off$, etc an appropriate way to handle code coverage of platform specific workarounds? Or is there a better solution?

@kanongil kanongil added feature New functionality or improvement test Test or coverage and removed feature New functionality or improvement labels Feb 9, 2015
@hueniverse
Copy link
Copy Markdown
Contributor

Not really. But I don't know what's the right approach here. The problem is that this turns off coverage for all cases, including the ones we need to make sure we test.

@kanongil
Copy link
Copy Markdown
Contributor

kanongil commented Feb 9, 2015

Well that pretty much mirrors my concerns. We really need a decent mechanism to handle platform specific workarounds, be it 0.10 vs. 0.12 & io.js, or linux vs. windows.

@hueniverse
Copy link
Copy Markdown
Contributor

Open an issue on lab to add conditional coverage exclusion support. Should not be too hard to add.

@kanongil
Copy link
Copy Markdown
Contributor

Conditional coverage support would only enable a fix for the symptoms. Eg. a future node release could adopt the io.js fix, causing the coverage test to fail because only io.js is part of the condition.

I am inclined to think that @pierreinglebert's solution is the more appropriate approach. With the io.js patch, this can be seen as a defensive programming expression catching the error on "old" platforms. With multiple supported platforms, 100% branch coverage is somewhat of a pipe dream.

@hueniverse
Copy link
Copy Markdown
Contributor

As long as node 0.10/12 is the official version supported, coverage must match that without any hacks. Once/if we switch to iojs, we can clean the code to remove any unused code.

kanongil added a commit to kanongil/inert that referenced this pull request Feb 20, 2015
@kanongil kanongil mentioned this pull request Feb 20, 2015
@lock
Copy link
Copy Markdown

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

test Test or coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants