Skip to content

Commit

Permalink
Merge branch 'master' into security/prevent_rootfs_escape
Browse files Browse the repository at this point in the history
  • Loading branch information
HorlogeSkynet authored Oct 10, 2022
2 parents 91de73f + 7766e98 commit 5d9b5ba
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 46 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install tox
run: python -m pip install tox
Expand All @@ -39,7 +41,7 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

Expand All @@ -64,7 +66,7 @@ jobs:
- uses: codecov/codecov-action@v3

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: 3.x

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Deploy to PyPI"
on:
workflow_dispatch:
inputs:
inputs:
tag:
description: "Git tag to deploy to PyPI"
required: true
Expand All @@ -15,13 +15,13 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.tag }}
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- shell: bash
run: |
python -m pip install --disable-pip-version-check -U pip
python -m pip install -U setuptools wheel twine
python setup.py sdist bdist_wheel
python -m pip install -U build twine
python -m build
python -m twine check dist/*
python -m twine upload --username=__token__ --password=${{ secrets.PYPI_TOKEN }} dist/*
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ repos:
args: ["--strict"]
additional_dependencies: [
"pytest==6.2.5",
"types-setuptools==57.4.2",
]
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## 1.8.0 (2022.10.10)

BACKWARD COMPATIBILITY:
* Replace `setup.py` with `build` [[#342](https://github.com/python-distro/distro/pull/342)]

ENHANCEMENTS:
* Lowered `LinuxDistribution._distro_release_info` method complexity [[#327](https://github.com/python-distro/distro/pull/327)]
* Added official support for Buildroot distribution [[#329](https://github.com/python-distro/distro/pull/329)]
* Added official support for Guix distribution [[#330](https://github.com/python-distro/distro/pull/330)]
* Added support for `/etc/debian_version` [[#333](https://github.com/python-distro/distro/pull/333)] & [[#349](https://github.com/python-distro/distro/pull/349)]
* Fixed a typography in CONTRIBUTING.md [[#340](https://github.com/python-distro/distro/pull/340)]
* Improved README.md "Usage" code block [[#343](https://github.com/python-distro/distro/pull/343)]

RELEASE:
* Bumped black to v22.3.0 in pre-commit.ci configuration [[#331](https://github.com/python-distro/distro/pull/331)]
* Enabled GitHub Dependabot to keep GitHub Actions up to date [[#335](https://github.com/python-distro/distro/pull/335)]

## 1.7.0 (2022.02.15)

BACKWARD COMPATIBILITY:
Expand Down Expand Up @@ -130,7 +147,7 @@ RELEASE:
## 1.0.4 (2017.04.01)

BUG FIXES:
* Guess common *-release files if /etc not readable [[#175](https://github.com/python-distro/distro/issues/175)]
* Guess common \*-release files if /etc not readable [[#175](https://github.com/python-distro/distro/issues/175)]

## 1.0.3 (2017.03.19)

Expand Down Expand Up @@ -213,4 +230,3 @@ TESTS:

DOCS:
* Documentation fixes

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def test_centos5_dist_release(self):
self._test_outcome(desired_outcome, 'centos', '5')
```

Where the name of the method is not indicative of the lookup folder but rather tha two last arguments in `_test_outcome`.
Where the name of the method is not indicative of the lookup folder but rather the two last arguments in `_test_outcome`.

A test case is mandatory under `TestOverall` for a PR to be complete.
A test case is mandatory under `TestOverall` for a PR to be complete.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ clean:

.PHONY: build
build:
python setup.py sdist bdist_wheel
python -m build

.PHONY: publish
publish:
Expand All @@ -72,12 +72,12 @@ dev: instdev test
.PHONY: instdev
instdev:
pip install -r dev-requirements.txt
python setup.py develop
pip install -e .
@echo "$@ done."

.PHONY: install
install:
python setup.py install
pip install .
@echo "$@ done."

.PHONY: clobber
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ $ distro -j

$ python
>>> import distro
>>> distro.linux_distribution(full_distribution_name=False)
('centos', '7.1.1503', 'Core')
>>> distro.name(pretty=True)
'CentOS Linux 8'
>>> distro.id()
'centos'
>>> distro.version(best=True)
'8.4.2105'
```


Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
17 changes: 0 additions & 17 deletions setup.py

This file was deleted.

26 changes: 15 additions & 11 deletions src/distro/distro.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# Python 3.7
TypedDict = dict

__version__ = "1.7.0"
__version__ = "1.8.0"


class VersionDict(TypedDict):
Expand Down Expand Up @@ -903,16 +903,7 @@ def version(self, pretty: bool = False, best: bool = False) -> str:
versions.insert(0, self.oslevel_info())
elif self.id() == "debian" or "debian" in self.like().split():
# On Debian-like, add debian_version file content to candidates list.
try:
with open(
self.__resolve_chroot_symlink_as_needed(
os.path.join(self.etc_dir, "debian_version")
),
encoding="ascii",
) as fp:
versions.append(fp.readline().rstrip())
except FileNotFoundError:
pass
versions.append(self._debian_version)
version = ""
if best:
# This algorithm uses the last version in priority order that has
Expand Down Expand Up @@ -1280,6 +1271,19 @@ def _oslevel_info(self) -> str:
return ""
return self._to_str(stdout).strip()

@cached_property
def _debian_version(self) -> str:
try:
with open(
self.__resolve_chroot_symlink_as_needed(
os.path.join(self.etc_dir, "debian_version")
),
encoding="ascii",
) as fp:
versions.append(fp.readline().rstrip())
except FileNotFoundError:
pass

@staticmethod
def _parse_uname_content(lines: Sequence[str]) -> Dict[str, str]:
if not lines:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -2297,6 +2297,6 @@ def test_repr(self) -> None:
repr_str = repr(distro._distro)
assert "LinuxDistribution" in repr_str
for attr in MODULE_DISTRO.__dict__.keys():
if attr in ("root_dir", "etc_dir", "usr_lib_dir"):
if attr in ("root_dir", "etc_dir", "usr_lib_dir", "_debian_version"):
continue
assert f"{attr}=" in repr_str
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
[tox]
minversion = 1.9
envlist = lint, py{36,37,38,39,310,py3}
isolated_build = true
skip_missing_interpreters = true

[testenv]
Expand Down

0 comments on commit 5d9b5ba

Please sign in to comment.