]> git.ipfire.org Git - thirdparty/FORT-validator.git/log
thirdparty/FORT-validator.git
2 months agoResolve more simple critical TODOs fort2
Alberto Leiva Popper [Wed, 21 May 2025 00:05:14 +0000 (18:05 -0600)] 
Resolve more simple critical TODOs

- Rename `file_exists()` to `file_stat_errno()`
- Make result string `node2file()` consistently free-able
- Move `valid_file_or_dir()` to file.c, rename to `file_is_valid()`
- Make cache threshold configurable
- Recover from errors in `__vfprintf()`
- Remove recursion from `cer_cleanup()` and `cer_free()`
- Delete snapshots and deltas after exploding them

2 months agoGrow cache unit tests more
Alberto Leiva Popper [Fri, 16 May 2025 23:48:43 +0000 (17:48 -0600)] 
Grow cache unit tests more

2 months agoDeprecate and no-op the incidences module
Alberto Leiva Popper [Thu, 15 May 2025 22:56:47 +0000 (16:56 -0600)] 
Deprecate and no-op the incidences module

The few almost useful incidences left were workarounds for the old
cache implementation.

2 months agoRemove the path tokenizer
Alberto Leiva Popper [Thu, 15 May 2025 22:28:26 +0000 (16:28 -0600)] 
Remove the path tokenizer

Seems it was obsoleted by URI normalization.

2 months agoClean up path_join() implementation
Alberto Leiva Popper [Thu, 15 May 2025 22:03:49 +0000 (16:03 -0600)] 
Clean up path_join() implementation

2 months agoResolve directory pruning critical TODOs
Alberto Leiva Popper [Thu, 15 May 2025 20:38:18 +0000 (14:38 -0600)] 
Resolve directory pruning critical TODOs

- Return error code when remove() fails, but keep deleting files until
  tree traversal complete.
- At least one platform thinks `nftw(a, b, c, d)` is an error when `a`
  is not a directory, so fall back to unlinking when that happens.

2 months agoResolve several simple critical TODOs
Alberto Leiva Popper [Thu, 15 May 2025 02:48:35 +0000 (20:48 -0600)] 
Resolve several simple critical TODOs

- Rename `struct sia_uris` into `struct extension_uris`
- Merge `certificate_refs` module into `certificate`
  (Includes a bunch of API review all over `certificate_refs`,
  `certificate`, `signed_object` and `signed_data`.)
- Deprecate rsync and HTTP configuration priorities
  (HTTP/RRDP is hardcoded to preferred to simplify things.)
- Add some comments to `struct cache_mapping`

2 months agoEnumerate some errcode-adjacent function results
Alberto Leiva Popper [Tue, 13 May 2025 02:48:07 +0000 (20:48 -0600)] 
Enumerate some errcode-adjacent function results

To reduce review friction; clarify when result codes matter, force
callers to worry about them, and prevent them from getting jumbled with
other error code types.

(In particular, the cache code was returning `EBUSY` to signal rsync
deferral. Since the code frequently propagates errno, it risked regular
standard library `EBUSY`s being mistaken by rsync deferrals.)

Also, remove negative error codes when they're not needed. (Though
error codes themselves are steadily becoming slop.)

2 months agoURI normalization: Allow and normalize IP literals in host
Alberto Leiva Popper [Thu, 8 May 2025 22:33:54 +0000 (16:33 -0600)] 
URI normalization: Allow and normalize IP literals in host

2 months agoURI normalization: Allow and normalize UTF-8
Alberto Leiva Popper [Thu, 8 May 2025 22:18:54 +0000 (16:18 -0600)] 
URI normalization: Allow and normalize UTF-8

Was previously rejecting non-ASCII characters.
It now converts them to percent-encoding.

2 months agoURI normalization: Propagate error messages properly
Alberto Leiva Popper [Thu, 8 May 2025 22:16:08 +0000 (16:16 -0600)] 
URI normalization: Propagate error messages properly

Forgot to clean this up in the previous commit.
Was printing errors in standard output as a quick fix.

2 months agoImplement URI normalization
Alberto Leiva Popper [Tue, 6 May 2025 23:43:47 +0000 (17:43 -0600)] 
Implement URI normalization

Stop deferring this to curl; it's not bound to come out soon.

2 months agoRename the "url" module to "uri"
Alberto Leiva Popper [Wed, 30 Apr 2025 16:26:52 +0000 (10:26 -0600)] 
Rename the "url" module to "uri"

