Debian Codegraph @

src/cli/cert/lint.rs

raw
1 //! Command-line parser for `sq cert lint`.
2
3 use clap::Args;
4
5 use crate::cli::examples::*;
6 use crate::cli::types::ClapData;
7 use crate::cli::types::FileOrStdout;
8 use crate::cli::types::cert_designator::*;
9
10 /// Checks for and optionally repairs OpenPGP certificates that use
11 /// SHA-1.
12 #[derive(Debug, Args)]
13 #[clap(
14 about = "Check certificates for issues",
15 long_about = "Check certificates for issues
16
17 `sq cert lint` checks the supplied certificates for the following \
18 SHA-1-related issues:
19
20 - Whether a certificate revocation uses SHA-1.
21
22 - Whether the current self signature for a non-revoked User ID uses \
23 SHA-1.
24
25 - Whether the current subkey binding signature for a non-revoked, \
26 live subkey uses SHA-1.
27
28 - Whether a primary key binding signature (\"backsig\") for a \
29 non-revoked, live subkey uses SHA-1.
30
31 Diagnostics are printed to stderr. At the end, some statistics are \
32 shown. This is useful when examining a keyring. If `--fix` is \
33 specified and at least one issue could be fixed, the fixed \
34 certificates are printed to stdout.
35
36 This tool does not currently support smart cards. But, if only the \
37 subkeys are on a smart card, this tool may still be able to partially \
38 repair the certificate. In particular, it will be able to fix any \
39 issues with User ID self signatures and subkey binding signatures for \
40 encryption-capable subkeys, but it will not be able to generate new \
41 primary key binding signatures for any signing-capable subkeys.
42 ",
43 after_help = EXAMPLES,
44 )]
45 pub struct Command {
46 /// Attempts to fix certificates, when possible.
47 #[arg(long)]
48 pub fix: bool,
49
50 #[command(flatten)]
51 pub certs: CertDesignators<FileCertUserIDEmailDomainGrepArgs,
52 CertPrefix,
53 OptionalValue>,
54
55 #[clap(
56 long,
57 value_name = FileOrStdout::VALUE_NAME,
58 help = "Write to the specified FILE",
59 long_help = "Write to the specified FILE
60
61 If not specified, and the \
62 certificate was read from the certificate store, imports the \
63 modified certificate into the cert store. If not specified, \
64 and the certificate was read from a file, writes the modified \
65 certificate to stdout.",
66 )]
67 pub output: Option<FileOrStdout>,
68 }
69
70 const EXAMPLES: Actions = Actions {
71 actions: &[
72 Action::setup().command(&[
73 "sq", "keyring", "merge",
74 "--output=certs.pgp",
75 "bob.pgp", "romeo.pgp",
76 ]).build(),
77
78 Action::setup().command(&[
79 "sq", "key", "import", "alice-secret.pgp",
80 ]).build(),
81
82 Action::example().comment(
83 " Gather statistics on the certificates in a keyring."
84 ).command (&[
85 "sq", "cert", "lint",
86 "--cert-file", "certs.pgp",
87 ]).build(),
88
89 Action::example().comment(
90 "Fix a key with known problems."
91 ).command (&[
92 "sq", "key", "export",
93 "--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
94 "|", "sq", "cert", "lint", "--fix", "--cert-file=-",
95 "|", "sq", "cert", "import"
96 ]).build(),
97 ],
98 };
99 test_examples!(sq_cert_lint, EXAMPLES);