From 2d91db9e76729de1aa32722db0af8ad5042f04c5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 10 Mar 2021 09:58:48 -0500 Subject: [PATCH] Add /.well-known/security.txt route and module --- src/Module/WellKnown/SecurityTxt.php | 43 ++++++++++++++++++++++++++++ static/routes.config.php | 1 + 2 files changed, 44 insertions(+) create mode 100644 src/Module/WellKnown/SecurityTxt.php diff --git a/src/Module/WellKnown/SecurityTxt.php b/src/Module/WellKnown/SecurityTxt.php new file mode 100644 index 000000000..9cdcde048 --- /dev/null +++ b/src/Module/WellKnown/SecurityTxt.php @@ -0,0 +1,43 @@ +. + * + */ + +namespace Friendica\Module\WellKnown; + +use Friendica\BaseModule; + +/** + * Standardized way of exposing metadata about the project security policy + * @see https://securitytxt.org + */ +class SecurityTxt extends BaseModule +{ + public static function rawContent(array $parameters = []) + { + $name = 'security.txt'; + $fp = fopen($name, 'rt'); + + header('Content-type: text/plain; charset=utf-8'); + header("Content-Length: " . filesize($name)); + + fpassthru($fp); + exit; + } +} diff --git a/static/routes.config.php b/static/routes.config.php index 031f6082b..1f3e9fa9f 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -44,6 +44,7 @@ return [ '/.well-known' => [ '/host-meta' => [Module\WellKnown\HostMeta::class, [R::GET]], '/nodeinfo' => [Module\WellKnown\NodeInfo::class, [R::GET]], + '/security.txt' => [Module\WellKnown\SecurityTxt::class, [R::GET]], '/webfinger' => [Module\Xrd::class, [R::GET]], '/x-nodeinfo2' => [Module\NodeInfo210::class, [R::GET]], '/x-social-relay' => [Module\WellKnown\XSocialRelay::class, [R::GET]],