]> git.ipfire.org Git - thirdparty/FORT-validator.git/log
thirdparty/FORT-validator.git
21 months agoFix new RRDP memory leak
Alberto Leiva Popper [Fri, 10 Nov 2023 16:48:05 +0000 (10:48 -0600)] 
Fix new RRDP memory leak

Introduced by 6d8081c992da9d677e3bd9cdf21bb63e604f0b4d.

21 months agoPatch FIXME: Delete existing RPP before expanding snapshot
Alberto Leiva Popper [Fri, 10 Nov 2023 00:01:44 +0000 (18:01 -0600)] 
Patch FIXME: Delete existing RPP before expanding snapshot

21 months agoPatch FIXME: Fall back to snapshot when deltas fail
Alberto Leiva Popper [Thu, 9 Nov 2023 23:51:43 +0000 (17:51 -0600)] 
Patch FIXME: Fall back to snapshot when deltas fail

21 months agoPatch TODO: Change RRDP serials into BIGNUMs
Alberto Leiva Popper [Wed, 8 Nov 2023 23:14:12 +0000 (17:14 -0600)] 
Patch TODO: Change RRDP serials into BIGNUMs

Serials used to be unsigned longs. RFC 8182:

> The serial attribute MUST be an unbounded, unsigned positive
> integer in decimal format indicating the current version of the
> repository.

21 months agoPatch FIXME: Raise severity of RRDP INFO messages
Alberto Leiva Popper [Wed, 8 Nov 2023 18:17:33 +0000 (12:17 -0600)] 
Patch FIXME: Raise severity of RRDP INFO messages

These are supposed to be errors, not infos.

21 months agoFix traversal result code
Alberto Leiva Popper [Wed, 8 Nov 2023 17:47:30 +0000 (11:47 -0600)] 
Fix traversal result code

handle_tal_uri() was returning 0 on soft errors and positive on success.
It's supposed to be the other way around.

This resulted in the main loop dropping successful tree traversals.

It also resulted in TA public key mismatches causing traversal
termination, which was a violation of RFC 8630:

> If the connection to the preferred URI fails or the retrieved CA
> certificate public key does not match the TAL public key, the RP
> SHOULD retrieve the CA certificate from the next URI, according to
> the local preference ranking of URIs.

This bug was introduced by 604f845ce6b9eb596dc9f1fdff7a7fa5752fcc87.

21 months agoAnother RRDP review, startup
Alberto Leiva Popper [Tue, 7 Nov 2023 21:25:06 +0000 (15:25 -0600)] 
Another RRDP review, startup

- Improve usage of `xmlChar *`
  (Was being casted to/from `char *` rather contract-breakingly.)
- Bunch of renames
- notification_metadata -> rrdp_session
  (These are not exclusive to Notifications.)
