Keep relevance matching precise and index construction responsive

This commit is contained in:
0xMarcio committed 2026-10-21 21:42:30 +02:00
1 parent ad3d6b4dc9
commit 00b9a0e4fa
3 files changed
+71 -21

No files matched your search

+1
View File
@@ -164,6 +164,7 @@ class HomepageListTests(unittest.TestCase):
cases = [(None, "N/A"), ("invalid", "N/A"), ("2026-02-30", "N/A"), ("2026-10-08T00:00:00Z", "just now"),
("2026-10-07T08:59:01Z", "just now"), ("2026-10-07T08:59:00Z", "1 minute ago"),
("2026-10-07T08:01:00", "59 minutes ago"), ("2026-10-07T08:00:00Z", "1 hour ago"),
("2026-10-07 08:00:00", "1 hour ago"),
("2026-10-06T09:00:00Z", "1 day ago"), ("2026-10-07", "today"),
("2026-10-06", "1 day ago")]
items = [{**LANDED[0], "released": value} for value, _ in cases]
+16 -1
View File
@@ -117,6 +117,17 @@ test('repository and file names outrank matching owners and GitHub routing segme
assert.deepEqual(search('main'), search('main', true));
});
test('collection routing and category folders stay searchable without outranking the subject', async t => {
const search = await searchFixture(t, [
{ cve: 'CVE-2026-1000', desc: 'Pending details', nuclei: ['https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2026/example.yaml'] },
{ cve: 'CVE-2026-2000', desc: 'HTTP request smuggling', poc: ['https://github.com/owner/poc'] },
{ cve: 'CVE-2026-3000', desc: 'Pending details', nuclei: ['https://github.com/projectdiscovery/nuclei-templates/blob/main/misc/http-smuggling.yaml'] }
]);
assert.deepEqual(search('http'), ['CVE-2026-3000', 'CVE-2026-2000', 'CVE-2026-1000']);
assert.deepEqual(search('http'), search('http', true));
assert.equal(search('nuclei').length, 2);
});
test('aliases, phrases, negatives, named vulnerabilities and typo correction remain usable', async t => {
const search = await searchFixture(t, [
{ cve: 'CVE-2026-1000', desc: 'WordPress SQL injection', poc: ['https://github.com/owner/wp-poc'] },
@@ -137,10 +148,14 @@ test('homepage relative ages advance without refreshing or changing the active s
const { context } = startPage(t, { trending: new Promise(() => {}) });
await new Promise(setImmediate);
vm.runInContext("state.query = 'php2shell'; Date.now = () => Date.parse('2026-10-21T20:00:00Z')", context);
const cell = { getAttribute: () => '2026-10-21T19:00:00Z', outerHTML: '' };
let writes = 0, markup = '';
const cell = { getAttribute: () => '2026-10-21T19:00:00Z',
get outerHTML() { return markup; }, set outerHTML(value) { markup = value; writes++; } };
context.document.querySelectorAll = selector => selector === 'time.trend-age' ? [cell] : [];
vm.runInContext('refreshTrendAges()', context);
assert.match(cell.outerHTML, />1 hour ago<\/time>/);
vm.runInContext('refreshTrendAges()', context);
assert.equal(writes, 1);
vm.runInContext("Date.now = () => Date.parse('2026-10-21T21:00:00Z'); refreshTrendAges()", context);
assert.match(cell.outerHTML, />2 hours ago<\/time>/);
assert.equal(vm.runInContext('state.query', context), 'php2shell');