From f77af7452527808a52b58f6bc6aec2e32e5c0f52 Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Fri, 9 Feb 2024 09:39:40 -0500 Subject: [PATCH 1/3] Bump version from 1.3.4 to 1.3.5 --- README.md | 20 ++++++++++---------- src/version.txt | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f77be98..446bf74 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ expects the secrets in a different location. To run the `cisagov/saver` image via Docker: ```console -docker run cisagov/saver:1.3.4 +docker run cisagov/saver:1.3.5 ``` ### Running with Docker Compose ### @@ -46,7 +46,7 @@ docker run cisagov/saver:1.3.4 services: saver: - image: cisagov/saver:1.3.4 + image: cisagov/saver:1.3.5 volumes: - type: bind source: @@ -92,7 +92,7 @@ environment variables. See the services: trustymail_reporter: - image: cisagov/saver:1.3.4 + image: cisagov/saver:1.3.5 volumes: - type: bind source: @@ -129,7 +129,7 @@ environment variables. See the 1. Pull the new image: ```console - docker pull cisagov/saver:1.3.4 + docker pull cisagov/saver:1.3.5 ``` 1. Recreate and run the container by following the [previous instructions](#running-with-docker). @@ -139,11 +139,11 @@ environment variables. See the The images of this container are tagged with [semantic versions](https://semver.org) of the underlying saver project that they containerize. It is recommended that most users use a version tag (e.g. -`:1.3.4`). +`:1.3.5`). | Image:tag | Description | |-----------|-------------| -|`cisagov/saver:1.3.4`| An exact release version. | +|`cisagov/saver:1.3.5`| An exact release version. | |`cisagov/saver:1.3`| The most recent release matching the major and minor version numbers. | |`cisagov/saver:1`| The most recent release matching the major version number. | |`cisagov/saver:edge` | The most recent image built from a merge into the `develop` branch of this repository. | @@ -206,8 +206,8 @@ Build the image locally using this git repository as the [build context](https:/ ```console docker build \ - --build-arg VERSION=1.3.4 \ - --tag cisagov/saver:1.3.4 \ + --build-arg VERSION=1.3.5 \ + --tag cisagov/saver:1.3.5 \ https://github.com/cisagov/saver.git#develop ``` @@ -237,9 +237,9 @@ Docker: docker buildx build \ --file Dockerfile-x \ --platform linux/amd64 \ - --build-arg VERSION=1.3.4 \ + --build-arg VERSION=1.3.5 \ --output type=docker \ - --tag cisagov/saver:1.3.4 . + --tag cisagov/saver:1.3.5 . ``` ## Contributing ## diff --git a/src/version.txt b/src/version.txt index f9e47b6..92857f8 100644 --- a/src/version.txt +++ b/src/version.txt @@ -1 +1 @@ -__version__ = "1.3.4" +__version__ = "1.3.5" From 8010f375312b8c078323dcf5ec29d422e17dca58 Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Fri, 9 Feb 2024 09:56:40 -0500 Subject: [PATCH 2/3] Prefer datetime.now(timezone.utc) to datetime.utcnow() The latter is deprecated. Note that we also remove the import of pytz from sslyze_csv2mongo.py, since it is not being used and conflicts with the import of datetime.timezone. --- src/create_sld_to_agency_name_and_id_mapping.py | 4 ++-- src/pshtt_csv2mongo.py | 6 ++---- src/sslyze_csv2mongo.py | 7 ++----- src/trustymail_csv2mongo.py | 6 ++---- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/create_sld_to_agency_name_and_id_mapping.py b/src/create_sld_to_agency_name_and_id_mapping.py index 4a3f1b1..26bc879 100755 --- a/src/create_sld_to_agency_name_and_id_mapping.py +++ b/src/create_sld_to_agency_name_and_id_mapping.py @@ -4,7 +4,7 @@ # Standard Python Libraries import csv -import datetime +from datetime import datetime, timezone import os # Third-Party Libraries @@ -63,7 +63,7 @@ def main(): # Mongo 4 we can use a transaction to atomically (1) drop all the # rows from the collection and (2) use insert_many() to insert all # the new data. That will be much cleaner! - now = datetime.datetime.utcnow() + now = datetime.now(timezone.utc) with open(CURRENT_FEDERAL_FILE, newline="") as current_federal_file: csvreader = csv.DictReader(current_federal_file) for row in csvreader: diff --git a/src/pshtt_csv2mongo.py b/src/pshtt_csv2mongo.py index 7b00274..451352b 100755 --- a/src/pshtt_csv2mongo.py +++ b/src/pshtt_csv2mongo.py @@ -4,7 +4,7 @@ # Standard Python Libraries import csv -import datetime +from datetime import datetime, time, timezone import os import re @@ -103,9 +103,7 @@ def store_data(clean_federal, agency_dict, db_config_file): :param db_config_file: The name of the file where the database configuration is stored """ - date_today = datetime.datetime.combine( - datetime.datetime.utcnow(), datetime.time.min - ) + date_today = datetime.combine(datetime.now(timezone.utc), time.min) db = db_from_config(db_config_file) # set up database connection f = open(PSHTT_RESULTS_FILE) csv_f = csv.DictReader(f) diff --git a/src/sslyze_csv2mongo.py b/src/sslyze_csv2mongo.py index e686b66..07ddf8d 100755 --- a/src/sslyze_csv2mongo.py +++ b/src/sslyze_csv2mongo.py @@ -4,12 +4,11 @@ # Standard Python Libraries import csv -import datetime +from datetime import datetime, time, timezone import os # Third-Party Libraries from mongo_db_from_config import db_from_config -from pytz import timezone DB_CONFIG_FILE = "/run/secrets/scan_write_creds.yml" HOME_DIR = os.environ.get("CISA_HOME") @@ -103,9 +102,7 @@ def store_data(clean_federal, agency_dict, db_config_file): :param db_config_file: The name of the file where the database configuration is stored """ - date_today = datetime.datetime.combine( - datetime.datetime.utcnow(), datetime.time.min - ) + date_today = datetime.combine(datetime.now(timezone.utc), time.min) db = db_from_config(db_config_file) # set up database connection f = open(SSLYZE_RESULTS_FILE) csv_f = csv.DictReader(f) diff --git a/src/trustymail_csv2mongo.py b/src/trustymail_csv2mongo.py index a2839f9..54d30e6 100755 --- a/src/trustymail_csv2mongo.py +++ b/src/trustymail_csv2mongo.py @@ -4,7 +4,7 @@ # Standard Python Libraries import csv -import datetime +from datetime import datetime, time, timezone import os # Third-Party Libraries @@ -101,9 +101,7 @@ def store_data(clean_federal, agency_dict, db_config_file): :param db_config_file: The name of the file where the database configuration is stored """ - date_today = datetime.datetime.combine( - datetime.datetime.utcnow(), datetime.time.min - ) + date_today = datetime.combine(datetime.now(timezone.utc), time.min) db = db_from_config(db_config_file) # set up database connection f = open(TRUSTYMAIL_RESULTS_FILE) csv_f = csv.DictReader(f) From ad7edf62cc6e138d4ad9e4b59258bf58ff8388d2 Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Fri, 9 Feb 2024 10:02:06 -0500 Subject: [PATCH 3/3] Remove pytz from pip install in Dockerfile This package is no longer being used, and in current versions of Python its functionality resides in datetime.timezone. --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index aebc2fa..34455ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,8 +68,7 @@ RUN pip3 install --no-cache-dir --upgrade \ # Install Python dependencies ### RUN pip3 install --no-cache-dir --upgrade \ - https://github.com/cisagov/mongo-db-from-config/tarball/develop \ - pytz + https://github.com/cisagov/mongo-db-from-config/tarball/develop ### # Put this just before we change users because the copy (and every