- delta_head -> notification_delta
  (The object specifically refers to Notification delta tags,
  I don't know what "head" is supposed to allude.)
- rdr_snapshot_ctx, rdr_delta_ctx -> rrdp_ctx
  (Slightly tweaked the semantics of this, to reduce argument
  lists.)
- Remove redundant fnstack pushes and pops
  (Rather comically, snapshots and deltas were being stacked twice:
  parse_snapshot() + rrdp_parse_snapshot(), parse_delta() +
  process_delta().)

There are still a few FIXMEs in RRDP yet.

21 months agoMerge the RRDP modules
Alberto Leiva Popper [Tue, 7 Nov 2023 18:40:05 +0000 (12:40 -0600)] 
Merge the RRDP modules

I don't really have any strong arguments to justify this. Been
progressively convincing myself to do it over time, and at this point I
think it's inevitable.

It's not that much code, most of this stuff doesn't need to be exported,
and the reduced API simplifies the review.

I'm becoming a minimalist, I suppose.

21 months agoPrivatize struct publish and struct withdraw
Alberto Leiva Popper [Mon, 6 Nov 2023 23:24:17 +0000 (17:24 -0600)] 
Privatize struct publish and struct withdraw

21 months agoDelete struct snapshot and struct delta
Alberto Leiva Popper [Mon, 6 Nov 2023 17:39:12 +0000 (11:39 -0600)] 
Delete struct snapshot and struct delta

Weird code design.

I originally meant to privatize and de-heap these structures,
but it turns out they were not just used by a single module;
they were only used by `parse_metadata()`.

(Their domain seemed larger than it was, because they were being
initialized elsewhere, for no apparent reason.)

Then, while trying to clean up the global namespace, I noticed that the
hack was actually intertwined with another one: `parse_metadata()` was
being used for two purposes that are never actually used simultaneously.
This cluttered it.

So also separate `parse_metadata()` from `validate_metadata()`.

21 months agoImprove the cache fallback algorithm
Alberto Leiva Popper [Tue, 31 Oct 2023 18:17:34 +0000 (12:17 -0600)] 
Improve the cache fallback algorithm

If all of a RPP's URLs fail, fall back to most sensible cached
candidate.
It seems this used to be only implemented for TAs, and the heuristics
for choosing a suitable fallback were rudimentary.
Elaborate, centralize and extend implementation to all cache content.

Side maintenance tweaks:

- Remove EREQFAILED, because it largely evolved from meaning "don't try
  again" to "try again." So now it was just a redundant EAGAIN.
- Ditch redundant arguments from valid_file_or_dir().
- Merge the three URI arraylist implementations (certificate.c, tal.c
  and manifest.c) into one.
- Move RRDP workspace URI, from a thread variable to the stack.
  (Code smell. It used to be awkward to follow this variable's lifespan
  through the tree traversal.)
- Move struct publish and struct withdraw from the heap to the stack.
  (Eliminate pointless allocations. These are not the only RRDP
  structures I want to move to the stack.)
- Change file_metadata.uri from `char *` to `struct rpki_uri *`.
  (This string was forcing the RRDP code to recompute the URI
  repeatedly.)

21 months agoAdd minor/stylistic tweaks to main loop
Alberto Leiva Popper [Mon, 30 Oct 2023 20:47:28 +0000 (14:47 -0600)] 
Add minor/stylistic tweaks to main loop

1. Merge notify and validation_run into main
2. Remove unused structure fields
3. Rename some symbols

21 months agoPrevent pthread_join from hiding some other thread's error
Alberto Leiva Popper [Mon, 30 Oct 2023 20:44:02 +0000 (14:44 -0600)] 
Prevent pthread_join from hiding some other thread's error

21 months agoUpdate unit tests
Alberto Leiva Popper [Mon, 30 Oct 2023 16:47:43 +0000 (10:47 -0600)] 
Update unit tests

21 months agoDelete the validation thread pool
Alberto Leiva Popper [Thu, 26 Oct 2023 21:40:48 +0000 (15:40 -0600)] 
Delete the validation thread pool

My original intent was "deprecate thread-pool.validation.max," but it
turns out it was just a symptom of a (mostly inoffensive)
overcomplication.

thread-pool.validation.max has proven confusing to users, because it
doesn't make sense for it to be configurable. The thread count should
always equal the number of RPKI trees, which in turn equals the number
of TALs. There's no reason why Fort should offload this decision to the
user.

As for the thread pool, the validation cycle is not really a fitting
problem for such an ellaborate solution, because the former involves a
very small amount (typically 5) of long-lived threads that start at the
same time, once every hour or so.

So instead of pooling a configured amount of threads in the beginning,
spawn raw threads as needed.

The RTR server still employs a thread pool.

21 months agoRemove unused includes
Alberto Leiva Popper [Wed, 25 Oct 2023 22:26:26 +0000 (16:26 -0600)] 
Remove unused includes

21 months agoUn-deprecate http.priority and rsync.priority
Alberto Leiva Popper [Wed, 25 Oct 2023 21:09:36 +0000 (15:09 -0600)] 
Un-deprecate http.priority and rsync.priority

Reverts relevant tweak from c717043aad5bf8306a437ac0020bdfceeb8d2234,
though it rewrites the mechanism.

Orders from above. But also, RRDP seems to be much faster than rsync.
Best prefer the former at all times by default.

21 months agoValidate Error Reports harder
Alberto Leiva Popper [Tue, 24 Oct 2023 21:28:11 +0000 (15:28 -0600)] 
Validate Error Reports harder

- Reject overly small Error Reports earlier and more clearly on the logs
- Compare Length of Encapsulated PDU to header length earlier

It seems both issues caused relevant malformed Error Reports to be
considered fragmentend rather than invalid.

21 months agoTruncate erroneos PDU if incomplete
Alberto Leiva Popper [Tue, 24 Oct 2023 18:52:09 +0000 (12:52 -0600)] 
Truncate erroneos PDU if incomplete

This can happen if eg. the client parrots length 512 in header, but only
sends 8 bytes.

Fort was trying to assemble a 512 length erroneous PDU using an 8 byte
buffer, and therefore leaking raw memory contents to the client.

21 months agoRemove PDU queuing
Alberto Leiva Popper [Sat, 21 Oct 2023 03:08:46 +0000 (21:08 -0600)] 
Remove PDU queuing

Tweak ideated during the commit message of the previous commit.

- If the read() yields at least one Error Report, drop the connection.

This is because all the server-received error codes currently defined
are supposed to result in immediate connection termination.

If a future RFC defines a nonfatal error code, Error Reports should
probably be downgraded to the 'last PDU' rule below.

- Otherwise, if a read() yields multile PDUs, drop all except for the
  last one.

Since it's what the client is most likely expecting, I guess. Serial
Queries and Reset Queries are alternate means to achieve the same goal,
so it doesn't make sense to queue them.

21 months agoRTR server maintenance
Alberto Leiva Popper [Fri, 20 Oct 2023 22:18:39 +0000 (16:18 -0600)] 
RTR server maintenance

Someone reported a security vulnerability in the server, but the details
are muddy, and clarifications have not arrived yet. I haven't been able
to reproduce it, but the review did yield room for improvement:

1. Buffer request bytes better

The old code seemed to assume each socket read consumed exactly one
(nonempty) TCP packet, and each such packet contained exactly one PDU.

I'm scratching my head at this, but I guess for most intents and
purposes, this assumption is not as lunatic as it seems. Benign RTR PDUs
are very small, and it doesn't make sense for a request packet to
contain multiple of them. Error Reports aside, it doesn't even make
sense for the client to send multiple PDUs in quick succession at all.

Regardless, I'm flushing that assumption down the toilet:

- If read() yields multiple PDUs, queue and handle them in sequence.

Although as I'm writing this I'm realizing that queuing PDUs is a dumb
idea, because Serial Queries and Reset Queries are alternate means to
achieve the same goal. If the client sent a new request, it's most
likely given up on the old one. Plus, queuing PDUs brings additional
complexity and risks. I'm going to have to change this in the next
commit.

- If a read() yields a fragmented PDU, buffer and prepend it to the next
  successful read.

This will probably never happen, but it's nice to handle it properly
anyway.

2. Drop unused PDU parsers

An RTR server only needs to handle PDU types Serial Query, Reset Query
and Error Report. Fort also had dead code meant for the other PDU types.

I'm guessing they were intended for the Error Report internal PDU field,
but it turns out that's also unused.

3. Improve PDU validation

Since Serial Queries and Reset Queries are supposed to have constant
length, Fort was often ignoring the PDU header length field.

Fort now punishes incorrect lengths more aggressively.

21 months agoPatch errors detected by unit tests
Alberto Leiva Popper [Fri, 20 Oct 2023 22:14:21 +0000 (16:14 -0600)] 
Patch errors detected by unit tests

22 months agoFix rsync target location
Alberto Leiva Popper [Fri, 6 Oct 2023 21:47:21 +0000 (15:47 -0600)] 
Fix rsync target location

Was downloading rsync://a.b/c into rsync://a.b/c/c, because of an rsync
complication (from rsync(1)):

> A trailing slash on the source changes this behavior to avoid creating
> an additional directory level at the destination. You can think of a
> trailing / on a source as meaning "copy the contents of this
> directory" as opposed to "copy the directory by name", but in both
> cases the attributes of the containing directory are transferred to
> the containing directory on the destination. In other words, each of
> the following commands copies the files in the same way, including
> their setting of the attributes of /dest/foo:
>
> rsync -av /src/foo /dest
> rsync -av /src/foo/ /dest/foo

22 months agoRestore certificate stack push
Alberto Leiva Popper [Thu, 5 Oct 2023 17:16:19 +0000 (11:16 -0600)] 
Restore certificate stack push

I had temporarily removed this code during the tree traversal review,
and forgot to restore it.

Push current certificate into certificate stack, so child objects can
validate themselves against it.

22 months agoFix global to local URI mapping on manifest entries
Alberto Leiva Popper [Thu, 5 Oct 2023 00:22:34 +0000 (18:22 -0600)] 
Fix global to local URI mapping on manifest entries

Straightforward bug; was neither downloading to the intended location
nor attempting to locate the file there afterwards.

22 months agoAdd some debug logs to RRDP
Alberto Leiva Popper [Thu, 5 Oct 2023 00:18:34 +0000 (18:18 -0600)] 
Add some debug logs to RRDP

22 months agoPrevent string from being released before it's returned
Alberto Leiva Popper [Wed, 4 Oct 2023 23:31:11 +0000 (17:31 -0600)] 
Prevent string from being released before it's returned

22 months agoMemorize notification URI before handling RRDP objects
Alberto Leiva Popper [Wed, 4 Oct 2023 23:20:09 +0000 (17:20 -0600)] 
Memorize notification URI before handling RRDP objects

The URI is needed both by RRDP objects and Manifest; it seems I was not
taking the former into account.

22 months agoRestore GeneralizedTime_constraint()
Alberto Leiva Popper [Wed, 4 Oct 2023 21:21:00 +0000 (15:21 -0600)] 
Restore GeneralizedTime_constraint()

Turns out this is being used, and trivial to implement.

22 months agoFix usage of incorrect configuration field
Alberto Leiva Popper [Wed, 4 Oct 2023 20:57:32 +0000 (14:57 -0600)] 
Fix usage of incorrect configuration field

22 months agoInclude cache dir in local counterpart of URIs
Alberto Leiva Popper [Wed, 4 Oct 2023 20:37:33 +0000 (14:37 -0600)] 
Include cache dir in local counterpart of URIs

Before:

- URI: https://a.b.c/d/e.xml
- Local path: https/a.b.c/d/e.xml

Now:

- URI: https://a.b.c/d/e.xml
- Local path: /path/to/cache/https/a.b.c/d/e.xml

Is a bit more memory-gluttonous, but prints a more helpful string,
and simplifies user code by taking care of the task up front.

22 months agoFeature test macro review (cont.)
Alberto Leiva Popper [Tue, 3 Oct 2023 21:26:08 +0000 (15:26 -0600)] 
Feature test macro review (cont.)

I found a couple of symbols I missed during the previous macro review:

- getline(). This forces POSIX >= 2008.
- IN6_ARE_ADDR_EQUAL(). I can't find where this is supposed to be
  standardized, so I decided to ditch it.

Also, declaring these macros in every dependent file is scaling poorly,
so I moved them to the CC directives, unifying them in the process.
_POSIX_C_SOURCE is now 200809L, and _XOPEN_SOURCE is 700 (to match).

Also, reduce -std to c99. I don't really have an issue with gnu11, but
it looks like the delta is heavily underutilized in the project.
Might revert it later.

Finally, update the unit tests.

22 months agoReduce severity of metadata.json not found
Alberto Leiva Popper [Tue, 3 Oct 2023 20:07:26 +0000 (14:07 -0600)] 
Reduce severity of metadata.json not found

Also improve the error messages by including the actual name of the
file.

22 months agoInit basic cache structure on validation start
Alberto Leiva Popper [Tue, 3 Oct 2023 18:52:51 +0000 (12:52 -0600)] 
Init basic cache structure on validation start

Perform a token attempt to create the cache directory, as well as a more
reasonable one to create its tmp/ subdirectory, whenever the validation
cycle begins.

22 months agoReview strchr() and strrchr() usage
Alberto Leiva Popper [Tue, 3 Oct 2023 18:49:00 +0000 (12:49 -0600)] 
Review strchr() and strrchr() usage

The code was sometimes falling into the strchr() const trap.

This wasn't really a problem because literals were never involved,
and the strings were not thread-shared.

But better be safe than sorry.

22 months agoCall X509_ALGOR_get0() instead of dereferencing ASN1_OBJECT
Alberto Leiva Popper [Tue, 3 Oct 2023 17:17:21 +0000 (11:17 -0600)] 
Call X509_ALGOR_get0() instead of dereferencing ASN1_OBJECT

Seems to be the formal way of doing it.

22 months agoZeroize validation.notification_uri on initialization
Alberto Leiva Popper [Tue, 3 Oct 2023 15:43:06 +0000 (09:43 -0600)] 
Zeroize validation.notification_uri on initialization

22 months agoRelease CRL on error branch
Alberto Leiva Popper [Tue, 3 Oct 2023 15:37:57 +0000 (09:37 -0600)] 
Release CRL on error branch

Fixes memory leak.

22 months agoRevert Autoconf version
Alberto Leiva Popper [Tue, 3 Oct 2023 15:34:33 +0000 (09:34 -0600)] 
Revert Autoconf version

Looks like 2.71 is not that widespread yet, and Fort is not using any
features past 2.69 anyway.

Revert from 62c65a79e142012067a76acf70b86438d56636e1.

22 months agoRemove timegm() and tm_gmtoff
Alberto Leiva Popper [Mon, 2 Oct 2023 16:20:27 +0000 (10:20 -0600)] 
Remove timegm() and tm_gmtoff

Perfects portability. Still missing some testing.

I hope this is not too aggressive. If there are RPKI objects not using
Zulu, this is going to need further tweaking.

22 months agoStop assuming time_t is long and represents seconds
Alberto Leiva Popper [Fri, 29 Sep 2023 20:43:53 +0000 (14:43 -0600)] 
Stop assuming time_t is long and represents seconds

22 months agoFeature test macro review
Alberto Leiva Popper [Thu, 28 Sep 2023 22:49:19 +0000 (16:49 -0600)] 
Feature test macro review

Stop relying on default features; explicitely define the macros that
enable the symbols we need.

It appears POSIX.1 usage is fairly widespread through the code, and its
minimum required version is 2001.

We also have one GNU extension: getopt_long().

And we also have one GNU extension marked as nonstandard: timegm().
I'm going to try to remove it in a future commit.

22 months agoRemove SO_REUSEPORT from the RTR socket bind
Alberto Leiva Popper [Thu, 28 Sep 2023 22:32:53 +0000 (16:32 -0600)] 
Remove SO_REUSEPORT from the RTR socket bind

This option is causing portability issues, and I can't figure out why it
was introduced. None of the Github issues mention it, and
6401a4739ac512985158e63499e037dc2f2078db says

> Use SO_REUSEPORT at sockopts so that the RTR port can be reused

But reused when? For what purpose?

I think this might be an allusion to
ac56d70c954caf49382f5f28ff4a017e859e2e0a:

> SO_REUSEADDR sockopt allows to reuse server address and port at once
> when the service has been stoped (or killed).

But that doesn't need SO_REUSEPORT for anything.

22 months agoSystem #include overhaul
Alberto Leiva Popper [Wed, 27 Sep 2023 21:49:57 +0000 (15:49 -0600)] 
System #include overhaul

Reorganize `#include <>`s in accordance with the IEEE Std 1003.1,
the Linux man pages (which do a pretty good job explaining portability
nuances), the documentation of the dependencies and some common sense.
(Since it seems some of this stuff is undefined.)

The algorithm still induces some unnecessary includes. (eg. the `NULL`
symbol induces `stddef.h`, `string.h`, `stdlib.h`, `stdio.h`, `unistd.h`
AND `locale.h`, because the standard states it should be defined in all
of them.) I don't think this is a problem for now; I'll optimize it
later.

22 months agoRemove some of the asn1c and uthash glue code
Alberto Leiva Popper [Wed, 27 Sep 2023 20:50:26 +0000 (14:50 -0600)] 
Remove some of the asn1c and uthash glue code

The asn1c stuff was autogenerated, and the uthash stuff was copy-pasted
from its source project.

None of it serves any purpose. I'm not allergic to the possibility of
supporting these other environments, but this is not the time for it.
Also, it probably doesn't work anyway, since it has never been tested
in the context of Fort.

This doesn't delete all the glue code; only the necessary parts needed
for the upcoming commit.

22 months agoUnify working directory #includes
Alberto Leiva Popper [Wed, 27 Sep 2023 20:30:56 +0000 (14:30 -0600)] 
Unify working directory #includes

I'm currently reviewing the system includes. There are some unnecesary
ones, as well as a few nonstandard quirks complicating portability.

This is the first of possibly quite a few commits intended to refactor
this relative mess. It makes all `#include ""`s relative to the root of
the source directory.

This makes them easier to analyze and copy-paste.

22 months agoTesting on the local cache code
Alberto Leiva Popper [Wed, 20 Sep 2023 00:08:15 +0000 (18:08 -0600)] 
Testing on the local cache code

- Recover from more errors
- Test more error paths

22 months agoRefactor path_builder
Alberto Leiva Popper [Fri, 15 Sep 2023 21:56:49 +0000 (15:56 -0600)] 
Refactor path_builder

Mainly so a local cache tree traversal recovers from a malformed URI.

1. Atomize append operations

Failure used to leave the path builder in an essentially undefined
state, which meant the path had to be thrown away, precluding further
tree traversal.

A failing `append()` no longer modifies the path builder, allowing the
tree traversal to simply skip the ailing branch.

2. Remove lazy failure

The old path_builder was postponing error reporting to path compilation
(`pb_peek()` and `pb_compile()`).

This was an old optimization (meant to simplify path building code),
and was getting in the way of the atomizing.

Errors are now fail-fast, thrown during path construction
(`pb_append*()`).

3. Move path normalization to `uri`

Path normalization (collapsing `.`, `..` and `/`) was getting in the
way of the atomizing, in addition to only really being useful for the
URI-to-cache conversion code.

3. Restore support for absolute paths

This was just a small TODO spawned a few commits ago.

22 months agoRename path_* functions to pb_*
Alberto Leiva Popper [Wed, 13 Sep 2023 22:06:24 +0000 (16:06 -0600)] 
Rename path_* functions to pb_*

Just a whim; I always get the prefix wrong.

22 months agoRemove recursion from cache's non-jansson ops
Alberto Leiva Popper [Wed, 13 Sep 2023 18:13:15 +0000 (12:13 -0600)] 
Remove recursion from cache's non-jansson ops

22 months agoAdd ARRAYLIST_FOREACH_IDX
Alberto Leiva Popper [Tue, 12 Sep 2023 21:54:27 +0000 (15:54 -0600)] 
Add ARRAYLIST_FOREACH_IDX

The old ARRAYLIST_FOREACH provided both a cursor and a counter.
Most users weren't using the counter, so I separated them:

The new ARRAYLIST_FOREACH uses a cursor,
the new ARRAYLIST_FOREACH_IDX uses a counter.

23 months agoOngoing rewrite of the local cache code
Alberto Leiva Popper [Tue, 11 Jul 2023 23:00:46 +0000 (17:00 -0600)] 
Ongoing rewrite of the local cache code

It's a bit smarter now. Addresses a bunch of issues at once, though it
still needs several tweaks and testing:

- #78: Provide a dedicated namespace for each RRDP notification, to
  prevent malicious RPPs from overriding files from other RPPs.
- #79: RRDP session and serial are no longer cached in RAM; they're
  extracted from cached notification files as they are needed.
  This prevents all RRDP from being considered outdated during startup.
- #80: rsync-strategy has been removed.
- #81: The cache now retains RRDP files.

The refactor has been more intrusive than intended. I've been retouching
the core loop and rrdp/https code, which has yielded the following
further disinfections:

- #77: Refactor the HTTP code so 304 is handled as success, despite no
  file modifications having been made.
- It seems the old code was refusing to download RPPs via RRDP when said
  RPP wasn't also (unrelatedly) served via rsync. This seemed to stem
  from an old RFC misunderstanding from the previous developer.
- I've deprecated `rsync.priority` and `rrdp.priority`, mostly just to
  simplify the code. I haven't seen anyone using these config fields,
  and I think SIAs and/or randomness should be the ones to decide which
  protocol is preferred for a given RPP, not Fort's admin.
- However, I have also decided to deprecate `shuffle_tal_uris`, because
  I also suspect it's completely unused, and would like to hear some
  complaints otherwise.
- Deprecated `rsync.arguments-flat`, because non-recursive rsyncs are
  not needed anymore.
- Since RRDP files are no longer deleted immediately after use, the
  `DEBUG_RRDP` compilation has lost its purpose, so I deleted it.
- The code was using `HASH_ADD_STR` on strings contained outside of the
  node structure. This is illegal according to uthash's documentation,
  and might have induced some crashes in the past.

2 years agoMerge branch 'main' into issue76
Alberto Leiva Popper [Mon, 10 Jul 2023 15:38:15 +0000 (09:38 -0600)] 
Merge branch 'main' into issue76

2 years agoPartial refactor of certificate_traverse()
Alberto Leiva Popper [Fri, 7 Jul 2023 21:28:19 +0000 (15:28 -0600)] 
Partial refactor of certificate_traverse()

Simplifies it by moving some of its clutter to helper functions,
seemingly in preparation for #58.

Part of a series of patches meant to manually rebase the issue58-proper
branch.

2 years agoAdd struct asn_range
Alberto Leiva Popper [Fri, 7 Jul 2023 19:16:04 +0000 (13:16 -0600)] 
Add struct asn_range

Slightly improves code that needs to deal with groups of contiguous
ASNs.

Also adds a bunch of healthy consts here and there.

Part of a series of patches meant to manually rebase the issue58-proper
branch.

2 years agoMove policy initialization to resources constructor
Alberto Leiva Popper [Fri, 7 Jul 2023 16:15:06 +0000 (10:15 -0600)] 
Move policy initialization to resources constructor

Yields cleaner resources initialization code.

Part of a series of patches meant to manually rebase the issue58-proper
branch.

2 years agoRename the cert_type enums
Alberto Leiva Popper [Fri, 7 Jul 2023 16:03:34 +0000 (10:03 -0600)] 
Rename the cert_type enums

Slightly more idiomatic C, makes it a bit clearer to see what they are.

Part of a series of patches meant to manually rebase the issue58-proper
branch.

2 years agoRemove status from README
Alberto Leiva Popper [Thu, 6 Jul 2023 20:35:40 +0000 (14:35 -0600)] 
Remove status from README

No need to hammer a status now that development has returned to normal.

2 years agoAdd simple uthash unit test
Alberto Leiva Popper [Thu, 6 Jul 2023 18:22:14 +0000 (12:22 -0600)] 
Add simple uthash unit test

I had this stashed for a long time. It's rather misplaced, because it
tests uthash rather than Fort. But I guess I already wrote it, meh.

In any case, uthash is copied code compiled into Fort, not a library.

2 years agocgcc review
Alberto Leiva Popper [Thu, 6 Jul 2023 17:40:10 +0000 (11:40 -0600)] 
cgcc review

2 years agoCleanup for packaging of version 1.5.4.1
Alberto Leiva Popper [Wed, 5 Jul 2023 23:48:06 +0000 (17:48 -0600)] 
Cleanup for packaging of version 1.5.4.1

2 years agoReset FILE on HTTP retry
Alberto Leiva Popper [Tue, 4 Jul 2023 17:28:07 +0000 (11:28 -0600)] 
Reset FILE on HTTP retry

Prevents the file from being appended to itself during retries.

Fixes #76.

2 years agoDeprecate and no-op --rsync.strategy
Alberto Leiva Popper [Fri, 30 Jun 2023 20:02:25 +0000 (14:02 -0600)] 
Deprecate and no-op --rsync.strategy

Only STRICT synchronizations are allowed now.

This orphans --rsync.arguments-recursive, so it has been deprecated and
no-op'd as well.

Fixes #80.

2 years agoDeprecate stale-repository-period better
Alberto Leiva Popper [Fri, 30 Jun 2023 22:14:11 +0000 (16:14 -0600)] 
Deprecate stale-repository-period better

This had been deprecated in efe3d0cca66fdf9cef220f4e76fff71b12a11c8b,
but I forgot to update the manual.

Also added deprecation warning message.

2 years agoDelete --init-locations
Alberto Leiva Popper [Fri, 30 Jun 2023 22:06:32 +0000 (16:06 -0600)] 
Delete --init-locations

It was deprecated a long time ago.

2 years agoMore miscellaneous cleanups
Alberto Leiva Popper [Fri, 30 Jun 2023 19:07:27 +0000 (13:07 -0600)] 
More miscellaneous cleanups

4c1dba27917715550fb2e6367ff20fa4efe89ac3 missed some bad words.
da2a10115fe9b0da3365cb1edeeae241ece0d84b missed one of ARIN's TAL workarounds.
39053843972926d6a8b55ccaf2ae2d792255189c didn't link to the tracker properly.
b6404ec81920c0ee8397cabedc90159795f38ed8 missed deprecated fields in examples and man.

The documentation will retain the deprecated fields until the new
release.

2 years agoUpdate status in the documentation
Alberto Leiva Popper [Fri, 30 Jun 2023 18:33:36 +0000 (12:33 -0600)] 
Update status in the documentation

2 years agoMerge branch 'THEWWWTHING-main'
Alberto Leiva Popper [Fri, 30 Jun 2023 18:13:30 +0000 (12:13 -0600)] 
Merge branch 'THEWWWTHING-main'

2 years agoMerge ASID and ASId into ASId
Alberto Leiva Popper [Fri, 30 Jun 2023 18:04:05 +0000 (12:04 -0600)] 
Merge ASID and ASId into ASId

They are the same data type.

I'm merging them into the latter because it's more widely used.

Fixes #94, I think.

2 years agoUpdate asn1c for its generated code
Alberto Leiva Popper [Fri, 30 Jun 2023 17:51:44 +0000 (11:51 -0600)] 
Update asn1c for its generated code

Inherits miscellaneous bugfixes.

Bumps asn1c from version 88ed3b5cf012918bc1084b606b0624c45e0d2191
to 9925dbbda86b436896108439ea3e0a31280a6065.

2 years agoMerge branch 'rrdp-refactor-2'
Alberto Leiva Popper [Thu, 29 Jun 2023 22:22:32 +0000 (16:22 -0600)] 
Merge branch 'rrdp-refactor-2'

2 years agoChange rsync.priority's config data type to uint
Alberto Leiva Popper [Thu, 29 Jun 2023 20:47:16 +0000 (14:47 -0600)] 
Change rsync.priority's config data type to uint

It was using uint32, even though it was declared as an unsigned int.

This orphans uint32, so purged.

2 years agoRemove the AIA validation
Alberto Leiva Popper [Thu, 29 Jun 2023 20:27:02 +0000 (14:27 -0600)] 
Remove the AIA validation

As discovered in 566835e8da0ce52b6bded39db72667eeb2e41001, this
validation was implemented incorrectly. Fort should locate the parent
certificate in the local cache by URI, not force-redownload by rsync.

The URI indexing will be implemented as part of #78. I'll reimplement
the validation properly then.

2 years agoUpdate the unit tests
Alberto Leiva Popper [Thu, 29 Jun 2023 16:37:38 +0000 (10:37 -0600)] 
Update the unit tests

2 years agoRemove obsolete config options
Alberto Leiva Popper [Tue, 27 Jun 2023 22:21:26 +0000 (16:21 -0600)] 
Remove obsolete config options

- sync-strategy
- rrdp.enabled
- rrdp.priority
- rrdp.retry.count
- rrdp.retry.interval
- http.idle-timeout

These were deprecated long ago.

2 years agoRemove the working_repo module
Alberto Leiva Popper [Tue, 27 Jun 2023 19:31:25 +0000 (13:31 -0600)] 
Remove the working_repo module

It's a thread variable that keeps track of a URI that roughly represents
the publication point currently being traversed.

I would have moved it to the validation state, but given the two
previous commits, it wasn't really doing anything anymore.

2 years agoRemove the reqs_errors module
Alberto Leiva Popper [Tue, 27 Jun 2023 17:35:32 +0000 (11:35 -0600)] 
Remove the reqs_errors module

It's a collection of failed downloads, and it's two-purposed:

1. To list the failed downloads once the validation is over.
   (Which is the functionality I deleted in the prevous commit.)
2. To clue the AIA validation code (through an EREQFAILED) not to...
   uh... redownload... the AIA certificate's... parent.
   Huh.

Yeah, I have a few issues with the implementation:

A. Purpose 1 is obsolete.

B. Regarding purpose 2: Fort should never redownload a file that was
   already traversed in the same validation cycle. This purpose is
   plainly wrong.

Oh, you know what? I get it.

The original coder was probably concerned that the parent might have
been downloaded via RRDP, yet the child's AIA is always an rsync URI...
and because RRDP and rsync are cached into separate namespaces, well,
Fort wasn't going to find the parent.

But the thing is, it's a URI, not a URL. RRDP also refers to these files
by way of their "rsync" *URI* in its snapshots and deltas. RRDP might
be HTTP, but there is no such thing as http://path.to/certificate.cer.

This should be fixed by way of clever local cache resolution, not an
awkward redownload.

C. The lifescope of this table should be a single validation run, not
   Fort's lifetime.

I think the reason why it's global is so the code could warn if a
particular resource had been down for several iterations.
But I wouldn't say that's Fort's job, and even if it is, it's probably
best to move it to Prometheus somehow. We're relying too much on the
logs.

2 years agoRemove "summary" logging
Alberto Leiva Popper [Tue, 27 Jun 2023 01:04:40 +0000 (19:04 -0600)] 
Remove "summary" logging

The "summary" was a list of failed downloads, and from what I gather,
it was intended to clue the admin of a possible disconnection problem.

Thing is, the implementation was rather bewilderingly large and
obtrusive, and now that we're going to have a Prometheus endpoint,
most likely replaceable by an elegant counter.

And I haven't implemented Prometheus yet, but I would definitely love to
stop running into this invasive code all over the place, thanks.

2 years agoRemove null handling from state_retrieve()
Alberto Leiva Popper [Mon, 26 Jun 2023 22:57:54 +0000 (16:57 -0600)] 
Remove null handling from state_retrieve()

If the function fails, it panics. Therefore, there is no reason to catch
NULL and the subsequent error codes.

Removes clutter.

2 years agoRemove a bunch of uprofessional jargon
Alberto Leiva Popper [Mon, 26 Jun 2023 21:47:30 +0000 (15:47 -0600)] 
Remove a bunch of uprofessional jargon

2 years agoFix multiple evaluation of HASH_ADD_STR argument
Alberto Leiva Popper [Mon, 26 Jun 2023 18:16:24 +0000 (12:16 -0600)] 
Fix multiple evaluation of HASH_ADD_STR argument

This bug was introduced by 330240b2b5de670858a492703f016da21cc374bd.

2 years agoWrap alloc functions, to remove boilerplate
Alberto Leiva Popper [Fri, 23 Jun 2023 22:49:24 +0000 (16:49 -0600)] 
Wrap alloc functions, to remove boilerplate

2 years agoPanic on ENOMEMs
Alberto Leiva Popper [Fri, 23 Jun 2023 15:49:23 +0000 (09:49 -0600)] 
Panic on ENOMEMs

Trying to recover is incorrect because we don't want to advertise an
incomplete or outdated VRP table to the routers. We don't want to rely
on the OOM-killer; we NEED to die on memory allocation failures ASAP.

Though this doesn't have much to do with the RRDP refactor, I'm doing it
early to get plenty of time for testing and review.

Partially F1xes #40. (Still need to update some dependency usages.)

2 years agoUpdate configure.ac
Alberto Leiva Popper [Thu, 22 Jun 2023 20:14:50 +0000 (14:14 -0600)] 
Update configure.ac

Fixes warning:

> warning: AC_OUTPUT should be used without arguments.
> configure.ac:52: You should run autoupdate.

2 years agoMain 94/head 95/head
THEWWWTHING [Sun, 16 Apr 2023 15:40:10 +0000 (17:40 +0200)] 
Main

2 years agoUpdate Dockerfile's documentation
Alberto Leiva Popper [Wed, 8 Feb 2023 01:00:36 +0000 (19:00 -0600)] 
Update Dockerfile's documentation

2 years agoUpdate Dockerfile
Alberto Leiva Popper [Tue, 7 Feb 2023 20:36:07 +0000 (14:36 -0600)] 
Update Dockerfile

2 years agoUpdate the TAL situation
Alberto Leiva Popper [Tue, 7 Feb 2023 17:11:04 +0000 (11:11 -0600)] 
Update the TAL situation

ARIN no longer requires the explicit RPA agreement.

2 years agoProtocolary updates for release 1.5.4 (2nd attempt) 1.5.4
Alberto Leiva Popper [Mon, 6 Feb 2023 19:46:09 +0000 (13:46 -0600)] 
Protocolary updates for release 1.5.4 (2nd attempt)

2 years agoFinal tweaks to #83/#89 (for release 1.5.4)
Alberto Leiva Popper [Mon, 6 Feb 2023 17:57:20 +0000 (11:57 -0600)] 
Final tweaks to #83/#89 (for release 1.5.4)

1. Revert panic back into the code.

- Fort SHOULD die as soon as it realizes the VRP table is corrupted, as
  we should not send garbage to the routers.
- Also, I'm not entirely sure the code would not crash later anyway,
  since the table is, in fact, corrupted.
- Plus, if it doesn't crash, there would be no core dump to further
  analyze the bug.

2. Point bug output to the currently active bug report

Might help us get some output earlier.

2 years agoRemove unnecessary stack traces
Alberto Leiva Popper [Sat, 4 Feb 2023 00:23:41 +0000 (18:23 -0600)] 
Remove unnecessary stack traces

2 years agoUpdate unit tests
Alberto Leiva Popper [Fri, 3 Feb 2023 21:43:23 +0000 (15:43 -0600)] 
Update unit tests

2 years agoBug #83/#89: Print even more data
Alberto Leiva Popper [Fri, 3 Feb 2023 18:44:32 +0000 (12:44 -0600)] 
Bug #83/#89: Print even more data

2 years agoDowngrade the "modulus too long" error to warning.
Alberto Leiva Popper [Fri, 3 Feb 2023 17:56:22 +0000 (11:56 -0600)] 
Downgrade the "modulus too long" error to warning.

Mirrors the new public key code's small forward compatibility gimmic
in the old code.

2 years agoModernize access to modulus length and exponent
Alberto Leiva Popper [Fri, 3 Feb 2023 03:31:28 +0000 (21:31 -0600)] 
Modernize access to modulus length and exponent

Fixes deprecation warning from newer versions of libcrypto.

2 years agoBug #83/#89: Print even more data
Alberto Leiva Popper [Wed, 1 Feb 2023 18:08:20 +0000 (12:08 -0600)] 
Bug #83/#89: Print even more data

2 years agoConvert vrps.table_lock into a mutex
Alberto Leiva Popper [Thu, 2 Feb 2023 00:56:09 +0000 (18:56 -0600)] 
Convert vrps.table_lock into a mutex

There are no readers, so there's no point in this being a reader-writer
lock.

Still not meant to be a fix for #83/#89. I'm mostly just trying to force
myself to interact with the code in hopes of finding the bug.

2 years agoBug #83/#89: Print more data
Alberto Leiva Popper [Wed, 1 Feb 2023 17:50:38 +0000 (11:50 -0600)] 
Bug #83/#89: Print more data

2 years agoAdd const to hashable_roa.data
Alberto Leiva Popper [Tue, 31 Jan 2023 23:58:52 +0000 (17:58 -0600)] 
Add const to hashable_roa.data

Not a fix, but it proves that the protocol never purposefully changes
outside of the ROA's constructors.

So I guess the options are... it's either inadvertently changing,
or the foreach is iterating into unrelated memory.

2 years agoMerge branch 'issue83'
Alberto Leiva Popper [Mon, 30 Jan 2023 21:50:20 +0000 (15:50 -0600)] 
Merge branch 'issue83'

I was hesitant to put this on main because it seemed like a performance
tank, but truth be told, I'm being a wuss. these table iterations are
nothing compared to the amount of time Fort has to spend downloading.

And it looks like I'm never going to find this bug with the stack trace
alone.

Does not fix #83 nor #89, but prevents the crash at least.