From 9f63ce4796e91de59d23b80f21f6b3f660a41278 Mon Sep 17 00:00:00 2001 From: RiccardoBifulco Date: Fri, 20 Nov 2026 13:56:14 +0100 Subject: [PATCH 1/2] fix: point installers, image and docs at secfoo-com; add PyPI version and link checks - install.sh, install.ps1, Dockerfile, release.yml, README, docs and the GitLab example referenced rakfortltd/secfoo, which returns 404. They now use secfoo-com/secfoo; the npm scope stays @rakfortltd (a published name) and docs/REFERENCE.md says so. - __about__.py 0.3.0 -> 0.3.1 to match the v0.3.1 tag and PyPI; docs state releases are cut from this repository. - CI: scripts/check_pypi_version.py fails when __about__.py is behind PyPI; lychee checks links in README.md and docs/. - tests/test_docs_consistency.py guards against the old org references. --- .github/workflows/ci.yml | 19 ++++++++++++ .github/workflows/release.yml | 4 +-- Dockerfile | 2 +- README.md | 4 +-- docs/CI.md | 4 +-- docs/REFERENCE.md | 19 +++++++----- examples/ci/gitlab-ci.yml | 2 +- install.ps1 | 4 +-- install.sh | 4 +-- npm/secfoo-darwin-arm64/package.json | 2 +- npm/secfoo-darwin-x64/package.json | 2 +- npm/secfoo-linux-arm64/package.json | 2 +- npm/secfoo-linux-x64/package.json | 2 +- npm/secfoo-win32-x64/package.json | 2 +- npm/secfoo/README.md | 2 +- npm/secfoo/package.json | 4 +-- scripts/check_pypi_version.py | 45 ++++++++++++++++++++++++++++ src/secfoo/__about__.py | 2 +- tests/test_docs_consistency.py | 29 ++++++++++++++++++ 19 files changed, 125 insertions(+), 29 deletions(-) create mode 100755 scripts/check_pypi_version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8271de..e7e6698 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,3 +84,22 @@ jobs: # it to make a PR pass. if: ${{ !cancelled() }} run: coverage report --fail-under=90 + + docs: + name: Docs (links, version) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: "3.12" + + - name: __about__.py is at or above the latest PyPI release + run: python scripts/check_pypi_version.py + + - name: Check links in README.md and docs/ + uses: lycheeverse/lychee-action@v2 + with: + args: --no-progress --max-retries 2 --accept 200,201,204,429 --exclude '^https?://(localhost|127\.0\.0\.1)' --exclude 'ghcr\.io' --exclude 'npmjs\.com' --exclude 'raw\.githubusercontent\.com/.*/leaderboard' README.md 'docs/**/*.md' + fail: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1ea0c7..a981618 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -197,5 +197,5 @@ jobs: context: . push: true tags: | - ghcr.io/rakfortltd/secfoo:${{ needs.check-version.outputs.version }} - ghcr.io/rakfortltd/secfoo:latest + ghcr.io/secfoo-com/secfoo:${{ needs.check-version.outputs.version }} + ghcr.io/secfoo-com/secfoo:latest diff --git a/Dockerfile b/Dockerfile index fe7e2fb..b8da6c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Published to ghcr.io/rakfortltd/secfoo by .github/workflows/release.yml. +# Published to ghcr.io/secfoo-com/secfoo by .github/workflows/release.yml. # Installs from PyPI rather than PyInstaller-bundling -- simplest, most # robust route for a container image, since there's no cross-platform # concern (the image itself is the platform). diff --git a/README.md b/README.md index 484bd25..5c4254a 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ uvx secfoo --help # run from PyPI without installing (uv) pipx install secfoo # isolated install, Python 3.10+ pip install secfoo # PyPI npm install -g @rakfortltd/secfoo # npm, no Python needed -docker run --rm ghcr.io/rakfortltd/secfoo --help +docker run --rm ghcr.io/secfoo-com/secfoo --help ``` No agent CLI? Use an API key: @@ -241,7 +241,7 @@ steps: - **GitHub Action** with SARIF upload, job summary and severity outputs: [docs/CI.md](https://github.com/secfoo-com/secfoo/blob/main/docs/CI.md#github-actions) - **pre-commit**: `repo: https://github.com/secfoo-com/secfoo`, hooks `secfoo-secrets` and `secfoo` ([example](https://github.com/secfoo-com/secfoo/blob/main/examples/ci/pre-commit-config.yaml)) - **GitLab CI** job with SARIF artifact: [examples/ci/gitlab-ci.yml](https://github.com/secfoo-com/secfoo/blob/main/examples/ci/gitlab-ci.yml) -- **Docker**: `docker run --rm ghcr.io/rakfortltd/secfoo --help` +- **Docker**: `docker run --rm ghcr.io/secfoo-com/secfoo --help` - **Anywhere else**: `secfoo run ... --json --fail-on high`, then `secfoo findings export --format sarif`. Exit codes `0` clean, `1` run failed, `2` findings gate, `3` cost gate. ## Learn more diff --git a/docs/CI.md b/docs/CI.md index 0172f3e..d92e2b3 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -204,12 +204,12 @@ including merge-request rules and a container-image variant: The image on GHCR has secfoo and git, nothing else: ```bash -docker run --rm -e OPENAI_API_KEY -v "$PWD:/workspace" ghcr.io/rakfortltd/secfoo \ +docker run --rm -e OPENAI_API_KEY -v "$PWD:/workspace" ghcr.io/secfoo-com/secfoo \ run --agent api --target /workspace --depth quick --json --rescan --skill sast --fail-on high ``` No agent CLI is installed in the image, so `--agent api` is the practical -choice; build `FROM ghcr.io/rakfortltd/secfoo` and `npm install -g +choice; build `FROM ghcr.io/secfoo-com/secfoo` and `npm install -g @anthropic-ai/claude-code` (or another CLI) if you want one. The store is `/root/.secfoo`; mount it to keep findings between jobs. See the [Distribution](REFERENCE.md#distribution) notes. diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 7b54d40..61767b3 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -721,16 +721,16 @@ pipx install secfoo npm install -g @rakfortltd/secfoo # Universal installer script (macOS/Linux, no Python or Node needed) -curl -fsSL https://raw.githubusercontent.com/rakfortltd/secfoo/main/install.sh | sh +curl -fsSL https://raw.githubusercontent.com/secfoo-com/secfoo/main/install.sh | sh # Windows (PowerShell), no Python or Node needed -irm https://raw.githubusercontent.com/rakfortltd/secfoo/main/install.ps1 | iex +irm https://raw.githubusercontent.com/secfoo-com/secfoo/main/install.ps1 | iex # Docker (nothing installed on the host at all) -docker run --rm ghcr.io/rakfortltd/secfoo --help +docker run --rm ghcr.io/secfoo-com/secfoo --help # Or grab a binary directly for your platform from the Releases page: -# https://github.com/rakfortltd/secfoo/releases +# https://github.com/secfoo-com/secfoo/releases ``` Developing on this repo instead? `pip install -e ".[dev]"`. @@ -1033,11 +1033,14 @@ when a maintainer with write access runs the Release workflow by hand deliberately not triggered by tag pushes. The run creates the GitHub Release for that tag, attaches the binaries and a `SHA256SUMS` file, and in the same run publishes to PyPI, npm and GHCR. A PyPI version cannot be re-uploaded, so -dispatch it only for a version you mean to release. +dispatch it only for a version you mean to release. Releases, tags and +the GitHub Release assets are cut from `secfoo-com/secfoo`; the tag must +already exist and match `src/secfoo/__about__.py`. - **pip**: the "real"/native path — a normal Python sdist+wheel, published to PyPI as usual. -- **npm**: `@rakfortltd/secfoo` is a tiny meta-package whose +- **npm**: `@rakfortltd/secfoo` (the npm scope is `@rakfortltd`; the source + repository and releases are `secfoo-com/secfoo`) is a tiny meta-package whose `optionalDependencies` are 5 per-platform packages (`@rakfortltd/secfoo-darwin-arm64`, etc.), each containing just that platform's binary. npm installs only the one matching your machine — @@ -1045,7 +1048,7 @@ dispatch it only for a version you mean to release. behind a locked-down corporate npm/Artifactory mirror. - **install.sh / install.ps1**: detect your OS/arch, download the matching binary from the latest GitHub Release, verify its SHA256, install it. -- **Docker**: `ghcr.io/rakfortltd/secfoo`, built from the PyPI package on +- **Docker**: `ghcr.io/secfoo-com/secfoo`, built from the PyPI package on a slim Python base (simplest, most robust route for a container image — no cross-platform concern since the image itself is the platform). **Note**: none of the agent CLIs listed in the @@ -1060,7 +1063,7 @@ dispatch it only for a version you mean to release. ```bash docker run --rm -p 8787:8787 -v ~/.secfoo:/root/.secfoo \ - ghcr.io/rakfortltd/secfoo serve --host 0.0.0.0 --port 8787 + ghcr.io/secfoo-com/secfoo serve --host 0.0.0.0 --port 8787 ``` - **GitHub Action**: `uses: secfoo-com/secfoo@main` (composite action in diff --git a/examples/ci/gitlab-ci.yml b/examples/ci/gitlab-ci.yml index 2871fe3..99bcf15 100644 --- a/examples/ci/gitlab-ci.yml +++ b/examples/ci/gitlab-ci.yml @@ -37,7 +37,7 @@ secfoo: # secfoo-docker: # stage: test # image: -# name: ghcr.io/rakfortltd/secfoo:latest +# name: ghcr.io/secfoo-com/secfoo:latest # entrypoint: [""] # script: # - secfoo run --agent api --target . --depth quick --json --rescan --skill sast --fail-on high > secfoo-result.json diff --git a/install.ps1 b/install.ps1 index d05c594..097ddb9 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,5 +1,5 @@ # Universal installer for secfoo (Windows). Usage: -# irm https://raw.githubusercontent.com/rakfortltd/secfoo/main/install.ps1 | iex +# irm https://raw.githubusercontent.com/secfoo-com/secfoo/main/install.ps1 | iex # # Downloads the latest secfoo-win32-x64.exe from GitHub Releases, verifies # its checksum, and installs it to $env:LOCALAPPDATA\secfoo\secfoo.exe, @@ -7,7 +7,7 @@ $ErrorActionPreference = "Stop" -$Repo = "rakfortltd/secfoo" +$Repo = "secfoo-com/secfoo" $InstallDir = Join-Path $env:LOCALAPPDATA "secfoo" $Asset = "secfoo-win32-x64.exe" diff --git a/install.sh b/install.sh index e0b6504..6eb2af2 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/sh # Universal installer for secfoo (macOS/Linux). Usage: -# curl -fsSL https://raw.githubusercontent.com/rakfortltd/secfoo/main/install.sh | sh +# curl -fsSL https://raw.githubusercontent.com/secfoo-com/secfoo/main/install.sh | sh # # Downloads the correct standalone binary from the latest GitHub Release, # verifies its checksum, and installs it to $PREFIX/bin (default @@ -8,7 +8,7 @@ # POSIX sh only -- no bashisms -- since /bin/sh is dash on many systems. set -e -REPO="rakfortltd/secfoo" +REPO="secfoo-com/secfoo" PREFIX="${PREFIX:-/usr/local}" os_name() { diff --git a/npm/secfoo-darwin-arm64/package.json b/npm/secfoo-darwin-arm64/package.json index 8b116a3..63437a6 100644 --- a/npm/secfoo-darwin-arm64/package.json +++ b/npm/secfoo-darwin-arm64/package.json @@ -7,6 +7,6 @@ "license": "Apache-2.0", "repository": { "type": "git", - "url": "git+https://github.com/rakfortltd/secfoo.git" + "url": "git+https://github.com/secfoo-com/secfoo.git" } } diff --git a/npm/secfoo-darwin-x64/package.json b/npm/secfoo-darwin-x64/package.json index 53af8b0..9201cb9 100644 --- a/npm/secfoo-darwin-x64/package.json +++ b/npm/secfoo-darwin-x64/package.json @@ -7,6 +7,6 @@ "license": "Apache-2.0", "repository": { "type": "git", - "url": "git+https://github.com/rakfortltd/secfoo.git" + "url": "git+https://github.com/secfoo-com/secfoo.git" } } diff --git a/npm/secfoo-linux-arm64/package.json b/npm/secfoo-linux-arm64/package.json index 5ece7cb..5a25854 100644 --- a/npm/secfoo-linux-arm64/package.json +++ b/npm/secfoo-linux-arm64/package.json @@ -7,6 +7,6 @@ "license": "Apache-2.0", "repository": { "type": "git", - "url": "git+https://github.com/rakfortltd/secfoo.git" + "url": "git+https://github.com/secfoo-com/secfoo.git" } } diff --git a/npm/secfoo-linux-x64/package.json b/npm/secfoo-linux-x64/package.json index 5fca1f8..8ce5fbe 100644 --- a/npm/secfoo-linux-x64/package.json +++ b/npm/secfoo-linux-x64/package.json @@ -7,6 +7,6 @@ "license": "Apache-2.0", "repository": { "type": "git", - "url": "git+https://github.com/rakfortltd/secfoo.git" + "url": "git+https://github.com/secfoo-com/secfoo.git" } } diff --git a/npm/secfoo-win32-x64/package.json b/npm/secfoo-win32-x64/package.json index 094f851..ece2713 100644 --- a/npm/secfoo-win32-x64/package.json +++ b/npm/secfoo-win32-x64/package.json @@ -7,6 +7,6 @@ "license": "Apache-2.0", "repository": { "type": "git", - "url": "git+https://github.com/rakfortltd/secfoo.git" + "url": "git+https://github.com/secfoo-com/secfoo.git" } } diff --git a/npm/secfoo/README.md b/npm/secfoo/README.md index e9fb1c4..c220a89 100644 --- a/npm/secfoo/README.md +++ b/npm/secfoo/README.md @@ -9,4 +9,4 @@ npm install -g @rakfortltd/secfoo secfoo run --skill security-architecture-review --agent claude ``` -Full documentation: https://github.com/rakfortltd/secfoo +Full documentation: https://github.com/secfoo-com/secfoo diff --git a/npm/secfoo/package.json b/npm/secfoo/package.json index c5f4299..6c6f16d 100644 --- a/npm/secfoo/package.json +++ b/npm/secfoo/package.json @@ -16,10 +16,10 @@ "node": ">=16" }, "license": "Apache-2.0", - "homepage": "https://github.com/rakfortltd/secfoo", + "homepage": "https://github.com/secfoo-com/secfoo", "repository": { "type": "git", - "url": "git+https://github.com/rakfortltd/secfoo.git" + "url": "git+https://github.com/secfoo-com/secfoo.git" }, "keywords": [ "security", diff --git a/scripts/check_pypi_version.py b/scripts/check_pypi_version.py new file mode 100755 index 0000000..8518c78 --- /dev/null +++ b/scripts/check_pypi_version.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +"""Fail if src/secfoo/__about__.py is behind the latest release on PyPI.""" + +from __future__ import annotations + +import json +import re +import sys +import urllib.request +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +def parse(version: str) -> tuple[int, ...]: + match = re.match(r"^(\d+(?:\.\d+)*)", version) + if not match: + raise ValueError(f"unparseable version: {version!r}") + return tuple(int(part) for part in match.group(1).split(".")) + + +def local_version() -> str: + text = (ROOT / "src" / "secfoo" / "__about__.py").read_text(encoding="utf-8") + match = re.search(r'^__version__ = "([^"]+)"', text, re.MULTILINE) + if not match: + raise ValueError("no __version__ in __about__.py") + return match.group(1) + + +def pypi_version(package: str = "secfoo") -> str: + with urllib.request.urlopen(f"https://pypi.org/pypi/{package}/json", timeout=20) as resp: + return json.load(resp)["info"]["version"] + + +def main() -> int: + local, remote = local_version(), pypi_version() + print(f"__about__.py: {local} PyPI: {remote}") + if parse(local) < parse(remote): + print(f"::error::__about__.py ({local}) is behind the latest PyPI release ({remote}).") + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/src/secfoo/__about__.py b/src/secfoo/__about__.py index 493f741..260c070 100644 --- a/src/secfoo/__about__.py +++ b/src/secfoo/__about__.py @@ -1 +1 @@ -__version__ = "0.3.0" +__version__ = "0.3.1" diff --git a/tests/test_docs_consistency.py b/tests/test_docs_consistency.py index d781440..b2350d9 100644 --- a/tests/test_docs_consistency.py +++ b/tests/test_docs_consistency.py @@ -101,3 +101,32 @@ def test_product_description_is_the_same_everywhere() -> None: for path in (ROOT / "src/secfoo/cli.py", ROOT / "CITATION.cff", ROOT / "npm/secfoo/package.json", ROOT / "npm/secfoo/README.md"): assert "Context-based security architectural assessment" not in path.read_text(encoding="utf-8"), path + + +# --- packaging drift (#120) ------------------------------------------------- + +_OBSOLETE_ORG_REFS = re.compile(r"github\.com/rakfortltd|raw\.githubusercontent\.com/rakfortltd|ghcr\.io/rakfortltd|REPO=\"rakfortltd|Repo = \"rakfortltd") + + +def _tracked_text_files() -> list[Path]: + suffixes = {".md", ".sh", ".ps1", ".yml", ".yaml", ".json", ".cff", ".toml"} + skip = {"node_modules", ".git"} + files = [p for p in ROOT.rglob("*") if p.is_file() and p.suffix in suffixes and not skip & set(p.parts)] + files += [ROOT / "Dockerfile"] + return [p for p in files if p.resolve() != Path(__file__).resolve()] + + +def test_no_references_to_the_old_github_org_or_image() -> None: + """Repo URLs, the installers and the image live under secfoo-com; the npm + scope `@rakfortltd/` is a published package name and is allowed.""" + offenders = [] + for path in _tracked_text_files(): + for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1): + if _OBSOLETE_ORG_REFS.search(line): + offenders.append(f"{path.relative_to(ROOT)}:{number}: {line.strip()}") + assert offenders == [] + + +def test_about_version_parses() -> None: + text = (ROOT / "src" / "secfoo" / "__about__.py").read_text(encoding="utf-8") + assert re.search(r'^__version__ = "\d+\.\d+\.\d+"$', text, re.MULTILINE) From 07a2631210be26250598f6c6a008c2e6a547ce99 Mon Sep 17 00:00:00 2001 From: Satyanarayana Vuppala Date: Fri, 20 Nov 2026 13:17:48 +0000 Subject: [PATCH 2/2] Pin lychee, scan tracked files only, PEP 440 version check, 0.3.2.dev0 - Pin lycheeverse/lychee-action to the v2.9.0 commit like every other action here, pass GITHUB_TOKEN so github.com links are not rate limited, and do not persist checkout credentials. - The old-org guard read every file under the checkout; on main it now crashes on the invalid-UTF-8 fuzz reproducers, and a local .venv/build/dist would give false hits. It now scans git ls-files, skipping fuzz/corpus and tests/fixtures. - check_pypi_version orders dev/a/b/rc/post releases per PEP 440, so a 0.3.1.dev0 no longer counts as level with 0.3.1. - main is ahead of the v0.3.1 tag, so it carries 0.3.2.dev0 rather than claiming to be the released 0.3.1; documented in REFERENCE.md. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 7 ++++- docs/REFERENCE.md | 3 ++ scripts/check_pypi_version.py | 17 ++++++++--- src/secfoo/__about__.py | 2 +- tests/test_docs_consistency.py | 54 ++++++++++++++++++++++++++++------ 5 files changed, 68 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7e6698..b59f067 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,6 +90,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: @@ -99,7 +101,10 @@ jobs: run: python scripts/check_pypi_version.py - name: Check links in README.md and docs/ - uses: lycheeverse/lychee-action@v2 + uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0 + env: + # Authenticated github.com requests avoid the anonymous rate limit. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: args: --no-progress --max-retries 2 --accept 200,201,204,429 --exclude '^https?://(localhost|127\.0\.0\.1)' --exclude 'ghcr\.io' --exclude 'npmjs\.com' --exclude 'raw\.githubusercontent\.com/.*/leaderboard' README.md 'docs/**/*.md' fail: true diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 61767b3..dd80e68 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -1036,6 +1036,9 @@ run publishes to PyPI, npm and GHCR. A PyPI version cannot be re-uploaded, so dispatch it only for a version you mean to release. Releases, tags and the GitHub Release assets are cut from `secfoo-com/secfoo`; the tag must already exist and match `src/secfoo/__about__.py`. +Between releases `main` carries the next development version (for example +`0.3.2.dev0`); the release commit sets it to the final `X.Y.Z` before tagging. +CI fails if `__about__.py` is ever behind the latest PyPI release. - **pip**: the "real"/native path — a normal Python sdist+wheel, published to PyPI as usual. diff --git a/scripts/check_pypi_version.py b/scripts/check_pypi_version.py index 8518c78..568b476 100755 --- a/scripts/check_pypi_version.py +++ b/scripts/check_pypi_version.py @@ -12,11 +12,20 @@ ROOT = Path(__file__).resolve().parents[1] -def parse(version: str) -> tuple[int, ...]: - match = re.match(r"^(\d+(?:\.\d+)*)", version) +# Pre-releases sort below the final release, post-releases above it: +# 0.3.2.dev0 < 0.3.2a1 < 0.3.2rc1 < 0.3.2 < 0.3.2.post1 (PEP 440). +_VERSION = re.compile(r"^(\d+(?:\.\d+)*)(?:\.?(dev|a|b|rc|post)\.?(\d*))?$") +_RANK = {"dev": 0, "a": 1, "b": 2, "rc": 3, None: 4, "post": 5} + + +def parse(version: str) -> tuple: + match = _VERSION.match(version.strip().lower()) if not match: raise ValueError(f"unparseable version: {version!r}") - return tuple(int(part) for part in match.group(1).split(".")) + release = [int(part) for part in match.group(1).split(".")] + while len(release) > 1 and release[-1] == 0: # 0.3 == 0.3.0 + release.pop() + return (tuple(release), _RANK[match.group(2)], int(match.group(3) or 0)) def local_version() -> str: @@ -28,7 +37,7 @@ def local_version() -> str: def pypi_version(package: str = "secfoo") -> str: - with urllib.request.urlopen(f"https://pypi.org/pypi/{package}/json", timeout=20) as resp: + with urllib.request.urlopen(f"https://pypi.org/pypi/{package}/json", timeout=20) as resp: # fixed https URL return json.load(resp)["info"]["version"] diff --git a/src/secfoo/__about__.py b/src/secfoo/__about__.py index 260c070..eda0371 100644 --- a/src/secfoo/__about__.py +++ b/src/secfoo/__about__.py @@ -1 +1 @@ -__version__ = "0.3.1" +__version__ = "0.3.2.dev0" diff --git a/tests/test_docs_consistency.py b/tests/test_docs_consistency.py index b2350d9..52e5f05 100644 --- a/tests/test_docs_consistency.py +++ b/tests/test_docs_consistency.py @@ -5,8 +5,11 @@ import inspect import json import re +import subprocess from pathlib import Path +import pytest + ROOT = Path(__file__).resolve().parents[1] # "tag push", "tag-push", "Tag push", "on every vX.Y.Z tag" ... unless negated. @@ -109,24 +112,57 @@ def test_product_description_is_the_same_everywhere() -> None: def _tracked_text_files() -> list[Path]: + """Text files git tracks, so a local .venv, build/ or dist/ can't produce + false hits; fuzz reproducers and test fixtures are deliberately odd bytes.""" suffixes = {".md", ".sh", ".ps1", ".yml", ".yaml", ".json", ".cff", ".toml"} - skip = {"node_modules", ".git"} - files = [p for p in ROOT.rglob("*") if p.is_file() and p.suffix in suffixes and not skip & set(p.parts)] - files += [ROOT / "Dockerfile"] - return [p for p in files if p.resolve() != Path(__file__).resolve()] + names = subprocess.run(["git", "ls-files", "-z"], cwd=ROOT, capture_output=True, check=True).stdout + paths = [ROOT / name for name in names.decode().split("\0") if name] + return [p for p in paths + if (p.suffix in suffixes or p.name == "Dockerfile") and p.is_file() + and not p.relative_to(ROOT).as_posix().startswith(("fuzz/corpus/", "tests/fixtures/")) + and p.resolve() != Path(__file__).resolve()] def test_no_references_to_the_old_github_org_or_image() -> None: """Repo URLs, the installers and the image live under secfoo-com; the npm scope `@rakfortltd/` is a published package name and is allowed.""" + files = _tracked_text_files() + assert any(p.name == "install.sh" for p in files) and any(p.name == "Dockerfile" for p in files) offenders = [] - for path in _tracked_text_files(): - for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1): + for path in files: + for number, line in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), start=1): if _OBSOLETE_ORG_REFS.search(line): offenders.append(f"{path.relative_to(ROOT)}:{number}: {line.strip()}") assert offenders == [] -def test_about_version_parses() -> None: - text = (ROOT / "src" / "secfoo" / "__about__.py").read_text(encoding="utf-8") - assert re.search(r'^__version__ = "\d+\.\d+\.\d+"$', text, re.MULTILINE) +def _check_pypi_version(): + import importlib.util + + spec = importlib.util.spec_from_file_location("check_pypi_version", ROOT / "scripts/check_pypi_version.py") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def test_about_version_is_pep440_and_not_behind_the_last_tagged_release() -> None: + check = _check_pypi_version() + local = check.local_version() + check.parse(local) # raises on anything the release check can't compare + tags = subprocess.run(["git", "tag", "--list", "v*"], cwd=ROOT, capture_output=True, text=True, check=False).stdout.split() + for tag in tags: + assert check.parse(local) >= check.parse(tag[1:]), f"__about__.py {local} is behind tag {tag}" + + +@pytest.mark.parametrize(("lower", "higher"), [ + ("0.3.0", "0.3.1"), ("0.3.1", "0.3.2.dev0"), ("0.3.2.dev0", "0.3.2a1"), ("0.3.2a1", "0.3.2rc1"), + ("0.3.2rc1", "0.3.2"), ("0.3.2", "0.3.2.post1"), ("0.3.9", "0.3.10"), ("0.9", "0.10.0"), +]) +def test_version_check_orders_like_pep440(lower, higher) -> None: + parse = _check_pypi_version().parse + assert parse(lower) < parse(higher) + + +def test_version_check_treats_trailing_zeros_as_equal() -> None: + parse = _check_pypi_version().parse + assert parse("0.3") == parse("0.3.0")