diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2021-06-23 15:49:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 15:49:51 +0200 |
commit | 19a84512d688ae899f0f8efc37b89d2a9676cc48 (patch) | |
tree | e412824a9805ee2b620867d35e8ee1043914e293 /apps | |
parent | a70fd1bad1626e67982ac59d8b3da486ffad70c5 (diff) | |
parent | 65742695d1bd856eb1ce55c1fa5311c4ddcc0a2b (diff) | |
download | nextcloud-server-19a84512d688ae899f0f8efc37b89d2a9676cc48.tar.gz nextcloud-server-19a84512d688ae899f0f8efc37b89d2a9676cc48.zip |
Merge pull request #27628 from nextcloud/security-txt
Add security.txt
Diffstat (limited to 'apps')
4 files changed, 54 insertions, 0 deletions
diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index c4a49aaca07..468afa7dacb 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -65,4 +65,5 @@ return array( 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php', + 'OCA\\Settings\\WellKnown\\SecurityTxtHandler' => $baseDir . '/../lib/WellKnown/SecurityTxtHandler.php', ); diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 0417683ebc6..5418e0cb7c5 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -80,6 +80,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php', + 'OCA\\Settings\\WellKnown\\SecurityTxtHandler' => __DIR__ . '/..' . '/../lib/WellKnown/SecurityTxtHandler.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 8f0434b9ab9..64bb42e0652 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -45,6 +45,7 @@ use OCA\Settings\Mailer\NewUserMailHelper; use OCA\Settings\Middleware\SubadminMiddleware; use OCA\Settings\Search\AppSearch; use OCA\Settings\Search\SectionSearch; +use OCA\Settings\WellKnown\SecurityTxtHandler; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -79,6 +80,9 @@ class Application extends App implements IBootstrap { $context->registerEventListener(UserAddedEvent::class, UserAddedToGroupActivityListener::class); $context->registerEventListener(UserRemovedEvent::class, UserRemovedFromGroupActivityListener::class); + // Register well-known handlers + $context->registerWellKnownHandler(SecurityTxtHandler::class); + /** * Core class wrappers */ diff --git a/apps/settings/lib/WellKnown/SecurityTxtHandler.php b/apps/settings/lib/WellKnown/SecurityTxtHandler.php new file mode 100644 index 00000000000..6e25d485f00 --- /dev/null +++ b/apps/settings/lib/WellKnown/SecurityTxtHandler.php @@ -0,0 +1,48 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2021 Lukas Reschke <lukas@statuscode.ch> + * + * @author 2021 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCA\Settings\WellKnown; + +use OCP\AppFramework\Http\TextPlainResponse; +use OCP\Http\WellKnown\GenericResponse; +use OCP\Http\WellKnown\IHandler; +use OCP\Http\WellKnown\IRequestContext; +use OCP\Http\WellKnown\IResponse; + +class SecurityTxtHandler implements IHandler { + public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse { + if ($service !== 'security.txt') { + return $previousResponse; + } + + $response = "Contact: https://hackerone.com/nextcloud +Expires: 2021-12-31T23:00:00.000Z +Acknowledgments: https://hackerone.com/nextcloud/thanks +Acknowledgments: https://github.com/nextcloud/security-advisories/security/advisories +Policy: https://hackerone.com/nextcloud"; + + return new GenericResponse(new TextPlainResponse($response, 200)); + } +} |