Q124: the file scan covers the whole file and says what it did and did not check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
91fa6b5f1e
commit
7a9059fbea
9 files changed
+175
-31
No files matched your search
@@ -5,7 +5,7 @@ import { join } from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { DatabaseConnection } from "../../src/main/database/connection";
|
||||
import { OrganizationService } from "../../src/main/services/organization-service";
|
||||
import { preserveRecordedFiles, recordWorkspaceFile } from "../../src/main/services/files/file-object-store";
|
||||
import { preserveRecordedFiles, recordWorkspaceFile, rescanLegacyFiles } from "../../src/main/services/files/file-object-store";
|
||||
import { ChatService } from "../../src/main/services/chat-service";
|
||||
import { readAttachmentTool } from "../../src/main/services/agent-attachment-tools";
|
||||
|
||||
@@ -81,3 +81,28 @@ describe("opening a recorded file", () => {
|
||||
connection.close();
|
||||
});
|
||||
});
|
||||
|
||||
describe("files scanned before whole-file scanning", () => {
|
||||
test("are scanned again when their bytes are intact, and marked as sampled when they are not", () => {
|
||||
const connection = new DatabaseConnection(join(tmpdir(), `ac-rescan-${randomUUID()}.db`));
|
||||
let orgId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = new OrganizationService(connection.db).createOrganization({ organizationName: "Acme", employeeName: "Dana", mission: "m", goal: "g" });
|
||||
});
|
||||
const path = join(tmpdir(), `ac-rescan-${randomUUID()}.txt`);
|
||||
const content = `${"x".repeat(2 * 1024 * 1024)}\nAKIAABCDEFGHIJKLMNOP\n`;
|
||||
writeFileSync(path, content);
|
||||
const insert = connection.db.prepare(`
|
||||
insert into file_objects(id, org_id, name, kind, size_bytes, sha256, storage_path, source_path, owner_type, owner_id, pinned, scan_state, scan_labels_json, created_at)
|
||||
values (?, ?, 'notes.txt', 'txt', 1, ?, ?, ?, 'agent', null, 0, 'approved', '["classification:internal"]', ?)
|
||||
`);
|
||||
insert.run("fil_intact", orgId, createHash("sha256").update(content).digest("hex"), path, path, new Date().toISOString());
|
||||
insert.run("fil_gone", orgId, "0".repeat(64), join(tmpdir(), "missing.txt"), join(tmpdir(), "missing.txt"), new Date().toISOString());
|
||||
rescanLegacyFiles(connection.db);
|
||||
const row = (id: string) => connection.db.prepare("select scan_state, scan_labels_json from file_objects where id = ?").get(id) as { scan_state: string; scan_labels_json: string };
|
||||
expect(row("fil_intact").scan_state).toBe("blocked");
|
||||
expect(JSON.parse(row("fil_intact").scan_labels_json)).toContain("scan:whole-file");
|
||||
expect(row("fil_gone")).toEqual({ scan_state: "approved", scan_labels_json: '["classification:internal","scan:legacy-sample"]' });
|
||||
connection.close();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user