3 months agoStrong type-fy URIs
Alberto Leiva Popper [Tue, 29 Apr 2025 23:53:42 +0000 (17:53 -0600)] 
Strong type-fy URIs

Fixes all the normalization TODOs.

...Well, except the curl URI normalization PR is on hold.
I might have to implement something myself later.

3 months agoSeparate cache key into own structure
Alberto Leiva Popper [Thu, 24 Apr 2025 22:22:11 +0000 (16:22 -0600)] 
Separate cache key into own structure

Not much. This is just a step towards applying the URI normalization
code.

3 months agoUpdate glue between main loop and rsync
Alberto Leiva Popper [Tue, 22 Apr 2025 22:03:30 +0000 (16:03 -0600)] 
Update glue between main loop and rsync

1. Propagate EBUSY so the main loop suspends the task (and takes care of
   other tasks) while the rsync runs.
2. Spawner now responds rsync URL and path to parent, so the cache can
   update the download state.

3 months agoAdd --rsync.max
Alberto Leiva Popper [Thu, 10 Apr 2025 22:14:51 +0000 (16:14 -0600)] 
Add --rsync.max

Maximum simultaneous forked rsyncs.

3 months agoMerge branch 'rsync' into fort2
Alberto Leiva Popper [Tue, 8 Apr 2025 17:40:39 +0000 (11:40 -0600)] 
Merge branch 'rsync' into fort2

3 months agorsync spawner: Poll all read file descriptors
Alberto Leiva Popper [Tue, 8 Apr 2025 17:33:36 +0000 (11:33 -0600)] 
rsync spawner: Poll all read file descriptors

The single thread requirement and lack of polling was preventing the
spawner from running multiple rsyncs at the same time (as their output
needs to be exhausted for them to end), and more importantly, from
consuming the request stream while the one rsync was running. (The
latter might result in dropped requests if too many rsyncs are queued.)

Therefore, poll both the request stream and the rsync pipes. All input
is now consumed immediately, and multiple rsyncs can be forked at the
same time. (Still needs a limit.)

3 months agoFigure out URI normalization
Alberto Leiva Popper [Thu, 3 Apr 2025 23:45:23 +0000 (17:45 -0600)] 
Figure out URI normalization

I haven't actually found much incentive to justify the normalization,
but libcurl provides a (still flawed as of 8.12.1, but workable) API to
do it effortlessly.

This is better than the previous implementation, and future-proof
enough.

3 months agoPatch bad enclosing in conditional
Alberto Leiva Popper [Thu, 3 Apr 2025 23:18:42 +0000 (17:18 -0600)] 
Patch bad enclosing in conditional

4 months agoExpand struct cache_node documentation comment
Alberto Leiva Popper [Mon, 24 Mar 2025 14:10:08 +0000 (11:10 -0300)] 
Expand struct cache_node documentation comment

4 months agoPrioritize https refreshes on TAL URLs
Alberto Leiva Popper [Mon, 24 Mar 2025 13:06:55 +0000 (10:06 -0300)] 
Prioritize https refreshes on TAL URLs

Few reasons:

1. rsync is a bit of a pain as a retrieval tool for RPKI,
   and I'd like to avoid it when I can get away with it.
2. Refresh by SIA was already prioritizing RRDP over rsync,
   so this makes the overall behavior more consistent.
3. Always preferring one protocol over the other tends to
   reduce bandwidth & cache usage.

So, mirror the SIA refresh order for TAs. From highest to lowest
priority:

1. Online HTTPS (including RRDP)
2. Online rsync
3. Fallback HTTPS (including RRDP)
4. Fallback rsync

4 months agoMove TAL step to thread pool
Alberto Leiva Popper [Thu, 6 Mar 2025 23:38:10 +0000 (17:38 -0600)] 
Move TAL step to thread pool

Sequential TALs meant sequential TAs.
(eg. Fort would first download the AFRINIC TA, then the APNIC TA, then
the ARIN TA, etc).
Waste of time.

Now thread pool tasks can be one of two types: TAL or RPP.
This results in TA downloads being treated like any other download.

4 months agoRename task states, to match documentation
Alberto Leiva Popper [Thu, 6 Mar 2025 22:15:32 +0000 (16:15 -0600)] 
Rename task states, to match documentation

6 months agoMerge branch 'main' into fort2
Alberto Leiva Popper [Sat, 25 Jan 2025 01:33:12 +0000 (19:33 -0600)] 
Merge branch 'main' into fort2

