mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
Stop the plaintext-waveform check passing on a coincidence
It asserted the stored ciphertext does not contain each sample rendered as a string. Base64 is full of digits, so a short sample value like 3 matches by accident: the check failed on a mutation that had nothing to do with encryption, and would equally have passed while leaking. It now asserts the column holds the keyId.base64 envelope and nothing else, which a serialised sample array cannot satisfy.
This commit is contained in:
1 parent
8f90fd3174
commit
42e16a6e12
1 file changed
+7
-4
@@ -194,10 +194,13 @@ describe("POST /api/insights/ecg — round trip through the real routes", () =>
|
||||
where: { id: posted.data.id },
|
||||
});
|
||||
const stored = Buffer.from(row.waveformEncrypted).toString("utf8");
|
||||
for (const sample of SAMPLES) {
|
||||
expect(stored).not.toContain(String(sample));
|
||||
}
|
||||
expect(stored).not.toContain("[12,-7,3");
|
||||
// The column holds the `<keyId>.<base64>` envelope and nothing else. A
|
||||
// serialised sample array cannot satisfy that shape — it carries
|
||||
// brackets, commas and minus signs — so this rules plaintext out without
|
||||
// asking whether some digit happens to appear in a base64 blob, which it
|
||||
// routinely does.
|
||||
expect(stored).toMatch(/^[A-Za-z0-9_-]+\.[A-Za-z0-9+/=]+$/);
|
||||
expect(stored).not.toContain(JSON.stringify(SAMPLES));
|
||||
});
|
||||
|
||||
it("reports a re-post as updated and does not grow the table", async () => {
|
||||
|
||||
Reference in new issue
Block a user