Python - Django 文档说这是一种不安全的提供静态文件的方式 - 这是真的吗?如果是,怎么会这样?

发布于 2024-10-17 17:20:08 字数 221 浏览 7 评论 0原文

我遵循这种方式传递静态文件,但根据免责声明在顶部,它既不安全又低效。这是真的吗?我应该怎么做呢?

另外,还有一个半题外话的问题:术语“媒体”和“静态文件”在网络编程的上下文中可以互换吗?我看到它们经常被扔来扔去,而且它们似乎指的是同一件事。

I follow this way of delivering static files but according to the disclaimer at the top, it's both insecure and inefficient. Is it true? How should I be doing it instead?

Also, a semi-off-topic question: Are the terms 'media' and 'static files' interchangeable in the context of web programming? I see them thrown around a lot and they seem to be referring to the same thing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遇到 2024-10-24 17:20:08

它既不安全又低效。这是真的吗?

当然。你认为他们为什么这么说?

我应该如何做呢?

这就是阿帕奇的用途。或者 Ngingx 或 lighttpd 或任何大量其他 Web 服务器。

术语“媒体”和“静态文件”在网络编程中可以互换吗?

通常。

Django 1.3 确实区分了“媒体”和静态文件,“媒体”是上传和下载的内容,静态文件是静态的。

it's both insecure and inefficient. Is it true?

Of course. Why do you think they say it?

How should I be doing it instead?

That's what Apache is for. Or Ngingx or lighttpd or any of a large number of other web servers.

Are the terms 'media' and 'static files' interchangeable in the context of web programming?

Usually.

Django 1.3 does make a distinction between "media" as stuff that gets uploaded and downloaded and static files which are -- well -- static.

思念绕指尖 2024-10-24 17:20:08

同意 S.Lott 的回答,但是当您质疑这是一种不安全的提供静态文件的方式,是真的吗?

我想有必要解释一下原因

为什么从 django 提供静态文件不安全的答案解释了原因。此处引用:

除非针对安全性进行设计和审核,否则任何事物都不能被认为是安全的。我们没有对静态文件服务器进行任何操作。它可能不存在现有的安全漏洞,但不应将其视为安全的,因为这不是设计目标。

例如,安全文件服务器需要检查资源分配问题,以便提供非常大的文件不会构成拒绝服务攻击。这需要大量额外的代码和管道管理,不值得将其放入仅用于开发目的的东西中。

Agree with S.Lott's Answer, but when you questioned It's an insecure way of serving static files, is it true?

I guess it's necessary to explain why.

The answer of Why serve static files from django is insecure explained the reason. Quoted here:

Nothing can be considered secure unless it is designed and audited for security. We have done neither with the static file server. It may not have existing security holes, but it should not be considered secure because that's not a design goal.

For example, a secure file server would need to check for resource allocation problems so that serving a very large file didn't constitute a denial-of-service attack. That requires a lot of extra code and pipeline management which isn't worth putting into something that's just for development purposes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文