6 months agoRRDP: Mirror rsync extension filters
Alberto Leiva Popper [Wed, 22 Jan 2025 23:26:39 +0000 (17:26 -0600)] 
RRDP: Mirror rsync extension filters

We've agreed extension filters are useful, and the manifest code no
longer drops RPPs due to unknown file-not-founds.

So prevent unknown file extensions from contaminating the RRDP side of
the cache as well.

Complements #155.

6 months agoStop rejecting RPPs if unrecognizable absent files are fileListed
Alberto Leiva Popper [Wed, 22 Jan 2025 22:38:37 +0000 (16:38 -0600)] 
Stop rejecting RPPs if unrecognizable absent files are fileListed

RFC 9286:

> The RP MUST acquire all of the files enumerated in the manifest
> (fileList) from the publication point. If there are files listed in
> the manifest that cannot be retrieved from the publication point,
> the RP MUST treat this as a failed fetch.

This was clashing with Fort's default rsync filters because they were
preventing unknown extensions from being downloaded:

> rsync (...) --include=*.cer --include=*.crl --include=*.gbr \
> --include=*.mft --include=*.roa --exclude=* (...)

Which will be a problem whenever the IETF defines new legal repository
extensions, such as .asa.

Therefore, ignore unknown manifest fileList extensions. This technically
violates RFC 9286, but it's necessary evil given that we can't trust
repositories to always only serve proper RPKI content.

Fixes #155.

6 months agoIndex each cache node separately
Alberto Leiva Popper [Mon, 20 Jan 2025 17:37:58 +0000 (11:37 -0600)] 
Index each cache node separately

Background:

- Fort shouldn't lose the cache index when a signal interrupts it.
- Writing the index during the signal handler is not possible,
  because of the async-signal-safe requirement.
- Writing the index outside of the signal handler is seemingly not
  viable, because of the infelicities between the signal and
  multithreading APIs in C.

I haven't completely discarded the "dropping multithreading" option,
but since it seems disproportionate, I've been rethinking the index.

This commit scatters the index across several files, to minimize lost
information during a stopping signal. This will exacerbate the inode
problem, but that's temporary.

Reverts e0880f8eac3d35e576a2c1a2cb588424ab4b3e1b.

6 months agoTentatively add new logging level: "clutter"
Alberto Leiva Popper [Wed, 8 Jan 2025 19:57:02 +0000 (13:57 -0600)] 
Tentatively add new logging level: "clutter"

It's below "debug." Meant to hide several debugging messages that
inflate the log but haven't been useful for many years.

It's hardcoded to disabled for now, and I've half a mind to commit to
this.

6 months agoName CVE-2024-56375
Alberto Leiva Popper [Thu, 2 Jan 2025 22:42:17 +0000 (16:42 -0600)] 
Name CVE-2024-56375

7 months agoAdd new CVE sketch
Alberto Leiva Popper [Fri, 20 Dec 2024 22:12:21 +0000 (16:12 -0600)] 
Add new CVE sketch

7 months agoProtocolary updates for release 1.6.5 1.6.5
Alberto Leiva Popper [Wed, 18 Dec 2024 22:57:58 +0000 (16:57 -0600)] 
Protocolary updates for release 1.6.5

7 months agoCheck manifest fileList emptiness before shuffling
Alberto Leiva Popper [Wed, 18 Dec 2024 21:58:54 +0000 (15:58 -0600)] 
Check manifest fileList emptiness before shuffling

Prevents the loop iterating indefinitely trying to shuffle an array
that's not actually there.

Fixes #154 and new CVE.

7 months agoName CVE-2024-56169 and CVE-2024-56170
Alberto Leiva Popper [Wed, 18 Dec 2024 18:57:46 +0000 (12:57 -0600)] 
Name CVE-2024-56169 and CVE-2024-56170

7 months agoClear the cache after a crash
Alberto Leiva Popper [Fri, 6 Dec 2024 19:41:05 +0000 (16:41 -0300)] 
Clear the cache after a crash

There are many ways in which a mismatching cache index can cause erratic
behavior that's hard to detect. Since the index is written at the end of
the validation cycle, crashing at any point between a cache refresh and
the index write results in a misindexed cache.

Deleting the index after loading it seems to be a reliable way to force
Fort to reset the cache after a crash.

Terminating signals are still a problem, though.

7 months agoGeneral index.json review
Alberto Leiva Popper [Thu, 5 Dec 2024 15:24:01 +0000 (12:24 -0300)] 
General index.json review

Not much; just moving things around for peace of mind.

