Commit Graph

406 Commits

Author SHA1 Message Date
2384d0337b fix(keyringctl): resolve cert dir per fingerprint and not parent user 2021-11-30 22:54:13 +01:00
03d5899f87 fix(keyring): use a single applied revocation to declare a key revoked
Otherwise the PGP trust and revocation status file will not match our
expectations. A single applied revocation to this directory structure
should be checked either way.

We can later create TODO's to have at least two revocations for the keys
that would otherwise be still trusted and then change this value.
2021-11-30 22:54:13 +01:00
878752dc13 fix(keyringctl): avoid leaking unclosed file descriptors 2021-11-30 22:54:13 +01:00
10d54ac35d feature(make): adding fmt target to format the project accordingly 2021-11-30 22:54:12 +01:00
a9e63edfa8 feature(keyringctl): adding ci command to verify newly added certs
Currently only newly added certificates will be checked against the
expectations as existing keys are not all fully compatible with those
assumptions.  New certificates are determined by using
$CI_MERGE_REQUEST_DIFF_BASE_SHA as the base,
2021-11-30 22:54:12 +01:00
9733fbafd8 feature(keyringctl): add verify command to check certificate expectation
This command checks certain expectations using sq and hokey, prints the
results to stdout and potentially exists non successfully.
2021-11-30 22:54:12 +01:00
94c3b4c8e9 fix(keyrinctl): yield file not found errors instead of blocking on stdin
Handle missing or wrong certificate paths in a way that does not lead to
a blocking command by reading from stdin. Instead throw either file not
found errors or expect optional outputs.
2021-11-30 22:54:12 +01:00
58307c629d chore(keyringctl): modularize the code for overview and testing 2021-11-30 22:54:12 +01:00
f90e860d16 fix(keyringctl): prioritize latest certification per issuer
When importing a non reduced keyring the certifications were not
deterministic for keys that have multiple certifications per issuer.
This was for example the case for self certifications to extend the
expiry time. Before this commit a random certification could remain the
final one which would lead to a non up to date keyring and a potentially
expired key.
2021-11-30 22:54:12 +01:00
32469720f8 fix(keyringctl): deterministic assembling order with single packet files
Fix the assembling of a certificate by joining the packets in the
correct order and splitting combined files into individual single
packets per file.
2021-11-30 22:54:12 +01:00
4b136dd6f6 feature(keyringctl): enrich inspect to show explicit label for main keys
This helps to identify if a certification issuer comes from a main key
or not.
2021-11-30 22:54:12 +01:00
b6c25fa531 chore(keyringctl): de-duplicate username/fprint transform code
We duplicated resolving usernames and fingerprints to actual keyring
paths in multiple places. De-duplicate the code by using dedicated
functions to do this job.
2021-11-30 22:54:12 +01:00
cced93480c fix(keyringctl): avoid walking non existing paths to resolve certs 2021-11-30 22:54:12 +01:00
02605edee5 feature(keyringctl): sort list command for alphabetical listing
Only do so when listing all keys, when a filter is provided, like
usernames or fingerprints, keep the order to allow a 1:1 mapping.
2021-11-30 22:54:12 +01:00
f3f3a63385 feature(keyringctl): avoid storing pubkey and uids in certifications
We do not need to duplicates packages in certifications and revocations.
Store the packets separated from their parent as those are already
persisted.
2021-11-30 22:54:12 +01:00
5249453726 feature(keyringctl): support passing fingerprint as source
This helps make the CLI more useful by listing, exporting or inspecting
a specific fingerprint.
2021-11-30 22:54:11 +01:00
6d336828e1 chore(keyringctl): remove docstring types as the signatures cover them
All modern tooling already reads type hinting from the signatures
instead of the docstring and supports annotating the parameter
accordingly. Remove the duplicated data to avoid out of sync
documentation.
2021-11-30 22:54:11 +01:00
619f2a3b68 chore(keyringctl): simplify convert usage by moving fingerprint filter 2021-11-30 22:54:11 +01:00
fc9ad848ab chore(keyringctl): simplify trust functions and return trusted/revoked
The API makes more sense to return (trusted,revoked) as the caller can
simply derive all certificates by joining the two sets.

