Commit Graph

46 Commits

Author SHA1 Message Date
ea131e4bc1
update 2024-04-29 11:02:40 -05:00
c9f1da7027
Update arch libs 2023-11-17 15:09:00 -05:00
d2e3b83a9f
update maintainers keys 2023-09-03 12:54:49 -05:00
David Runge
3365f8607c
feat: Replace sq-keyring-linter with sq >= 0.31.0 2023-07-09 15:56:34 +02:00
David Runge
f3d2c171e7
fix: Adapt to changes in sequoia-sq 0.31.0.
With sequoia-sq 0.31.0 the `--export` parameter for `sq key generate`
has been replaced by the generalized `--output`.
2023-07-09 15:56:12 +02:00
David Runge
ddc037fa33
Simplify trust_color() using match statement 2023-05-29 13:32:50 +02:00
David Runge
f6d2b35318
Fix issue with Trust Enum values
As `auto()` was not used for `Trust.unknown` it led to wrong data being
returned from `trust_color()`.
2023-05-29 13:18:51 +02:00
Levente Polyak
099df52a04
feature(keyringctl): support query expressions for packet field selection
Instead of simply string matching a line, we now traverse the packet as
a tree and match the path based on a depth first search.

While traversing, we support logical OR and current depth * wildcard
processed as a component based query expression.

Callee's are adjusted to specifically select the appropriate Issuer at
the correct depth.

Fixes #185
2022-07-20 21:34:37 +02:00
Levente Polyak
db84e8208d
fix(util): support shells passing subshell fd as /dev/fd
This adds support orthogonal to shells that pass subshell fd as
/proc/self/fd.
2022-05-11 20:28:23 +02:00
David Runge
29dc5d228d
Import Iterable and Iterator depending on Python version
libkeyringctl/{keyring,sequoia,util}.py:
As Iterable and Iterator are only used for type hints, switch to using
typing.{Iterable,Iterator} instead of
collections.abc.{Iterable,Iterator} for Python < 3.9.0, as older Python
interpreters will otherwise raise TypeError.
2022-04-14 16:59:22 +02:00
Levente Polyak
f908838822
fix(trust): do not count revoked main keys for packager trust
If a main key is revoked we do not want to use those keys to count
the required trust threshold.
2022-02-25 21:36:35 +01:00
Levente Polyak
37ad62d6e5
feature(keyringctl): add clean functionality to match import-clean
De-duplicate not needed certifications by cleaning the keyring after
import to remove old files when processing revocations. This basically
adds the functionality compared to import-clean.
2021-12-08 20:50:45 +01:00
Levente Polyak
d0ea790c6a
fix(make): use proper dependency tracking for the build output
Declare the whole keyring data as well as the code as input dependency
for the build target. This way we can properly depend on the build
target for installation without forcing rebuilding on every invocation.

A rebuild will be triggered if either the keyring or the source code
creating the build output changes.

The directories are added to the source dependencies on purpose to
guarantee that changes like deleted files will result in a rebuild.

The mtime of the build directory is force updated on every run to allow
make to track the output artifacts mtime compared against the
dependencies.
2021-11-30 22:54:17 +01:00
Levente Polyak
0ceb6c743e
fix(keyringctl): avoid simplified uid collisions using a hash
Add a postfix hash of the raw uid data to the filenames to avoid
collisions with the simplified uid.
2021-11-30 22:54:17 +01:00
Levente Polyak
4821087b2b
feature(keyringctl): mark main keys bold during inspect highlight 2021-11-30 22:54:17 +01:00
Levente Polyak
b32c37bec1
feature(keyringctl): raise exception on duplicate uid data 2021-11-30 22:54:17 +01:00
Levente Polyak
b653edfcdc
feature(keyringctl): add trust and colors to inspect output 2021-11-30 22:54:17 +01:00
Levente Polyak
c651bdc61e
feature(keyringctl): add option to filter listing by trust 2021-11-30 22:54:17 +01:00
Levente Polyak
e9dc04df32
feature(keyringctl): split direct key packets into own directory 2021-11-30 22:54:16 +01:00
David Runge
e43a28f4a7
Simplify libkeyringctl.keyring.convert_certificate
libkeyringctl/keyring.py:
Simplify `convert_certificate()` by splitting out the conversion of
signature packets to `convert_signature_packet()` and the persistence of
packet material to `persist_key_material()`.
Add `convert_pubkey_signature_packet()`,
`convert_uid_signature_packet()` and
`convert_subkey_signature_packet()` to deal with the conversion of
public key signatures, UID signatures and subkey signatures
(respectively).

