Skip to content

Commit

Permalink
waring on serving unfiltered path
Browse files Browse the repository at this point in the history
  • Loading branch information
rif committed Nov 8, 2018
1 parent aae3627 commit 560f686
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spark.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
port = flag.String("port", "8080", "Listening port")
sslPort = flag.String("sslPort", "10433", "SSL listening port")
path = flag.String("path", "/", "URL path")
deny = flag.String("deny", "", "Sesitive directory or file patterns to be denied when listing path (comma sperated)")
deny = flag.String("deny", "", "Sesitive directory or file patterns to be denied when serving directory (comma sperated)")
status = flag.Int("status", 200, "Returned HTTP status code")
cert = flag.String("cert", "cert.pem", "SSL certificate path")
key = flag.String("key", "key.pem", "SSL private Key path")
Expand Down Expand Up @@ -70,6 +70,9 @@ func main() {
if fi, err := os.Stat(body); err == nil {
switch mode := fi.Mode(); {
case mode.IsDir():
if *deny == "" {
log.Print("Warning: serving files without any filter!")
}
handler = http.StripPrefix(*path, http.FileServer(protectdFileSystem{http.Dir(body)}))
case mode.IsRegular():
if content, err := ioutil.ReadFile(body); err != nil {
Expand Down

0 comments on commit 560f686

Please sign in to comment.