To simplify the functions, some code has been replaced to use helper
methods to flatten the nested loops.
2021-11-30 22:54:11 +01:00
e0abfd195c feature(keyringctl): collect usernames to fingerprints to enrich output
By collecting the matching usernames to all fingerprints we are able to
enrich the output of `inspect` to show the usernames next to the
certifications.
2021-11-30 22:54:11 +01:00
2d1eb93a39 chore(keyringctl): move cert depth first search to own function
This way we can reuse the functionality which will allow to simplify a
lot of places that have multiple layers of inflexible nested loops.
2021-11-30 22:54:11 +01:00
3776ca942c fix(keyringctl): preserve keyring split filenames in separated dirs
This aids initial imports of keyrings that contain multiple certificates
by allowing keyring_split to enforce preserving the filenames. This is
achieved by moving each split keyring into unique sub directories where
the original input filename remains unique.
2021-11-30 22:54:11 +01:00
090d63ae20 fix(keyringctl): force overwrite packets when persisting
When we import new packet data, always allow overwrites of the final
packet files. This may happen when importing from multiple files that
provide the same packets, which is fine as they should still yield to
the same results.
2021-11-30 22:54:11 +01:00
82254e0a36 feature(keyringctl): add inspect command to pretty print certificates
This command prints a new and pretty representation of the certificate
data to visualize the keyring and its signatures.
2021-11-30 22:54:11 +01:00
0168ce1db0 feature(keyringctl): add simple command to list all certificates 2021-11-30 22:54:11 +01:00
1a8ea8397d chore(keyringctl): throw exception instead of exit on failed system calls 2021-11-30 22:54:11 +01:00
f6e3a4e94b feature(keyringctl): use build command to create final artifacts
This allows an easy to use cli which invokes the export function to get
the keyring and uses the ownertrust and revoke functions to write all
artifacts into a target directory.
2021-11-30 22:54:10 +01:00
77e5b36872 feature(keyringctl): add force parameter to keyring_merge 2021-11-30 22:54:10 +01:00
86747ecab7 feature(keyringctl): use the export command purely to export keyrings
This gives more control over the export command that may be useful to
export a single packager to import it into gpg. This will also give more
flexibility to chain this function to the future verify stage.

By default the command exports the whole keyring directory.
2021-11-30 22:54:10 +01:00
aa2f2ea497 feature(keyringctl): add dedicated keyring_merge function 2021-11-30 22:54:10 +01:00
cb95b92778 chore(editorconfig): sync line length with flake8 config to 120 chars 2021-11-30 22:54:10 +01:00
52178f38d5 feature(keyringctl): improve packet_join to optionally return the result 2021-11-30 22:54:10 +01:00
deaa312b7d feature(keyringctl): print a stack trace in case a system cmd fails 2021-11-30 22:54:10 +01:00
bc8c51749c chore(doc): improve import usage section exmaples 2021-11-30 22:54:10 +01:00
94b910a55e fix(ci): use unified multi import command 2021-11-30 22:54:10 +01:00
edbbc77086 chore(keyringctl): use python 3.9 iterable/iterator type imports 2021-11-30 22:54:10 +01:00
74f317344f feature(keyringctl): support importing multiple paths
Lets pass in a list of path's and reduce them to one set of path
iterables. This allows us to specify multiple source files/directories
2021-11-30 22:54:10 +01:00
1b1aa7f738 fix(doc): improve splitting topics across README.md and CONTRIBUTING.md 2021-11-30 22:54:09 +01:00
c214022300 fix(keyringctl): restore --target option for convert command 2021-11-30 22:54:09 +01:00
40592b3534 feature(keyringctl): print help if invoked without any subcommand 2021-11-30 22:54:09 +01:00
8bc0ae1da0 feature(keyringctl): unify import subcommand for condensed api
Both commands are basically doing the same with the same params except
the target directory differs. Lets condense this behavior by using a
single subcommand with a boolean options.
2021-11-30 22:54:09 +01:00
2f9ef0ef1d feature(keyringctl): keep filename if keyring split yields one keyring
Instead of always returning an artificial name try to preserve the
keyring filename if the split only yields a single certificate.
2021-11-30 22:54:09 +01:00
b91e8b983c feature(keyringctl): move main/packager folders to isolated keyring dir
This helps to structure the layout of the repository better by having
one root folder that contains the actual decomposed keyring structure.
2021-11-30 22:54:09 +01:00
48e9bb67cb chore(keyringctl): use singular for packager directory as well
So far we have used singular for all directories, lets keep that for the
packager directory as well.
2021-11-30 22:54:09 +01:00
37d0a5f633 chore(keyringctl): apply black formatter 2021-11-30 22:54:09 +01:00
930b5896a0 feature(keyringctl): introduce Username type instead of plain str 2021-11-30 22:54:09 +01:00
e422149c8a feature(keyringctl): add type hinting direct sigs/revocations 2021-11-30 22:54:09 +01:00
147287959f feature(keyringctl): derive username from short key id fingerprints
Allow short key id fingerprints to be used with the username derive
function by adding a glob in front of the fingerprint component.
2021-11-30 22:54:09 +01:00
60ee3d6d94 feature(keyringctl): avoid splitting a certificate multiple times
Move the name cascade to derive the username into the
`convert_certificate` function which allows to use the
certificate_fingerprint directly instead of trying to find it by
splitting the certificate one more time before converting.
2021-11-30 22:54:09 +01:00
cf6bac5fd9 chore(keyringctl): fix typo in docstring for convert_certificate 2021-11-30 22:54:08 +01:00