|
@@ -3756,19 +3756,21 @@ TEST_F(ApiFixture, BootstrapAsksForEncryptionOnAnAlreadyEXISTINGCollection) {
|
|
|
|
|
|
|
|
// --- is a credential actually encrypted at rest? ----------------------------
|
|
// --- is a credential actually encrypted at rest? ----------------------------
|
|
|
//
|
|
//
|
|
|
-// The test above asserts getCollectionInfo()->encrypted, which is THE FLAG.
|
|
|
|
|
-// The database team then established, by code reading and a canary of their
|
|
|
|
|
-// own, that nothing in the write path reads that flag - so the flag is not
|
|
|
|
|
-// evidence about the bytes, and a test asserting it was pinning a mechanism
|
|
|
|
|
-// that does not exist. That is the same proxy-not-the-thing failure this file
|
|
|
|
|
-// is full of notes about, committed by me.
|
|
|
|
|
|
|
+// The test above asserts getCollectionInfo()->encrypted, which is THE FLAG,
|
|
|
|
|
+// and a flag is not evidence about bytes. Worse than merely weak: measured on
|
|
|
|
|
+// 2.17.0, `info default:vectorapi_settings` reports `encrypted: no` while the
|
|
|
|
|
+// stored data IS encrypted, because that call reports the collection's OWN
|
|
|
|
|
+// options and not the merged rule actually enforced (a bare-name alias can
|
|
|
|
|
+// carry the flag). So the flag can be wrong in BOTH directions, and reading it
|
|
|
|
|
+// as the answer is how this file's author once concluded that two credential
|
|
|
|
|
+// collections would survive the migration unencrypted. They did not.
|
|
|
//
|
|
//
|
|
|
// This asserts the PROPERTY: write a credential through our own route, then
|
|
// This asserts the PROPERTY: write a credential through our own route, then
|
|
|
// look for it in the database's data directory. It needs the directory to be
|
|
// look for it in the database's data directory. It needs the directory to be
|
|
|
// readable from here, which it is for the bind-mounted dev container, so the
|
|
// readable from here, which it is for the bind-mounted dev container, so the
|
|
|
// test SKIPS rather than fails when it is not - a skip says "not checked",
|
|
// test SKIPS rather than fails when it is not - a skip says "not checked",
|
|
|
// which is honest, where a pass would be a false assurance.
|
|
// which is honest, where a pass would be a false assurance.
|
|
|
-TEST_F(ApiFixture, AStoredSecretIsCurrentlyPLAINTEXTatRest) {
|
|
|
|
|
|
|
+TEST_F(ApiFixture, AStoredSecretIsENCRYPTEDatRest) {
|
|
|
const char* dataDir = "/data/smartbotic-db/data";
|
|
const char* dataDir = "/data/smartbotic-db/data";
|
|
|
struct stat st{};
|
|
struct stat st{};
|
|
|
if (::stat(dataDir, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
|
if (::stat(dataDir, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
|
@@ -3800,26 +3802,21 @@ TEST_F(ApiFixture, AStoredSecretIsCurrentlyPLAINTEXTatRest) {
|
|
|
}
|
|
}
|
|
|
c.Delete(path.c_str());
|
|
c.Delete(path.c_str());
|
|
|
|
|
|
|
|
- // ASSERTS THE DEFECT, deliberately. The property we want does NOT hold:
|
|
|
|
|
- // collection-level `encrypted=true` encrypts nothing, and the database's
|
|
|
|
|
- // sensitive-field patterns need a dot before the name so our top-level
|
|
|
|
|
- // `value` never matched. Measured here: the canary appears in
|
|
|
|
|
- // `wal/wal-current.log` and in the project's `env/data.mdb`.
|
|
|
|
|
|
|
+ // FLIPPED on 2026-10-12, by this test failing and telling us to. It used
|
|
|
|
|
+ // to assert the DEFECT - that the canary WAS findable on disk - and said
|
|
|
|
|
+ // the moment to turn it round would be the release that shipped encryption
|
|
|
|
|
+ // at rest. Database 2.17.0 is that release, and this is what a
|
|
|
|
|
+ // self-correcting test is for: the suite announced the change rather than
|
|
|
|
|
+ // staying green through it or being quietly deleted.
|
|
|
//
|
|
//
|
|
|
- // Pinned this way round rather than left failing, for two reasons. A
|
|
|
|
|
- // permanently red test gets ignored, and this one is self-correcting: when
|
|
|
|
|
- // the database ships encryption at rest, THIS TEST FAILS and says so,
|
|
|
|
|
- // which is the moment to flip it back to `hits.empty()` and delete this
|
|
|
|
|
- // comment. A silent skip would have hidden the exposure instead.
|
|
|
|
|
- EXPECT_FALSE(hits.empty())
|
|
|
|
|
- << "A secret is NO LONGER plaintext at rest - the database appears to have shipped "
|
|
|
|
|
- "encryption. Flip this assertion back to hits.empty() and remove the known-defect "
|
|
|
|
|
- "framing; the credentials written before that release are still plaintext and need "
|
|
|
|
|
- "rewriting.";
|
|
|
|
|
- if (!hits.empty()) {
|
|
|
|
|
- GTEST_LOG_(WARNING)
|
|
|
|
|
- << "KNOWN DEFECT: a project secret written through our own route is PLAINTEXT in "
|
|
|
|
|
- "the database's data directory, and therefore in every backup of it. Files:\n"
|
|
|
|
|
- << hits;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Now it asserts the PROPERTY, which is the only form worth having. Not a
|
|
|
|
|
+ // flag, not getCollectionInfo, not a capability name: a credential is
|
|
|
|
|
+ // written through our own HTTP route and then looked for in the bytes on
|
|
|
|
|
+ // disk. `grep -F`, because a bare `$ENC$` pattern is a regex anchor and
|
|
|
|
|
+ // matches nothing - a false clean.
|
|
|
|
|
+ EXPECT_TRUE(hits.empty())
|
|
|
|
|
+ << "A project secret written through our own route is PLAINTEXT in the database's data "
|
|
|
|
|
+ "directory, and therefore in every backup of it. Encryption at rest is not in "
|
|
|
|
|
+ "effect for this collection. Files:\n"
|
|
|
|
|
+ << hits;
|
|
|
}
|
|
}
|