From f0dbe0bfa657800f3e17627b3cd86e58c31e94fd Mon Sep 17 00:00:00 2001 From: Rory Flynn <75283103+roaree@users.noreply.github.com> Date: Mon, 27 May 2024 19:15:32 +0200 Subject: [PATCH] Prevent command.log from being appended to when run in a loop (#501) * Prevent command.log from being appended to when run in a loop * Ignore a rather stupid vulnerability scan alert for pip --- .safety-policy.yml | 9 +++++++++ mvt/common/command.py | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 .safety-policy.yml diff --git a/.safety-policy.yml b/.safety-policy.yml new file mode 100644 index 00000000..e6e6d04b --- /dev/null +++ b/.safety-policy.yml @@ -0,0 +1,9 @@ +# Safety Security and License Configuration file +# We recommend checking this file into your source control in the root of your Python project +# If this file is named .safety-policy.yml and is in the same directory where you run `safety check` it will be used by default. +# Otherwise, you can use the flag `safety check --policy-file ` to specify a custom location and name for the file. +# To validate and review your policy file, run the validate command: `safety validate policy_file --path ` +security: # configuration for the `safety check` command + ignore-vulnerabilities: # Here you can list multiple specific vulnerabilities you want to ignore (optionally for a time period) + 67599: # Example vulnerability ID + reason: disputed, inapplicable \ No newline at end of file diff --git a/mvt/common/command.py b/mvt/common/command.py index 963d1dbd..b44a56b8 100644 --- a/mvt/common/command.py +++ b/mvt/common/command.py @@ -85,6 +85,15 @@ def _setup_logging(self): ) file_handler.setLevel(logging.DEBUG) file_handler.setFormatter(formatter) + + # MVT can be run in a loop + # Old file handlers stick around in subsequent loops + # Remove any existing logging.FileHandler instances + for handler in logger.handlers: + if isinstance(handler, logging.FileHandler): + logger.removeHandler(handler) + + # And finally add the new one logger.addHandler(file_handler) def _store_timeline(self) -> None: