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.
This commit is contained in:
@ -11,6 +11,7 @@ from typing import List
|
||||
from typing import Optional
|
||||
|
||||
from .types import Fingerprint
|
||||
from .types import PacketKind
|
||||
from .types import Uid
|
||||
from .types import Username
|
||||
from .util import cwd
|
||||
@ -208,6 +209,26 @@ def packet_signature_creation_time(packet: Path) -> datetime:
|
||||
return datetime.strptime(packet_dump_field(packet, "Signature creation time"), "%Y-%m-%d %H:%M:%S %Z")
|
||||
|
||||
|
||||
def packet_kinds(packet: Path) -> List[PacketKind]:
|
||||
"""Retrieve the PGP packet types of a packet path
|
||||
|
||||
Parameters
|
||||
----------
|
||||
packet: The path to the PGP packet to retrieve the kind of
|
||||
|
||||
Returns
|
||||
-------
|
||||
The kind of PGP packet
|
||||
"""
|
||||
|
||||
dump = packet_dump(packet)
|
||||
lines = [line for line in dump.splitlines()]
|
||||
lines = list(
|
||||
filter(lambda line: not line.startswith(" ") and not line.startswith("WARNING") and line.strip(), lines)
|
||||
)
|
||||
return [PacketKind(line.split()[0]) for line in lines]
|
||||
|
||||
|
||||
def latest_certification(certifications: Iterable[Path]) -> Path:
|
||||
"""Returns the latest certification based on the signature creation time from a list of packets.
|
||||
|
||||
|
Reference in New Issue
Block a user