sangop 2026.11.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.
- sangop-2026.11.0/.gitattributes +5 -0
- sangop-2026.11.0/.github/ISSUE_TEMPLATE/bug_report.md +15 -0
- sangop-2026.11.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- sangop-2026.11.0/.github/ISSUE_TEMPLATE/false_positive_or_miss.md +17 -0
- sangop-2026.11.0/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- sangop-2026.11.0/.github/REPO_SETUP.md +47 -0
- sangop-2026.11.0/.github/dependabot.yml +10 -0
- sangop-2026.11.0/.github/workflows/ci.yml +41 -0
- sangop-2026.11.0/.github/workflows/release.yml +72 -0
- sangop-2026.11.0/.gitignore +21 -0
- sangop-2026.11.0/CHANGELOG.md +63 -0
- sangop-2026.11.0/CODE_OF_CONDUCT.md +31 -0
- sangop-2026.11.0/CONTRIBUTING.md +39 -0
- sangop-2026.11.0/LICENSE +177 -0
- sangop-2026.11.0/NOTICE +6 -0
- sangop-2026.11.0/PKG-INFO +612 -0
- sangop-2026.11.0/README.md +586 -0
- sangop-2026.11.0/SECURITY.md +29 -0
- sangop-2026.11.0/SHARED_RESPONSIBILITY.md +47 -0
- sangop-2026.11.0/TRADEMARKS.md +33 -0
- sangop-2026.11.0/bench/bench.py +59 -0
- sangop-2026.11.0/bench/india_pii/README.md +64 -0
- sangop-2026.11.0/bench/india_pii/dataset_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/holdout2_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/holdout3_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/holdout4_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/holdout5_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/holdout6_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/holdout7_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/holdout_v0_1.sha256 +1 -0
- sangop-2026.11.0/bench/india_pii/score.py +186 -0
- sangop-2026.11.0/docs/CERTIN_CIAD_2026_0049_MAPPING.md +38 -0
- sangop-2026.11.0/docs/CERT_IN_AGENT_LOGGING.md +46 -0
- sangop-2026.11.0/docs/LICENSES_THIRD_PARTY.md +105 -0
- sangop-2026.11.0/docs/MCP_COMPAT.md +42 -0
- sangop-2026.11.0/examples/demo_server.py +70 -0
- sangop-2026.11.0/examples/fastmcp_guarded_tool.py +20 -0
- sangop-2026.11.0/examples/ledger_verify.py +16 -0
- sangop-2026.11.0/examples/quickstart/claude_desktop_config.example.json +9 -0
- sangop-2026.11.0/examples/quickstart/client_demo.py +89 -0
- sangop-2026.11.0/examples/quickstart/ladder.md +49 -0
- sangop-2026.11.0/examples/quickstart/server.py +16 -0
- sangop-2026.11.0/examples/quickstart/tools.py +105 -0
- sangop-2026.11.0/examples/sql_guard_only.py +13 -0
- sangop-2026.11.0/pyproject.toml +41 -0
- sangop-2026.11.0/scripts/prepublish_check.py +291 -0
- sangop-2026.11.0/src/sangop/__init__.py +23 -0
- sangop-2026.11.0/src/sangop/audit.py +234 -0
- sangop-2026.11.0/src/sangop/cli.py +173 -0
- sangop-2026.11.0/src/sangop/detectors.py +361 -0
- sangop-2026.11.0/src/sangop/example_policy/purpose.yaml +14 -0
- sangop-2026.11.0/src/sangop/example_policy/retention.yaml +17 -0
- sangop-2026.11.0/src/sangop/example_policy/safeguards.yaml +25 -0
- sangop-2026.11.0/src/sangop/guard.py +464 -0
- sangop-2026.11.0/src/sangop/media.py +282 -0
- sangop-2026.11.0/src/sangop/plugins.py +168 -0
- sangop-2026.11.0/src/sangop/policy.py +251 -0
- sangop-2026.11.0/src/sangop/sqlguard.py +1210 -0
- sangop-2026.11.0/src/sangop/tokenizer.py +663 -0
- sangop-2026.11.0/tests/compat_server.py +16 -0
- sangop-2026.11.0/tests/conftest.py +31 -0
- sangop-2026.11.0/tests/test_a4_1_scalar_subquery_aggregate.py +98 -0
- sangop-2026.11.0/tests/test_allowlist_2026_11_15.py +321 -0
- sangop-2026.11.0/tests/test_cli_and_fastmcp.py +45 -0
- sangop-2026.11.0/tests/test_dependency_floor.py +54 -0
- sangop-2026.11.0/tests/test_detectors.py +55 -0
- sangop-2026.11.0/tests/test_detectors_v011.py +112 -0
- sangop-2026.11.0/tests/test_detectors_v012.py +99 -0
- sangop-2026.11.0/tests/test_examples_run.py +161 -0
- sangop-2026.11.0/tests/test_find_all_speed.py +40 -0
- sangop-2026.11.0/tests/test_guard_and_ledger.py +102 -0
- sangop-2026.11.0/tests/test_hardening_2026_11.py +362 -0
- sangop-2026.11.0/tests/test_keygen.py +115 -0
- sangop-2026.11.0/tests/test_m2_m5_regressions.py +106 -0
- sangop-2026.11.0/tests/test_mcp_compat.py +306 -0
- sangop-2026.11.0/tests/test_mcp_sdk_server_compat.py +120 -0
- sangop-2026.11.0/tests/test_media_guard.py +451 -0
- sangop-2026.11.0/tests/test_media_m0_followups.py +300 -0
- sangop-2026.11.0/tests/test_nested_lazy_iterables.py +196 -0
- sangop-2026.11.0/tests/test_no_network.py +31 -0
- sangop-2026.11.0/tests/test_open_core_plugins.py +200 -0
- sangop-2026.11.0/tests/test_package_contents.py +55 -0
- sangop-2026.11.0/tests/test_pem_truncated.py +174 -0
- sangop-2026.11.0/tests/test_policy.py +179 -0
- sangop-2026.11.0/tests/test_prepublish.py +255 -0
- sangop-2026.11.0/tests/test_quickstart.py +105 -0
- sangop-2026.11.0/tests/test_readme_example.py +45 -0
- sangop-2026.11.0/tests/test_reaudit_regressions.py +372 -0
- sangop-2026.11.0/tests/test_release_workflow.py +131 -0
- sangop-2026.11.0/tests/test_security_regressions.py +428 -0
- sangop-2026.11.0/tests/test_shield_2026_11_14.py +237 -0
- sangop-2026.11.0/tests/test_shield_2026_11_14_28b.py +155 -0
- sangop-2026.11.0/tests/test_shield_2026_11_14_run2.py +244 -0
- sangop-2026.11.0/tests/test_shield_2026_11_14_run3.py +176 -0
- sangop-2026.11.0/tests/test_shield_2026_11_15_run4.py +196 -0
- sangop-2026.11.0/tests/test_shield_2026_11_15_run5.py +294 -0
- sangop-2026.11.0/tests/test_shield_2026_11_15_run6.py +110 -0
- sangop-2026.11.0/tests/test_sql_families_2026_11_14.py +140 -0
- sangop-2026.11.0/tests/test_sqlguard.py +51 -0
- sangop-2026.11.0/tests/test_text_query_rule_2026_11_14.py +228 -0
- sangop-2026.11.0/tests/test_tokenizer.py +44 -0
- sangop-2026.11.0/tests/test_version.py +63 -0
- sangop-2026.11.0/tests/test_weak_ledger_key.py +53 -0
- sangop-2026.11.0/tests/test_written_names_2026_11_15.py +68 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something does not work as documented
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
> **Do NOT paste real personal data, real credentials or production logs.** Use invented examples only. If you cannot reproduce it with invented data, describe the shape of the data instead (for example "12 digits, grouped 4-4-4").
|
|
8
|
+
|
|
9
|
+
**What happened**
|
|
10
|
+
|
|
11
|
+
**What you expected**
|
|
12
|
+
|
|
13
|
+
**Minimal example (invented values only)**
|
|
14
|
+
|
|
15
|
+
**Versions** (`sangop version`, Python, FastMCP/mcp, OS)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: False alarm or missed value
|
|
3
|
+
about: Sangop masked something that is not personal data, or did not mask something it should have
|
|
4
|
+
labels: detection
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
> **Do NOT paste real personal data or secrets.** Replace every real value with an invented one that has the same *shape* (same length, separators, and checksum validity where you can). If you are unsure whether a value is safe to share, do not share it.
|
|
8
|
+
|
|
9
|
+
**Which kind** (Aadhaar / PAN / GSTIN / IFSC / phone / UPI / card / e-mail / secret / other), and the label you saw
|
|
10
|
+
|
|
11
|
+
**Invented example text** (a sentence or two around the value)
|
|
12
|
+
|
|
13
|
+
**Result you saw** and **result you expected**
|
|
14
|
+
|
|
15
|
+
**Which rule set was active?** (the `"rules"` value printed by `sangop selftest`)
|
|
16
|
+
|
|
17
|
+
Known limits are listed in the README; a report that matches one of them is still useful as evidence of how often it happens.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- External pull requests are not being accepted yet (see CONTRIBUTING.md). This template is for the maintainer's own changes and for when that changes. -->
|
|
2
|
+
|
|
3
|
+
## What and why
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] Commits are signed off (`git commit -s`, DCO)
|
|
8
|
+
- [ ] Tests added or updated; `pytest` passes
|
|
9
|
+
- [ ] `python scripts/prepublish_check.py` shows no FAIL
|
|
10
|
+
- [ ] Synthetic data only; no network calls or telemetry added
|
|
11
|
+
- [ ] README "Known limits" updated if behaviour changed (include any recall or precision cost)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# GitHub repository setup (draft, applied by hand by the maintainer)
|
|
2
|
+
|
|
3
|
+
Nothing here is active. The maintainer copies these values into the GitHub settings of the public repository.
|
|
4
|
+
|
|
5
|
+
## About box
|
|
6
|
+
|
|
7
|
+
- **Description** (119 characters): `Local guard for AI agent tools: masks Indian personal data and secrets, blocks unsafe SQL, keeps a verifiable audit log`
|
|
8
|
+
- **Website:** leave empty until the project site exists.
|
|
9
|
+
- **Topics:** `mcp`, `fastmcp`, `pii`, `dpdp`, `india`, `aadhaar`, `llm-security`, `ai-agents`, `data-masking`, `audit-log`
|
|
10
|
+
|
|
11
|
+
## Social preview image (1280 x 640, made later by the maintainer; no third-party logos)
|
|
12
|
+
|
|
13
|
+
- Line 1: **Sangop**
|
|
14
|
+
- Line 2: Local guard for AI agent tools
|
|
15
|
+
- Line 3: masks Indian personal data · blocks unsafe SQL · verifiable audit log
|
|
16
|
+
- Small footer: Apache-2.0 · Python 3.10+ · runs inside your process, no network
|
|
17
|
+
|
|
18
|
+
## Discussions: three categories
|
|
19
|
+
|
|
20
|
+
1. **Q&A** (answers can be marked): installing, configuring `@guard`, reading the ledger.
|
|
21
|
+
2. **False positives and misses** (open-ended): a value that was masked but should not be, or the other way round.
|
|
22
|
+
Synthetic examples only; never paste real personal data or real keys.
|
|
23
|
+
3. **Ideas** (open-ended): new secret formats, examples, docs. Not for security issues: those go through
|
|
24
|
+
`SECURITY.md` (private report).
|
|
25
|
+
|
|
26
|
+
## Security settings (turn on before the repository becomes public)
|
|
27
|
+
|
|
28
|
+
In the repository's **Settings**, in the "Security" part of the sidebar (GitHub calls the page "Advanced Security";
|
|
29
|
+
some views say "Security and quality"):
|
|
30
|
+
|
|
31
|
+
1. **Private vulnerability reporting:** Enable. `SECURITY.md` and the issue form's "Security issue (private)" link
|
|
32
|
+
send reporters there.
|
|
33
|
+
2. **Secret scanning** (Secret Protection; free for public repositories): Enable.
|
|
34
|
+
3. **Push protection** (under Secret Protection): Enable, so a push that contains a recognised secret is blocked.
|
|
35
|
+
|
|
36
|
+
Also check: **Dependabot alerts** on (public repositories have them by default).
|
|
37
|
+
|
|
38
|
+
## Ideas for later (Discussions)
|
|
39
|
+
|
|
40
|
+
External pull requests are not accepted yet (`CONTRIBUTING.md`), so these are not issues for others to take. The
|
|
41
|
+
maintainer may post them under Discussions > Ideas to see which ones people want:
|
|
42
|
+
|
|
43
|
+
1. Recognise Hugging Face access tokens (`hf_...`) as a secret.
|
|
44
|
+
2. Recognise Stripe secret keys (`sk_live_...`, `rk_live_...`); the README lists them as not recognised today.
|
|
45
|
+
3. An example: a guarded tool over a read-only SQLite database (20 lines or fewer).
|
|
46
|
+
4. Docs: a table of the SQL guard's block messages, what each means and how to fix the query or the policy.
|
|
47
|
+
5. `sangop sql-check --json`: machine-readable output for use in CI scripts.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Once a week, opens pull requests for newer versions of the Python dependencies in pyproject.toml.
|
|
2
|
+
# Nothing is merged automatically; every update goes through CI and a maintainer's review.
|
|
3
|
+
version: 2
|
|
4
|
+
updates:
|
|
5
|
+
- package-ecosystem: "pip"
|
|
6
|
+
directory: "/"
|
|
7
|
+
schedule:
|
|
8
|
+
interval: "weekly"
|
|
9
|
+
open-pull-requests-limit: 5
|
|
10
|
+
labels: ["dependencies"]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Runs the test suite, the self-test and the pre-publish check on every push to main and on every pull request,
|
|
2
|
+
# on Linux and Windows with Python 3.10 to 3.13 (Windows added 13 Nov 2026 after the first Windows run found four
|
|
3
|
+
# test/tooling gaps; see CHANGELOG). It uses no secrets and no network service except the package index.
|
|
4
|
+
name: ci
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main]
|
|
9
|
+
pull_request:
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: ci-${{ github.ref }}
|
|
16
|
+
cancel-in-progress: true
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
test:
|
|
20
|
+
runs-on: ${{ matrix.os }}
|
|
21
|
+
timeout-minutes: 30
|
|
22
|
+
strategy:
|
|
23
|
+
fail-fast: false
|
|
24
|
+
matrix:
|
|
25
|
+
os: [ubuntu-latest, windows-latest]
|
|
26
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
- name: Install
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
python -m pip install -e ".[dev]"
|
|
36
|
+
- name: Tests (the machine-dependent timing tests marked "slow" are skipped by default)
|
|
37
|
+
run: python -m pytest -q
|
|
38
|
+
- name: Self-test
|
|
39
|
+
run: sangop selftest
|
|
40
|
+
- name: Pre-publish check
|
|
41
|
+
run: python scripts/prepublish_check.py
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Active in the public repository: the public export publishes this file as .github/workflows/release.yml
|
|
2
|
+
# (D-122, 15 Nov 2026). In the private repository it keeps the .disabled ending and never runs.
|
|
3
|
+
# Builds from the public repository it runs in (never from a private copy) and refuses packages that carry a
|
|
4
|
+
# private file. Publishes to PyPI with Trusted Publishing (OpenID Connect): no PyPI password or API token is stored anywhere.
|
|
5
|
+
# Runs only when a version tag such as v0.1.4 is pushed, and the upload waits for a human approval on the
|
|
6
|
+
# "pypi" environment (set "Required reviewers" on that environment in the repository settings).
|
|
7
|
+
name: release
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
tags: ["v*"]
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
timeout-minutes: 20
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
- name: Tag must match the package version
|
|
26
|
+
run: |
|
|
27
|
+
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
28
|
+
test "v${VERSION}" = "${GITHUB_REF_NAME}" || { echo "tag ${GITHUB_REF_NAME} does not match version ${VERSION}"; exit 1; }
|
|
29
|
+
- name: Test before building
|
|
30
|
+
run: |
|
|
31
|
+
python -m pip install --upgrade pip
|
|
32
|
+
python -m pip install -e ".[dev]"
|
|
33
|
+
python -m pytest -q
|
|
34
|
+
python scripts/prepublish_check.py
|
|
35
|
+
- name: Build sdist and wheel
|
|
36
|
+
run: |
|
|
37
|
+
python -m pip install build
|
|
38
|
+
python -m build
|
|
39
|
+
- name: Nothing private in the packages
|
|
40
|
+
run: |
|
|
41
|
+
python - <<'PY'
|
|
42
|
+
import sys, tarfile, zipfile, glob
|
|
43
|
+
bad = ("_HI.md", "policies/", "private/", ".jsonl", "_PRIVATE.md", ".env", ".db",
|
|
44
|
+
"scripts/private_", "pro_markers.txt", "private_strings.txt", "make_public_export.py")
|
|
45
|
+
names = []
|
|
46
|
+
for w in glob.glob("dist/*.whl"):
|
|
47
|
+
names += zipfile.ZipFile(w).namelist()
|
|
48
|
+
for s in glob.glob("dist/*.tar.gz"):
|
|
49
|
+
names += tarfile.open(s).getnames()
|
|
50
|
+
hits = [n for n in names if any(b in n for b in bad)]
|
|
51
|
+
print("\n".join(hits) or "clean")
|
|
52
|
+
sys.exit(1 if hits else 0)
|
|
53
|
+
PY
|
|
54
|
+
- uses: actions/upload-artifact@v4
|
|
55
|
+
with:
|
|
56
|
+
name: dist
|
|
57
|
+
path: dist/
|
|
58
|
+
|
|
59
|
+
publish:
|
|
60
|
+
needs: build
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
environment:
|
|
63
|
+
name: pypi
|
|
64
|
+
url: https://pypi.org/p/sangop
|
|
65
|
+
permissions:
|
|
66
|
+
id-token: write
|
|
67
|
+
steps:
|
|
68
|
+
- uses: actions/download-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
name: dist
|
|
71
|
+
path: dist/
|
|
72
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
.venv/
|
|
4
|
+
dist/
|
|
5
|
+
build/
|
|
6
|
+
*.egg-info/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.sangop/
|
|
9
|
+
examples/demo.db
|
|
10
|
+
*.db
|
|
11
|
+
*.db-wal
|
|
12
|
+
*.db-shm
|
|
13
|
+
.env
|
|
14
|
+
tools-venv/
|
|
15
|
+
bench/india_pii/dataset_*.jsonl
|
|
16
|
+
bench/india_pii/holdout*_*.jsonl
|
|
17
|
+
policies/
|
|
18
|
+
docs/*_HI.md
|
|
19
|
+
private/
|
|
20
|
+
*.sha256.bak
|
|
21
|
+
*_PRIVATE.md
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the open-core `sangop` package. Versions are dates: `YEAR.MONTH.PATCH` (a new release
|
|
4
|
+
every month or so; Sangop Pro, a separate add-on, follows the same numbering). Pre-release (alpha).
|
|
5
|
+
|
|
6
|
+
## 2026.11.0 (2026-11-14) - first public release of the open core
|
|
7
|
+
|
|
8
|
+
What the open core does today:
|
|
9
|
+
|
|
10
|
+
- **Detectors (basic rule set, ASCII digits 0-9):** Aadhaar (Verhoeff checksum), PAN, GSTIN (check character), IFSC,
|
|
11
|
+
Indian mobile numbers (5-5 digits with or without one space or hyphen, optional `+91`, `91` or `0`), e-mail, payment
|
|
12
|
+
cards (Luhn; ISBN-13 excluded), UPI IDs (known handles, or any handle right after the word "UPI" or "VPA"), and nine
|
|
13
|
+
secret formats (private keys, Anthropic, OpenAI, GitHub, AWS access key, Google API, Slack, Telegram bot, JWT).
|
|
14
|
+
A PEM private key block cut off before its `END` line (length limit, pagination) is masked from the header to the
|
|
15
|
+
end of its key lines; scanning stays linear on 1 MB of headers without `END` (measured under 0.5 s).
|
|
16
|
+
- **Tokenizer:** values are replaced by tokens such as `[PII_PAN_3f9a12c04b7d51e8]` (64 bit) before a tool result
|
|
17
|
+
reaches the model; a tool you trust can get selected kinds back (`detokenize_kinds`, every reveal is logged).
|
|
18
|
+
Results are scrubbed in nested containers, dataclasses, pydantic models, generators and error messages.
|
|
19
|
+
- **`@guard` decorator** for MCP / FastMCP tools, with `shadow` modes that only count and log.
|
|
20
|
+
- **SQL guard** (sqlglot AST): blocks writes, DDL, several statements, missing or unsafe LIMITs (also on set
|
|
21
|
+
operations and hidden aggregates in scalar sub-queries), row-folding aggregates, file/network/session functions,
|
|
22
|
+
`FOR UPDATE`, and weak tenant filters; optional allow-lists for tables and functions.
|
|
23
|
+
- **Audit ledger:** SQLite hash chain, HMAC-keyed with `SANGOP_LEDGER_KEY`; `verify` reports keyed / unkeyed / mixed
|
|
24
|
+
and detects cut-off rows with an anchor; values Sangop detects as personal data are not written in clear. `sangop keygen`.
|
|
25
|
+
- **Media:** images, PDFs, Office files, archives and audio are recognised by their first bytes and blocked by default
|
|
26
|
+
(`media_mode="block"`), or passed unscanned and logged (`"allow"`).
|
|
27
|
+
- **CLI:** `sangop scan`, `sql-check`, `audit verify/tail`, `keygen`, `selftest`.
|
|
28
|
+
- **Rules plugins:** an installed package can provide a different rule set through the `sangop.plugins` entry point;
|
|
29
|
+
`selftest()` reports which rule set is active, and a plugin that fails to load stops detection instead of falling
|
|
30
|
+
back to weaker rules.
|
|
31
|
+
- **Hardening before the first release:** a SQL argument that is not a string or `None` is blocked (`None`, for
|
|
32
|
+
example an optional argument that was not given, means "no SQL"); a misspelt `sql_param` is
|
|
33
|
+
an error when the guard is made; a SQL argument that gets real values back through detokenization is checked
|
|
34
|
+
again before the tool runs; exceptions that are not `Exception` subclasses keep their type but lose personal
|
|
35
|
+
data from their message; `memoryview` results are read like bytes; `Enum` members and other shared objects are
|
|
36
|
+
never changed by scrubbing; pydantic models are also checked in their JSON form.
|
|
37
|
+
|
|
38
|
+
- **Minimum sqlglot raised to 28.5** (found by the weekly maintenance check, test first): measured on sqlglot
|
|
39
|
+
28.4.0, the bulk-extraction check missed a Postgres `json_agg` with a `LIMIT`; from 28.5.0 the whole test suite
|
|
40
|
+
passes. **httpx added to the `dev` extra** so the MCP compatibility tests run on a clean install.
|
|
41
|
+
- **Tests:** regression tests for row-folding aggregates with LIMIT (Postgres `json_agg` / `jsonb_agg`).
|
|
42
|
+
- SQL guard: blocks MySQL/MariaDB executable comments and more row-folding and table-dumping functions (internal AI-assisted review, 14 Nov 2026).
|
|
43
|
+
- SQL guard: blocked more write, row-folding and file-reading functions, PostgreSQL attribute-notation aggregates and DuckDB top-N aggregates, SQLite virtual tables and pragma functions, unicode-escaped names, http/fdw extension calls (internal AI-assisted review, 14 Nov 2026).
|
|
44
|
+
- SQL guard: PostgreSQL `pg_*` / `lo_*` / `txid_*` / `dblink*`, SQLite `sqlite_*` and DuckDB `read_*` / `*_scan` names are blocked as whole families, with a short named list of harmless exceptions; SQL over 100 KB is refused; with `dialect="mysql"` (also for MariaDB), `--` without a following space is refused (see README, Supported SQL dialects). README: database settings for the agent's user, each checked on PostgreSQL 16 and SQLite.
|
|
45
|
+
- SQL guard: blocked PostgreSQL crosstab/xpath_table, DuckDB serialized-SQL execution and dynamic PIVOT (row-folding), plus more system tables (internal AI-assisted review 3, 14 Nov 2026)
|
|
46
|
+
- SQL guard: PostgreSQL and SQLite now use a default function allow-list; unknown functions are refused unless added via extra_allowed_functions (internal AI-assisted review 4, 15 Nov 2026).
|
|
47
|
+
- SQL guard: percentile functions only take a plain number as the fraction; format() width is limited; names are checked as written (internal AI-assisted review 5, 15 Nov 2026).
|
|
48
|
+
- SQL guard: schema-qualified calls (pg_catalog., main.) are checked like plain names; sha2 functions allowed; nested-value and bind-parameter limits documented (internal AI-assisted review 6, 15 Nov 2026).
|
|
49
|
+
- **Windows:** the first full test run on Windows found two gaps in the open core's tests (none in the library): the
|
|
50
|
+
test that keeps the examples offline also blocked the loopback connection that every asyncio event loop makes on
|
|
51
|
+
Windows, and the HTTP compatibility test sent its helper server's output to a pipe nobody read, so the server
|
|
52
|
+
stopped once Windows' small pipe was full. Both are fixed, with tests of their own; the CI workflow now runs on
|
|
53
|
+
Linux and Windows.
|
|
54
|
+
- **Docs and examples:** the README starts with the install line and a short before/after example whose output is
|
|
55
|
+
checked by a test; three short examples (`examples/fastmcp_guarded_tool.py`, `sql_guard_only.py`,
|
|
56
|
+
`ledger_verify.py`), run offline by the test suite; a note on CERT-In advisory CIAD-2026-0058 and agent tool-call
|
|
57
|
+
records (`docs/CERT_IN_AGENT_LOGGING.md`).
|
|
58
|
+
|
|
59
|
+
See the README for measured accuracy and the Known limits.
|
|
60
|
+
|
|
61
|
+
## Earlier private previews
|
|
62
|
+
|
|
63
|
+
Versions 0.1.0 to 0.1.4 (October-November 2026) were private previews, not published.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
Sangop is a small project with one maintainer. We want every issue, discussion and
|
|
4
|
+
review to be useful and respectful.
|
|
5
|
+
|
|
6
|
+
## Expected
|
|
7
|
+
|
|
8
|
+
- Be kind and patient. Assume good intent; criticise code and ideas, not people.
|
|
9
|
+
- Keep to the topic of the project.
|
|
10
|
+
- Use synthetic examples only. Never post real personal data, real credentials or
|
|
11
|
+
production logs - yours or anyone else's.
|
|
12
|
+
|
|
13
|
+
## Not accepted
|
|
14
|
+
|
|
15
|
+
- Harassment, insults, threats, or discriminatory remarks of any kind.
|
|
16
|
+
- Sharing someone's private information without their permission.
|
|
17
|
+
- Spam, vote manipulation, or repeated off-topic promotion.
|
|
18
|
+
|
|
19
|
+
## Reporting
|
|
20
|
+
|
|
21
|
+
Write to arvind@sangop.com. Reports are read by the maintainer and kept as private as
|
|
22
|
+
possible. Security vulnerabilities go through SECURITY.md, not here.
|
|
23
|
+
|
|
24
|
+
## What the maintainer may do
|
|
25
|
+
|
|
26
|
+
Edit, hide or delete comments, lock threads, and block accounts from the project's
|
|
27
|
+
spaces, temporarily or permanently. The maintainer may also step back from a
|
|
28
|
+
discussion that becomes abusive.
|
|
29
|
+
|
|
30
|
+
This code applies in the project's GitHub repository, issues, discussions and pull
|
|
31
|
+
requests, and when someone represents the project elsewhere.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing to Sangop
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in Sangop.
|
|
4
|
+
|
|
5
|
+
Everyone who takes part follows our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
6
|
+
|
|
7
|
+
## Current policy
|
|
8
|
+
|
|
9
|
+
Issues and Discussions are welcome. External pull requests are not accepted yet.
|
|
10
|
+
|
|
11
|
+
- **Bug reports and ideas are welcome** via GitHub Issues and Discussions. Never include real
|
|
12
|
+
personal data, credentials or production logs - use synthetic examples only.
|
|
13
|
+
- **Security issues:** report privately, see [SECURITY.md](SECURITY.md).
|
|
14
|
+
- **Code contributions:** we are not yet accepting external pull requests.
|
|
15
|
+
Before we do, contributors will be asked to sign a Contributor License
|
|
16
|
+
Agreement (CLA) so that the project's licensing stays clear for all users.
|
|
17
|
+
This page will be updated when the CLA is available.
|
|
18
|
+
|
|
19
|
+
## Developer Certificate of Origin (DCO)
|
|
20
|
+
|
|
21
|
+
Every commit in this project, the maintainer's own commits included, must carry a
|
|
22
|
+
sign-off line:
|
|
23
|
+
|
|
24
|
+
Signed-off-by: Your Name <you@example.com>
|
|
25
|
+
|
|
26
|
+
Add it automatically with `git commit -s`. By signing off you certify the
|
|
27
|
+
[Developer Certificate of Origin 1.1](https://developercertificate.org/): that you wrote the
|
|
28
|
+
change or otherwise have the right to submit it under the project's licence (Apache-2.0).
|
|
29
|
+
|
|
30
|
+
The DCO documents where each change came from; it does **not** transfer ownership. When
|
|
31
|
+
external pull requests open, the CLA mentioned above will still be required **in addition**
|
|
32
|
+
to the DCO sign-off. Until then external pull requests remain closed and will not be merged.
|
|
33
|
+
|
|
34
|
+
## Ground rules for any future contribution
|
|
35
|
+
|
|
36
|
+
- Only code you wrote yourself, or code under MIT / Apache-2.0 / BSD licences
|
|
37
|
+
with the licence notice preserved.
|
|
38
|
+
- Tests and examples must use synthetic data only.
|
|
39
|
+
- No network calls or telemetry may be added to the library.
|
sangop-2026.11.0/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
sangop-2026.11.0/NOTICE
ADDED