diff --git a/.github/super-linter.env b/.github/super-linter.env index e696775..218a28f 100644 --- a/.github/super-linter.env +++ b/.github/super-linter.env @@ -10,5 +10,12 @@ VALIDATE_MARKDOWN=false VALIDATE_HTML_PRETTIER=false VALIDATE_PYTHON_PYLINT=false VALIDATE_PYTHON_RUFF=false -VALIDATE_PYTHON_PYINK=false -VALIDATE_PYTHON_ISORT=false \ No newline at end of file +VALIDATE_PYTHON_ISORT=false +VALIDATE_PYTHON_RUFF_FORMAT=false +VALIDATE_GIT_COMMITLINT=false +VALIDATE_BIOME_FORMAT=false +VALIDATE_BIOME_LINT=false +VALIDATE_GITHUB_ACTIONS_ZIZMOR=false + +# Tool-specific configuration +TRIVY_IGNOREFILE=.trivyignore.yaml \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86e0581..72ac8a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: statuses: write strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.8, 3.9] steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index bdd6123..877f038 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -29,6 +29,6 @@ jobs: # Ref: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable run: grep -v '^#' .github/super-linter.env >> "$GITHUB_ENV" - name: super-linter - uses: super-linter/super-linter/slim@v7.1.0 + uses: super-linter/super-linter/slim@v8.2.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 58231e6..d91c5e7 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -29,7 +29,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install .[dist] + pip install --group dist - name: Build run: | python -m build diff --git a/.trivyignore.yaml b/.trivyignore.yaml new file mode 100644 index 0000000..00daf72 --- /dev/null +++ b/.trivyignore.yaml @@ -0,0 +1,7 @@ +misconfigurations: + - id: AVD-DS-0002 + paths: + - "Dockerfile" + - id: AVD-DS-0026 + paths: + - "Dockerfile" diff --git a/CHANGELOG.md b/CHANGELOG.md index d3a1ae1..5f5534f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ ## [1.1.1](https://github.com/cshamrick/stsauth/compare/v1.1.0...v1.1.1) (2024-09-20) -### Bug Fixes +### Bugfixes -* handle connection errors more gracefully ([0497547](https://github.com/cshamrick/stsauth/commit/049754726aeeccba43c5a0343c4a25a87758c587)) +- handle connection errors more gracefully ([0497547](https://github.com/cshamrick/stsauth/commit/049754726aeeccba43c5a0343c4a25a87758c587)) ## [1.1.0](https://github.com/cshamrick/stsauth/compare/v1.0.3...v1.1.0) (2023-10-03) @@ -20,7 +20,7 @@ ### Bugfixes -- **Dockerfile:** fix docker build ([d492181](https://github.com/cshamrick/stsauth/commit/d492181cf0e15cd50c303faf13d216322de2f4c4)) +- **Dockerfile:** fix Docker build ([d492181](https://github.com/cshamrick/stsauth/commit/d492181cf0e15cd50c303faf13d216322de2f4c4)) ### [1.0.1](https://github.com/cshamrick/stsauth/compare/v1.0.0...v1.0.1) (2021-07-29) diff --git a/Dockerfile b/Dockerfile index 1f774e3..0f851e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8-slim as build +FROM python:3.9-slim AS build # checkov:skip=CKV_DOCKER_3 # checkov:skip=CKV_DOCKER_2 WORKDIR /usr/src/stsauth @@ -8,10 +8,11 @@ RUN apt-get update -y \ && apt-get install --no-install-recommends -y git \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ - && pip install --no-cache-dir .[dist] \ + && pip install --no-cache-dir --upgrade pip \ + && pip install --no-cache-dir --group dist \ && python -m build -FROM python:3.8-slim as runtime +FROM python:3.9-slim AS runtime COPY --from=build /usr/src/stsauth/dist/*.whl /dist/ RUN pip install --no-cache-dir dist/stsauth*.whl diff --git a/pyproject.toml b/pyproject.toml index dcae026..cc5f31e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,26 +2,85 @@ requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] build-backend = "setuptools.build_meta" +[project] +name = "stsauth" +dynamic = ["version"] +authors = [{ name = "Scott Hamrick", email = "scott@scotthamrick.com" }] +description = "CLI tool for fetching AWS tokens." +readme = { file = "README.md", content-type = "text/markdown" } +license = { file = "LICENSE" } +# # This below format is for py3.9 and above +# license = "MIT" +# license-files = ["LICENSE"] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Operating System :: OS Independent", + "Topic :: Utilities", +] +requires-python = ">=3.8" +dependencies = [ + "boto3 <2", + "beautifulsoup4 <5", + "Click >=8,<9", + "click-log <0.4", + "requests <3", + "requests_ntlm <2", + "lxml <5", + "pyotp <3", + "urllib3<1.30", + "importlib_metadata;python_version<'3.8'", + "backoff<2.3", +] + +[dependency-groups] +dist = ["build", "twine"] +dev = ["ipython", "ipdb", "pylint"] +tests = ["tox", "mock", "nose", "flake8", "pytest", "coverage", "pytest-cov"] + +[project.scripts] +stsauth = "sts_auth.cli:cli" + +[project.urls] +Homepage = "https://github.com/cshamrick/stsauth" +Repository = "https://github.com/cshamrick/stsauth" +Issues = "https://github.com/cshamrick/stsauth/issues" +Changelog = "https://github.com/cshamrick/stsauth/blob/main/CHANGELOG.md" + [tool.black] line-length = 120 [tool.mypy] show_error_codes = true +[tool.setuptools.packages] +find = {} + [tool.setuptools_scm] write_to = "sts_auth/_version.py" [tool.tox] -legacy_tox_ini = """ -[tox] -skipsdist=True -minversion=2.3.1 -envlist = py37,py38,py39 - -[testenv] -deps = - .[tests] -commands = - coverage run -m pytest {posargs} - coverage xml -""" \ No newline at end of file +requires = ["tox>=4"] +env_list = ["py38", "py39"] +skipsdist = true + +[tool.tox.env_run_base] +description = "Run test under {base_python}" +deps = ["."] +dependency_groups = ["tests"] +commands = [ + [ + "coverage", + "run", + "-m", + "pytest", + "{posargs}", + ], + [ + "coverage", + "xml", + ], +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e8ba20f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,54 +0,0 @@ -[metadata] -name = stsauth -author = Scott Hamrick -author_email = scott@scotthamrick.com -description = CLI tool for fetching AWS tokens. -license = MIT -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/cshamrick/stsauth -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Developers - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Operating System :: OS Independent - Topic :: Utilities - -[options] -python_requires = >=3.6,<4.0 -packages = find: -install_requires = - boto3 <2 - beautifulsoup4 <5 - Click >=8,<9 - click-log <0.4 - requests <3 - requests_ntlm <2 - lxml <5 - pyotp <3 - urllib3<1.30 - importlib_metadata;python_version<'3.8' - backoff<2.3 -[options.entry_points] -console_scripts = - stsauth=sts_auth.cli:cli - -[options.extras_require] -dist = - build - twine -dev = - ipython - ipdb - pylint -tests = - tox - mock - nose - flake8 - pytest - coverage - pytest-cov diff --git a/sts_auth/cli.py b/sts_auth/cli.py index 627b671..0169f38 100644 --- a/sts_auth/cli.py +++ b/sts_auth/cli.py @@ -356,7 +356,7 @@ def prompt_for_role(account_map: Mapping[str, str], account_roles: collections.O if not role_selection_is_valid(selected_role_index, flat_roles): return prompt_for_role(account_map, account_roles) - role = next((v for v in flat_roles if int(v["num"]) == selected_role_index), None) + role = next((v for v in flat_roles if int(v["num"]) == selected_role_index), {}) utils.logger.debug("Selected Role: ") utils.logger.debug(role) diff --git a/super-linter.env b/super-linter.env index b9972f5..d696c54 100644 --- a/super-linter.env +++ b/super-linter.env @@ -11,9 +11,16 @@ VALIDATE_MARKDOWN=false VALIDATE_HTML_PRETTIER=false VALIDATE_PYTHON_PYLINT=false VALIDATE_PYTHON_RUFF=false -VALIDATE_PYTHON_PYINK=false VALIDATE_PYTHON_ISORT=false +VALIDATE_PYTHON_RUFF_FORMAT=false +VALIDATE_GIT_COMMITLINT=false +VALIDATE_BIOME_FORMAT=false +VALIDATE_BIOME_LINT=false +VALIDATE_GITHUB_ACTIONS_ZIZMOR=false FIX_YAML_PRETTIER=true FIX_MARKDOWN_PRETTIER=true -FIX_PYTHON_BLACK=true \ No newline at end of file +FIX_PYTHON_BLACK=true + +# Tool-specific configuration +TRIVY_IGNOREFILE=.trivyignore.yaml \ No newline at end of file