From 8f87de0510b7eef04c1ee53d79f1cdedb3244703 Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Mon, 30 Sep 2024 10:43:39 -0700 Subject: [PATCH 1/2] Fix reissue by serial number issues --- lemur/certificates/cli.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lemur/certificates/cli.py b/lemur/certificates/cli.py index e672b0b03..d7721ec14 100644 --- a/lemur/certificates/cli.py +++ b/lemur/certificates/cli.py @@ -11,6 +11,7 @@ import arrow import click from flask import current_app +from flask.cli import with_appcontext from flask_principal import Identity, identity_changed from sentry_sdk import capture_exception from sqlalchemy import or_ @@ -547,6 +548,7 @@ def rotate_region(endpoint_name, new_certificate_name, old_certificate_name, mes @cli.command("reissue") +@with_appcontext @click.option( "-o", "--old-certificate", @@ -577,7 +579,7 @@ def rotate_region(endpoint_name, new_certificate_name, old_certificate_name, mes help="Persist changes.", ) def reissue_command(old_certificate_name, serial_numbers, notify, commit): - reissue(old_certificate_name, serial_numbers, notify, commit) + reissue(old_certificate_name, notify, commit, serial_numbers) def reissue(old_certificate_name, notify, commit, serial_numbers): From 53281e117b3194d83be83468d7775f2ae4ca7512 Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Mon, 30 Sep 2024 11:09:49 -0700 Subject: [PATCH 2/2] Correct all cli groups --- lemur/acme_providers/cli.py | 8 +++++--- lemur/certificates/cli.py | 2 +- lemur/dns_providers/cli.py | 6 ++++-- lemur/notifications/cli.py | 5 +++-- lemur/pending_certificates/cli.py | 4 +++- lemur/policies/cli.py | 2 ++ lemur/reporting/cli.py | 3 ++- lemur/sources/cli.py | 14 +++++++------- 8 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lemur/acme_providers/cli.py b/lemur/acme_providers/cli.py index 0951c419a..d0a6c06bc 100644 --- a/lemur/acme_providers/cli.py +++ b/lemur/acme_providers/cli.py @@ -1,11 +1,12 @@ -import time import json +import time + import arrow import click - from flask import current_app - +from flask.cli import with_appcontext from sentry_sdk import capture_exception + from lemur.common.utils import check_validation from lemur.constants import SUCCESS_METRIC_STATUS from lemur.plugins import plugins @@ -14,6 +15,7 @@ @click.group(name="acme", help="Handles all ACME related tasks") +@with_appcontext def cli(): pass diff --git a/lemur/certificates/cli.py b/lemur/certificates/cli.py index d7721ec14..b1dcd131d 100644 --- a/lemur/certificates/cli.py +++ b/lemur/certificates/cli.py @@ -51,6 +51,7 @@ @click.group(name="certificates", help="Handles all certificate related tasks.") +@with_appcontext def cli(): pass @@ -548,7 +549,6 @@ def rotate_region(endpoint_name, new_certificate_name, old_certificate_name, mes @cli.command("reissue") -@with_appcontext @click.option( "-o", "--old-certificate", diff --git a/lemur/dns_providers/cli.py b/lemur/dns_providers/cli.py index 6b4165e39..f6fd4c59b 100644 --- a/lemur/dns_providers/cli.py +++ b/lemur/dns_providers/cli.py @@ -1,15 +1,17 @@ import sys -import click +import click +from flask.cli import with_appcontext from sentry_sdk import capture_exception from lemur.constants import SUCCESS_METRIC_STATUS -from lemur.plugins.lemur_acme.acme_handlers import AcmeDnsHandler from lemur.dns_providers.service import get_all_dns_providers, set_domains from lemur.extensions import metrics +from lemur.plugins.lemur_acme.acme_handlers import AcmeDnsHandler @click.group(name="dns_providers", help="Iterates through all DNS providers and sets DNS zones in the database.") +@with_appcontext def cli(): pass diff --git a/lemur/notifications/cli.py b/lemur/notifications/cli.py index ea2e6b4c0..14e38010b 100644 --- a/lemur/notifications/cli.py +++ b/lemur/notifications/cli.py @@ -6,20 +6,21 @@ .. moduleauthor:: Kevin Glisson """ import click - from flask import current_app +from flask.cli import with_appcontext from sentry_sdk import capture_exception from lemur.certificates.service import get_expiring_deployed_certificates from lemur.constants import SUCCESS_METRIC_STATUS, FAILURE_METRIC_STATUS from lemur.extensions import metrics +from lemur.notifications.messaging import send_authority_expiration_notifications from lemur.notifications.messaging import send_expiration_notifications, \ send_expiring_deployed_certificate_notifications -from lemur.notifications.messaging import send_authority_expiration_notifications from lemur.notifications.messaging import send_security_expiration_summary @click.group(name="notify", help="Handles notification related tasks.") +@with_appcontext def cli(): pass diff --git a/lemur/pending_certificates/cli.py b/lemur/pending_certificates/cli.py index ac70b6b6d..118cbeaff 100644 --- a/lemur/pending_certificates/cli.py +++ b/lemur/pending_certificates/cli.py @@ -5,11 +5,12 @@ .. moduleauthor:: Curtis Castrapel """ -import click import copy import sys +import click from flask import current_app +from flask.cli import with_appcontext from lemur.authorities.service import get as get_authority from lemur.constants import ACME_ADDITIONAL_ATTEMPTS @@ -19,6 +20,7 @@ @click.group(name="pending_certs", help="Handles pending certificate related tasks.") +@with_appcontext def cli(): pass diff --git a/lemur/policies/cli.py b/lemur/policies/cli.py index 06e142d10..7979b45a8 100644 --- a/lemur/policies/cli.py +++ b/lemur/policies/cli.py @@ -6,11 +6,13 @@ .. moduleauthor:: Kevin Glisson """ import click +from flask.cli import with_appcontext from lemur.policies import service as policy_service @click.group(name="policy", help="Handles all policy related tasks.") +@with_appcontext def cli(): pass diff --git a/lemur/reporting/cli.py b/lemur/reporting/cli.py index 38e3ce5fa..a6db67cac 100644 --- a/lemur/reporting/cli.py +++ b/lemur/reporting/cli.py @@ -6,13 +6,14 @@ .. moduleauthor:: Kevin Glisson """ import click - +from flask.cli import with_appcontext from tabulate import tabulate from lemur.reporting.service import fqdns, expiring_certificates @click.group(name="report", help="Reporting related tasks.") +@with_appcontext def cli(): pass diff --git a/lemur/sources/cli.py b/lemur/sources/cli.py index 3ea1b9431..8af8ee2e9 100644 --- a/lemur/sources/cli.py +++ b/lemur/sources/cli.py @@ -5,28 +5,28 @@ :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson """ -from copy import deepcopy -import click import sys import time +from copy import deepcopy -from tabulate import tabulate +import click from flask import current_app +from flask.cli import with_appcontext from sentry_sdk import capture_exception +from tabulate import tabulate +from lemur.certificates import service as certificate_service from lemur.constants import SUCCESS_METRIC_STATUS, FAILURE_METRIC_STATUS - +from lemur.destinations import service as dest_service from lemur.extensions import metrics from lemur.plugins.base import plugins from lemur.plugins.utils import get_plugin_option, set_plugin_option - -from lemur.destinations import service as dest_service from lemur.sources import service as source_service from lemur.users import service as user_service -from lemur.certificates import service as certificate_service @click.group(name="source", help="Handles all source related tasks.") +@with_appcontext def cli(): pass