rss-bridge/bridges/OSVBridge.php
Cristian 'void' Giustini 9922787aa9
Some checks failed
Build Image on Commit and Release / bake (push) Failing after 23s
Lint / phpcs (7.4) (push) Failing after 1m2s
Lint / phpcompatibility (7.4) (push) Successful in 1m6s
Lint / executable_php_files_check (push) Failing after 4s
Tests / phpunit8 (7.4) (push) Failing after 55s
Tests / phpunit8 (8.0) (push) Failing after 56s
Tests / phpunit8 (8.1) (push) Failing after 57s
add cybermonit, feedproxy and OSV bridges
remove unnecessary salt
2025-03-23 06:25:04 +01:00

55 lines
1.9 KiB
PHP
Executable File

<?php
class OSVBridge extends BridgeAbstract
{
const NAME = 'OSV';
const DESCRIPTION = 'Parse osv.dev vulns';
const MAINTAINER = 'void';
const URI = "https://osv.dev/list";
const MAIN_DOMAIN = "https://osv.dev";
const PARAMETERS = [[
]];
protected function parseItems($html) {
foreach ($html->find('.vuln-table-row') as $element) {
$item = [];
$link = $element->find('.vuln-table-cell > a', 0);
if (empty($link)) continue;
$time = $element->find('span.vuln-table-cell',3)->find('relative-time',0);
$summary = $element->find('.vuln-summary',0);
$tags = $element->find('ul.tags > li',0);
$item['uri'] = self::MAIN_DOMAIN . $link->href;
$item['title'] = $link->innertext;
$item['title'] .= sprintf(" - %s", trim($summary->innertext));
$item['timestamp'] = $time->datetime;
$packages = "";
foreach ($element->find('ul.packages > li',0) as $pack) {
$packages .= !empty($pack->innertext) ? "<li>$pack->innertext</li>" : "";
}
$tagsout = "";
foreach ($element->find('ul.tags > li > span') as $tag) {
$tagsout .= !empty($tag->innertext) ? "<li>{$tag->innertext}</li>" : "";
}
$item['content'] = "{$link->innertext} - {$summary->innertext}<br/>Published: {$time->innertext}<br/>Packages: <ul>{$packages}</ul><br/>Tags: <ul>{$tagsout}</ul>";
$item['uid'] = $link->innertext;
$this->items[] = $item;
}
}
public function collectData()
{
$html = getSimpleHTMLDOM($this->getURI());
$this->parseItems($html);
usort($this->items, function($a, $b) {
if ($a['timestamp'] == $b['timestamp']) {
return 0;
}
return ($a['timestamp'] > $b['timestamp']) ? -1 : 1;
});
}
}