From ac747e1a5bf749c1f3e72d8435c3d3b692ff6e7e Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Sun, 23 Feb 2020 18:30:59 +0100
Subject: [PATCH] [FEATURE] Dashboard widget: TYPO3 security advisories

A new widget is added which displays a list of security
advisories from the typo3.org RSS feed.

Resolves: #90512
Releases: master
Change-Id: Ie01eb859c8f434efea7383e43134aafa251fdc10
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63397
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Kay Strobach <typo3@kay-strobach.de>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Kay Strobach <typo3@kay-strobach.de>
Reviewed-by: Richard Haeser <richard@maxserv.com>
---
 .../master/Feature-90333-Dashboard.rst        |  1 +
 .../Widgets/T3SecurityAdvisoriesWidget.php    | 31 +++++++++++++++++++
 .../dashboard/Configuration/Services.yaml     |  7 +++++
 .../Resources/Private/Language/locallang.xlf  | 10 ++++++
 4 files changed, 49 insertions(+)
 create mode 100644 typo3/sysext/dashboard/Classes/Widgets/T3SecurityAdvisoriesWidget.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-90333-Dashboard.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-90333-Dashboard.rst
index 884f3e92021b..41613a8aa325 100644
--- a/typo3/sysext/core/Documentation/Changelog/master/Feature-90333-Dashboard.rst
+++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-90333-Dashboard.rst
@@ -31,6 +31,7 @@ Available widgets
 The following widgets are shipped by core extensions now:
 
 * TYPO3 news: A widget showing the latest 5 news items from typo3.org (EXT:dashboard)
+* TYPO3 security advisories: A widget showing the latest 5 security advisories from typo3.org (EXT:dashboard)
 * TYPO3: This widget will show you some background information about TYPO3 and shows the current version of TYPO3 installed (EXT:dashboard)
 * Getting started with TYPO3: This widget will provide a link to the Getting Started Tutorial (EXT:dashboard)
 * TypoScript Template Reference: This widget will provide a link to the TypoScript Template Reference (EXT:dashboard)
diff --git a/typo3/sysext/dashboard/Classes/Widgets/T3SecurityAdvisoriesWidget.php b/typo3/sysext/dashboard/Classes/Widgets/T3SecurityAdvisoriesWidget.php
new file mode 100644
index 000000000000..3d8b17dbdeab
--- /dev/null
+++ b/typo3/sysext/dashboard/Classes/Widgets/T3SecurityAdvisoriesWidget.php
@@ -0,0 +1,31 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Dashboard\Widgets;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * This widget will show the latest security advisories from the TYPO3 news RSS feed
+ * right on the dashboard.
+ */
+class T3SecurityAdvisoriesWidget extends AbstractRssWidget
+{
+    protected $rssFile = 'https://typo3.org/?type=101';
+    protected $lifeTime = 43200; // 12 hours cache
+    protected $title = 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3securityAdvisories.title';
+    protected $description = 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3securityAdvisories.description';
+    protected $iconIdentifier = 'content-widget-rss';
+    protected $moreItemsLink = 'https://typo3.org/help/security-advisories';
+    protected $moreItemsText = 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3securityAdvisories.moreItems';
+}
diff --git a/typo3/sysext/dashboard/Configuration/Services.yaml b/typo3/sysext/dashboard/Configuration/Services.yaml
index 1dd70867675e..711d9111cb5d 100644
--- a/typo3/sysext/dashboard/Configuration/Services.yaml
+++ b/typo3/sysext/dashboard/Configuration/Services.yaml
@@ -71,3 +71,10 @@ services:
       - name: dashboard.widget
         identifier: t3news
         widgetGroups: 'typo3'
+
+  TYPO3\CMS\Dashboard\Widgets\T3SecurityAdvisoriesWidget:
+    arguments: ['t3securityAdvisories']
+    tags:
+      - name: dashboard.widget
+        identifier: t3securityAdvisories
+        widgetGroups: 'typo3'
diff --git a/typo3/sysext/dashboard/Resources/Private/Language/locallang.xlf b/typo3/sysext/dashboard/Resources/Private/Language/locallang.xlf
index 4d1e13e2b42b..4ddb44c4523d 100644
--- a/typo3/sysext/dashboard/Resources/Private/Language/locallang.xlf
+++ b/typo3/sysext/dashboard/Resources/Private/Language/locallang.xlf
@@ -171,6 +171,16 @@
 				<source>Information about the number of failed logins during the last 24 hours.</source>
 			</trans-unit>
 
+			<trans-unit id="widgets.t3securityAdvisories.title" xml:space="preserve">
+				<source>TYPO3 security advisories</source>
+			</trans-unit>
+			<trans-unit id="widgets.t3securityAdvisories.description" xml:space="preserve">
+				<source>Add a list of security advisories from the TYPO3 project</source>
+			</trans-unit>
+			<trans-unit id="widgets.t3securityAdvisories.moreItems" xml:space="preserve">
+				<source>More TYPO3 security advisories</source>
+			</trans-unit>
+
 			<trans-unit id="widget_group.general" xml:space="preserve">
 				<source>General</source>
  			</trans-unit>
-- 
GitLab