mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-03 15:27:56 +01:00
fix: verify re-derives native labels with the collect's class (GST-987, after #3717)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
e03ae75df8
commit
8b591faf9c
2 files changed
+11
-2
No files matched your search
@@ -433,7 +433,7 @@ export function verify(ledger: string): { rows: VerifyRow[]; clean: boolean; bri
|
||||
notes.push(typeof o.file === 'string' ? 'output_file_missing' : 'output_file_unrecorded');
|
||||
differs.push(...ids);
|
||||
} else if (promptHash(text) === o.sha256) {
|
||||
const parsed = parseFindings(reader, text);
|
||||
const parsed = parseFindings(reader, text, o.fixable_raises !== false);
|
||||
const off = ids.filter((id, k) => { const m = lines.find(l => l.id === id); return !m || parsed[k]?.label !== m.label || parsed[k]?.raw !== m.raw; });
|
||||
if (unavailableOutput(o) && parsed.length) { status = 'MISMATCH'; notes.push('unavailable_output_has_findings'); }
|
||||
else if (!unavailableOutput(o)) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { fixableRaises, parseFindings } from '../lib/review-ledger';
|
||||
import { collect, fixableRaises, parseFindings, verify } from '../lib/review-ledger';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const NATIVE = fs.readFileSync(path.join(ROOT, 'test/fixtures/review-ledger/gsta-141-native.md'), 'utf8').split('\n').filter(l => /^\d+\. /.test(l)).join('\n\n');
|
||||
@@ -73,4 +73,13 @@ describe('native FIXABLE by review class (GST-987)', () => {
|
||||
expect(labels(['--manifest', foreign])).toEqual(['CRITICAL', 'CRITICAL']);
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
});
|
||||
test('verify re-derives a code-class collect with the class it was collected under', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gst987v-'));
|
||||
const out = path.join(dir, 'native.txt');
|
||||
fs.writeFileSync(out, NATIVE + '\n');
|
||||
const c = collect(path.join(dir, 'l.jsonl'), 'adversarial-native', NATIVE + '\n', path.join(dir, 'm.jsonl'), out, undefined, undefined, false);
|
||||
expect(c.lines.map(l => l.label)).toEqual(['Medium', 'Low']);
|
||||
expect(JSON.stringify(verify(path.join(dir, 'l.jsonl')))).not.toContain('merged_line_differs');
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user