tests/test_keyring.py:
Add tests for `convert_certificate()`, `convert_signature_packet()`,
`convert_{pubkey,uid,subkey}_signature_packet()` and
`persist_subkey_revocations()`.
2021-11-30 22:54:16 +01:00
David Runge
743d2bb3bb
Add tests for introspection and export
libkeyringctl/keyring.py:
Change `get_packets_from_path()` to use full conditional statements
which is easier to cover in tests.

tests/test_keyring.py:
Add simple tests for `get_packets_from_path()`,
`get_packets_from_listing()`, `export()` and `build()`.
2021-11-30 22:54:16 +01:00
Levente Polyak
8689995b69
feature(keyringctl): yell and abort if processing private key data 2021-11-30 22:54:16 +01:00
Levente Polyak
5a83a7b6c1
feature(keyringctl): skip user attribute packets as none relevant 2021-11-30 22:54:16 +01:00
Levente Polyak
e8fb9d17b3
chore(keyringctl): add test for simplify_ascii 2021-11-30 22:54:16 +01:00
Levente Polyak
83a345a1b8
feature(keyringctl): rework ci module to execute full lint for new certs 2021-11-30 22:54:16 +01:00
Levente Polyak
bce5bc550e
feature(keyringctl): rework str simplification for printable uids 2021-11-30 22:54:16 +01:00
Levente Polyak
2030de06a0
fix(keyringctl): set HOME, PATH, LANG required for hokey
This effectively requires en_US.UTF-8 to be an available lang, which is
a relative fair requirement and mandatory to set for hokey.
2021-11-30 22:54:15 +01:00
Levente Polyak
f74a1be1ac
chore(keyringctl): add integrity checks for binding/revocation sigs 2021-11-30 22:54:15 +01:00
Levente Polyak
9741ada9ef
fix(keyringctl): put subkey revocations into the correct subkey dirs 2021-11-30 22:54:15 +01:00
Levente Polyak
5f36beff90
feature(ci): run keyring integrity check if keyring or code changes 2021-11-30 22:54:15 +01:00
Levente Polyak
e55042e45b
feature(keyringctl): verify file structure integrity and packets
This moves all verify code to an own module and adds support to check
all packet files in the structure for integrity. This is done by parsing
assumptions like packet kind, type, issuer and location etc.
2021-11-30 22:54:15 +01:00
Levente Polyak
d9e9453d84
feature(keyringctl): write all packet files with full issuer fingerprint
This avoids collision between same issuer using key-id and full
fingerprint in different versions of a packet, like signature.
2021-11-30 22:54:15 +01:00
Levente Polyak
279765b22a
fix(keyringctl): fix system stderr case due to wrongly written test
CalledProcessError returns bytes for our invocations, the fix that
decoded bytes of stdout was purely to make the mocked test happy while
breaking the actual usage. Restore the behavior and fix the wrong mocked
data.
2021-11-30 22:54:14 +01:00
Levente Polyak
cd585f4be2
chore(keyringctl): increase test coverage and fix trust expectations 2021-11-30 22:54:14 +01:00
Levente Polyak
86eb172ac3
chore(keyringctl): add missing type annotations for tests 2021-11-30 22:54:14 +01:00
David Runge
a21e6f21fb
Write bytes to stderr when raising during system call
libkeyringctl/util.py:
Change `system()` to write bytes to stderr.buffer, as before
CalledProcessError.stdout had been used, which returns a string.
2021-11-30 22:54:13 +01:00
Levente Polyak
0ca74e243b
feature(keyringctl): adding basic infrastructure for running tests 2021-11-30 22:54:13 +01:00
Levente Polyak
8ba7dc1dc9
feature(keyringctl): acquire trust status from key assumptions
Rework the whole trust handling by acquiring the trust status from
actual assumptions related to the amount of ownertrust signatures and
revocations.
2021-11-30 22:54:13 +01:00
Levente Polyak
26c7027660
feature(keyringctl): support importing from a piped fd
This feature allows to import from a piped fd like:
> ./keyringctl import --name foobar <(gpg --export foo@bar)

We achieve this even with hidepid by taking the naive approach of
copying the processes fd source to a tempfile and pass around latter.
2021-11-30 22:54:13 +01:00
Levente Polyak
2384d0337b
fix(keyringctl): resolve cert dir per fingerprint and not parent user 2021-11-30 22:54:13 +01:00
Levente Polyak
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
Levente Polyak
878752dc13
fix(keyringctl): avoid leaking unclosed file descriptors 2021-11-30 22:54:13 +01:00
Levente Polyak
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
Levente Polyak
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
Levente Polyak
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
Levente Polyak
58307c629d
chore(keyringctl): modularize the code for overview and testing 2021-11-30 22:54:12 +01:00