- Shell 70.6%
- C 22.9%
- HTML 3.8%
- CSS 1.8%
- Makefile 0.9%
- src/folio-list.h (new): the list shared by folio-generate and folio-search: the row of search criteria (Search by, Keywords, Out of Date, Sort by, Sort order, Per page, Go, Orphans), the headings that sort (Name, Votes, Popularity, Maintainer, Last Updated; the current one turns the order round), the rows (Name, Version, Part, Votes, Popularity, Description, Maintainer, Last Updated; a flagged package's version marked), the order (ties by name). - folio-search: the question's parts as the AUR names them (q, SeB, outdated, SB, SO, PP, O, submit=Orphans), each one of a fixed list or at most nine digits, else the default. Search by name and description, name, exact name, keyword, maintainer, co-maintainer, both, submitter; no words lists every package. "N packages found. Page X of Y." with First, Previous, pages, Next, Last, above and under the table. No 200-match cap: up to 200000 matches (64 MB) kept and sorted. A line of the index cut off, and the rest of it, is skipped. Popularity is carried on from the day it was reckoned. - folio-generate: every package gathered once; the packages page is the list, most popular first, with the criteria and sorting headings when the search is on (one plain page without it). index.tsv has 14 fields (co-maintainers, submitter, flagged, newest upload, popularity, its day, whether the maintainer has a page); packages.json gains "popularity". The search page holds the default form between <!--folio:form--> and <!--folio:results-->. - Popularity as the AUR's: each vote weighs 0.98 for every day since it was cast; older than ten years, nothing. folio-door's vote writes "cast = YYYY-MM-DD" into votes/ACCOUNT; a vote without it counts as cast on the package's first upload (submitted). - folio.css: the criteria row, compact so that it fits across the page from a window about 1024 pixels wide (it wraps on a phone); the table smaller, every column fitting at that width, and scrolling by itself when wider than the window; the count and pages; sort marks on the headings. The theme's colours. The count is div.pager, not the home page's .stats, whose style lifted it over the criteria and so caught every click on their controls. - Docs: design.md/.html (4.3, the record's layout, the limits table), Public Guide. - Tests: the criteria coming back as asked, unknown choices as the default, each search-by, the out-of-date filter, Orphans, pages past the end, the headings' links, a vote's day, popularity of today's, old and undated votes, a flagged version marked. Fuzz harness and seeds for the new index and question; regress input updated; the count's own class. make test: passed 2355, failed 0. Tried on the test site (bin/update) in Chromium at 1024 and 1366 pixels wide. |
||
|---|---|---|
| client | ||
| debian | ||
| deploy | ||
| desktop | ||
| doc | ||
| guides | ||
| node | ||
| server | ||
| src | ||
| static | ||
| test | ||
| tools | ||
| .gitignore | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
Folio
Folio turns projects that live on a forge into installable packages.
- Projects stay where they are: in git repositories on a forge (a Forgejo, for example).
- A Folio site is pointed at them. It imports the source as it is, works out how to build and package it, and builds every new commit.
- It offers the result as a signed apt archive and as a website made only of files.
- A new site imports only commits signed with a PGP key on the account of whoever imports them or of the package's maintainers, and its reviewed part takes only what an administrator or the owner approved, or the owner imported, or an administrator imported to a package that is not the owner's (only the owner approves the owner's work).
- It can write everything back to the forge: its record, its pages and the packages as git repositories with a commit for every change, and the packages into the forge's own package list.
A Folio site hosts no git repositories, has no web logins, no passwords
and no database server. Whatever changes on it goes through SSH with a
key, and is recorded as a signed commit, never an unsigned one: while the
site's signing key has run out, the site takes no changes. Every change
must also come as a request signed with the GPG key of the account that
asks, so a stolen SSH key alone changes nothing; plain SSH can only look.
The folio command and the desktop program make and sign those requests,
and the record keeps each one beside the change it asked for. The site
publishes its own SSH keys on its pages (ssh-host-keys), and the folio
command, the desktop program and build nodes connect only to a server
that shows one of them.
It is written in C and POSIX shell, for Devuan.
The documentation
doc/wiki/ is the full documentation, one page per kind of reader. It
uses made-up addresses throughout (dur.example.org, forge.example.org).
| Page | For |
|---|---|
Home.md |
what Folio is, and which page to read |
Quick-Start.md |
a first site, in the fewest steps |
How-It-Works.md |
everything a site does, step by step, and where each thing lives |
Owner-Install-Guide.md |
setting a site up, start to finish |
Forge-Setup.md |
connecting a site and a forge, both directions |
Owner-and-Administrator-Guide.md |
running a site |
Backup-and-Restore.md |
what must be backed up and why, how, and how to bring a site back or move it |
Member-Guide.md |
getting an account, offering projects, taking part |
Public-Guide.md |
browsing, installing, downloading |
Build-Node-Guide.md |
lending a computer that builds |
Desktop-Program.md |
every button of the desktop program |
Settings-Reference.md |
every setting |
Command-Reference.md |
every command |
Troubleshooting.md |
where to look, and what to do about each thing you may see |
Auditing-a-Site.md |
checking a site's whole history yourself, with folio-audit and public keys alone |
_Sidebar.md |
the list of pages the forge shows beside each one |
The pages are named and linked the way a forge's wiki expects. They live
in this repository; make wiki WIKI=ADDRESS sends that folder to a forge
as the project's wiki (the address is the wiki's own, for example
ssh://git@forge.example.org/you/folio.wiki.git). Commit first: what is
sent is the committed pages.
Other documents, for people working on Folio. Each comes twice, as a
.md file and as an .html page; the two say the same thing, and the
pages open in a browser straight from the folder:
| Document | .md |
.html |
What it is |
|---|---|---|---|
| Design | doc/design.md |
doc/design.html |
the design of Folio as it is now |
| Install | doc/INSTALL.md |
doc/INSTALL.html |
the shortest path from the source to a running site, pointing into the wiki |
| Packaging | doc/packaging.md |
doc/packaging.html |
how the site packages a project that has no debian/ folder |
| Erasing | doc/erasing.md |
doc/erasing.html |
the rule for taking something out of the record's history, and what it does |
| Security audit | doc/security-audit.md |
doc/security-audit.html |
the audit's record: scope, method, every finding with its fix and test, and dated addenda |
doc/doc.css: the stylesheet the HTML documents share.guides/: the five guides a site shows under Help, with that site's own addresses filled in.
How it fits together
forge (git repositories) people (folio, desktop)
| ^ | ssh; changes signed
| | | with their GPG key
import | | record, pages, packages v
v | server/folio-door
+----------------------------------------------------+
| a Folio site: one folder |
| record/ every fact, as signed commits |
| site/ the pages (written by folio-generate) |
| apt/ the signed archive (reprepro) |
| builds/ each build's facts, log and files |
| private/ the public key, mail addresses, ... |
+----------------------------------------------------+
^ |
| take a build, hand in the result | plain files
| v
build nodes (node/folio-node) web server (nginx): visitors, apt
doc/wiki/How-It-Works.md goes through each arrow.
What is in this folder
The server (server/)
| File | What it does |
|---|---|
folio-door |
the one way to change anything. sshd runs it, and nothing else, for the user folio; each key is tied to one account. Every command (help lists them) is here. A command that changes something is taken only as a signed request (signed REQUEST SIGNATURE), checked against the account's GPG key |
folio-node-door |
the same for build nodes: take a build, say it is alive, hand in the result. A claim and a result are taken only as requests signed with the node's own GPG key, checked as the door checks a person's; the signed result is kept beside its build |
folio-keys |
writes sshd's keys file from the record: each account's keys run folio-door, each node's key folio-node-door |
folio-fetch |
imports projects from the forges: one repository (follow), an account (watch), or looks at a whole forge and lists what it finds as waiting (admin watch-forge). The timed job runs it |
folio-upload-check |
judges an imported project: can it be packaged, its version, its facts; writes them into the record and queues the builds |
folio-builds.sh |
the build queue (DATA/builds/NUMBER/) |
folio-publish |
puts finished builds into the signed apt archive, keeping the review and verification rules; makes the site's keyring package |
apt-setup.sh.in |
the script a site offers at /apt/setup.sh, which adds the site to apt on someone's computer and installs the site's keyring package, which apt then keeps up to date |
folio-mirror |
sends the record, the pages and the archive to a forge as two git repositories, and the packages into the forge's package list |
folio-mail |
sends waiting notifications through the system's sendmail |
folio-releases |
once a day asks each distribution's mirror what its releases are now, and mails the owner and administrators when one is new, has changed or has gone (admin releases) |
folio-key |
the site's own key, on the server: show it and what is due, take what the owner made on their own computer (import BUNDLE), switch to new signing keys; on a site of the older kind, take its master off (master-out, master-gone) |
folio-signer |
the site's signer, run as the user folio-sign through one sudo rule: it alone holds the signing keys and the forge's key, signs only an apt Release file with the archive's key and a commit of the record or the site's copy with the record's, sends only to the forge the record names, and logs every signature |
folio-sign-git |
what git runs instead of gpg to sign a commit: it hands the commit to the signer |
folio-backup |
the whole site into one file, and back |
folio-erase |
takes a comment, an account or a removed package out of the record's history |
folio-setup |
makes a new site in a folder (asks the questions) |
folio-install |
the guided setup for a real server: the users folio and folio-sign, the sudo rule, the site, sshd, nginx with https, the timed jobs; run again after an upgrade, it updates the files it wrote that nobody changed; --migrate FILE moves an older site's keys to a signer and its master to the owner |
folio-lib.sh |
small helpers the scripts share, among them the signed requests: how one is kept in a change's message, with the trailers that name what authorised a change the site makes by itself (Authorised-by:, Source-commit:) |
folio-verify.sh |
the checks anyone can make with public keys alone: a request's form and signature, what may start an import, and the count of the record's signatures. The door, the node door and folio-audit all use it, so admin verify and folio-audit cannot disagree |
The programs in C (src/)
| File | What it does |
|---|---|
folio-generate.c |
reads the record and writes every page, packages.json, feed.xml and ssh-host-keys (the server's SSH keys, from /etc/ssh) |
folio-search.c |
the one program that answers visitors: a read-only search, started by the web server |
Build nodes (node/)
| File | What it does |
|---|---|
folio-node |
fetches the site's SSH keys from its pages, asks the site for work, fetches the source from the forge, builds with sbuild in a throwaway system, hands in the result |
folio-debianize |
writes the Debian packaging for a project that has none, from the project's own files. Used by the site at import and by the node at each build |
For people (client/, desktop/)
| File | What it does |
|---|---|
client/folio |
the folio command: runs a site's commands from a terminal. A command that only looks goes as it is; a change is made into a request, signed with the person's GPG key and sent. It knows several sites, each with its own keys (~/.config/folio/sites/NAME; folio --sites, --use, --add-site, --site NAME), and trusts only each site's published SSH keys; a site with its own certificate authority is fetched from trusting that authority alone, once the person confirmed its fingerprint |
client/folio-audit |
the offline checker: checks a copy of a site's record (a clone of the record it publishes, or a backup) with public keys alone, trusting nothing from the site. Every change signed by the site's key; every person's change carrying their own signed request, for exactly what the change did; every change the site made by itself naming what authorised it; with --builds, every build's signed claim and result. A clear report, or --tsv; exit status 0 only if everything holds (doc/wiki/Auditing-a-Site.md) |
client/folio-site-key |
the site's master key on the owner's own computer: makes the key (init), changes, renews and revokes the signing keys under it, takes a master off an older server (adopt); each writes a bundle for folio-key import on the server |
client/folio-mykeys |
makes an SSH key and a PGP key for someone who has none; shows the ones they have; chooses which PGP key signs (folio-mykeys use FINGERPRINT) |
desktop/folio-desktop.c |
the desktop program: a button for every command, each with a tooltip. It runs the same commands the folio command sends, signing each change the same way, after fetching the site's SSH keys from its pages. Its Site window keeps several sites, each with its own keys and, if the site has one, its own certificate authority (confirmed by its fingerprint) |
desktop/folio-checks.c, desktop/folio-checks.h |
what the desktop program checks before it sends a key file (never a private key) and before it trusts the site's published keys, which commands must be signed, how a request is made, the sites' files, and a site's certificate authority (its fingerprint, from PEM to DER to SHA-256); plain C, without GTK |
The rest
| Path | What it is |
|---|---|
static/ |
the stylesheet (folio.css), the colours (theme.css and the twelve theme-NAME.css), Folio's own mark (folio.svg) |
static/artwork/ |
the Devuan logo and emblem, a new site's default pictures. Not under Folio's licence: see static/artwork/README |
guides/ |
the five guides a site shows under Help |
doc/ |
the documentation (above) |
deploy/nginx-folio.conf |
the web server's settings for a site; folio-install writes it out with the site's name and folder |
deploy/dev.Dockerfile |
the small Devuan image make test-all runs test/run in: git, ssh, gpg, dpkg-dev and reprepro, and a user with the uid 1000. Not for real use |
debian/ |
Folio's own packaging: folio-server, folio-node, folio-client, folio-desktop (control, rules, changelog, copyright, one .install file per package, source/format) |
test/run |
the tests (make test) |
test/desktop-checks.c |
the desktop program's checks, tried without GTK (make test-desktop-checks; make test runs it first) |
test/hardening |
that each C program built is built hardened (make test-hardening; make test runs it first) |
test/fuzz/ |
the fuzzing of folio-search, of the generator's readers and of the desktop program's checks and its reading of the door's answers (make fuzz-search, make fuzz-record, make fuzz-checks, make fuzz-door-output): driver.c, the fuzzer; search.c, record.c, checks.c and door-output.c, what they are given; seeds-*, inputs to start from; regress-*, inputs that once found a mistake (make test-regress, which make test runs first, and make test-fuzz) |
test/apt-proof |
a real apt, in a throwaway Docker image, through a whole change of the site's signing key, an emergency and setup.sh --remove (test/apt-proof docker) |
tools/folio-local |
replaced by the security-test setup (~/Projects/folio-test/README.md); it no longer runs |
Makefile |
builds the C programs, installs them, runs the tests and the checks for mistakes, sends the wiki |
LICENSE |
the licence |
.gitignore |
what git leaves out: bin/ (the built programs), what building the packages leaves in debian/, and working notes |
bin/ is made by make and is not part of the repository.
Building
sudo apt install build-essential debhelper pkg-config libgtk2.0-dev git gnupg openssh-client
make
make test
-
makebuildsbin/folio-generateandbin/folio-search. You should see two compiler lines. Any compiler warning stops the build (see How the programs are built). -
make testfirst builds and runsbin/desktop-checks(the desktop program's checks of key files, without GTK), which ends withN passed, 0 failed (desktop checks); runs every input intest/fuzz/regress-*andtest/fuzz/seeds-*once through the fuzz harnesses, built with the sanitizers but without the fuzzer (fuzz inputs of NAME: N run, no errorfor each); and checks that the programs are built hardened (hardening: passed: N failed: 0; it needsreadelf, from binutils). Then it makes a throwaway site and tries every command on it, the right way and the wrong. You should see a last linepassed: N failed: 0. A test that fails prints what it wanted and what it got. It needs git, gpg, dpkg-dev and ssh-keygen; no network, no Docker, and it leaves nothing running. The parts that needreprepro(publishing) are skipped, with a note, where it is not installed. -
make test-allruns the same inside the image fromdeploy/dev.Dockerfile, whererepreprois installed, so publishing is tried too. Needs Docker.test/apt-proof dockerpoints a real apt at a real archive and takes the site through a change of signing key, a renewal and an emergency, showing what apt says at each step. It should end withapt-proof: everything as it should be. Needs Docker and the network (to build its image). -
dpkg-buildpackage -us -uc -bbuilds the four packages, one folder up:Package For Holds folio-serverthe server the door and the site's scripts, folio-generate,folio-search,folio-debianize(for importing), and the site's signerfolio-signer, whichfolio-installsets up as a user of its own (folio-sign)folio-nodeeach build node folio-node,folio-debianizefolio-clienteveryone who changes something on a site, and anyone who checks one /usr/bin/folio,/usr/bin/folio-mykeys,/usr/bin/folio-site-key,/usr/bin/folio-audit,/usr/share/folio-client/folio-verify.shfolio-desktoppeople who want buttons /usr/bin/folio-desktop(it needsfolio-client) -
make install DESTDIR=FOLDERputs the programs where a system keeps them, the way the packages do. One part at a time:make install-server,make install-node,make install-client(folio,folio-mykeys,folio-site-keyandfolio-audit),make install-desktop.
Run make test before every commit.
How the programs are built
Every C program (folio-generate, folio-search, folio-desktop, the
tests) is built hardened, by a plain make as by the package build:
| Flags | What they are for |
|---|---|
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 |
the C library checks the sizes of what is copied into a buffer it can measure. Level 3 wins over the level 2 that dpkg-buildflags gives |
-fstack-protector-strong, -fstack-clash-protection |
a program stops when its stack has been overwritten, or would run into other memory |
-fcf-protection |
marks the places a jump may land, for processors that check that |
-fPIE, -pie |
the program is put at a different address each time it starts |
-Wl,-z,relro -Wl,-z,now |
the table of library functions is filled when the program starts and is read-only after |
-Wl,-z,noexecstack |
the stack cannot be run as code |
The Makefile's HARDEN and LDHARDEN hold them. The package build adds
dpkg-buildflags' own (debian/rules asks for hardening=+all) before
them; CPPFLAGS, CFLAGS and LDFLAGS given to make are used too.
_FORTIFY_SOURCE needs optimisation: with CFLAGS=-O0, also give
HARDEN_FORTIFY=.
The warnings, any of which stops the build, are -std=c99 -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 -Wconversion -Wsign-conversion -Wcast-qual -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wvla -Wundef -Wnull-dereference -Wimplicit-fallthrough -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wformat-overflow=2 -Wformat-truncation=2 -Wformat-signedness -Wstringop-overflow=4 -Warray-bounds=2 -Werror. The desktop program takes
the same as GNU C (-std=gnu99), with GTK's folders given as system
headers so that the warnings are about Folio's code, not GTK's; a GTK call
marked as old is warned about but does not stop the build.
hardening-check bin/folio-search (package devscripts) shows the result.
On Devuan amd64 two of its lines say no whatever is done: "Control flow
integrity", because Devuan's own start files carry no note for it, and
"Branch Protection", which is for arm64. "Stack clash protection" says
unknown when a program's stack frames are small enough to need no loop.
Checks for mistakes, which no ordinary build runs:
| Command | What it does |
|---|---|
make analyze |
GCC's static analyser on each program |
make cppcheck |
cppcheck (apt install cppcheck), style checks included; it passes, and must go on passing |
make test-asan |
the whole of make test with the programs built with AddressSanitizer and UndefinedBehaviorSanitizer, which stop at the first memory error or undefined behaviour; then make test-fuzz. The programs go into bin/asan/bin, and bin/asan links to the rest of the tree, so that test/run uses them (every folio-setup it starts is given FOLIO_GENERATE, so the generator used is the one in bin/asan/bin) |
make fuzz-search FUZZ_TIME=600 |
ten minutes of made-up questions, indexes and pages for folio-search, kept when they reach code nothing reached before, with the sanitizers on. It also checks that the question always comes back into the page escaped. A crash is written to bin/fuzz/crash-* |
make fuzz-record FUZZ_TIME=600 |
the same for the generator: its readers of the record, and whole runs on made-up records |
make fuzz-checks FUZZ_TIME=600 |
the same for every reader and writer of desktop/folio-checks.c, each checked against what folio-checks.h promises |
make fuzz-door-output FUZZ_TIME=600 |
the same for the desktop program's reading of what the door answers (comments, lists, key list, admin log, request-info, ssh-keygen -l) |
make test-fuzz |
runs every input in test/fuzz/regress-* and test/fuzz/seeds-* once, through the fuzz builds (make test-regress, part of make test, runs them through builds without the fuzzer) |
bin/fuzz-search FILE runs one input again, to look at a crash. The
fuzzers are built with GCC (-fsanitize-coverage=trace-pc); a harness is
written as for libFuzzer, so clang's -fsanitize=fuzzer can build it too
where clang's runtime is installed.
The desktop program against gtk2-ng
make desktop builds bin/folio-desktop against the system's GTK 2. To
build against gtk2-ng installed in its own folder:
make -B desktop GTK2NG=/path/to/gtk2-ng/prefix
-B builds again even if the program is there. GTK2NG names the folder
gtk2-ng was installed into; the program then looks for its libraries
there.
The program sets no colours of its own: it wears whatever GTK 2 theme the desktop is set to. A gtk2-ng in its own folder looks for themes and theme engines in that folder only, so a build against it comes up plain. To have it use the themes installed on the system, start it with:
GTK_DATA_PREFIX=/usr GTK_PATH=/usr/lib/x86_64-linux-gnu/gtk-2.0 bin/folio-desktop
GTK_DATA_PREFIX says where the themes are (/usr/share/themes);
GTK_PATH says where the theme engines are. A build against the system's
GTK 2, and the folio-desktop package, need neither.
Trying a real install on your own computer
tools/folio-local is replaced by the security-test setup; see
~/Projects/folio-test/README.md. It served its site over plain http and
started its build node without the https-only setup, neither of which
Folio takes any more, so it no longer runs: it says
folio-local: tools/folio-local is replaced by the security-test setup; see ~/Projects/folio-test/README.md
and stops. Its code stays in the file for the new setup to take parts
from.
Themes
The pages carry no scripts, yet a visitor can choose among twelve colour themes, and the choice is remembered. How:
- Every page loads its colours from one address,
static/theme.css. - The Theme links lead to
/theme/NAME. The web server answers those itself: it stores the choice in a cookie and sends the visitor back to the page they were on. - For
static/theme.cssthe web server looks at that cookie and hands out that theme's colours under the same name. A visitor who has not chosen getstheme.cssitself, which is light or dark as their browser asks.
A new theme is three things: its colours in static/theme-NAME.css, a
line in the list themes[] in src/folio-generate.c (kept in
alphabetical order; it writes the menu), and its name in the two lists in
deploy/nginx-folio.conf.
Rules for the code
- C and POSIX shell only, around tools Devuan ships (git, gpg, dpkg, reprepro, sbuild, ssh, curl).
- Shell scripts use the shell itself and simple tools (
cut,tr,grep,printf); no stream editors or awk. - Pages carry no scripts and work with JavaScript switched off.
- The desktop program has a place for every command; its top comment maps
each command to its button. Keep that map, the door's
help, and the wiki's Command Reference in step. - Which commands must be signed is one table in the door (
door_kind), and the same inclient/folioanddesktop/folio-checks.c;test/runchecks that the three agree.
Licence
MIT; see LICENSE. The pictures in static/artwork/ are not Folio's and
have their own terms: see static/artwork/README.