Skip to content

Commit aad6623

Browse files
Merge pull request #4 from Infinitode/arena/ac26170c-codesafe
Release v0.0.6: security hardening, bug fixes, packaging & CI modernization
2 parents 916cd04 + dc2d23e commit aad6623

11 files changed

Lines changed: 835 additions & 238 deletions

File tree

‎.github/workflows/build_and_publish.yml‎

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,47 @@ name: Publish Python 🐍 distributions 📦 to PyPI
33
on:
44
push:
55
tags:
6-
- '*'
6+
- '*'
77

88
jobs:
99
build-n-publish:
1010
name: Build and publish Python 🐍 distributions 📦 to PyPI
1111
runs-on: ubuntu-latest
12+
13+
# Required for PyPI Trusted Publishing (OIDC). No API token or
14+
# password is stored in this repository. The token is minted on
15+
# demand by GitHub and verified by PyPI against the trusted
16+
# publisher configuration for this project.
17+
permissions:
18+
id-token: write
19+
1220
steps:
13-
- uses: actions/checkout@master
14-
- name: Set up Python 3.12
15-
uses: actions/setup-python@v3
16-
with:
17-
python-version: '3.12'
18-
- name: Install pypa/setuptools
19-
run: >-
20-
python -m
21-
pip install setuptools wheel
22-
- name: Extract tag name
23-
id: tag
24-
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
25-
- name: Update version in setup.py
26-
run: >-
27-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
28-
- name: Build a binary wheel
29-
run: >-
30-
python setup.py sdist bdist_wheel
31-
- name: Publish distribution 📦 to PyPI
32-
uses: pypa/gh-action-pypi-publish@master
33-
with:
34-
password: ${{ secrets.PYPI_API_TOKEN }}
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python 3.12
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.12'
27+
28+
- name: Install build tooling
29+
run: python -m pip install --upgrade pip build
30+
31+
- name: Verify that the tag matches the package version
32+
run: |
33+
TAG_NAME="${GITHUB_REF_NAME#v}"
34+
PACKAGE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
35+
echo "Tag: $TAG_NAME"
36+
echo "Package version: $PACKAGE_VERSION"
37+
if [ "$TAG_NAME" != "$PACKAGE_VERSION" ]; then
38+
echo "::error::Tag '${GITHUB_REF_NAME}' does not match the version '${PACKAGE_VERSION}' in pyproject.toml."
39+
exit 1
40+
fi
41+
42+
- name: Build a binary wheel and source distribution
43+
run: python -m build
44+
45+
# Publishes via PyPI Trusted Publishing (OIDC). The distribution
46+
# is attested (PEP 740) and the provenance is shown on PyPI under
47+
# the "Provenance" information for the release files.
48+
- name: Publish distribution 📦 to PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1

‎.github/workflows/test.yml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Tests ✅
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
name: Run tests (Python ${{ matrix.python-version }}, ${{ matrix.os }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest]
16+
python-version: ['3.10', '3.11', '3.12']
17+
include:
18+
# Python 3.8/3.9 are not available in the ubuntu-latest (24.04)
19+
# toolcache, so they run on ubuntu-22.04 instead.
20+
- os: ubuntu-22.04
21+
python-version: '3.8'
22+
- os: ubuntu-22.04
23+
python-version: '3.9'
24+
- os: windows-latest
25+
python-version: '3.12'
26+
- os: macos-latest
27+
python-version: '3.12'
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
37+
- name: Install dependencies
38+
# The test suite imports codesafe from the repository root, so the
39+
# package itself does not need to be built; only its runtime
40+
# dependencies are required.
41+
run: |
42+
python -m pip install --upgrade pip
43+
python -m pip install "cryptography>=41" "cloudpickle>=2.2"
44+
45+
- name: Run test suite
46+
run: python -m unittest test.py test_poc_vulnerability.py -v

‎.gitignore‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@ __pycache__
22
*.pyc
33
dist/
44
build/
5-
venv/
5+
venv/
6+
*.egg-info/
7+
.eggs/
8+
htmlcov/
9+
.pytest_cache/
10+
.coverage
11+
venv/
12+
.venv/
13+
encrypted_code.encrypt
14+
decrypted.py
15+
codesafe_rce_marker.txt
16+
pathlib_test.txt
17+
v2_test_prog.encrypt

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Thank you for considering contributing to **CodeSafe**! Contributions, whether t
88
Create a fork of this repository to your GitHub account and clone it locally.
99

1010
2. **Set Up the Environment**
11-
Ensure you have Python 3.6+ installed. You should also install compatible versions of the necessary dependencies for the project.
11+
Ensure you have Python 3.8+ installed. You should also install compatible versions of the necessary dependencies for the project.
1212

1313
3. **Run Tests**
1414
Before making changes, run tests to confirm that everything works.

0 commit comments

Comments
 (0)