austinheap/laravel-security-txt

此包已被放弃,不再维护。未建议替代包。

为 Laravel 5.5+ 提供服务的 `security.txt` 包,基于配置设置。

v0.4.1 2018-03-03 00:28 UTC

This package is auto-updated.

Last update: 2021-04-22 03:12:30 UTC


README

laravel-security-txt banner from the documentation

License Current Release Total Downloads Build Status Dependency Status Scrutinizer CI StyleCI Maintainability Test Coverage SensioLabs

为 Laravel 5.5+ 提供服务的 security.txt 包,基于配置设置。

此项目的目的是创建一个“设置并忘记”的包,无需费力即可将 Laravel 项目符合当前 security.txt 规范。因此,它具有高度的意见性,但专为配置而构建。

启用后,允许所有客户端访问并服务 security.txt。否则,它几乎与 Laravel 默认配置相同,拒绝所有客户端访问。

security.txt 是一个 草稿 "标准",允许网站定义安全策略。此“标准”为安全研究人员设定了如何报告安全问题的明确指南,并允许赏金计划定义范围。Security.txt 是与 robots.txt 类似的文件,但用于安全问题。

有关 laravel-security-txt 的在线文档位于 此处,源代码位于 docs/ 目录中。最佳起点是 SecurityTxt 类的文档

目录

安装

步骤 1: Composer

通过 Composer 命令行

$ composer require austinheap/laravel-security-txt

或将包添加到您的 composer.json

{
    "require": {
        "austinheap/laravel-security-txt": "0.3.*"
    }
}

步骤 2: 删除任何现有的 security.txt

Laravel 并未提供默认的 security.txt 文件。如果您已添加,则需要删除它才能使配置的路由工作。

$ rm public/.well-known/security.txt

步骤 3: 启用包(可选)

此包实现了 Laravel 5.5 的自动发现功能。安装后,包提供者和外观会自动添加。

如果您想显式声明提供者和/或别名,则可以将服务提供者添加到您的 config/app.php

将服务提供商添加到您的 config/app.php 文件中

'providers' => [
    //
    AustinHeap\Security\Txt\SecurityTxtServiceProvider::class,
];

然后,将别名添加到您的 config/app.php 文件中

'aliases' => [
    //
    'SecurityTxt' => AustinHeap\Security\Txt\SecurityTxtFacade::class,
];

第4步:配置软件包

发布软件包配置文件

$ php artisan vendor:publish --provider="AustinHeap\Security\Txt\SecurityTxtServiceProvider"

您现在可以通过编辑 config/security-txt.php 文件来允许客户端通过 security.txt,从而打开公共路由

return [
    'enabled' => env('SECURITY_TXT_ENABLED', true),
];

或者简单地通过 Laravel 的 .env 文件或托管环境将 SECURITY_TXT_ENABLED 环境变量设置为 true。

SECURITY_TXT_ENABLED=true

完整的 .env 示例

使用 composer 安装软件包后,只需将以下内容添加到您的 .env 文件中

SECURITY_TXT_ENABLED=true
SECURITY_TXT_CACHE=true
SECURITY_TXT_CONTACT=security@your-site.com
SECURITY_TXT_ENCRYPTION=https://your-site.com/pgp.key
SECURITY_TXT_DISCLOSURE=full
SECURITY_TXT_ACKNOWLEDGEMENT=https://your-site.com/security-champions

现在,将您的浏览器指向 http://your-site.com/.well-known/security.txt,您应该会看到

# Our security address
Contact: me@austinheap.com

# Our PGP key
Encryption: http://some.url/pgp.key

# Our disclosure policy
Disclosure: Full

# Our public acknowledgement
Acknowledgement: http://some.url/acks

#
# Generated by "laravel-security-txt" v0.4.0 (https://github.com/austinheap/laravel-security-txt/releases/tag/v0.4.0)
# using "php-security-txt" v0.4.0 (https://github.com/austinheap/php-security-txt/releases/tag/v0.4.0)
# in 0.041008 seconds on 2017-11-22 20:31:25.
#
# Cache is enabled with key "cache:AustinHeap\Security\Txt\SecurityTxt".
#

单元测试

此软件包使用优秀的 orchestral/testbench 软件包构建了具有侵略性的单元测试,该软件包建立在 PHPUnit 之上。

有关 laravel-security-txt 的代码覆盖率报告可在网上找到。[链接](https://austinheap.github.io/laravel-security-txt/coverage/)

参考

致谢

这是一个 InfusionWeb/laravel-robots-route 的分支,它是一个 ellisthedev/laravel-5-robots 的分支,它是一个 jayhealey/Robots 的分支,它基于早期的工作。

许可

MIT 许可证(MIT)。有关更多信息,请参阅许可文件