Skip to content
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
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,27 @@ 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
with:
persist-credentials: false

- 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@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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 14 additions & 8 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]"`.
Expand Down Expand Up @@ -1033,19 +1033,25 @@ 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`.
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.
- **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 —
no `postinstall` network fetch, which is what makes this safe to use
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
Expand All @@ -1060,7 +1066,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
Expand Down
2 changes: 1 addition & 1 deletion examples/ci/gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# 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,
# adding that directory to the user PATH if it isn't there already.

$ErrorActionPreference = "Stop"

$Repo = "rakfortltd/secfoo"
$Repo = "secfoo-com/secfoo"
$InstallDir = Join-Path $env:LOCALAPPDATA "secfoo"
$Asset = "secfoo-win32-x64.exe"

Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/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
# /usr/local/bin, falling back to ~/.local/bin if that isn't writable).
# 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() {
Expand Down
2 changes: 1 addition & 1 deletion npm/secfoo-darwin-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion npm/secfoo-darwin-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion npm/secfoo-linux-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion npm/secfoo-linux-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion npm/secfoo-win32-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion npm/secfoo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions npm/secfoo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
54 changes: 54 additions & 0 deletions scripts/check_pypi_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/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]


# 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}")
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:
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: # fixed https URL
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())
2 changes: 1 addition & 1 deletion src/secfoo/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.0"
__version__ = "0.3.2.dev0"
65 changes: 65 additions & 0 deletions tests/test_docs_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -101,3 +104,65 @@ 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]:
"""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"}
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 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 _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")
Loading