Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): recover undecryptable connection catalogs safely #13656

Closedwidingmarcus-cyber(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/13656/headopened View on GitHub

Showing 2 changed files with 105 additions and 21 deletions.

x
0 of 2 viewed, 2 left
65 additions and 18 deletionsapps/desktop/src/app/DesktopConnectionCatalogStore.test.tsModified
View file
@@ -405,7 +405,7 @@
​
- it.effect("surfaces a catalog that can no longer be decrypted without deleting it", () =>
+ it.effect("preserves an undecryptable catalog and allows a fresh encrypted catalog", () =>
Effect.gen(function* () {
const path = yield* Path.Path;
const fileSystem = yield* FileSystem.FileSystem;
@@ -413,31 +413,78 @@
prefix: "t3-desktop-connection-catalog-test-",
});
const failDecrypt = yield* Ref.make(false);
- const layer = makeLayer(baseDir, true, failDecrypt);
const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore.pipe(
- Effect.provide(layer),
+ Effect.provide(makeLayer(baseDir, true, failDecrypt)),
+ const stateDir = path.join(baseDir, "userdata");
+ const catalogPath = path.join(stateDir, "connection-catalog.json");
+ const catalog = '{"schemaVersion":1,"targets":[]}';
+ assert.isTrue(yield* store.set(catalog));
+ const original = yield* fileSystem.readFileString(catalogPath);
+ yield* Ref.set(failDecrypt, true);
+​
+ const results = yield* Effect.all([store.get, store.get], { concurrency: "unbounded" });
+ assert.deepStrictEqual(results, [Option.none(), Option.none()]);
+ const backups = (yield* fileSystem.readDirectory(stateDir)).filter((name) =>
+ name.endsWith(".undecryptable"),