forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1346 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
13 changed files
with
302 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'HITCON', | ||
url: 'hitcon.org', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<ul> | ||
<li>{{ vender }}</li> | ||
<li>ZDID: {{ code }}</li> | ||
<li>風險: {{ risk }}</li> | ||
<li>處理狀態: {{ status }}</li> | ||
<li>通報者: {{ reporter }}</li> | ||
<li>通報日期: {{ date }}</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import type { Data, DataItem, Route } from '@/types'; | ||
import type { Context } from 'hono'; | ||
import { load } from 'cheerio'; | ||
import puppeteer from '@/utils/puppeteer'; | ||
import logger from '@/utils/logger'; | ||
import { art } from '@/utils/render'; | ||
import path from 'node:path'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import { getCurrentPath } from '@/utils/helpers'; | ||
|
||
const __dirname = getCurrentPath(import.meta.url); | ||
|
||
export const route: Route = { | ||
name: '漏洞', | ||
categories: ['programming'], | ||
path: '/zeroday/vulnerability/:status?', | ||
example: '/hitcon/zeroday/vulnerability', | ||
parameters: { | ||
status: '漏洞状态,见下表', | ||
}, | ||
maintainers: ['KarasuShin'], | ||
radar: [ | ||
{ | ||
source: ['zeroday.hitcon.org/vulnerability/:status?'], | ||
}, | ||
], | ||
features: { | ||
requirePuppeteer: true, | ||
}, | ||
handler, | ||
description: `| 缺省 | all | closed | disclosed | patching | | ||
| ------ | ---- | ------ | --------- | -------- | | ||
| 活動中 | 全部 | 關閉 | 公開 | 修補中 |`, | ||
}; | ||
|
||
const baseUrl = 'https://zeroday.hitcon.org/vulnerability'; | ||
|
||
const titleMap = { | ||
all: '全部', | ||
closed: '關閉', | ||
disclosed: '公開', | ||
patching: '修補中', | ||
}; | ||
|
||
async function handler(ctx: Context): Promise<Data> { | ||
let url = baseUrl; | ||
const status = ctx.req.param('status'); | ||
if (status) { | ||
url += `/${status}`; | ||
} | ||
|
||
const browser = await puppeteer(); | ||
const page = await browser.newPage(); | ||
await page.setRequestInterception(true); | ||
|
||
page.on('request', (request) => { | ||
request.resourceType() === 'document' ? request.continue() : request.abort(); | ||
}); | ||
|
||
logger.http(`Requesting ${url}`); | ||
await page.goto(url, { | ||
waitUntil: 'domcontentloaded', | ||
}); | ||
|
||
const response = await page.evaluate(() => document.documentElement.innerHTML); | ||
browser.close(); | ||
|
||
const $ = load(response); | ||
const items: DataItem[] = $('.zdui-strip-list>li') | ||
.toArray() | ||
.map((el) => { | ||
const title = $(el).find('.title a'); | ||
const vulData = $(el).find('.vul-data'); | ||
const code = vulData | ||
.find('.code') | ||
.contents() | ||
.filter(function () { | ||
return this.nodeType === 3; | ||
}) | ||
.text(); | ||
const risk = vulData.find('.risk span').eq(1).text(); | ||
const vender = vulData.find('.vender').find('.v-name-full').text(); | ||
const status = vulData.find('.status').text().replace('Status:', '').trim(); | ||
const date = vulData.find('.date').text().replace('Date:', '').trim(); | ||
const reporter = vulData.find('.zdui-author-badge').find('a>span').text(); | ||
const description = art(path.join(__dirname, 'templates/zeroday.art'), { | ||
code, | ||
risk, | ||
vender, | ||
status, | ||
date, | ||
reporter, | ||
}); | ||
|
||
return { | ||
title: title.text(), | ||
link: title.attr('href'), | ||
description, | ||
pubDate: parseDate(date), | ||
}; | ||
}); | ||
|
||
return { | ||
title: status ? titleMap[status] ?? 'ZeroDay' : '活動中', | ||
link: url, | ||
item: items, | ||
image: 'https://zeroday.hitcon.org/images/favicon/favicon.png', | ||
}; | ||
} |
Oops, something went wrong.