fix: 发布 1.1.34,知识库列出本机模板,更新包在三端都能解压

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-28 18:28:55 +08:00
1 parent b74c7f9bea
commit 769515e1f1
12 files changed
+447 -56

No files matched your search

+27 -14
View File
@@ -739,11 +739,14 @@ export function dispatch(store, req = {}) {
/* 知识库是全局的(跨靶标共享),所以这几个 op 不需要 engagement */
if (op === 'pocSearch') {
const items = store.searchPocs(req)
/* "现成的"有两层:本机沉淀的 POC/EXP + 本机 nuclei 模板库。一次返回,省一轮往返。 */
/* "现成的"有两层:本机沉淀的 POC/EXP + 本机 nuclei 模板库。一次返回,省一轮往返。
没关键字时也返回一页模板,面板才能看见本机模板,而不是只显示总数。 */
const q = req.q || req.query || req.cve || req.component || ''
const templates = q
? store.searchTemplates(q, Math.min(Number(req.templateLimit) || 20, 100))
: { dir: store.nucleiTemplatesDir() || null, total: store.templateStats().total, items: [] }
const templates = store.searchTemplates(
q,
Math.min(Number(req.templateLimit) || 40, 80),
Number(req.templateOffset) || 0,
)
return { ok: true, items, stats: store.pocStats(), templates }
}
if (op === 'pocList') return { ok: true, items: store.searchPocs(req), stats: store.pocStats() }
@@ -3762,19 +3765,29 @@ export class RedteamStore {
* 在本机 nuclei 模板库里检索:CVE 编号按文件名就能命中,组件/关键字再匹配 name 与 tags。
* 这是"知识库里没有、但本机其实已有现成 POC"的那一层,先查它能省掉一轮互联网检索。
*/
searchTemplates(q, limit = 40) {
searchTemplates(q, limit = 40, offset = 0) {
const { dir, items } = this.#nucleiIndex()
if (dir === null) return { dir: null, total: 0, items: [] }
if (dir === null) return { dir: null, total: 0, matched: 0, offset: 0, items: [] }
const cap = Math.min(Math.max(Number(limit) || 40, 1), 80)
const start = Math.max(Number(offset) || 0, 0)
const raw = String(q || '').trim()
if (raw === '') return { dir, total: items.length, items: [] }
const needle = raw.toLowerCase()
const out = []
for (const [path, name, severity, tags] of items) {
const hay = (path + ' ' + name + ' ' + tags).toLowerCase()
if (hay.includes(needle)) out.push({ path, name, severity, tags })
if (out.length >= limit) break
/* 没关键字时也要列出一页。跳过 .github 这类没有 name/severity 的 yaml,否则第一页不是模板。 */
const listed = (row) => {
const file = String(row[0] || '').replace(/\\/g, '/')
if (file.startsWith('.') || file.includes('/.')) return false
return Boolean(row[1] || row[2])
}
return { dir, total: items.length, items: out }
let matched = items.filter(listed)
if (raw !== '') {
const needle = raw.toLowerCase()
matched = []
for (const row of items) {
const hay = (row[0] + ' ' + row[1] + ' ' + row[3]).toLowerCase()
if (hay.includes(needle)) matched.push(row)
}
}
const page = matched.slice(start, start + cap).map(([path, name, severity, tags]) => ({ path, name, severity, tags }))
return { dir, total: items.length, matched: matched.length, offset: start, items: page }
}