repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix(bootstrap): separate safe linking from explicit secret restoration

eae2bce2cd455fd38c3263fda468c46dddd75920

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (5)

.gitattributes

Added
new file mode 100644
1 +# BEGIN bootstripper secrets
2 +MusicBrainz/Picard.ini -text filter=dotfiles-aes -diff merge=dotfiles-aes
3 +zed/settings.json -text filter=dotfiles-aes -diff merge=dotfiles-aes
4 +ssh/github.key -text filter=dotfiles-aes -diff merge=dotfiles-aes
5 +ssh/box.bugabinga.net.key -text filter=dotfiles-aes -diff merge=dotfiles-aes
6 +ssh/klops.key -text filter=dotfiles-aes -diff merge=dotfiles-aes
7 +ssh/tini.key -text filter=dotfiles-aes -diff merge=dotfiles-aes
8 +ssh/hetzner.key -text filter=dotfiles-aes -diff merge=dotfiles-aes
9 +ssh/aur.key -text filter=dotfiles-aes -diff merge=dotfiles-aes
10 +ssh/bugabinga.net.key -text filter=dotfiles-aes -diff merge=dotfiles-aes
11 +ssh/code.isp-insoft.de -text filter=dotfiles-aes -diff merge=dotfiles-aes
12 +gh/hosts.yml -text filter=dotfiles-aes -diff merge=dotfiles-aes
13 +aerc/accounts.conf -text filter=dotfiles-aes -diff merge=dotfiles-aes
14 +nushell/secrets.nu -text filter=dotfiles-aes -diff merge=dotfiles-aes
15 +pi/google-workspace/tokens/o.krylow%40isp-insoft.de.json -text filter=dotfiles-aes -diff merge=dotfiles-aes
16 +# END bootstripper secrets

AGENTS.md

Modified
1 1 # Dotfiles
3 3 Dorkfiles repo.
4 +Run this file's commands from the dotfiles root, not a nested project directory.
4 5 Preserve unrelated dirty work.
5 6 Check `git status --short` before edits.
6 7 Prefer repo paths (`pi/agent/...`) over `$HOME` paths.
16 17 `.secrets` is plaintext.
17 18 It lists repo-relative paths to encrypt.
19 -Encryption comes from local Git filter `dotfiles-aes` via `.git/info/attributes`.
20 -`bootstripper` generates that file from `.secrets`.
20 +Encryption comes from local Git filter `dotfiles-aes` via tracked `.gitattributes`.
21 +`bootstripper` generates its managed block from `.secrets` and removes the obsolete block from `.git/info/attributes`.
22 23 For non-interactive crypto bootstrap, env is `DOTFILES_AES_PASSPHRASE`; do not ask for or expose it unless user explicitly initiates setup.
26 27 ```sh
27 28 $EDITOR .secrets
28 29 java bootstripper.java check
30 +git add .secrets .gitattributes
29 31 git check-attr -a -- path/to/secret
79 81 mise run clean
84 +`link` only validates manifests and creates symlinks; it does not configure crypto, restore secrets, install hooks, or fix unrelated permissions.
85 +For initial checkout decryption, explicitly run `mise run setup-crypto`.
86 +It refuses staged edits, local edits, and deletions before writing any tracked secret.
87 +`bootstrap` no longer restores secrets automatically.
82 89 Crypto/hooks:
84 91 ```sh
86 93 java bootstripper.java pre-commit
87 94 java bootstripper.java install-hooks
88 95 java bootstripper.java init-crypto
96 +java bootstripper.java setup-crypto
91 99 ## Global Mise config
97 105 - Settings: `pi/agent/settings.json`
98 106 - Models: `pi/agent/models.json`
99 -- Extensions: `pi/agent/extensions/`
107 +- Extension sources: `pi-ext/extensions/`, loaded through the package configured in `pi/agent/settings.json`.
100 108 - Modes: `pi/agent/modes/`
101 109 - Personal skills: `pi/agent/skills/<name>/SKILL.md` or `pi/agent/skills/<name>.md`
102 110 - `pi/agent/auth.json` is secret; avoid reading/editing unless explicitly asked.
106 114 - Neovim: read `neovim/AGENTS.md` before changes; tests via `cd neovim && just test`.
107 115 - Nugu: load `nugu` skill before palette/theme work.
108 -- Pi-specific changes: load `pi` skill/docs before editing extensions/settings/skills.
116 +- Pi-specific changes: read Pi docs before editing extensions/settings/skills.

