-
-
Notifications
You must be signed in to change notification settings - Fork 340
add --disable-indexing
cli flag to completely disable directory indexing
#1329
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
Conversation
Please add a test for this. It's a fairly impactful change. |
src/listing.rs
Outdated
if conf.disable_indexing { | ||
return Ok(ServiceResponse::new( | ||
req.clone(), | ||
HttpResponse::NotFound() | ||
.content_type(mime::TEXT_PLAIN_UTF_8) | ||
.body("File not found."), | ||
)); | ||
} | ||
|
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.
Doesn't putting it here result in the index still being downloadable via requesting an archive? This seems to me like a potential security problem or at least something people might not expect. I think it might be safer to prohibit index generation entirely in main.rs
.
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 wasn't aware that was a thing. I'll take a look.
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.
After looking at it closer, I think it'll be more clean to just move this check all the way to the top of this function. All file listings seem to go through this handler.
Plus, it seems to render a nicer looking error page when it's handled here.
I added a couple tests. I'm not super familiar with your codebase, so let me know if there's some better assertions I could use. |
if conf.disable_indexing { | ||
return Ok(ServiceResponse::new( | ||
req.clone(), | ||
HttpResponse::NotFound() | ||
.content_type(mime::TEXT_PLAIN_UTF_8) | ||
.body("File not found."), | ||
)); | ||
} |
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 think this is probably fine but I'm wondering: Can we just disable indexing entirely in main.rs
?
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 yes, and if you want to see what that looks like, you can check out 7b5b1a0. Reiterating what I said in this comment I think it would be less complicated to do it like this.
Excellent stuff, tests are spot on, too! |
closes #1328