Synology - Infos von Webseite "Synology Product Security Advisory" in HTMLBox

Hallo allerseits :slight_smile:

Da es grad aktuell einen Fall gab (FalsePositiv einer Synology System-Datei), was eher unschön ist, hab ich mal ein Skript gebaut, das die Infos von dieser Webseite ausliest und kompakt in eine HTMLBox steckt. Die Absätze in der Beschreibung habe ich bewusst nicht übernommen, da es so einfach kompakter darstellbar ist :slight_smile:

Quell-Webseite:
Security Advisory - Support - Synology - Network Attached Storage (NAS)

So sieht es aus, wenn man die HTMLBox in sein WebFront verlinkt:

Das Skript:

<?
/*********** Synology Security Advisory **************/
/*   Script by Bayaro - for IP-Symcon                                                                         */

/*   Skript 1x ausführen und Variable + Timer werden automatisch erstellt    */
/*   https://www.synology.com/en-us/support/security/                                   */
/*  https://www.symcon.de/forum/threads/28587-Synology-Infos-von-Webseite-Synology-Product-Security-Advisory-in-HTMLBox  */

$AktualisierungsIntervall = 90; // Daten werden alle 90 Minuten aktualisiert


IPS_SetScriptTimer($_IPS['SELF'], $AktualisierungsIntervall * 60);
$curl = curl_init('https://www.synology.com/en-us/support/security/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$page = curl_exec($curl);

if(curl_errno($curl)) // check for execution errors
{
    echo 'Scraper error: ' . curl_error($curl);
    exit;
}
curl_close($curl);

$DOM = new DOMDocument;
libxml_use_internal_errors(true);

if (!$DOM->loadHTML($page))
    {
        $errors="";
        foreach (libxml_get_errors() as $error)  {
            $errors.=$error->message."<br/>";
        }
        libxml_clear_errors();
        print "libxml errors:<br>$errors";
        return;
    }
$xpath = new DOMXPath($DOM);


// Datum
$DatumAR = $xpath->query('.//*[@id="security"]/div[2]/table/tbody/tr[li]/td[1]');[/li]foreach ($DatumAR as $datum_entry) {
	$DatumARx[] = $datum_entry->nodeValue;
}
//print_r($DatumARx);


// Überschrift
$UeberschriftAR = $xpath->query('.//*[@id="security"]/div[2]/table/tbody/tr[li]/td[2]/a/text()');[/li]foreach ($UeberschriftAR as $ueberschrift_entry) {
	$UeberschriftARx[] = $ueberschrift_entry->nodeValue;
}
//print_r($UeberschriftARx);


// Beschreibung
$BeschreibungAR = $xpath->query('.//*[@id="security"]/div[2]/table/tbody/tr[li]/td[2]/div');[/li]foreach ($BeschreibungAR as $beschreibung_entry) {
	$BeschreibungARx[] = str_replace("Description", "", utf8_decode($beschreibung_entry->nodeValue));
}
//print_r($BeschreibungARx);



// Ausgabe in HTMLBox
$HTML = "<html><table>";
for ($i=0; $i<count($DatumARx); $i++) {
	$HTML .= "<tr><th>".$DatumARx[$i]."</th>";
	$HTML .= "<th>".$UeberschriftARx[$i]."</th></tr>";
	$HTML .= "<tr><td colspan='2'>".$BeschreibungARx[$i]."</td></tr>";
	$HTML .= "<tr><th>&nbsp</th></tr> <tr><th>&nbsp</th></tr>";
}
$HTML .= "</table></html>";


// Variable erstellen, falls nicht vorhanden, und den Inhalt setzen
$HTMLBox_VarID = CreateVariableByName($_IPS['SELF'], "Synology - Sicherheitsluecken", 3, "~HTMLBox", "");
SetValue($HTMLBox_VarID, $HTML);



function CreateVariableByName($ParentID, $VarName, $VarTyp, $VarProfile = "", $VarActionScript = "") {
	$VarID = @IPS_GetVariableIDByName($VarName, $ParentID);
   if($VarID === false) {
		$VarID = IPS_CreateVariable($VarTyp);
      IPS_SetParent($VarID, $ParentID);
      IPS_SetName($VarID, $VarName);
      IPS_SetInfo($VarID, "This variable was created by script #".$_IPS["SELF"]);
      if($VarProfile !== "") {
			IPS_SetVariableCustomProfile($VarID, $VarProfile);
		}
		if($VarActionScript !== "") {
			IPS_SetVariableCustomAction($VarID, $VarActionScript);
		}
	}
   return $VarID;
}
?>

Grüße,
Chris