7 months agoIndex sequences properly
Alberto Leiva Popper [Thu, 5 Dec 2024 15:13:52 +0000 (12:13 -0300)] 
Index sequences properly

Postponed task from some previous refactor; the object was only
partially being serialized.

Fixes XXX-style TODO.

7 months agoFix random errors
Alberto Leiva Popper [Thu, 5 Dec 2024 12:44:56 +0000 (09:44 -0300)] 
Fix random errors

Not much to say. Testing some slightly dirtier inputs; these pipelines
were crashing or returning incorrectly.

7 months agoAlways pick most recent known manifest
Alberto Leiva Popper [Tue, 3 Dec 2024 19:58:10 +0000 (16:58 -0300)] 
Always pick most recent known manifest

Strict version.

7 months agoAlways pick most recent known manifest
Alberto Leiva Popper [Mon, 2 Dec 2024 21:11:45 +0000 (18:11 -0300)] 
Always pick most recent known manifest

Non-strict version.

Fixes new (still unnumbered) CVE.

7 months agoMakefile maintenance
Alberto Leiva Popper [Mon, 2 Dec 2024 17:15:39 +0000 (14:15 -0300)] 
Makefile maintenance

Triggered by fixing compilation in MacOS.

- Rename extension.h to ext.h; the former collides with Extension.h.
- Move _DEFAULT_SOURCE to the source; it's not widespread enough for
  Makefile.am.
- Add _DARWIN_C_SOURCE, needed by MacOS for timegm() and mkdtemp().
- Add -flto to unit test AM_CFLAGS. This minimizes superflous #includes
  and mocks needed, and will hopefully make them consistent across
  platforms.
- Delete _BSD_SOURCE; it seems orphaned. (Though see below.)

Works on Linux and Mac. Might have broken the BSDs; I can't test them
ATM.

8 months agoAdd new CVE sketches
Alberto Leiva Popper [Tue, 26 Nov 2024 23:58:19 +0000 (17:58 -0600)] 
Add new CVE sketches

8 months agoCache cleanup review
Alberto Leiva Popper [Thu, 14 Nov 2024 19:54:14 +0000 (13:54 -0600)] 
Cache cleanup review

Fixes several XXXs.

- Separate node->mtim into attempt_ts and success_ts.
  Because they're really two different timestamps; The former is meant
  for node expiration, the latter for HTTP IMS.
- Move removal of orphaned fallbacks to remove_abandoned().
  Because orphaned refreshes need the same logic.
- Added the (randomly missing) expiration threshold for orphans.

It's still missing the implementation of remove_orphaned_files(),
but I'm still weighting options, as it seems it's going to be an
expensive operation that's rarely going to do anything.

8 months agoSeparate rsync fallbacks from RRDP fallbacks
Alberto Leiva Popper [Wed, 13 Nov 2024 22:25:19 +0000 (16:25 -0600)] 
Separate rsync fallbacks from RRDP fallbacks

Both used to be indexed by caRepository, inducing possible collision.
RRDP fallbacks are now indexed by rkiNotify+caRepository, ensuring
they're caged separately.

8 months agoCommit TAs into cache fallback on success
Alberto Leiva Popper [Mon, 11 Nov 2024 21:06:14 +0000 (15:06 -0600)] 
Commit TAs into cache fallback on success

Forgot these during c7be17b62db6262e0bc9e33b7b9ad049b8563453.

8 months agoAdd thread safety to the new cache
Alberto Leiva Popper [Sat, 9 Nov 2024 01:00:05 +0000 (19:00 -0600)] 
Add thread safety to the new cache

The thread that handles the first task that needs repository A
refreshes A.

While the refresh happens, threads handling other tasks that also need
A postpone said tasks.

Such postponed tasks wake up when the refresh completes.

8 months agoRewrite the core loop and its threading
Alberto Leiva Popper [Tue, 5 Nov 2024 23:16:49 +0000 (17:16 -0600)] 
Rewrite the core loop and its threading

Decouples threads from TALs; threads claim RPPs now.

Aside from scaling better, this unclogs the way to several future
improvements.

9 months agoMove the rsync spawner to a separate process
Alberto Leiva Popper [Sat, 19 Oct 2024 00:18:00 +0000 (18:18 -0600)] 
Move the rsync spawner to a separate process

The fork()s (needed to spawn rsyncs) duplicate Fort's process.

Which is messy in a multithreaded program. Quoting the Linux man page:

