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
92 changes: 82 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Python CI

on:
pull_request:
branches: [master]
branches: [main]
push:
branches: [master]
branches: [main]
release:
types: [released]

permissions: {}

jobs:
test:
Expand All @@ -15,12 +19,6 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.9"
platform: ubuntu-latest
toxenv: py39
- python-version: "3.10"
platform: ubuntu-latest
toxenv: py310
- python-version: "3.11"
platform: ubuntu-latest
toxenv: py311
Expand All @@ -36,12 +34,17 @@ jobs:
- python-version: "3.13"
platform: windows-latest
toxenv: py313
- python-version: "3.14"
platform: windows-latest
toxenv: py314

steps:
- uses: actions/checkout@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -50,3 +53,72 @@ jobs:

- name: Run lint
run: tox -e lint

- name: Run tests
run: tox -e ${{ matrix.toxenv }} -- -vv

release:
name: Semantic Release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-latest
concurrency:
group: semantic-release-main
permissions:
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
tag: ${{ steps.release.outputs.tag }}

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"

- name: Run semantic release
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pipx run --python python 'python-semantic-release==10.7.0' -v version --no-changelog --skip-build

publish:
name: Build & Publish to PyPI
# The release job is skipped for releases published manually in GitHub.
if: >-
!cancelled() && needs.test.result == 'success' &&
(github.event_name == 'release' ||
(needs.release.result == 'success' && needs.release.outputs.released == 'true'))
needs: [test, release]
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event_name == 'release' && github.ref || format('refs/tags/{0}', needs.release.outputs.tag) }}
# setuptools_scm needs tags to derive a release version
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"

- name: Install build
run: python -m pip install --upgrade build

- name: Build package
run: python -m build

- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
skip-existing: true
22 changes: 22 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: zizmor

on:
pull_request:
push:
branches: [main]

permissions: {}

jobs:
zizmor:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: zizmorcore/zizmor-action@1b4550e929643b8b26a62303c6bd64814271a4f1 # v0.9.2
with:
version: v1.33.1
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.0
rev: v0.17.6
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-ast
- id: check-docstring-first
Expand All @@ -22,7 +22,7 @@ repos:
args: ['--django']
- id: check-json
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
rev: v2.4.3
hooks:
- id: codespell
exclude_types: [json]
Expand All @@ -43,6 +43,10 @@ repos:
language: system
require_serial: true
types: [python]
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.33.1
hooks:
- id: zizmor

default_language_version:
python: python3
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
Common config for Sentry for Fuzzing tools
# mozsec-sentry

Common config for [Sentry](https://sentry.io/) for Fuzzing tools.

This package centralises the Sentry setup shared by Mozilla's fuzzing tools, so
each tool gets identical error reporting and the same extra diagnostic context
attached to every event.

## Install

```sh
pip install mozsec-sentry
```

## Usage

Call `init()` once, as early as possible in your program's startup:

```python
from mozsec_sentry import init

init()
```

`init()` is a no-op unless the `SENTRY_DSN` environment variable is set, so it
is safe to call unconditionally — tools can ship the call and only enable
reporting where a DSN is configured. It is also deliberately a no-op while
running under pytest (detected via `PYTEST_CURRENT_TEST`) so test suites never
report to Sentry.

## Configuration

| Variable | Purpose |
| --- | --- |
| `SENTRY_DSN` | The Sentry DSN to report to. Reporting is disabled if unset. |
| `TASK_ID` | Taskcluster task ID, used to build a link back to the task. |
| `TASKCLUSTER_ROOT_URL` | Taskcluster deployment root URL. Defaults to `unknown`. |
| `RUN_ID` | Taskcluster run ID. Defaults to `unknown`. |
| `TASKCLUSTER_FUZZING_POOL` | Name of the fuzzing pool the task belongs to. |

## Event context

Every event is enriched via a `before_send` hook with:

- **System Stats** — free memory (MB), free disk (MB), and OS name.
- **Taskcluster** — task ID, a direct task URL, and the fuzzing pool, when the
corresponding environment variables are present.
- An `origin_module` tag naming the module the exception was raised from, which
makes it possible to group issues by the component at fault.
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ log_level = "DEBUG"

[tool.ruff]
fix = true
target-version = "py39"
target-version = "py310"

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -73,4 +73,10 @@ select = [
"W",
]

[tool.semantic_release]
tag_format = "{version}"

[tool.semantic_release.branches.main]
match = "^main$"

[tool.setuptools_scm]
18 changes: 12 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
[metadata]
classifiers =
Development Status :: 5 - Production/Stable
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Programming Language :: Python :: 3
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Topic :: Security
Topic :: Software Development :: Testing
description = Common config for Sentry for Fuzzing tools
keywords = fuzz fuzzing security test testing
license = MPL 2.0
license_files = LICENSE.md
long_description = file: README.md
long_description_content_type = text/markdown
maintainer = Mozilla Fuzzing Team
maintainer_email = fuzzing@mozilla.com
name = sentry-fuzzing-config
name = mozsec-sentry
platforms = any
url = https://github.com/MozillaSecurity/sentry

[options]
install_requires =
psutil
sentry_sdk
sentry-sdk >= 1.44.0
package_dir =
= src
packages =
sentry_fuzzing_config
mozsec_sentry
zip_safe = False
python_requires = >=3.9
python_requires = >=3.10

[options.extras_require]
dev =
pre-commit
tox

[options.package_data]
sentry_fuzzing_config =
mozsec_sentry =
py.typed
File renamed without changes.
File renamed without changes.
Loading
Loading