From f12f6a2dba100f7622874e5b5fd35d7417ab9582 Mon Sep 17 00:00:00 2001 From: ORelio Date: Mon, 16 Sep 2019 21:25:28 +0200 Subject: [PATCH] [DarkReading] Add DarkReading Bridge (#1289) --- bridges/DarkReadingBridge.php | 79 +++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 bridges/DarkReadingBridge.php diff --git a/bridges/DarkReadingBridge.php b/bridges/DarkReadingBridge.php new file mode 100644 index 00000000000..3baaad75500 --- /dev/null +++ b/bridges/DarkReadingBridge.php @@ -0,0 +1,79 @@ + array( + 'name' => 'Feed', + 'type' => 'list', + 'values' => array( + 'All Dark Reading Stories' => '000_AllArticles', + 'Attacks/Breaches' => '644_Attacks/Breaches', + 'Application Security' => '645_Application%20Security', + 'Database Security' => '646_Database%20Security', + 'Cloud' => '647_Cloud', + 'Endpoint' => '648_Endpoint', + 'Authentication' => '649_Authentication', + 'Privacy' => '650_Privacy', + 'Mobile' => '651_Mobile', + 'Perimeter' => '652_Perimeter', + 'Risk' => '653_Risk', + 'Compliance' => '654_Compliance', + 'Operations' => '655_Operations', + 'Careers and People' => '656_Careers%20and%20People', + 'Identity and Access Management' => '657_Identity%20and%20Access%20Management', + 'Analytics' => '658_Analytics', + 'Threat Intelligence' => '659_Threat%20Intelligence', + 'Security Monitoring' => '660_Security%20Monitoring', + 'Vulnerabilities / Threats' => '661_Vulnerabilities%20/%20Threats', + 'Advanced Threats' => '662_Advanced%20Threats', + 'Insider Threats' => '663_Insider%20Threats', + 'Vulnerability Management' => '664_Vulnerability%20Management', + ) + ) + )); + + public function collectData(){ + $feed = $this->getInput('feed'); + $feed_splitted = explode('_', $feed); + $feed_id = $feed_splitted[0]; + $feed_name = $feed_splitted[1]; + if(empty($feed) || !ctype_digit($feed_id) || !preg_match('/[A-Za-z%20\/]/', $feed_name)) { + returnClientError('Invalid feed, please check the "feed" parameter.'); + } + $feed_url = $this->getURI() . 'rss_simple.asp'; + if ($feed_id != '000') { + $feed_url .= '?f_n=' . $feed_id . '&f_ln=' . $feed_name; + } + $this->collectExpandableDatas($feed_url); + } + + protected function parseItem($newsItem){ + $item = parent::parseItem($newsItem); + $article = getSimpleHTMLDOMCached($item['uri']) + or returnServerError('Could not request Dark Reading: ' . $item['uri']); + $item['content'] = $this->extractArticleContent($article); + $item['enclosures'] = array(); //remove author profile picture + return $item; + } + + private function extractArticleContent($article){ + $content = $article->find('div#article-main', 0)->innertext; + + foreach (array( + '
'); + + return $content; + } +}