> * The child process is created with a single thread—the one that
>   called fork(). The entire virtual address space of the parent is
>   replicated in the child, including the states of mutexes, condition
>   variables, and other pthreads objects. (...)
> * After a fork() in a multithreaded program, the child can safely call
>   only async-signal-safe functions (...) until such time as it calls
>   execve(2).

As far as I can tell, since the forked child was, in fact, careful to
only invoke async-signal-safe functions, this wasn't really a bug.
Still, it wasn't quality architecture either.

Moving the rsync spawner to a dedicated subprocess should stop the forks
from threatening to clash with the multithreading completely.

Relies on the new core loop design, so this won't work properly until
that's implemented.

9 months agoMove the rsync arg builder to the child pipeline
Alberto Leiva Popper [Thu, 17 Oct 2024 23:29:59 +0000 (17:29 -0600)] 
Move the rsync arg builder to the child pipeline

This was (annoyingly) outside because it used to allocate.
(The child is only allowed to call async-signal-safe functions.)

But

a) It doesn't allocate anymore.
b) The async-signal-safe constraint is going to die in a few refactors.

Incidentally deletes the argument echoer, since the arguments are not
variable anymore.

9 months agoRemove rsync & HTTP retries
Alberto Leiva Popper [Thu, 17 Oct 2024 16:44:23 +0000 (10:44 -0600)] 
Remove rsync & HTTP retries

Glad to ditch these. They'll be made redundant by the new threading.

9 months agoAtomize output files
Alberto Leiva Popper [Wed, 16 Oct 2024 19:43:42 +0000 (13:43 -0600)] 
Atomize output files

I feel like I need to relearn signals every time I have to interact with
them. Best get this done while the iron's hot.

1. The ROA file is first written as `<cache>/.roa`.
   The RK file is first written as `<cache>/.rk`.
2. When the validation run is done, `.roa` is renamed to `--output.roa`,
   and `.rk` becomes `--output.bgpsec`.
3. Most terminating signals unlink `.roa` and `.rk`.

Fixes #124.

9 months agoAdd lockfile to the cache
Alberto Leiva Popper [Wed, 16 Oct 2024 19:43:34 +0000 (13:43 -0600)] 
Add lockfile to the cache

To prevent other (well-behaved) instances from accidentally reading and
writing the same directory simultaneously.

Fixes #149.

9 months agoMove the signal code out of the logging module
Alberto Leiva Popper [Wed, 16 Oct 2024 19:28:09 +0000 (13:28 -0600)] 
Move the signal code out of the logging module

The sigaction() code was in logging because it was originally conceived
by the SIGSEGV stack trace printing hack. The SIGPIPE ignorer was also
incidentally moved there at some point, but it has never had anything
to do with logging.

And I'm going to catch more signals in the upcoming commits, so this
really needs to be formalized into its own module.

9 months agoMirror the previous commit on the read pipeline
Alberto Leiva Popper [Tue, 15 Oct 2024 17:24:09 +0000 (11:24 -0600)] 
Mirror the previous commit on the read pipeline

9 months agocache index: Allow NULL dlerr, mtim, session_id and serial
Alberto Leiva Popper [Mon, 14 Oct 2024 23:41:31 +0000 (17:41 -0600)] 
cache index: Allow NULL dlerr, mtim, session_id and serial

NULL dlerr can mean "no error", mtim isn't always set,
and session_id/serial do not exist in fallback.

9 months agoJoin cache.json and TAL metafiles into index.json
Alberto Leiva Popper [Mon, 14 Oct 2024 23:27:41 +0000 (17:27 -0600)] 
Join cache.json and TAL metafiles into index.json

Per design 5, there's only one metafile now, and it's named
"index.json".

cache.json was just a single field that could be sensibly moved to the
index.

9 months agoMove stuff between cache_setup() and cache_prepare()
Alberto Leiva Popper [Mon, 14 Oct 2024 23:07:49 +0000 (17:07 -0600)] 
Move stuff between cache_setup() and cache_prepare()

The former is intended for stuff that needs to be done once,
the latter sets up a single validation cycle.

9 months agoDo `rm -r cache/*` instead of `rm -r cache` on reset
Alberto Leiva Popper [Mon, 14 Oct 2024 22:33:59 +0000 (16:33 -0600)] 
Do `rm -r cache/*` instead of `rm -r cache` on reset

Skips a pointless warning on the logs when dropping an incompatible
cache:

> Cannot delete .: Invalid argument

9 months agoAttempt to mkdir the cache before cd'ing into it
Alberto Leiva Popper [Mon, 14 Oct 2024 22:20:45 +0000 (16:20 -0600)] 
Attempt to mkdir the cache before cd'ing into it

