From 3ee2401832a2782dcf10277dbf120d7bfc9a9c02 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Mon, 15 Jul 2024 16:51:27 -0400 Subject: [PATCH 1/3] chore(deps): updates trestle to new major version Signed-off-by: Jennifer Power --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index c4f739c..46a9a63 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ packages = find: include_package_data = True install_requires = - compliance-trestle>=2.5.1 + compliance-trestle>=3.3.0 saxonche>=12.4.1.0 [options.packages.find] From 3bbc6c29f519a6b2eb40a1af23e234107f954ab5 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Mon, 15 Jul 2024 17:20:44 -0400 Subject: [PATCH 2/3] chore(deps): drops python 3.8 support, adds 3.10 and 3.11 Aligns supported python versions with compliance-trestle Signed-off-by: Jennifer Power --- .github/workflows/python-push.yml | 20 ++++++++++---------- .github/workflows/python-test.yml | 12 ++++++------ setup.cfg | 5 +++-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/python-push.yml b/.github/workflows/python-push.yml index a691788..1b1391b 100644 --- a/.github/workflows/python-push.yml +++ b/.github/workflows/python-push.yml @@ -21,7 +21,7 @@ jobs: path: ~/Library/Caches/pip # - os: windows-latest # path: ~\AppData\Local\pip\Cache - python-version: [3.8, 3.9] + python-version: [3.9, 3.11] steps: - name: Don't mess with line endings run: | @@ -44,35 +44,35 @@ jobs: run: | make develop - name: Setup pre-commit - if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8') }} + if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9') }} run: | make pre-commit - name: Install dependencies run: | make install - name: Run md document formatting (mdformat) - if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8') }} + if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9') }} run: | make mdformat - name: Run code formatting (yapf) - if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8') }} + if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9') }} run: | make code-format - name: Run code linting (flake8) - if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8') }} + if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9') }} run: | make code-lint - name: Run code typing check (mypy) - if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8') }} + if: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9') }} continue-on-error: true run: | make code-typing - name: Pytest Fast - if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8') }} + if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9') }} run: | make test - name: Pytest Cov - if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }} + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }} run: | make test-cov @@ -86,10 +86,10 @@ jobs: submodules: true fetch-depth: 0 token: ${{ secrets.ADMIN_PAT }} - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.9 - name: Install build tools run: | make develop diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 50b0eea..dcb80ed 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -100,7 +100,7 @@ jobs: path: ~/Library/Caches/pip # - os: windows-latest # path: ~\AppData\Local\pip\Cache - python-version: [3.8, 3.9] + python-version: [3.9, 3.11] steps: - name: Don't mess with line endings run: | @@ -124,16 +124,16 @@ jobs: run: | make develop - name: Pytest Fast - if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8') }} + if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9') }} run: | make test - name: Pytest Cov - if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }} + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }} run: | make test-cov - name: Upload artifact - if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8' }} + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' }} uses: actions/upload-artifact@v2 with: name: coverage @@ -156,7 +156,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.9 - uses: actions/cache@v2 with: path: ~/.cache/pip @@ -180,7 +180,7 @@ jobs: -Dsonar.python.coverage.reportPaths=coverage.xml -Dsonar.tests=tests/ -Dsonar.sources=trestle_fedramp/ - -Dsonar.python.version=3.8 + -Dsonar.python.version=3.9 -Dsonar.projectKey=compliance-trestle-fedramp -Dsonar.organization=compliance-trestle - name: SonarQube Quality Gate check diff --git a/setup.cfg b/setup.cfg index 46a9a63..596a604 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,11 +15,12 @@ classifiers = Operating System :: POSIX Operating System :: Microsoft Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 long_description_content_type = text/markdown long_description = file: README.md -python_require= '>=3.8' +python_require= '>=3.9' [options] packages = find: include_package_data = True From 4e484d6b682bc6140ed8c60d2aae9f3f8454b391 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Mon, 15 Jul 2024 17:31:09 -0400 Subject: [PATCH 3/3] chore: replaces pkg_resources with importlib.resources pkg_resources is deprecated in Python 3.11 Signed-off-by: Jennifer Power --- trestle_fedramp/core/fedramp.py | 16 ++++++---------- trestle_fedramp/core/format_convert.py | 8 ++------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/trestle_fedramp/core/fedramp.py b/trestle_fedramp/core/fedramp.py index 005ee62..347bbc6 100644 --- a/trestle_fedramp/core/fedramp.py +++ b/trestle_fedramp/core/fedramp.py @@ -17,8 +17,7 @@ import pathlib import sys import tempfile - -from pkg_resources import resource_filename +from importlib.resources import files from saxonche import (PySaxonApiError, PySaxonProcessor, PyXslt30Processor) @@ -37,21 +36,18 @@ class FedrampValidator: def __init__(self): """Intialize FedRAMP validator.""" - self.baselines_path = pathlib.Path(resource_filename('trestle_fedramp.resources', - const.FEDRAM_BASELINE)).resolve() + self.baselines_path = files('trestle_fedramp.resources').joinpath(const.FEDRAM_BASELINE) + if not self.baselines_path.exists(): raise TrestleError(f'Fedramp baseline directory {self.baselines_path} does not exist') - self.registry_path = pathlib.Path(resource_filename('trestle_fedramp.resources', - const.FEDRAMP_REGISTRY)).resolve() + self.registry_path = files('trestle_fedramp.resources').joinpath(const.FEDRAMP_REGISTRY) if not self.registry_path.exists(): raise TrestleError(f'Fedramp registry directory {self.registry_path} does not exist') - self.ssp_xsl_path = pathlib.Path(resource_filename('trestle_fedramp.resources', - const.FEDRAMP_SSP_XSL)).resolve() + self.ssp_xsl_path = files('trestle_fedramp.resources').joinpath(const.FEDRAMP_SSP_XSL) - self.svrl_xsl_path = pathlib.Path(resource_filename('trestle_fedramp.resources', - const.FEDRAM__SVRL_XSL)).resolve() + self.svrl_xsl_path = files('trestle_fedramp.resources').joinpath(const.FEDRAM__SVRL_XSL) logger.debug(f'Baselines dir: {self.baselines_path}') logger.debug(f'Registry dir: {self.registry_path}') diff --git a/trestle_fedramp/core/format_convert.py b/trestle_fedramp/core/format_convert.py index 05e2457..657bf71 100644 --- a/trestle_fedramp/core/format_convert.py +++ b/trestle_fedramp/core/format_convert.py @@ -15,10 +15,8 @@ import base64 import logging -import pathlib import sys - -from pkg_resources import resource_filename +from importlib.resources import files from saxonche import PySaxonProcessor @@ -36,9 +34,7 @@ class JsonXmlConverter: def __init__(self): """Initialize JSON to XML converter.""" - self.ssp_j_x_xsl_path = pathlib.Path( - resource_filename('trestle_fedramp.resources', const.NIST_SSP_JSON_XML_XSL) - ).resolve() + self.ssp_j_x_xsl_path = files('trestle_fedramp.resources').joinpath(const.NIST_SSP_JSON_XML_XSL) logger.info(f'SSP converter from JSON to XML: {self.ssp_j_x_xsl_path}') self.initial_template = const.NIST_INITIAL_TEMPLATE