Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Get back to a working state #1224

Merged
merged 6 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=${{ github.workspace }}/.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pip install --constraint=${{ github.workspace }}/.github/workflows/constraints.txt poetry
poetry --version

- name: Check if there is a parent commit
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=${{ github.workspace }}/.github/workflows/constraints.txt pip
pip --version

- name: Upgrade pip in virtual environments
Expand All @@ -59,12 +59,12 @@ jobs:

- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt poetry
poetry --version

- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt nox
nox --version

- name: Install nox-poetry
Expand Down Expand Up @@ -127,17 +127,17 @@ jobs:

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=${{ github.workspace }}/.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt poetry
poetry --version

- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt nox
nox --version

- name: Install nox-poetry
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

project = "nox-poetry"
author = "Claudio Jolowicz"
copyright = "2020, Claudio Jolowicz"
Expand Down
21 changes: 20 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""

import os
import shlex
import shutil
Expand Down Expand Up @@ -133,7 +134,25 @@ def safety(session: Session) -> None:
"""Scan dependencies for insecure packages."""
requirements = session.poetry.export_requirements()
session.install("safety")
session.run("safety", "check", "--full-report", f"--file={requirements}")

ignore = [
# ADVISORY: In Jinja2, the from_string function is prone to Server
# Side Template Injection (SSTI) where it takes the "source" parameter as a
# template object, renders it, and then returns it. The attacker can exploit
# it with {{INJECTION COMMANDS}} in a URI. NOTE: The maintainer and multiple
# third parties believe that this vulnerability isn't valid because users
# shouldn't use untrusted templates without sandboxing.
# CVE-2019-8341
"70612",
]

session.run(
"safety",
"check",
"--full-report",
f"--file={requirements}",
f"--ignore={','.join(ignore)}",
)


@session(python=python_versions)
Expand Down
497 changes: 352 additions & 145 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/nox_poetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- :const:`WHEEL`
- :const:`SDIST`
"""

from nox_poetry.poetry import DistributionFormat
from nox_poetry.sessions import Session
from nox_poetry.sessions import session
Expand Down
1 change: 1 addition & 0 deletions src/nox_poetry/poetry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Poetry interface."""

import re
import sys
from enum import Enum
Expand Down
3 changes: 2 additions & 1 deletion src/nox_poetry/sessions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Replacements for the ``nox.session`` decorator and the ``nox.Session`` class."""

import functools
import hashlib
import re
Expand Down Expand Up @@ -66,7 +67,7 @@ def to_constraint(requirement_string: str, line: int) -> Optional[str]:

try:
requirement = Requirement(requirement_string)
except InvalidRequirement as error:
except InvalidRequirement as error: # pragma: no cover
raise RuntimeError(f"line {line}: {requirement_string!r}: {error}") from error

if not (requirement.name and requirement.specifier):
Expand Down
1 change: 1 addition & 0 deletions src/nox_poetry/sessions.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Type stubs for nox_poetry.sessions."""

from pathlib import Path
from typing import Any
from typing import Callable
Expand Down
1 change: 1 addition & 0 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixtures for functional tests."""

import inspect
import os
import subprocess # noqa: S404
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_installroot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functional tests for ``installroot``."""

import nox_poetry
from tests.functional.conftest import Project
from tests.functional.conftest import list_packages
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_poetry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functional tests for ``session.poetry``."""

import nox_poetry
from tests.functional.conftest import Project
from tests.functional.conftest import list_packages
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functional tests for the `@session` decorator."""

import sys
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixtures."""

import sys
from pathlib import Path
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_nox_poetry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests."""

from typing import Iterable

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_poetry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for the poetry module."""

from pathlib import Path
from textwrap import dedent
from typing import Any
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_sessions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for the sessions module."""

from textwrap import dedent
from typing import Callable
from typing import Iterator
Expand Down Expand Up @@ -179,6 +180,7 @@ def test_to_constraints(requirements: str, expected: str) -> None:
assert to_constraints(requirements) == expected


@pytest.mark.xfail(reason="This requirement now seems to be valid.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjolowicz let me know how you'd prefer to deal with this

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good to me for now

def test_invalid_constraint() -> None:
"""It raises an exception."""
with pytest.raises(RuntimeError):
Expand Down
Loading