Probably not very useful outside of testing environments because of
permissions.

9 months agoMove write_simple_file() to file.c
Alberto Leiva Popper [Mon, 14 Oct 2024 21:25:33 +0000 (15:25 -0600)] 
Move write_simple_file() to file.c

Was too similar to file_write_full(), so merged.

9 months agoName CVE-2024-48943
Alberto Leiva Popper [Mon, 14 Oct 2024 17:32:22 +0000 (11:32 -0600)] 
Name CVE-2024-48943

9 months agoRemove mkdir_p()
Alberto Leiva Popper [Tue, 8 Oct 2024 23:14:56 +0000 (17:14 -0600)] 
Remove mkdir_p()

It induced too many redundant mkdir() and stat() system calls.

It's now best to use mkdir() directly, since the cache structure no
longer involves long and pointless directory chains.

Incidentally fixes a missing mkdir("cache/fallback"), which was
preventing the cache from backing up any valid RPPs.

9 months agoRemove the path builder
Alberto Leiva Popper [Tue, 8 Oct 2024 21:11:24 +0000 (15:11 -0600)] 
Remove the path builder

This has become overkill since design 5 and chdir() trivialized cache
pathing.

9 months agocd to cache directory instead of prefixing every path
Alberto Leiva Popper [Mon, 7 Oct 2024 22:00:35 +0000 (16:00 -0600)] 
cd to cache directory instead of prefixing every path

Reduces busywork, memory usage and allows the cache to be moved.

9 months agoUnify test suite function names
Alberto Leiva Popper [Mon, 7 Oct 2024 22:00:14 +0000 (16:00 -0600)] 
Unify test suite function names

It seems I always forget to update these during copy-pastes,
so most of them were misnamed.

9 months agoNew cache design
Alberto Leiva Popper [Mon, 7 Oct 2024 21:58:23 +0000 (15:58 -0600)] 
New cache design

For #82.

It seems I'm finally done making dramatic wide-reaching changes to the
codebase. There's still plenty to add and test, but I would like to
start pushing atomic commits from now on.

This is a squashed version of development brach "issue82". It includes
a few merges with main.

```
cache/
    rsync/              # rsync refresh
        0/              # rsync module: rsync://a.b.c/mod1
            rpp1/       # Repository Publication Point 1
                d.mft
                d.crl
                d1.roa
            rpp2/
                e.mft
                e.crl
            ta.cer      # Trust Anchor
        1/              # rsync module: rsync://a.b.c/mod2
            ...
        2/              # rsync module: rsync://x.y.z/mod1
            ...
    https/              # HTTPS refresh
        0               # https://a.b.c/repo/ta.cer
        1               # https://x.y.z/repo/ta.cer
    rrdp/               # RRDP refresh
        0/              # https://m.n.o/notification.xml
            0           # rsync://m.n.o/mod1/rpp1/a.mft
            1           # rsync://m.n.o/mod1/rpp1/b.crl
            2           # rsync://m.n.o/mod1/rpp2/c.mft
            3           # rsync://m.n.o/mod1/rpp2/d.cer
        1/              # https://p.q.r/notification.xml
            ...
    fallback/           # Committed RPPs
        0/              # Fallback of rsync://a.b.c/mod1/rpp1
            0           # Hard link: cache/rsync/0/rpp1/d.mft
            1           # Hard link: cache/rsync/0/rpp1/d.crl
            2           # rsync://a.b.c/mod1/rpp1/d2.roa
                        # (Unique because of refresh)
        1               # Hard link: cache/https/0
        2/              # Fallback of m.n.o's rsync://m.n.o/mod1/rpp1
            0           # Hard link: cache/rrdp/0/0
            1           # Hard link: cache/rrdp/0/1
    index.json          # URL/path mappings and some metadata
```

- `cache/rsync`, `cache/https` and `cache/rrdp` contain "refreshes"
  (the exact latest files according to the servers). RRDP withdraws are
  honored, and rsyncs run without --compare-dest.
- "Refresh" files marked as valid are backed up in `cache/fallback`
  at the end of each validation cycle.
- Validation first tests fallback+refresh. (If a file exists in both,
  refresh wins.) If that fails, it retries with fallback only.
- The index is not a tree; everything is caged in numbered directories
  and indexed by exact URL, to prevent file overriding by URL hacking.

There's also a `cache/tmp` directory, where Fort temporarily dumps
notifications, snapshots and deltas. This directory will be removed
once #127 is fixed.

