presidio-deident 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- presidio_deident-0.7.0/.gitattributes +3 -0
- presidio_deident-0.7.0/.github/CODEOWNERS +8 -0
- presidio_deident-0.7.0/.github/dependabot.yml +23 -0
- presidio_deident-0.7.0/.github/workflows/ci.yml +54 -0
- presidio_deident-0.7.0/.github/workflows/codeql.yml +68 -0
- presidio_deident-0.7.0/.github/workflows/publish.yml +104 -0
- presidio_deident-0.7.0/.github/workflows/scorecard.yml +54 -0
- presidio_deident-0.7.0/.gitignore +17 -0
- presidio_deident-0.7.0/ARCHITECTURE.md +64 -0
- presidio_deident-0.7.0/ASSURANCE.md +80 -0
- presidio_deident-0.7.0/CHANGELOG.md +167 -0
- presidio_deident-0.7.0/CODE_OF_CONDUCT.md +116 -0
- presidio_deident-0.7.0/CONTRIBUTING.md +160 -0
- presidio_deident-0.7.0/GOVERNANCE.md +79 -0
- presidio_deident-0.7.0/LICENSE +21 -0
- presidio_deident-0.7.0/PKG-INFO +234 -0
- presidio_deident-0.7.0/PRESIDIO-REQ.md +258 -0
- presidio_deident-0.7.0/README.md +200 -0
- presidio_deident-0.7.0/SECURITY.md +78 -0
- presidio_deident-0.7.0/SEMVER.md +52 -0
- presidio_deident-0.7.0/allowed_signers +10 -0
- presidio_deident-0.7.0/docs/KEYS.md +46 -0
- presidio_deident-0.7.0/docs/SPEC.md +177 -0
- presidio_deident-0.7.0/docs/THREAT-MODEL.md +59 -0
- presidio_deident-0.7.0/docs/adr/0001-package-name.md +10 -0
- presidio_deident-0.7.0/docs/adr/0002-policy-format-toml.md +15 -0
- presidio_deident-0.7.0/docs/adr/0003-vendored-detector.md +27 -0
- presidio_deident-0.7.0/docs/adr/0004-record-format-and-home.md +26 -0
- presidio_deident-0.7.0/docs/adr/0005-pseudonym-domain.md +22 -0
- presidio_deident-0.7.0/docs/adr/0006-suppression-matching.md +24 -0
- presidio_deident-0.7.0/docs/adr/0007-recipient-risk-statement.md +16 -0
- presidio_deident-0.7.0/docs/adr/0008-publishing.md +14 -0
- presidio_deident-0.7.0/docs/adr/0009-public-contract.md +80 -0
- presidio_deident-0.7.0/docs/adr/0010-hardening-gates.md +18 -0
- presidio_deident-0.7.0/docs/adr/0011-going-public.md +11 -0
- presidio_deident-0.7.0/docs/adr/README.md +15 -0
- presidio_deident-0.7.0/examples/README.md +24 -0
- presidio_deident-0.7.0/examples/optout.txt +2 -0
- presidio_deident-0.7.0/examples/policy.toml +25 -0
- presidio_deident-0.7.0/examples/sample-release/release.evidence.json +19 -0
- presidio_deident-0.7.0/examples/sample-release/release.json +115 -0
- presidio_deident-0.7.0/examples/sample-release/tickets.csv +3 -0
- presidio_deident-0.7.0/examples/sample-trust.json +6 -0
- presidio_deident-0.7.0/examples/tickets.csv +4 -0
- presidio_deident-0.7.0/fuzz/fuzz_readers.py +37 -0
- presidio_deident-0.7.0/fuzz/fuzz_verify.py +46 -0
- presidio_deident-0.7.0/hardening.toml +19 -0
- presidio_deident-0.7.0/pyproject.toml +65 -0
- presidio_deident-0.7.0/schemas/dataset-release.v1.json +404 -0
- presidio_deident-0.7.0/src/presidio_deident/__init__.py +14 -0
- presidio_deident-0.7.0/src/presidio_deident/_detect.py +394 -0
- presidio_deident-0.7.0/src/presidio_deident/cli.py +307 -0
- presidio_deident-0.7.0/src/presidio_deident/croissant.py +53 -0
- presidio_deident-0.7.0/src/presidio_deident/errors.py +2 -0
- presidio_deident-0.7.0/src/presidio_deident/generalise.py +53 -0
- presidio_deident-0.7.0/src/presidio_deident/inspect.py +78 -0
- presidio_deident-0.7.0/src/presidio_deident/policy.py +354 -0
- presidio_deident-0.7.0/src/presidio_deident/release.py +425 -0
- presidio_deident-0.7.0/src/presidio_deident/risk.py +74 -0
- presidio_deident-0.7.0/src/presidio_deident/tables.py +257 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/README.md +11 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/envelope-mismatch/release.evidence.json +19 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/envelope-mismatch/release.json +115 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/envelope-mismatch/tickets.csv +3 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/expectations.json +12 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/float-in-record/release.evidence.json +19 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/float-in-record/release.json +115 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/float-in-record/tickets.csv +3 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/other-trust.json +6 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/record-edited/release.evidence.json +19 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/record-edited/release.json +115 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/record-edited/tickets.csv +3 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/sample-release/release.evidence.json +19 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/sample-release/release.json +115 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/sample-release/tickets.csv +3 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/tampered-file/release.evidence.json +19 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/tampered-file/release.json +115 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/tampered-file/tickets.csv +3 -0
- presidio_deident-0.7.0/src/presidio_deident/vectors/trust.json +6 -0
- presidio_deident-0.7.0/src/presidio_deident/verify.py +225 -0
- presidio_deident-0.7.0/tests/conftest.py +102 -0
- presidio_deident-0.7.0/tests/test_ca_drop.py +102 -0
- presidio_deident-0.7.0/tests/test_cli.py +127 -0
- presidio_deident-0.7.0/tests/test_detect.py +56 -0
- presidio_deident-0.7.0/tests/test_history.py +157 -0
- presidio_deident-0.7.0/tests/test_mutation.py +97 -0
- presidio_deident-0.7.0/tests/test_parquet.py +172 -0
- presidio_deident-0.7.0/tests/test_policy_tables.py +146 -0
- presidio_deident-0.7.0/tests/test_public_contract.py +156 -0
- presidio_deident-0.7.0/tests/test_release.py +313 -0
- presidio_deident-0.7.0/tests/test_review_fixes.py +253 -0
- presidio_deident-0.7.0/tests/test_risk_generalise.py +229 -0
- presidio_deident-0.7.0/tests/test_verify.py +143 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Code owners for presidio-deident
|
|
2
|
+
#
|
|
3
|
+
# Every change to this repository requires review from a code owner other than
|
|
4
|
+
# the author (enforced by branch protection: required review + code-owner
|
|
5
|
+
# review). Listing two owners keeps the two-person gate robust — whoever is not
|
|
6
|
+
# the author of a given pull request provides the required review.
|
|
7
|
+
|
|
8
|
+
* @vstantch @ceoofcyber
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "pip"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
open-pull-requests-limit: 5
|
|
8
|
+
labels:
|
|
9
|
+
- "dependencies"
|
|
10
|
+
- "security"
|
|
11
|
+
|
|
12
|
+
- package-ecosystem: "github-actions"
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "weekly"
|
|
16
|
+
open-pull-requests-limit: 5
|
|
17
|
+
labels:
|
|
18
|
+
- "dependencies"
|
|
19
|
+
- "github-actions"
|
|
20
|
+
groups:
|
|
21
|
+
# One PR for all action bumps, so codeql-action's init/autobuild/analyze stay in step.
|
|
22
|
+
github-actions:
|
|
23
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
lint:
|
|
13
|
+
runs-on: ubuntu-24.04
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
16
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- run: pip install -e ".[dev]"
|
|
20
|
+
- run: ruff check . && ruff format --check .
|
|
21
|
+
|
|
22
|
+
test:
|
|
23
|
+
runs-on: ubuntu-24.04
|
|
24
|
+
strategy:
|
|
25
|
+
matrix:
|
|
26
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
29
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
- run: pip install -e ".[dev,parity,parquet]"
|
|
33
|
+
- run: python -m pytest
|
|
34
|
+
|
|
35
|
+
audit:
|
|
36
|
+
runs-on: ubuntu-24.04
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
39
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
40
|
+
with:
|
|
41
|
+
python-version: "3.12"
|
|
42
|
+
- run: pip install -e ".[dev]"
|
|
43
|
+
- run: pip-audit --skip-editable
|
|
44
|
+
|
|
45
|
+
fuzz:
|
|
46
|
+
runs-on: ubuntu-24.04
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
49
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
50
|
+
with:
|
|
51
|
+
python-version: "3.12"
|
|
52
|
+
- run: pip install -e . "atheris>=2.3"
|
|
53
|
+
- run: python fuzz/fuzz_readers.py -max_total_time=60
|
|
54
|
+
- run: python fuzz/fuzz_verify.py -max_total_time=60
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: CodeQL
|
|
2
|
+
|
|
3
|
+
# Real CodeQL analysis (free on public repos) uploads results to code scanning,
|
|
4
|
+
# which OpenSSF Scorecard recognises as a SAST tool. Bandit is kept as a second,
|
|
5
|
+
# fast Python-specific SAST pass.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [main]
|
|
10
|
+
pull_request:
|
|
11
|
+
branches: [main]
|
|
12
|
+
schedule:
|
|
13
|
+
- cron: "30 5 * * 1"
|
|
14
|
+
|
|
15
|
+
# Least privilege: read-only token at the top level (OpenSSF Scorecard Token-Permissions).
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
analyze:
|
|
21
|
+
name: CodeQL Analyze (Python)
|
|
22
|
+
# Code scanning needs GitHub Advanced Security on private repositories, which the
|
|
23
|
+
# free plan lacks. Skip here; the job runs once the repository is public.
|
|
24
|
+
if: github.event.repository.visibility == 'public'
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
permissions:
|
|
27
|
+
contents: read
|
|
28
|
+
security-events: write # upload CodeQL results to code scanning
|
|
29
|
+
actions: read
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
32
|
+
with:
|
|
33
|
+
persist-credentials: false
|
|
34
|
+
|
|
35
|
+
- name: Initialize CodeQL
|
|
36
|
+
uses: github/codeql-action/init@c35d1b164463ee62a100735382aaaa525c5d3496 # codeql-bundle-v2.25.6
|
|
37
|
+
with:
|
|
38
|
+
languages: python
|
|
39
|
+
queries: security-extended
|
|
40
|
+
|
|
41
|
+
- name: Perform CodeQL analysis
|
|
42
|
+
uses: github/codeql-action/analyze@c35d1b164463ee62a100735382aaaa525c5d3496 # codeql-bundle-v2.25.6
|
|
43
|
+
with:
|
|
44
|
+
category: "/language:python"
|
|
45
|
+
|
|
46
|
+
bandit:
|
|
47
|
+
name: Bandit SAST
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
permissions:
|
|
50
|
+
contents: read
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
53
|
+
with:
|
|
54
|
+
persist-credentials: false
|
|
55
|
+
|
|
56
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
57
|
+
with:
|
|
58
|
+
python-version: "3.12"
|
|
59
|
+
|
|
60
|
+
- name: Install Bandit
|
|
61
|
+
run: pip install bandit[toml]
|
|
62
|
+
|
|
63
|
+
- name: Run Bandit SAST scan
|
|
64
|
+
run: |
|
|
65
|
+
bandit -r src/ \
|
|
66
|
+
--severity-level medium \
|
|
67
|
+
--confidence-level medium \
|
|
68
|
+
-f txt
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Trusted Publisher (OIDC, no stored secrets) + PEP 740 attestations.
|
|
4
|
+
# Triggered by a signed v* tag. The publish job runs in the `release`
|
|
5
|
+
# environment, which carries a required-reviewer maintainer gate.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags:
|
|
10
|
+
- "v*"
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
name: Build distribution
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
permissions:
|
|
20
|
+
contents: read
|
|
21
|
+
id-token: write # OIDC token for GitHub artifact attestations
|
|
22
|
+
attestations: write
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
25
|
+
with:
|
|
26
|
+
persist-credentials: false
|
|
27
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.12"
|
|
30
|
+
- name: Build sdist and wheel
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip build
|
|
33
|
+
python -m build
|
|
34
|
+
- name: Check metadata
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install --upgrade twine
|
|
37
|
+
twine check dist/*
|
|
38
|
+
- name: Generate SBOM
|
|
39
|
+
run: |
|
|
40
|
+
python -m pip install --upgrade cyclonedx-bom
|
|
41
|
+
python -m pip install dist/*.whl
|
|
42
|
+
cyclonedx-py environment --output-format JSON --output-file sbom.cdx.json
|
|
43
|
+
- name: Attest build provenance
|
|
44
|
+
id: attest
|
|
45
|
+
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
|
|
46
|
+
with:
|
|
47
|
+
subject-path: dist/*
|
|
48
|
+
- name: Stage provenance bundle as a release asset
|
|
49
|
+
# Copy the Sigstore/in-toto attestation bundle to a named file so it can
|
|
50
|
+
# be attached to the GitHub Release. OpenSSF Scorecard's Signed-Releases
|
|
51
|
+
# check inspects release assets and recognises `.intoto.jsonl` provenance.
|
|
52
|
+
run: cp "${{ steps.attest.outputs.bundle-path }}" provenance.intoto.jsonl
|
|
53
|
+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
54
|
+
with:
|
|
55
|
+
name: release-artifacts
|
|
56
|
+
path: |
|
|
57
|
+
dist/
|
|
58
|
+
sbom.cdx.json
|
|
59
|
+
provenance.intoto.jsonl
|
|
60
|
+
|
|
61
|
+
publish:
|
|
62
|
+
name: Publish to PyPI (Trusted Publishing)
|
|
63
|
+
needs: build
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
environment:
|
|
66
|
+
name: release
|
|
67
|
+
permissions:
|
|
68
|
+
id-token: write # OIDC token for PyPI Trusted Publishing + sigstore
|
|
69
|
+
attestations: write # PEP 740 provenance attestations
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
72
|
+
with:
|
|
73
|
+
name: release-artifacts
|
|
74
|
+
path: .
|
|
75
|
+
- name: Publish to PyPI
|
|
76
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
77
|
+
with:
|
|
78
|
+
attestations: true
|
|
79
|
+
|
|
80
|
+
release-assets:
|
|
81
|
+
name: Attach release assets
|
|
82
|
+
needs: [build, publish]
|
|
83
|
+
runs-on: ubuntu-latest
|
|
84
|
+
permissions:
|
|
85
|
+
contents: write
|
|
86
|
+
steps:
|
|
87
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
88
|
+
with:
|
|
89
|
+
name: release-artifacts
|
|
90
|
+
path: .
|
|
91
|
+
- name: Publish GitHub release assets
|
|
92
|
+
env:
|
|
93
|
+
GH_TOKEN: ${{ github.token }}
|
|
94
|
+
GH_REPO: ${{ github.repository }}
|
|
95
|
+
run: |
|
|
96
|
+
if gh release view "$GITHUB_REF_NAME" --repo "$GH_REPO" >/dev/null 2>&1; then
|
|
97
|
+
gh release upload "$GITHUB_REF_NAME" dist/* sbom.cdx.json provenance.intoto.jsonl --repo "$GH_REPO" --clobber
|
|
98
|
+
else
|
|
99
|
+
gh release create "$GITHUB_REF_NAME" dist/* sbom.cdx.json provenance.intoto.jsonl \
|
|
100
|
+
--repo "$GH_REPO" \
|
|
101
|
+
--verify-tag \
|
|
102
|
+
--title "$GITHUB_REF_NAME" \
|
|
103
|
+
--notes "Release $GITHUB_REF_NAME"
|
|
104
|
+
fi
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Scorecard supply-chain security
|
|
2
|
+
|
|
3
|
+
# OpenSSF Scorecard — weekly supply-chain posture check.
|
|
4
|
+
# Target score >= 7.0 (see sdlc/supply-chain.md). Results are published to the
|
|
5
|
+
# repo Security tab (code scanning) and to the public OpenSSF results store; a
|
|
6
|
+
# dip below target is triaged into the risk register.
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
# Re-run when branch-protection settings change (a Scorecard input).
|
|
10
|
+
branch_protection_rule:
|
|
11
|
+
schedule:
|
|
12
|
+
- cron: "40 6 * * 1" # Mondays 06:40 UTC
|
|
13
|
+
push:
|
|
14
|
+
branches: ["main"]
|
|
15
|
+
|
|
16
|
+
# Least privilege by default; the analysis job elevates only what it needs.
|
|
17
|
+
permissions: read-all
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
analysis:
|
|
21
|
+
name: Scorecard analysis
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
id-token: write # OIDC for publish_results to the OpenSSF store
|
|
25
|
+
steps:
|
|
26
|
+
- name: Checkout code
|
|
27
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
28
|
+
with:
|
|
29
|
+
persist-credentials: false
|
|
30
|
+
|
|
31
|
+
- name: Run Scorecard analysis
|
|
32
|
+
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
|
33
|
+
with:
|
|
34
|
+
results_file: results.sarif
|
|
35
|
+
results_format: sarif
|
|
36
|
+
# The default GITHUB_TOKEN cannot read branch-protection rules, so the
|
|
37
|
+
# Branch-Protection check errors. A fine-grained PAT (admin:read on this
|
|
38
|
+
# repo) stored as SCORECARD_TOKEN lets that check score; falls back to
|
|
39
|
+
# the default token when the secret is absent (non-breaking).
|
|
40
|
+
repo_token: ${{ secrets.SCORECARD_TOKEN || github.token }}
|
|
41
|
+
# Publish to the public OpenSSF store so the score is externally
|
|
42
|
+
# verifiable and a Scorecard badge can be rendered.
|
|
43
|
+
publish_results: true
|
|
44
|
+
|
|
45
|
+
# SARIF is published to the OpenSSF store (publish_results) and rendered via
|
|
46
|
+
# the README badge; it is deliberately NOT uploaded to GitHub code scanning,
|
|
47
|
+
# which would flood the Security tab with posture-check findings already
|
|
48
|
+
# tracked by the score. Kept as a build artifact for debugging only.
|
|
49
|
+
- name: Upload SARIF artifact
|
|
50
|
+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
51
|
+
with:
|
|
52
|
+
name: scorecard-results
|
|
53
|
+
path: results.sarif
|
|
54
|
+
retention-days: 5
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
This document describes the high-level design of `presidio-deident`: its
|
|
4
|
+
components, how data flows through them, and the trust boundaries the project is
|
|
5
|
+
built to enforce. For the security requirements and threat model that motivate
|
|
6
|
+
this design, see [SECURITY.md](SECURITY.md) and the assurance case in
|
|
7
|
+
[ASSURANCE.md](ASSURANCE.md).
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
`presidio-deident` is a command-line tool and Python package with two users. A **releaser**
|
|
12
|
+
(a company or data broker) runs it in its own environment to de-identify a tabular dataset
|
|
13
|
+
under a written policy and to sign a release record. A **buyer** (typically an AI lab) runs
|
|
14
|
+
it offline to verify that record against the files it received. It is stateless between
|
|
15
|
+
runs, makes **no network calls**, and has no hosted mode. Its design stance: document what was
|
|
16
|
+
done, in counts and hashes only, and fail closed on anything it cannot do faithfully.
|
|
17
|
+
|
|
18
|
+
## Components
|
|
19
|
+
|
|
20
|
+
| Component | Responsibility |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `policy.py` | Parse and validate the TOML policy (fail closed on unknown keys, missing columns, PII in free text) |
|
|
23
|
+
| `tables.py` | Read and write CSV, JSONL and Parquet; refuse input it cannot write back faithfully |
|
|
24
|
+
| `_detect.py` | Structural PII detector (`presidio-regex-pii/1`): normalisation, decoding, six patterns |
|
|
25
|
+
| `generalise.py` | Coarsen dates, prefixes and integer bins |
|
|
26
|
+
| `release.py` | The run: transforms, suppression lists, pseudonyms, residual scan, atomic output, record, signing |
|
|
27
|
+
| `risk.py` | Quasi-identifier equivalence classes (`min_k`, uniqueness, `min_l`) as integers |
|
|
28
|
+
| `verify.py` | Offline verification of one release and of a re-release chain |
|
|
29
|
+
| `inspect.py` | Column profile and suggested actions, counts only |
|
|
30
|
+
| `croissant.py` | A minimal Croissant pointer to a verified release |
|
|
31
|
+
| `cli.py` | The `deident` command; exit codes 0/1/2 |
|
|
32
|
+
|
|
33
|
+
Signing, canonical hashing and trust stores come from `presidio-evidence`; nothing
|
|
34
|
+
cryptographic is implemented here.
|
|
35
|
+
|
|
36
|
+
## Data / processing flow
|
|
37
|
+
|
|
38
|
+
**Run:** load and validate the policy → open the input → for each row: apply suppression lists
|
|
39
|
+
(drop the row on a match), then each column's action (drop, keep with residual scan,
|
|
40
|
+
pseudonymise, scrub_text, generalise) → write to `<out>.partial` (files `0600`, directory
|
|
41
|
+
`0700`) → compute the risk report and apply the `require_min_k` gate → hash every file →
|
|
42
|
+
build the record → sign it as an `evidence-ref@3` envelope → rename `<out>.partial` to
|
|
43
|
+
`<out>`. Any error at any step stops the run and leaves no release directory. The order
|
|
44
|
+
"suppress, then transform" is part of the contract: suppression matches the original values.
|
|
45
|
+
|
|
46
|
+
**Verify:** read the record and the envelope (size-bounded) → check the record's fields →
|
|
47
|
+
verify the signature against the trust store → bind the unsigned envelope fields to the
|
|
48
|
+
signed record → check the row arithmetic → hash every listed file. Every check is evaluated
|
|
49
|
+
and reported; the release verifies only if all pass. See `docs/SPEC.md` section 4.
|
|
50
|
+
|
|
51
|
+
## Trust boundaries
|
|
52
|
+
|
|
53
|
+
1. **Input data → the run.** The dataset is untrusted and may be malformed. Readers refuse what
|
|
54
|
+
they cannot round-trip (bad UTF-8, lone surrogates, NaN, nested values, malformed CSV).
|
|
55
|
+
Errors name the row and column, never the value.
|
|
56
|
+
2. **Policy and lists → the run.** Written by the releaser, but validated strictly; free text
|
|
57
|
+
that goes into the record is checked for PII.
|
|
58
|
+
3. **The run → the release directory.** The only data leaving the run. The record and envelope
|
|
59
|
+
carry counts and hashes only; tests assert that no input value appears in them.
|
|
60
|
+
4. **Keys.** The signing and pseudonym keys stay in the releaser's environment, as `0600`
|
|
61
|
+
files; nothing outputs them.
|
|
62
|
+
5. **Release directory → verify.** Everything the buyer receives is untrusted: file names are
|
|
63
|
+
plain basenames, symlinks are refused, JSON is size-bounded, and only the trust store
|
|
64
|
+
(obtained out of band) is trusted.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Security Assurance Case
|
|
2
|
+
|
|
3
|
+
This document is the assurance case for `presidio-deident`: an explicit argument
|
|
4
|
+
for why the project's security requirements are met. It has four parts, as
|
|
5
|
+
required by the OpenSSF Best Practices silver criterion `assurance_case`:
|
|
6
|
+
|
|
7
|
+
1. the threat model,
|
|
8
|
+
2. the trust boundaries,
|
|
9
|
+
3. the argument that secure design principles are applied, and
|
|
10
|
+
4. the argument that common implementation weaknesses are countered.
|
|
11
|
+
|
|
12
|
+
It is a summary that links to the authoritative detail in
|
|
13
|
+
[`SECURITY.md`](SECURITY.md) (controls, known limits, reporting) and
|
|
14
|
+
[`ARCHITECTURE.md`](ARCHITECTURE.md) (components, flow, boundaries) for
|
|
15
|
+
`presidio-v/presidio-deident`.
|
|
16
|
+
|
|
17
|
+
## 1. Threat model
|
|
18
|
+
|
|
19
|
+
The full statement of what a record proves and does not is in
|
|
20
|
+
[`docs/THREAT-MODEL.md`](docs/THREAT-MODEL.md). In short:
|
|
21
|
+
|
|
22
|
+
| Threat | Control |
|
|
23
|
+
|---|---|
|
|
24
|
+
| Released files swapped or edited | per-file SHA-256 and size in the signed record |
|
|
25
|
+
| Record edited after signing | Ed25519 signature over the canonical record hash (`evidence-ref@3`) |
|
|
26
|
+
| Unsigned envelope fields edited (dates, versions) | verify requires them to equal the signed record |
|
|
27
|
+
| A record presented for another dataset | `@3` subject binding to `dataset-release` and `dataset_id` |
|
|
28
|
+
| Path traversal or symlinks in a crafted release | plain basenames only; symlinks refused |
|
|
29
|
+
| Resource exhaustion on verify | size-bounded JSON, recursion guard; linear-time detector patterns |
|
|
30
|
+
| Input values leaking into evidence | counts and hashes only; tests assert no value appears in any output |
|
|
31
|
+
| A failed run mistaken for a release | atomic `<out>.partial` rename after signing |
|
|
32
|
+
|
|
33
|
+
Out of scope: the releaser's honesty (it holds the key and the code), the truth of the
|
|
34
|
+
source and the rights declarations, detector recall (structural patterns only), and whether
|
|
35
|
+
the output is personal data for a given recipient.
|
|
36
|
+
|
|
37
|
+
## 2. Trust boundaries
|
|
38
|
+
|
|
39
|
+
Same boundaries as [ARCHITECTURE.md](ARCHITECTURE.md#trust-boundaries): input data → run,
|
|
40
|
+
policy and lists → run, run → release directory, keys, release directory → verify. At each,
|
|
41
|
+
untrusted data is validated before use and the run or the check fails closed.
|
|
42
|
+
|
|
43
|
+
## 3. Secure design principles applied
|
|
44
|
+
|
|
45
|
+
- **Fail closed.** An unknown policy key, a column without a policy entry, a value that cannot be
|
|
46
|
+
written faithfully, a leftover `.partial`: each stops the run. A release verifies only if every
|
|
47
|
+
check passes; malformed input is a failed check, never a pass.
|
|
48
|
+
- **Least privilege and least data.** No network access, no hosted mode, and the record holds no
|
|
49
|
+
values. Output files are `0600` in a `0700` directory.
|
|
50
|
+
- **Complete mediation.** Every listed file is re-hashed on every verify; nothing is cached.
|
|
51
|
+
- **Defense in depth.** The signature covers the record; the record covers the files; the
|
|
52
|
+
unsigned envelope fields are bound to the record; history checks bind releases together.
|
|
53
|
+
- **Economy of mechanism.** Ed25519, SHA-256 and HMAC-SHA256 through `presidio-evidence` and
|
|
54
|
+
`cryptography`; no bespoke cryptography. One base dependency.
|
|
55
|
+
|
|
56
|
+
## 4. Common implementation weaknesses countered
|
|
57
|
+
|
|
58
|
+
| Weakness class | How it is countered |
|
|
59
|
+
|---|---|
|
|
60
|
+
| Path traversal (CWE-22) | output names must be plain basenames and not the release files; symlinks refused |
|
|
61
|
+
| Uncontrolled resource consumption (CWE-400, CWE-1333) | size-bounded JSON; recursion errors caught; the email pattern anchored to stay linear |
|
|
62
|
+
| Improper input validation (CWE-20) | strict CSV/JSONL/Parquet readers; identifiers and timestamps matched in full |
|
|
63
|
+
| Information exposure (CWE-200, CWE-532) | errors and outputs name rows, columns and counts, never values |
|
|
64
|
+
| Insecure randomness (CWE-330) | keys from `secrets` / `cryptography`; `S311` allowed only in tests |
|
|
65
|
+
| Hard-coded secrets (CWE-798) | keys are files, never in code; `S105`/`S106` enforced outside tests |
|
|
66
|
+
| Integrity of data (CWE-345, CWE-354) | signature over the canonical record; per-file hashes |
|
|
67
|
+
|
|
68
|
+
Static analysis: CodeQL and OpenSSF Scorecard on pushes to `main` and on pull requests, ruff with the bandit-derived
|
|
69
|
+
`S` rules in CI, `pip-audit` for dependencies, and Atheris fuzzing of the readers and the
|
|
70
|
+
verifier. Two internal review passes were done during development (CHANGELOG 0.2.0 and 0.5.0);
|
|
71
|
+
there has been no external review or security audit yet.
|
|
72
|
+
|
|
73
|
+
## Conclusion
|
|
74
|
+
|
|
75
|
+
The threats above are each matched to a control; the controls sit at explicit
|
|
76
|
+
trust boundaries; the design follows fail-safe, least-privilege, complete-
|
|
77
|
+
mediation, defense-in-depth, and economy-of-mechanism principles; and the common
|
|
78
|
+
implementation weakness classes are countered by design and checked by automated
|
|
79
|
+
analysis. The project's stated security requirements are therefore met, subject
|
|
80
|
+
to the documented out-of-scope assumptions.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.7.0] — 2026-11-08
|
|
4
|
+
|
|
5
|
+
The first version prepared for publication: a public contract a lab can script against.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `docs/SPEC.md`: the `dataset-release@1` record, the envelope, and the verification algorithm,
|
|
10
|
+
enough to write an independent verifier. A test keeps its key table in step with the schema.
|
|
11
|
+
- `SEMVER.md`: what is public and how it may change; `docs/KEYS.md` (trust-store delivery,
|
|
12
|
+
rotation, what is not supported); `docs/THREAT-MODEL.md` (what a record proves and does not).
|
|
13
|
+
- `examples/sample-release/` and `examples/sample-trust.json`: a signed release of the synthetic
|
|
14
|
+
example, verified by a test as a compatibility vector.
|
|
15
|
+
- `verify --json` now carries `result` (`presidio-deident/verify-result@1`), `schema`,
|
|
16
|
+
`release_id` (both `null` unless verified) and `verifier` versions. Check names are frozen by
|
|
17
|
+
a test.
|
|
18
|
+
- A history test for signing-key rotation (two keys for one signer in the trust store).
|
|
19
|
+
- Test vectors in the package (`presidio_deident/vectors/`): one release that must verify and
|
|
20
|
+
five that must fail (untrusted signer, tampered file, edited envelope, edited record, float
|
|
21
|
+
in the record), each with the checks that must fail. Append-only (ADR-0009).
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- `dataset-release@1` is no longer called a draft: it is final from the first public
|
|
26
|
+
release, and a change becomes `@2` while `@1` records keep verifying (ADR-0009).
|
|
27
|
+
- Check names are frozen; their order is not.
|
|
28
|
+
- **Record:** the detector is recorded as `presidio-regex-pii/1` instead of
|
|
29
|
+
`x402-regex (vendored)`, a stable id that does not name where the code came from (ADR-0009).
|
|
30
|
+
- `keygen` makes the pseudonym key from 32 random bytes directly, not from an Ed25519 key
|
|
31
|
+
generator.
|
|
32
|
+
- Package metadata: Alpha status and project URLs.
|
|
33
|
+
|
|
34
|
+
### Added (repository)
|
|
35
|
+
|
|
36
|
+
- The OpenSSF silver governance set: `GOVERNANCE.md`, `CODE_OF_CONDUCT.md`,
|
|
37
|
+
`CONTRIBUTING.md`, `ARCHITECTURE.md`, `ASSURANCE.md`, `allowed_signers`, CODEOWNERS,
|
|
38
|
+
Dependabot, CodeQL and bandit, Scorecard, and a Trusted Publishing `publish.yml` with an SBOM
|
|
39
|
+
and build provenance.
|
|
40
|
+
|
|
41
|
+
## [0.6.0] — 2026-11-08
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- `format = "ca-drop"` for California DROP deletion lists: one DROP CSV (`Id,Hash`, SHA-256
|
|
46
|
+
in Base64) per suppression entry. `normalise = ["drop-email"]` or `["drop-phone"]` applies
|
|
47
|
+
DROP's standardisation. Tested against the official CalPrivacy vectors. A list with
|
|
48
|
+
another header, such as the `Removed` file, is refused. Composite NDZ and NameVIN lists are
|
|
49
|
+
not supported yet (ADR-0006).
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- Decisions recorded in ADR-0002 to ADR-0008.
|
|
54
|
+
|
|
55
|
+
## [0.5.0] — 2026-11-08
|
|
56
|
+
|
|
57
|
+
Second code review, at v0.3.1.
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- `verify` now checks:
|
|
62
|
+
- that `dataset_id`, `recipient` and `signer` are identifiers;
|
|
63
|
+
- that `released_at` is a UTC timestamp (before, `history` ordered free text);
|
|
64
|
+
- that row counts are integers, not booleans;
|
|
65
|
+
- that each output file is listed once and is not named after the release files.
|
|
66
|
+
- An unreadable data file is a failed check, not a traceback.
|
|
67
|
+
- `history` and `croissant` no longer crash on a record without a valid recipient.
|
|
68
|
+
- `run --parent` refuses a release to another recipient.
|
|
69
|
+
- File-system errors on any command are reported as `error:` with exit code 2.
|
|
70
|
+
- `scrub_text` writes a value with no finding unchanged. Before, it wrote the
|
|
71
|
+
Unicode-normalised form and counted it as changed.
|
|
72
|
+
- Generalised dates and integer bins accept ASCII digits only.
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
|
|
76
|
+
- **Record (draft schema):** a kept column's residual findings now use the same
|
|
77
|
+
`entities` key as `scrub_text`; the column's `action` tells them apart.
|
|
78
|
+
`risk.min_l_cap` records the cap on `min_l`.
|
|
79
|
+
- A leftover `<out>.partial` is refused instead of deleted.
|
|
80
|
+
- `History` reuses `Verification`, and `REF_KEYS` comes from presidio-evidence.
|
|
81
|
+
|
|
82
|
+
## [0.4.0] — 2026-11-08
|
|
83
|
+
|
|
84
|
+
### Added
|
|
85
|
+
|
|
86
|
+
- Parquet input and output through the optional `[parquet]` extra (pyarrow):
|
|
87
|
+
- streamed in batches;
|
|
88
|
+
- kept columns keep their type, and changed columns become strings;
|
|
89
|
+
- nested, binary and decimal columns are refused;
|
|
90
|
+
- output is reproducible for the same pyarrow version, which the record names.
|
|
91
|
+
- `inspect`, `risk` and `run` share one table layer for all three formats.
|
|
92
|
+
|
|
93
|
+
## [0.3.1] — 2026-11-08
|
|
94
|
+
|
|
95
|
+
### Fixed
|
|
96
|
+
|
|
97
|
+
- `verify` now binds the envelope fields that `evidence-ref@3` does not sign (`claimed_at`,
|
|
98
|
+
`source`, `source_version`, `generated_at`) to the signed record, and refuses extra keys.
|
|
99
|
+
Before, an edited `claimed_at` still verified. Found by the new mutation tests.
|
|
100
|
+
|
|
101
|
+
### Added
|
|
102
|
+
|
|
103
|
+
- Seeded mutation tests for verify, the readers and the policy parser.
|
|
104
|
+
- Atheris harnesses (`fuzz/`) and a CI fuzz job.
|
|
105
|
+
- A clean-install check: the wheel installs into a fresh Python 3.11 venv with presidio-evidence
|
|
106
|
+
and cryptography only, and the worked example runs and verifies.
|
|
107
|
+
|
|
108
|
+
## [0.3.0] — 2026-11-08
|
|
109
|
+
|
|
110
|
+
### Added
|
|
111
|
+
|
|
112
|
+
- `deident run --parent DIR`: the earlier release's record hash goes into `parents`. A release
|
|
113
|
+
of another dataset is refused.
|
|
114
|
+
- `deident history DIR...`: verifies releases of one dataset to one recipient as a chain:
|
|
115
|
+
- each release verifies;
|
|
116
|
+
- there is one root;
|
|
117
|
+
- every parent is in the set and was released earlier;
|
|
118
|
+
- `--records-only` skips the old data files.
|
|
119
|
+
|
|
120
|
+
## [0.2.0] — 2026-11-08
|
|
121
|
+
|
|
122
|
+
### Added
|
|
123
|
+
|
|
124
|
+
- `generalise` action: dates to year or month, string prefixes, integer bins with bottom and
|
|
125
|
+
top coding.
|
|
126
|
+
- `[risk]` policy section:
|
|
127
|
+
- quasi-identifier equivalence classes over the output, recorded as integers (classes,
|
|
128
|
+
`min_k`, unique rows, rows by class size, `min_l` per sensitive column);
|
|
129
|
+
- an optional `require_min_k` gate that stops the run.
|
|
130
|
+
- `deident risk`: the same report for any CSV or JSONL file.
|
|
131
|
+
|
|
132
|
+
### Fixed (from the v0.1 code review)
|
|
133
|
+
|
|
134
|
+
- The email pattern was quadratic on long runs of local-part characters (40k characters:
|
|
135
|
+
seconds; a 1 MB cell: hours). A lookbehind now anchors it at run starts; matches are
|
|
136
|
+
unchanged. **The same pattern is in presidio-hardened-x402** (see ADR-0003).
|
|
137
|
+
- `verify` fails cleanly, without a traceback, on:
|
|
138
|
+
- non-integer row counts;
|
|
139
|
+
- deeply nested JSON;
|
|
140
|
+
- a record without a matching `release_id`, which is now a verified check.
|
|
141
|
+
- `run` refuses input it cannot write faithfully, naming the line and field and never the
|
|
142
|
+
value:
|
|
143
|
+
- JSONL lone surrogates, `NaN`, `Infinity` and out-of-range numbers;
|
|
144
|
+
- non-UTF-8 input.
|
|
145
|
+
- Identifiers, timestamps and `parents` are matched in full; a trailing newline no longer
|
|
146
|
+
passes.
|
|
147
|
+
- `croissant` reports a bad trust store as an error (exit 2).
|
|
148
|
+
|
|
149
|
+
## [0.1.0] — 2026-11-08
|
|
150
|
+
|
|
151
|
+
### Added
|
|
152
|
+
|
|
153
|
+
- `deident inspect`: columns, missing values, detected PII types and suggested actions,
|
|
154
|
+
counts only.
|
|
155
|
+
- `deident policy-init`: a TOML policy skeleton listing every column.
|
|
156
|
+
- `deident keygen`: an Ed25519 signing key and a pseudonym key, both `0600`, plus the trust
|
|
157
|
+
store to hand to the buyer.
|
|
158
|
+
- `deident run`: the column actions `drop`, `keep` (with a residual PII scan),
|
|
159
|
+
`pseudonymise` (HMAC-SHA256 per recipient) and `scrub_text`, plus suppression lists in
|
|
160
|
+
plain or SHA-256 format. Writes the data file, `release.json` (the record) and
|
|
161
|
+
`release.evidence.json` (an `evidence-ref@3` envelope).
|
|
162
|
+
- `deident verify`: offline, fail-closed checks of the signature, subject binding, record
|
|
163
|
+
hash, row arithmetic and file hashes, with a `--json` output.
|
|
164
|
+
- `deident croissant`: a minimal Croissant file pointing at a verified release by its record
|
|
165
|
+
hash.
|
|
166
|
+
- A structural PII detector vendored from presidio-hardened-x402 0.14.0, with a parity test.
|
|
167
|
+
- Draft JSON Schema `schemas/dataset-release.v1.json`.
|