bootstripper.java

Modified
16 16 import java.util.Base64;
17 17 import java.util.HashSet;
18 18 import java.util.List;
19 +import java.util.LinkedHashMap;
19 20 import java.util.regex.Pattern;
20 21 import java.util.stream.Collectors;
21 22 import javax.crypto.SecretKeyFactory;
64 65 return;
66 67 if ("check".equals(command)) {
67 - setup_crypto(root, false);
68 + setup_crypto(root);
68 69 check(root);
69 70 return;
71 72 if ("pre-commit".equals(command)) {
72 - setup_crypto(root, false);
73 + setup_crypto(root);
73 74 pre_commit(root);
74 75 return;
86 87 return;
89 - setup_crypto(root, true);
90 + if ("link".equals(command)) {
91 + check_symlink_sources(root);
92 + create_symlinks(root, symlinks_file(root));
93 + print_attention(false);
94 + return;
95 + }
97 + setup_crypto(root);
98 + if ("setup-crypto".equals(command)) {
99 + restore_tracked_secrets(root, read_secrets(root));
100 + return;
90 102 install_hooks(root);
91 103 check(root);
92 104 var symlinks_file = symlinks_file(root);
97 109 static boolean is_command(String argument) {
98 - return "bootstrap".equals(argument) || "clean".equals(argument) || "check".equals(argument) || "pre-commit".equals(argument) || "install-hooks".equals(argument) || "init-crypto".equals(argument);
110 + return "bootstrap".equals(argument) || "link".equals(argument) || "clean".equals(argument) || "check".equals(argument) || "pre-commit".equals(argument) || "install-hooks".equals(argument) || "init-crypto".equals(argument) || "setup-crypto".equals(argument);
101 113 static void init_crypto(Path root) throws Throwable {
111 123 log("Created crypto salt: {0}", emphasize_local(salt_file));
114 - static void setup_crypto(Path root, boolean restore) throws Throwable {
126 + static void setup_crypto(Path root) throws Throwable {
115 127 require_git_repo(root);
116 128 var secrets = read_secrets(root);
117 129 if (secrets.isEmpty())
118 130 return;
119 131 install_filter(root);
120 132 write_attributes(root, secrets);
133 + remove_local_attributes(root);
121 134 ensure_key(root);
122 135 self_test_aes(root);
123 - if (restore)
124 - restore_tracked_secrets(root, secrets);
125 136 apply_secret_permissions(root, secrets);
182 193 return "'" + argument.replace("'", "'\\''") + "'";
185 - static void write_attributes(Path root, List<String> secrets) throws Throwable {
196 + static void write_attributes(Path root, List<String> secrets) throws IOException {
197 + var attributes = root.resolve(".gitattributes");
198 + var content = Files.exists(attributes) ? without_managed_attributes(Files.readString(attributes)) : "";
199 + if (!content.isEmpty() && !content.endsWith("\n"))
200 + content += "\n";
201 + var lines = new ArrayList<String>();
202 + lines.add(attributes_begin);
203 + for (var secret : secrets)
204 + lines.add(secret + " -text filter=" + filter_name + " -diff merge=" + filter_name);
205 + lines.add(attributes_end);
206 + Files.writeString(attributes, content + String.join("\n", lines) + "\n", StandardCharsets.UTF_8);
209 + static void remove_local_attributes(Path root) throws Throwable {
186 210 var attributes = git_common_path(root, "info/attributes");
187 - Files.createDirectories(attributes.getParent());
188 - var previous = Files.exists(attributes) ? Files.readString(attributes) : "";
211 + if (!Files.exists(attributes))
212 + return;
213 + var previous = Files.readString(attributes);
214 + var content = without_managed_attributes(previous);
215 + if (!content.equals(previous))
216 + Files.writeString(attributes, content, StandardCharsets.UTF_8);
219 + static String without_managed_attributes(String content) {
189 220 var lines = new ArrayList<String>();
190 221 var in_block = false;
191 - for (var line : previous.split("\n", -1)) {
222 + for (var line : content.split("\n", -1)) {
192 223 if (attributes_begin.equals(line)) {
193 224 in_block = true;
194 225 continue;
197 228 in_block = false;
198 229 continue;
200 - if (!in_block && !line.isEmpty())
231 + if (!in_block)
201 232 lines.add(line);
203 - lines.add(attributes_begin);
204 - for (var secret : secrets)
205 - lines.add(secret + " -text filter=" + filter_name + " -diff merge=" + filter_name);
206 - lines.add(attributes_end);
207 - Files.writeString(attributes, String.join("\n", lines) + "\n", StandardCharsets.UTF_8);
234 + return String.join("\n", lines);
210 237 static void ensure_key(Path root) throws Throwable {
263 290 static void restore_tracked_secrets(Path root, List<String> secrets) throws Throwable {
264 - var tracked = new ArrayList<String>();
291 + var pending = new LinkedHashMap<Path, byte[]>();
265 292 for (var secret : secrets) {
266 - var result = run(root, List.of("git", "cat-file", "-e", "HEAD:" + secret), null, false, false);
267 - if (result.exit == 0) {
268 - tracked.add(secret);
269 - var path = root.resolve(secret);
270 - if (Files.exists(path) && starts_with(Files.readAllBytes(path), aes_magic))
271 - Files.delete(path);
272 - }
293 + var committed = run(root, List.of("git", "cat-file", "blob", "HEAD:" + secret), null, false, false);
294 + if (committed.exit != 0)
295 + continue;
296 + var path = root.resolve(secret);
297 + var staged = run(root, List.of("git", "diff", "--cached", "--quiet", "HEAD", "--", secret), null, false, false);
298 + if (staged.exit != 0 || !Files.isRegularFile(path, LinkOption.NOFOLLOW_LINKS))
299 + throw fail("Refusing to restore locally changed secret: {0}", secret);
300 + var plain = run(root, List.of("java", aes_tool_argument(root), "decrypt", "--key-file", key_argument(root)), committed.stdout, false).stdout;
301 + var current = Files.readAllBytes(path);
302 + if (Arrays.equals(current, committed.stdout))
303 + pending.put(path, plain);
304 + else if (!Arrays.equals(current, plain))
305 + throw fail("Refusing to restore locally changed secret: {0}", secret);
274 - if (tracked.isEmpty())
275 - return;
276 - var command = new ArrayList<String>();
277 - command.addAll(List.of("git", "restore", "--source=HEAD", "--worktree", "--"));
278 - command.addAll(tracked);
279 - run(root, command, null, false);
307 + for (var entry : pending.entrySet())
308 + Files.write(entry.getKey(), entry.getValue());
282 311 static void apply_secret_permissions(Path root, List<String> secrets) throws IOException {
299 328 static void pre_commit(Path root) throws Throwable {
300 329 check(root);
330 + check_staged_matches_worktree(root, secrets_file);
331 + check_staged_matches_worktree(root, ".gitattributes");
334 + static void check_staged_matches_worktree(Path root, String path) throws Throwable {
335 + var tracked = run(root, List.of("git", "ls-files", "--error-unmatch", "--", path), null, false, false);
336 + var changed = run(root, List.of("git", "diff", "--quiet", "--", path), null, false, false);
337 + if (tracked.exit != 0 || changed.exit != 0)
338 + throw fail("{0} must match the staged version.", path);
303 341 static void check(Path root) throws Throwable {
648 686 static void usage() {
649 687 log("Bootstraps bugabingas {0}.", emphasize_local("dorkfiles"));
650 - log("{0}: java bootstripper.java [init-crypto|check|pre-commit|install-hooks|clean] [dotfiles root path]", emphasize_global("Usage"));
688 + log("{0}: java bootstripper.java [bootstrap|link|init-crypto|setup-crypto|check|pre-commit|install-hooks|clean] [dotfiles root path]", emphasize_global("Usage"));
653 691 static String emphasize_global(String message) {

mise.toml

Modified
22 22 hide = true
23 23 run = 'run("java", "./scripts/dotfiles_integration_test.java", "--inside");'
25 +[tasks.crypto-test]
26 +description = "Run focused crypto integration tests"
27 +hide = true
28 +run = 'run("java", "./scripts/dotfiles_integration_test.java", "--crypto");'
25 30 [tasks.link]
26 -description = "Link dorkfiles into HOME"
27 -run = '''
28 -run("java", "bootstripper.java", "bootstrap");
29 -run("java", "scripts/fix_permissions.java");
30 -'''
31 +description = "Validate manifests and link dorkfiles into HOME"
32 +run = 'run("java", "bootstripper.java", "link");'
34 +[tasks.setup-crypto]
35 +description = "Configure crypto and decrypt unchanged checkout secrets; refuse local changes"
36 +run = 'run("java", "bootstripper.java", "setup-crypto");'
32 38 [tasks.clean]
33 39 description = "Remove managed dorkfiles links from HOME"
47 53 description = "Fix local file permissions"
48 54 hide = true
49 55 run = 'run("java", "scripts/fix_permissions.java");'

scripts/dotfiles_integration_test.java

Modified
9 9 public static void main(String[] args) throws Exception {
10 10 if (args.length > 0 && args[0].equals("--inside")) inside();
11 - else host();
11 + else if (args.length > 0 && args[0].equals("--crypto")) {
12 + root = Path.of(run(null, "git", "rev-parse", "--show-toplevel").trim());
13 + freshCryptoChecks();
14 + } else host();
14 17 static void host() throws Exception {
80 83 if (!run(root, "git", "show", "HEAD:nushell/secrets.nu").startsWith("DFAES1")) fail("committed-encrypted");
81 84 ok("committed-encrypted");
86 + run(root, "mise", "run", "setup-crypto");
83 87 var hosts = allHosts();
84 88 System.out.println("manifests=" + String.join(" ", hosts));
85 89 for (var host : hosts) runManifest(host);
93 97 run(root, ".git/hooks/pre-commit");
94 98 ok("pre-commit-hook");
96 - freshCryptoSmoke();
100 + freshCryptoChecks();
97 101 System.out.println("RESULT:ok");
146 150 ok("clean:" + host);
149 - static void freshCryptoSmoke() throws Exception {
150 - var home = Path.of(System.getProperty("user.home"), "fresh-crypto-home");
153 + static void freshCryptoChecks() throws Exception {
154 + var home = Files.createTempDirectory(Path.of(System.getProperty("user.home")), "dotfiles-crypto-test-");
155 + try {
156 + freshCryptoChecks(home);
157 + } finally {
158 + deleteTree(home);
162 + static void freshCryptoChecks(Path home) throws Exception {
151 163 var repo = home.resolve("repo");
152 - deleteTree(home);
153 164 Files.createDirectories(repo.resolve("tools"));
154 165 Files.createDirectories(home);
155 166 Files.copy(root.resolve("bootstripper.java"), repo.resolve("bootstripper.java"));
156 167 Files.copy(root.resolve("tools/aes.java"), repo.resolve("tools/aes.java"));
168 + Files.copy(root.resolve("mise.toml"), repo.resolve("mise.toml"));
169 + Files.createDirectories(repo.resolve("scripts"));
170 + Files.copy(root.resolve("scripts/mise_shell.java"), repo.resolve("scripts/mise_shell.java"));
157 171 Files.writeString(repo.resolve(".secrets"), "secret.txt\n");
158 172 Files.writeString(repo.resolve("mini.symlinks"), "dummy.txt\n~/dummy.txt\n");
159 173 Files.writeString(repo.resolve("secret.txt"), "alpha=base\nmiddle=stable\nomega=base\n");
161 175 run(repo, "git", "init", "--quiet");
162 176 run(repo, "git", "config", "user.name", "Dotfiles Test");
163 177 run(repo, "git", "config", "user.email", "dotfiles@example.invalid");
178 + Files.writeString(repo.resolve(".git/info/attributes"), "*.bin -diff\n# BEGIN bootstripper secrets\nsecret.txt -text filter=dotfiles-aes -diff merge=dotfiles-aes\n# END bootstripper secrets\n");
164 179 var env = Map.of("DOTFILES_AES_PASSPHRASE", "test", "JAVA_TOOL_OPTIONS", "-Duser.home=" + home);
180 + run(repo, "mise", "trust", "--yes");
181 + linkOnlyChecks(repo, home, env);
165 182 run(repo, env, "java", "bootstripper.java", "init-crypto");
183 + run(repo, env, "mise", "run", "setup-crypto");
166 184 run(repo, env, "java", "bootstripper.java", "check");
167 - run(repo, env, "git", "add", ".dotfiles-aes-salt", ".secrets", "bootstripper.java", "tools/aes.java", "mini.symlinks", "dummy.txt", "secret.txt");
168 - run(repo, env, "java", "bootstripper.java", "check");
185 + if (!Files.readString(repo.resolve(".gitattributes")).contains("secret.txt -text filter=dotfiles-aes -diff merge=dotfiles-aes")) fail("tracked-attributes-generated");
186 + if (!Files.readString(repo.resolve(".git/info/attributes")).equals("*.bin -diff\n")) fail("local-attributes-migrated");
187 + if (!runExpectFail(repo, env, "java", "bootstripper.java", "pre-commit").contains(".secrets must match the staged version")) fail("unstaged-secret-manifest-not-rejected");
188 + run(repo, env, "git", "add", ".dotfiles-aes-salt", ".gitattributes", ".secrets", "bootstripper.java", "tools/aes.java", "mini.symlinks", "dummy.txt", "secret.txt");
189 + run(repo, env, "java", "bootstripper.java", "pre-commit");
169 190 if (!run(repo, "git", "show", ":secret.txt").startsWith("DFAES1")) fail("fresh-staged-encrypted");
170 191 run(repo, "git", "commit", "--quiet", "-m", "base");
171 192 var base = run(repo, "git", "rev-parse", "HEAD").trim();
194 + Files.writeString(repo.resolve(".gitattributes"), Files.readString(repo.resolve(".gitattributes")) + "*.tmp -diff\n");
195 + if (!runExpectFail(repo, env, "java", "bootstripper.java", "pre-commit").contains(".gitattributes must match the staged version")) fail("unstaged-attributes-not-rejected");
196 + run(repo, "git", "restore", ".gitattributes");
197 + Files.writeString(repo.resolve(".secrets"), "secret.txt\nincoming-secret.txt\n");
198 + Files.writeString(repo.resolve("incoming-secret.txt"), "incoming=plain\n");
199 + run(repo, env, "java", "bootstripper.java", "check");
200 + run(repo, "git", "add", ".secrets", ".gitattributes", "incoming-secret.txt");
201 + run(repo, env, "java", "bootstripper.java", "pre-commit");
202 + run(repo, "git", "commit", "--quiet", "-m", "add encrypted secret");
203 + var incoming = run(repo, "git", "rev-parse", "HEAD").trim();
204 + run(repo, "git", "switch", "--quiet", "--detach", base);
205 + run(repo, "git", "merge", "--quiet", "--ff-only", incoming);
206 + if (!Files.readString(repo.resolve("incoming-secret.txt")).equals("incoming=plain\n")) fail("same-pull-secret-not-smudged");
207 + ok("same-pull-secret-smudged");
208 + base = incoming;
209 + cryptoRestoreChecks(repo, env);
173 211 run(repo, "git", "switch", "--quiet", "-c", "secret-other");
174 212 Files.writeString(repo.resolve("secret.txt"), "alpha=other\nmiddle=stable\nomega=base\n");
175 213 run(repo, "git", "add", "secret.txt");
212 250 wslEnv.put("WSL_DISTRO_NAME", "mini");
213 251 wslEnv.put("HOSTNAME", "ignored");
214 252 run(repo, wslEnv, "java", "bootstripper.java", "bootstrap");
253 + if (!Files.readString(repo.resolve("secret.txt")).equals("not a real secret\n")) fail("bootstrap-overwrote-local-secret");
215 254 if (!Files.isSymbolicLink(wslHome.resolve("dummy.txt"))) fail("fresh-wsl-distro-manifest");
216 255 run(repo, wslEnv, "java", "bootstripper.java", "clean");
217 256 var env2 = new HashMap<>(env); env2.put("HOSTNAME", "mini");
224 263 ok("fresh-crypto");
266 + static void linkOnlyChecks(Path repo, Path home, Map<String, String> env) throws Exception {
267 + var linkEnv = new HashMap<>(env);
268 + linkEnv.put("DOTFILES_SYMLINKS", "mini");
269 + var config = Files.readString(repo.resolve(".git/config"));
270 + var attributes = Files.readString(repo.resolve(".git/info/attributes"));
271 + var secret = Files.readString(repo.resolve("secret.txt"));
272 + for (var attempt = 0; attempt < 2; attempt++) run(repo, linkEnv, "mise", "run", "link");
273 + if (!Files.isSymbolicLink(home.resolve("dummy.txt")) || !Files.isSameFile(home.resolve("dummy.txt"), repo.resolve("dummy.txt"))) fail("link-only-target");
274 + if (!Files.readString(repo.resolve("secret.txt")).equals(secret)) fail("link-only-secret-changed");
275 + if (!Files.readString(repo.resolve(".git/config")).equals(config)) fail("link-only-config-changed");
276 + if (!Files.readString(repo.resolve(".git/info/attributes")).equals(attributes)) fail("link-only-attributes-changed");
277 + for (var path : List.of(".git/dotfiles-aes.key", ".gitattributes", ".git/hooks/pre-commit"))
278 + if (Files.exists(repo.resolve(path))) fail("link-only-created:" + path);
279 + Files.delete(home.resolve("dummy.txt"));
281 + var manifest = repo.resolve("mini.symlinks");
282 + var original = Files.readString(manifest);
283 + for (var invalid : List.of("missing.txt\n~/missing.txt\n", "dummy.txt\n", "dummy.txt\n~/dummy.txt\n", "dummy.txt\n/etc/dotfiles-test\n")) {
284 + Files.writeString(manifest, original + invalid);
285 + runExpectFail(repo, linkEnv, "mise", "run", "link");
286 + if (Files.exists(home.resolve("dummy.txt"), LinkOption.NOFOLLOW_LINKS)) fail("link-before-validation");
288 + Files.writeString(manifest, original);
289 + ok("link-only-and-manifest-validation");
292 + static void cryptoRestoreChecks(Path repo, Map<String, String> env) throws Exception {
293 + var first = repo.resolve("secret.txt");
294 + var second = repo.resolve("incoming-secret.txt");
295 + var firstPlain = Files.readAllBytes(first);
296 + var secondPlain = Files.readAllBytes(second);
297 + run(repo, env, "java", "tools/aes.java", "encrypt", "--key-file", ".git/dotfiles-aes.key", "secret.txt", "encrypted-secret.txt");
298 + var encrypted = Files.readAllBytes(repo.resolve("encrypted-secret.txt"));
299 + Files.delete(repo.resolve("encrypted-secret.txt"));
300 + Files.write(first, encrypted);
301 + var index = Files.readAllBytes(repo.resolve(".git/index"));
302 + run(repo, env, "mise", "run", "setup-crypto");
303 + if (!Arrays.equals(Files.readAllBytes(first), firstPlain)) fail("explicit-crypto-decryption");
304 + if (!Arrays.equals(Files.readAllBytes(repo.resolve(".git/index")), index)) fail("crypto-changed-index");
305 + var modified = Files.getLastModifiedTime(first);
306 + run(repo, env, "mise", "run", "setup-crypto");
307 + if (!Files.getLastModifiedTime(first).equals(modified)) fail("crypto-rewrote-plaintext");
309 + for (var change : List.of("plaintext", "ciphertext", "deleted", "staged", "staged-deletion")) {
310 + Files.write(first, encrypted);
311 + Files.write(second, secondPlain);
312 + switch (change) {
313 + case "plaintext", "staged" -> Files.writeString(second, "local change\n");
314 + case "ciphertext" -> Files.write(second, encrypted);
315 + case "deleted" -> Files.delete(second);
316 + case "staged-deletion" -> run(repo, "git", "rm", "--cached", "--quiet", "incoming-secret.txt");
318 + if (change.equals("staged")) run(repo, "git", "add", "incoming-secret.txt");
319 + var before = Files.exists(second) ? Files.readAllBytes(second) : null;
320 + index = Files.readAllBytes(repo.resolve(".git/index"));
321 + if (!runExpectFail(repo, env, "mise", "run", "setup-crypto").contains("Refusing to restore locally changed secret")) fail("crypto-accepted:" + change);
322 + if (!Arrays.equals(Files.readAllBytes(first), encrypted)) fail("crypto-partial-restore:" + change);
323 + if (before == null ? Files.exists(second) : !Arrays.equals(Files.readAllBytes(second), before)) fail("crypto-overwrote:" + change);
324 + if (!Arrays.equals(Files.readAllBytes(repo.resolve(".git/index")), index)) fail("crypto-changed-index:" + change);
325 + run(repo, "git", "reset", "--quiet", "HEAD", "--", "incoming-secret.txt");
326 + ok("crypto-refuses:" + change);
328 + var linkEnv = new HashMap<>(env);
329 + linkEnv.put("DOTFILES_SYMLINKS", "mini");
330 + run(repo, linkEnv, "mise", "run", "link");
331 + if (!Arrays.equals(Files.readAllBytes(first), encrypted)) fail("link-decrypted-secret");
332 + run(repo, linkEnv, "java", "bootstripper.java", "clean");
333 + Files.write(first, firstPlain);
334 + Files.write(second, secondPlain);
335 + ok("explicit-crypto-preserves-local-changes");
227 338 interface Mapping { void accept(String source, String target) throws Exception; }
228 339 static void forEachMapping(Path manifest, Mapping mapping) throws Exception {
229 340 String source = null;