mjpclab / go-http-file-server

Simple command line based HTTP file server to share local file system
MIT License
370 stars 56 forks source link

try url decode uri in access log #18

Open kevinlemonra opened 2 years ago

kevinlemonra commented 2 years ago

请求日志中的中文路径显示不出来 小改一下

marjune163 commented 2 years ago

我这边测试下来在Linux VGA终端上不加载字体的情况下,中文都会变成方块,可能这种情况下辨识度更低了。

另外这里直接记录了用户的请求而没有做过滤,与unicode有关的漏洞时有发生,如果用户精心构造一个特殊的字节序列,查看日志的计算机可能受到攻击,需要如何防范呢?

kevinlemonra commented 2 years ago

我觉得,如果不是记录到数据库或是显示在网页上,而只是记录到日志文件中的话,问题不大。至于查看日志的机器的安全性,那就要看他怎么查看了。

marjune163 commented 2 years ago

%08 是退格键,我试下来如果请求带有这个序列就可以往前删除。

marjune163 commented 2 years ago

我增加了过滤逻辑,并且保留了Unescape前的原始URL:https://github.com/mjpclab/go-http-file-server/commit/a9be3ecb74888ad7672a7721286831bdfe251e8d