9 months agoEnclose each test sandbox in a dedicated directory
Alberto Leiva Popper [Mon, 30 Sep 2024 18:06:17 +0000 (12:06 -0600)] 
Enclose each test sandbox in a dedicated directory

Prevents them from interfering with each other.

Fixes #148.

10 months agoUpdate Docker
Alberto Leiva Popper [Tue, 24 Sep 2024 16:51:02 +0000 (10:51 -0600)] 
Update Docker

10 months agoAdd 1.6.4 CVE
Alberto Leiva Popper [Tue, 24 Sep 2024 00:19:58 +0000 (18:19 -0600)] 
Add 1.6.4 CVE

10 months agoProtocolary updates for release 1.6.4 1.6.4
Alberto Leiva Popper [Mon, 23 Sep 2024 19:34:19 +0000 (13:34 -0600)] 
Protocolary updates for release 1.6.4

10 months agoMisc log review
Alberto Leiva Popper [Thu, 5 Sep 2024 20:39:11 +0000 (14:39 -0600)] 
Misc log review

- Print dependency versions during startup
- Print date ranges for certificates and CRLs

10 months agoFix default values in the documentation
Alberto Leiva Popper [Tue, 3 Sep 2024 22:22:29 +0000 (16:22 -0600)] 
Fix default values in the documentation

The retry counts and intervals were wrong.

10 months agoMerge branch 'job-rsync_timeout_poll'
Alberto Leiva Popper [Tue, 3 Sep 2024 21:45:50 +0000 (15:45 -0600)] 
Merge branch 'job-rsync_timeout_poll'

10 months agoAdd more unit tests to the rsync timeout
Alberto Leiva Popper [Tue, 3 Sep 2024 20:25:41 +0000 (14:25 -0600)] 
Add more unit tests to the rsync timeout

Aight, think I'm done testing this.

11 months agoExhaust rsync's stderr and stdout at the same time
Alberto Leiva Popper [Fri, 30 Aug 2024 02:48:54 +0000 (20:48 -0600)] 
Exhaust rsync's stderr and stdout at the same time

I'm assuming this consumes less RAM, as stdout no longer has to buffer
completely until stderr is done.

11 months agoRefactor exhaust_read_fd()'s return value
Alberto Leiva Popper [Thu, 29 Aug 2024 22:49:55 +0000 (16:49 -0600)] 
Refactor exhaust_read_fd()'s return value

Allows the unit test to tell the difference between timeout and error.

11 months agoSeparate POLLERR and POLLNVAL for rsync poll
Alberto Leiva Popper [Thu, 29 Aug 2024 22:33:40 +0000 (16:33 -0600)] 
Separate POLLERR and POLLNVAL for rsync poll

POLLERR must induce close(), POLLNVAL must not.

11 months agoRename the exhaust stream functions, simplify arg list
Alberto Leiva Popper [Thu, 29 Aug 2024 22:27:23 +0000 (16:27 -0600)] 
Rename the exhaust stream functions, simplify arg list

11 months agoUpdate timeout during every rsync poll
Alberto Leiva Popper [Thu, 29 Aug 2024 21:19:02 +0000 (15:19 -0600)] 
Update timeout during every rsync poll

Ensures the timeout is absolute even when poll() returns repeatedly.

11 months agoIntroduce a rsync transfer timeout 147/head
Job Snijders [Thu, 22 Aug 2024 16:33:59 +0000 (16:33 +0000)] 
Introduce a rsync transfer timeout

Default set to 900 (same as rpki-client)

Fixes https://github.com/NICMx/FORT-validator/issues/74

11 months agoFill up CVE numbers in documentation
Alberto Leiva Popper [Tue, 27 Aug 2024 14:52:00 +0000 (08:52 -0600)] 
Fill up CVE numbers in documentation

11 months agoMerge branch 'job-pr146'
Alberto Leiva Popper [Fri, 23 Aug 2024 20:07:50 +0000 (14:07 -0600)] 
Merge branch 'job-pr146'

11 months agoMerge branch 'job-pr144'
Alberto Leiva Popper [Thu, 22 Aug 2024 20:14:42 +0000 (14:14 -0600)] 
Merge branch 'job-pr144'

11 months agoImprove Key Usage validation more
Alberto Leiva Popper [Thu, 22 Aug 2024 18:40:48 +0000 (12:40 -0600)] 
Improve Key Usage validation more

