-
Notifications
You must be signed in to change notification settings - Fork 1
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
#36: fix for unsafe paths #38
Conversation
This deserves unit tests. |
I guess Contains() would also do the trick. |
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.
Ok. Make sure the CI passes before merging :)
|
||
public interface ISafeFileSystemPathTraversalService | ||
{ | ||
string Traverse(string root, string path); |
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.
"Traverse" is not the correct verb for what the method does, I think. Maybe "SafeCombine"? Or "VerifyCombine"?
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.
Hmmmmmm. I don't love SafeCombine but sure.
[TestCategory("Services")] | ||
public class PathTraversalTests | ||
{ | ||
private const string MacOsRoot = "/var/folders/ab/cdefg/T/TRENZ.Docs.API/trenz-docs-test"; |
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.
Technically the only paths the service will ever see are Linux paths... This is really minor, but the correct name would probably be UnixPathRoot
or something along those lines
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.
I went with MacOs since it's derived from an actual (temp) path in debug on my Mac. In theory, we could also test this with a bunch of Windows paths…
It didn't. |
Fixes #36