From 73634fd1a87636809b7aee35cb9ede40cc0e7c92 Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Tue, 7 Jan 2025 09:11:32 -0300 Subject: [PATCH 1/2] Fix config.toml for release and devel path --- config.toml | 2 +- .../config.toml | 0 data/release/xdg/config.toml | 11 +++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) rename data/development/config/{command_line_assistant => command-line-assistant}/config.toml (100%) diff --git a/config.toml b/config.toml index 34d14ef..bcb6dfc 120000 --- a/config.toml +++ b/config.toml @@ -1 +1 @@ -data/development/config/command_line_assistant/config.toml \ No newline at end of file +data/development/config/command-line-assistant/config.toml \ No newline at end of file diff --git a/data/development/config/command_line_assistant/config.toml b/data/development/config/command-line-assistant/config.toml similarity index 100% rename from data/development/config/command_line_assistant/config.toml rename to data/development/config/command-line-assistant/config.toml diff --git a/data/release/xdg/config.toml b/data/release/xdg/config.toml index 2758322..333849c 100644 --- a/data/release/xdg/config.toml +++ b/data/release/xdg/config.toml @@ -13,5 +13,16 @@ file = "/var/lib/command-line-assistant/history.json" [backend] endpoint = "http://localhost:8080" +[backend.auth] +# cert_file = "/etc/pki/consumer/cert.pem" +# key_file = "/etc/pki/consumer/key.pem" +# verify_ssl = true + + [logging] level = "DEBUG" +responses = true # Global setting - don't log responses by default +question = true # Global setting - don't log questions by default + +# User-specific settings +# users.admin = { responses = true, question = true } From ada52e723bbfebfb690bf4a9b802a2c3662cdf85 Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Tue, 7 Jan 2025 09:23:59 -0300 Subject: [PATCH 2/2] Add audit logging to sys.stdout --- command_line_assistant/logger.py | 16 ++++++++++++++-- pdm.lock | 16 +--------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/command_line_assistant/logger.py b/command_line_assistant/logger.py index 65ab45a..f34a7e0 100644 --- a/command_line_assistant/logger.py +++ b/command_line_assistant/logger.py @@ -33,11 +33,16 @@ "formatter": "audit", "mode": "a", }, + "audit_journald": { + "class": "logging.StreamHandler", + "formatter": "audit", + "stream": "ext://sys.stdout", + }, }, "loggers": { "root": {"handlers": ["console"], "level": "DEBUG"}, "audit": { - "handlers": ["audit_file", "console"], + "handlers": ["audit_file", "audit_journald"], "level": "INFO", "propagate": False, }, @@ -110,6 +115,13 @@ def format(self, record: logging.LogRecord) -> str: def _create_audit_formatter(config: Config) -> AuditFormatter: """Internal method to create a new audit formatter instance. + Note: + This appears to be not used, but the logging class will call this + function to initialize the formatter options for audit logger. + + Do not remove this function, only if there is a better idea on how to + do it. + Args: config (Config): The application configuration @@ -118,7 +130,7 @@ def _create_audit_formatter(config: Config) -> AuditFormatter: """ fmt = '{"timestamp": "%(asctime)s", "user": "%(user)s", "message": "%(message)s"%(query)s%(response)s}' - datefmt = "%Y-%m-%dT%H:%M:%S.%fZ" + datefmt = "%Y-%m-%dT%H:%M:%S" return AuditFormatter(config=config, fmt=fmt, datefmt=datefmt) diff --git a/pdm.lock b/pdm.lock index 0cd114e..2d72997 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:d314b2d22c5ff42fb0d68d7cac161bc8514119924c90fde6b0648a819278db6a" +content_hash = "sha256:a6e6c281ff5554109c71f24bb23cbd2000b41d87de93ca95c765dda9efdbb669" [[metadata.targets]] requires_python = ">=3.9" @@ -841,20 +841,6 @@ files = [ {file = "sphinx-7.4.7.tar.gz", hash = "sha256:242f92a7ea7e6c5b406fdc2615413890ba9f699114a9c09192d7dfead2ee9cfe"}, ] -[[package]] -name = "sphinx-argparse" -version = "0.4.0" -requires_python = ">=3.7" -summary = "A sphinx extension that automatically documents argparse commands and options" -groups = ["dev"] -dependencies = [ - "sphinx>=1.2.0", -] -files = [ - {file = "sphinx_argparse-0.4.0-py3-none-any.whl", hash = "sha256:73bee01f7276fae2bf621ccfe4d167af7306e7288e3482005405d9f826f9b037"}, - {file = "sphinx_argparse-0.4.0.tar.gz", hash = "sha256:e0f34184eb56f12face774fbc87b880abdb9017a0998d1ec559b267e9697e449"}, -] - [[package]] name = "sphinx-argparse-cli" version = "1.17.0"