Artifact 58d26cf4f7a6155ffb913292846d8019a562acfe240ddc56198af34efd711879:
- File
test/fuzz_remote.c
— part of check-in
[fe29cebc6a]
at
2026-11-13 20:38:51
on branch trunk
— Phase 7b-1: a wardrobe syncs with a remote, over file:// and http://
suit remote sets, shows or clears a wardrobe's remote address. An address that carries a user name or password is refused. suit login reads a secret from standard input into a credentials file of mode 0600, and suit refuses to use that file if anyone else can read it. The secret is never printed, never put in an error message or another file, and is wiped from memory after each use.
suit sync pulls, brings the working copy forward with the safe update, and pushes. When both sides have new check-ins it tries a merge as a dry run. A clean merge is checked in and pushed. A conflicting one changes no file, is pushed as a fork so nothing is lost, and is written to the attention file. No conflict marker is ever written to a live file. With local changes in the working copy the pull is kept and nothing else happens.
suit tend now continues into a sync after its check-in.
Three limits of libfossil, each handled here: its merge drops a file the other side deleted, so suit finds those itself and treats a delete against an edit as a conflict; a merge that changes no file cannot be checked in, so the files are put back and the fork stays open; and a file:// remote is reached through the stock fossil program, which must be on the path. http:// uses libfossil's own socket code and starts no other program.
An https:// address is accepted and stored, and syncing it says this build cannot use https yet. There is no clone command yet.
Also: LICENSE (BSD 2-Clause, the same as libfossil), a license section and current status in the README, and a state table in docs/phases.md.
1204 unit checks, 227 shell cases, 555 store cases, 612 placement cases and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask. 100% coverage in all 22 source files. Seven fuzz targets. No suite has fewer cases than at the last check-in. (user: dmestas, size: 1699) [annotate] [blame] [check-ins using]
// Fuzz target for the remotes and credentials parsers: whatever parses must // write back out and parse again to the same entries, and a failed parse // leaves nothing behind. #include "platform.h" #include "remote.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static Remotes r1; static Remotes r2; static Creds c1; static Creds c2; static char rpath[4096 + 32]; static char cpath[4096 + 32]; int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (rpath[0] == '\0') { const char *tmp = getenv("TMPDIR"); char dir[4096]; snprintf(dir, sizeof dir, "%s/suit-fuzz-remote.XXXXXX", tmp != nullptr ? tmp : "/tmp"); if (mkdtemp(dir) == nullptr) abort(); snprintf(rpath, sizeof rpath, "%s/remotes", dir); snprintf(cpath, sizeof cpath, "%s/credentials", dir); } RemoteError e; if (!remotes_parse(&r1, (const char *)data, size, &e)) { ensure(e.msg[0] != '\0' && r1.n == 0); } else { [[maybe_unused]] int written = remotes_write(&r1, rpath); ensure(written == 0); [[maybe_unused]] bool again = remotes_load(&r2, rpath, &e); ensure(again && r2.n == r1.n); } if (!creds_parse(&c1, (const char *)data, size, &e)) { ensure(e.msg[0] != '\0' && c1.n == 0); } else { [[maybe_unused]] int written = creds_write(&c1, cpath); ensure(written == 0); [[maybe_unused]] bool again = creds_load(&c2, cpath, &e); ensure(again && c2.n == c1.n); } secret_wipe(&c1, sizeof c1); secret_wipe(&c2, sizeof c2); return 0; }