- Was not checking the decipherOnly bit
- Was not using the buffer meant to ease checking the decipherOnly bit

Again, thanks to Niklas Vogel and Haya Schulmann for reporting this.

11 months agoSet default HTTP transfer timeout to 900 146/head
Job Snijders [Thu, 22 Aug 2024 16:40:42 +0000 (16:40 +0000)] 
Set default HTTP transfer timeout to 900

11 months agoCredit Haya Schulmann for her contributions to the CVEs
Alberto Leiva Popper [Thu, 22 Aug 2024 16:27:23 +0000 (10:27 -0600)] 
Credit Haya Schulmann for her contributions to the CVEs

11 months agoImprove compliance with RFC 9589 144/head
Job Snijders [Thu, 22 Aug 2024 11:15:37 +0000 (11:15 +0000)] 
Improve compliance with RFC 9589

As of 9589, the CMS SigningTime attribute is mandatory and the
CMS BinarySigningTime attribute is forbidden.

11 months agoUpdate Docker
Alberto Leiva Popper [Thu, 22 Aug 2024 03:19:50 +0000 (21:19 -0600)] 
Update Docker

11 months agoAdd CVE "reference" sketch
Alberto Leiva Popper [Thu, 22 Aug 2024 02:46:03 +0000 (20:46 -0600)] 
Add CVE "reference" sketch

11 months agoProtocolary updates for release 1.6.3 1.6.3
Alberto Leiva Popper [Mon, 19 Aug 2024 19:11:44 +0000 (13:11 -0600)] 
Protocolary updates for release 1.6.3

11 months agoReview of #includes
Alberto Leiva Popper [Thu, 15 Aug 2024 23:48:25 +0000 (17:48 -0600)] 
Review of #includes

Now featuring local includes too.

11 months agoRemove redundant forward declarations in ASN1
Alberto Leiva Popper [Thu, 15 Aug 2024 23:41:55 +0000 (17:41 -0600)] 
Remove redundant forward declarations in ASN1

11 months agoPrevent crash on BER-encoded signedAttrs
Alberto Leiva Popper [Tue, 6 Aug 2024 16:35:59 +0000 (10:35 -0600)] 
Prevent crash on BER-encoded signedAttrs

The code was assuming the object was DER-encoded, and the relevant
integer was therefore in short form.

Because I postponed the DER enforcement in
deef7b7823f21914b17838f152a8bd510a348f54, the code should not make
reckless assumptions about the signedAttrs encoding.

Thanks to Niklas Vogel for reporting this.

11 months agoPrevent crash on missing eContent
Alberto Leiva Popper [Tue, 6 Aug 2024 16:35:24 +0000 (10:35 -0600)] 
Prevent crash on missing eContent

Applies to the RouteOriginAttestation and Manifest octet strings.

Thanks to Niklas Vogel for reporting this.

11 months agoPrevent crash on missing signedAttrs
Alberto Leiva Popper [Tue, 6 Aug 2024 16:35:14 +0000 (10:35 -0600)] 
Prevent crash on missing signedAttrs

Though RPKI enforces the presence of this field, it is very much
optional in CMS.
Also adds missing validation messages in relevant error paths.

Thanks to Niklas Vogel for reporting this.

11 months agoPrevent crash on missing Authority Key Identifier
Alberto Leiva Popper [Tue, 6 Aug 2024 16:29:44 +0000 (10:29 -0600)] 
Prevent crash on missing Authority Key Identifier

Another missing NULL check.

Thanks to Niklas Vogel for reporting this.

11 months agoPrevent crash on malformed Key Usage
Alberto Leiva Popper [Tue, 6 Aug 2024 16:29:16 +0000 (10:29 -0600)] 
Prevent crash on malformed Key Usage

Key Usage bit strings longer than 2 bytes were inducing buffer overflow.

Thanks to Niklas Vogel for reporting this.

11 months agoPrevent crash on malformed subjectPublicKey
Alberto Leiva Popper [Tue, 6 Aug 2024 16:28:57 +0000 (10:28 -0600)] 
Prevent crash on malformed subjectPublicKey

A malformed subjectPublicKey causes X509_PUBKEY_get0() to return NULL.
Fort wasn't catching this when linked specifically to OpenSSL < 3.

Thanks to Niklas Vogel for reporting this.

11 months agoUse HTTP compressed encoding when available 143/head
Job Snijders [Sat, 3 Aug 2024 13:30:53 +0000 (15:30 +0200)] 
Use HTTP compressed encoding when available

This reduces network traffic by about 50%.