Compare commits
No commits in common. "main" and "v0.0.2" have entirely different histories.
2 changed files with 39 additions and 88 deletions
3
setup.py
3
setup.py
|
@ -10,7 +10,7 @@ setup(
|
|||
#long_description_content_type="text/markdown",
|
||||
install_requires=["requests>=2.20.0,<3.0", "PyYAML", "tabulate"],
|
||||
keywords=["step-ca-inspector"],
|
||||
version="0.0.4",
|
||||
version="0.0.2",
|
||||
classifiers=[
|
||||
"Intended Audience :: Developers",
|
||||
"Development Status :: 3 - Alpha",
|
||||
|
@ -19,7 +19,6 @@ setup(
|
|||
entry_points={
|
||||
"console_scripts": [
|
||||
"step-ca-inspector = step_ca_inspector_client.cli:main",
|
||||
"step-inspector-plugin = step_ca_inspector_client.cli:main",
|
||||
],
|
||||
},
|
||||
)
|
||||
|
|
|
@ -9,31 +9,9 @@ from step_ca_inspector_client.config import config
|
|||
|
||||
config()
|
||||
|
||||
CERT_STATUS = ["Valid", "Expired", "Revoked"]
|
||||
PROVISIONER_TYPES = [
|
||||
"ACME",
|
||||
"AWS",
|
||||
"GCP",
|
||||
"JWK",
|
||||
"Nebula",
|
||||
"OIDC",
|
||||
"SCEP",
|
||||
"SSHPOP",
|
||||
"X5C",
|
||||
"K8sSA",
|
||||
]
|
||||
SSH_CERT_TYPES = ["Host", "User"]
|
||||
|
||||
|
||||
def case_insensitive_choice(choices):
|
||||
def find_choice(choice):
|
||||
for key, item in enumerate([choice.lower() for choice in choices]):
|
||||
if choice.lower() == item:
|
||||
return choices[key]
|
||||
else:
|
||||
return choice
|
||||
return find_choice
|
||||
|
||||
def delta_text(delta):
|
||||
s = "s"[: abs(delta.days) ^ 1]
|
||||
|
||||
|
@ -62,14 +40,16 @@ def fetch_api(endpoint, params={}):
|
|||
|
||||
def list_ssh_certs(
|
||||
sort_key,
|
||||
cert_status=["Valid"],
|
||||
revoked=False,
|
||||
expired=False,
|
||||
cert_type=SSH_CERT_TYPES,
|
||||
key=None,
|
||||
principal=None,
|
||||
):
|
||||
params = {
|
||||
"sort_key": sort_key,
|
||||
"cert_status": cert_status,
|
||||
"revoked": revoked,
|
||||
"expired": expired,
|
||||
"cert_type": cert_type,
|
||||
"key": key,
|
||||
"principal": principal,
|
||||
|
@ -172,21 +152,11 @@ def dump_ssh_cert(serial):
|
|||
print(cert["public_identity"])
|
||||
|
||||
|
||||
def list_x509_certs(
|
||||
sort_key,
|
||||
cert_status=["Valid"],
|
||||
provisioner_type=None,
|
||||
provisioner_name=None,
|
||||
subject=None,
|
||||
san=None,
|
||||
):
|
||||
def list_x509_certs(sort_key, revoked=False, expired=False):
|
||||
params = {
|
||||
"sort_key": sort_key,
|
||||
"cert_status": cert_status,
|
||||
"provisioner_type": provisioner_type,
|
||||
"provisioner": provisioner_name,
|
||||
"subject": subject,
|
||||
"san": san,
|
||||
"revoked": revoked,
|
||||
"expired": expired,
|
||||
}
|
||||
cert_list = fetch_api(f"x509/certs", params=params)
|
||||
cert_tbl = []
|
||||
|
@ -318,12 +288,18 @@ def main():
|
|||
)
|
||||
x509_list_parser = x509_subparsers.add_parser("list", help="List x509 certificates")
|
||||
x509_list_parser.add_argument(
|
||||
"--status",
|
||||
type=case_insensitive_choice(CERT_STATUS),
|
||||
choices=CERT_STATUS,
|
||||
default=["Valid"],
|
||||
nargs="+",
|
||||
help="Filter by x509 certificate status (default: Valid)",
|
||||
"--show-expired",
|
||||
"-e",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Show expired certificates",
|
||||
)
|
||||
x509_list_parser.add_argument(
|
||||
"--show-revoked",
|
||||
"-r",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Show revoked certificates",
|
||||
)
|
||||
x509_list_parser.add_argument(
|
||||
"--sort-by",
|
||||
|
@ -333,34 +309,6 @@ def main():
|
|||
default="not_after",
|
||||
help="Sort certificates",
|
||||
)
|
||||
x509_list_parser.add_argument(
|
||||
"--provisioner-type",
|
||||
"-t",
|
||||
type=case_insensitive_choice(PROVISIONER_TYPES),
|
||||
choices=PROVISIONER_TYPES,
|
||||
default=None,
|
||||
nargs="+",
|
||||
help="Filter by provisioner type",
|
||||
)
|
||||
x509_list_parser.add_argument(
|
||||
"--provisioner-name",
|
||||
"-p",
|
||||
type=str,
|
||||
default=None,
|
||||
help="Filter by provisioner name",
|
||||
)
|
||||
x509_list_parser.add_argument(
|
||||
"--subject",
|
||||
type=str,
|
||||
default=None,
|
||||
help="Search for subject",
|
||||
)
|
||||
x509_list_parser.add_argument(
|
||||
"--san",
|
||||
type=str,
|
||||
default=None,
|
||||
help="Search for Subject Alt Name",
|
||||
)
|
||||
x509_details_parser = x509_subparsers.add_parser(
|
||||
"details", help="Show an x509 certificate details"
|
||||
)
|
||||
|
@ -401,12 +349,18 @@ def main():
|
|||
)
|
||||
ssh_list_parser = ssh_subparsers.add_parser("list", help="List ssh certificates")
|
||||
ssh_list_parser.add_argument(
|
||||
"--status",
|
||||
type=case_insensitive_choice(CERT_STATUS),
|
||||
choices=CERT_STATUS,
|
||||
default=["Valid"],
|
||||
nargs="+",
|
||||
help="Filter by SSH certificate status (default: Valid)",
|
||||
"--show-expired",
|
||||
"-e",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Show expired certificates",
|
||||
)
|
||||
ssh_list_parser.add_argument(
|
||||
"--show-revoked",
|
||||
"-r",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Show revoked certificates",
|
||||
)
|
||||
ssh_list_parser.add_argument(
|
||||
"--sort-by",
|
||||
|
@ -419,14 +373,14 @@ def main():
|
|||
ssh_list_parser.add_argument(
|
||||
"--type",
|
||||
"-t",
|
||||
type=case_insensitive_choice(SSH_CERT_TYPES),
|
||||
type=str,
|
||||
choices=SSH_CERT_TYPES,
|
||||
default=SSH_CERT_TYPES,
|
||||
nargs="+",
|
||||
help="Filter by SSH certificate type",
|
||||
)
|
||||
ssh_list_parser.add_argument(
|
||||
"--key-id",
|
||||
"--key",
|
||||
"-k",
|
||||
type=str,
|
||||
default=None,
|
||||
|
@ -454,12 +408,9 @@ def main():
|
|||
if args.object == "x509":
|
||||
if args.action == "list":
|
||||
list_x509_certs(
|
||||
cert_status=args.status,
|
||||
revoked=args.show_revoked,
|
||||
expired=args.show_expired,
|
||||
sort_key=args.sort_by,
|
||||
provisioner_type=args.provisioner_type,
|
||||
provisioner_name=args.provisioner_name,
|
||||
subject=args.subject,
|
||||
san=args.san,
|
||||
)
|
||||
elif args.action == "details":
|
||||
get_x509_cert(
|
||||
|
@ -472,10 +423,11 @@ def main():
|
|||
elif args.object == "ssh":
|
||||
if args.action == "list":
|
||||
list_ssh_certs(
|
||||
cert_status=args.status,
|
||||
revoked=args.show_revoked,
|
||||
expired=args.show_expired,
|
||||
sort_key=args.sort_by,
|
||||
cert_type=args.type,
|
||||
key=args.key_id,
|
||||
key=args.key,
|
||||
principal=args.principal,
|
||||
)
|
||||
elif args.action == "details":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue