通过构建脚本对文件进行病毒检查

发布于 2024-09-02 05:46:43 字数 722 浏览 1 评论 0原文

我希望能够调用病毒检查作为构建过程的最后阶段(请不要询问为什么开发机器会感染病毒,这只是避免被客户起诉的风险的一种安全措施......)。另外,我希望可以选择在计算机上安装 AV,但关闭自动文件系统保护(至少对于构建目录)。

我想要的是使用任何现有的 AV 系统扫描文件的通用方法。我假设有一个 Windows API 可以执行此操作,因为 Windows 会检测到 AV 系统的存在,并且每当下载文件时,Firefox 等浏览器都会调用病毒扫描。那么他们使用的 API 是什么?有 Microsoft AntiVirus API 但这似乎特定于办公文件。该方法是否涉及使用 WMI? (如果您可以从那里检测到 AV 提供程序,那么您如何调用它来扫描文件?)

我知道我可以编写脚本来手动调用我知道要安装的 AV 扫描仪,但作为一项智力练习我更感兴趣的是像 Firefox 这样的应用程序是如何做到这一点的。

I would like to be be able to invoke a virus check as the final stage of the build process (please don't question why a dev machine would get a virus, it's just a belt-and-braces approach to avoid the risk of getting sued by customers...). Also I'd like the option of having AV on a machine but switching the auto file system protection off (at least for the build directories).

What I would like is a generic way of scanning a file using whatever AV system is in place. I'm assuming that there's an Windows API to do this, given that Windows detects the presence of an AV system, and browsers such as Firefox invoke a virus scan whenever a file is downloaded. So what's the API that they're using? There's the Microsoft AntiVirus API but that seems to be specific to Office documents. Does the approach involve using WMI? (and if you can detect the AV provider from there, how do you then invoke it to scan a file?)

I know that I could write the script to manually call the AV scanner that I know to be installed, but as an intellectual exercise I'm more interested to know how apps like Firefox are doing this.

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

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

发布评论

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

评论(2

め可乐爱微笑 2024-09-09 05:46:43

好吧,您可能想直接在 Firefox 源代码上查看 nsDownloadScanner 系统:

正如该文件的注释所述:

Download scanner attempts to make use of one of two different
virus scanning interfaces available on Windows - IOfficeAntiVirus
(Windows 95/NT 4 and IE 5) and IAttachmentExecute (XPSP2 and up).
The latter interface supports calling IOfficeAntiVirus internally,
while also adding support for XPSP2+ ADS forks which define security
related prompting on downloaded content.

可以在此处找到有关这些接口的文档:

如果您的软件是开源的 符合 MPL 许可证(感谢@MSalters),您也可以直接使用Firefox的代码,以避免重新发明轮子。

Well, you may want to take a look at the nsDownloadScanner system directly on the Firefox source code:

As told by the comments on that files:

Download scanner attempts to make use of one of two different
virus scanning interfaces available on Windows - IOfficeAntiVirus
(Windows 95/NT 4 and IE 5) and IAttachmentExecute (XPSP2 and up).
The latter interface supports calling IOfficeAntiVirus internally,
while also adding support for XPSP2+ ADS forks which define security
related prompting on downloaded content.

Documentations on those interfaces can be found here:

If your software is open-source is compliant with the MPL licence (thanks, @MSalters), you may also directly use Firefox' code, to avoid reinventing the wheel.

爱的十字路口 2024-09-09 05:46:43

Firefox 使用 IAttachmentExecute API。但是,您不想在构建脚本中使用它,因为它会添加备用流信息,告诉窗口在执行文件时显示恼人的警告窗口。

Firefox uses the IAttachmentExecute API. However, you don't want to use that in a build script since it will add alternate stream information telling windows to show an annoying warning window when executing the file.

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