maskguard 1.0.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.
- maskguard-1.0.0/.env.example +27 -0
- maskguard-1.0.0/.github/workflows/ci.yml +48 -0
- maskguard-1.0.0/.github/workflows/release.yml +46 -0
- maskguard-1.0.0/.gitignore +8 -0
- maskguard-1.0.0/Dockerfile +13 -0
- maskguard-1.0.0/LICENSE +202 -0
- maskguard-1.0.0/Makefile +40 -0
- maskguard-1.0.0/NOTICE +7 -0
- maskguard-1.0.0/PKG-INFO +96 -0
- maskguard-1.0.0/README.md +606 -0
- maskguard-1.0.0/bench/bpb_export.py +34 -0
- maskguard-1.0.0/bench/bpb_export_t3.py +22 -0
- maskguard-1.0.0/bench/eval_dp.py +74 -0
- maskguard-1.0.0/bench/eval_scanner.py +89 -0
- maskguard-1.0.0/bench/eval_textpii.py +72 -0
- maskguard-1.0.0/bench/eval_threat.py +86 -0
- maskguard-1.0.0/bench/overhead.py +42 -0
- maskguard-1.0.0/deploy/postgres-init/10-gateway-role.sh +16 -0
- maskguard-1.0.0/deploy/production.env.example +22 -0
- maskguard-1.0.0/deploy/users.example.yaml +11 -0
- maskguard-1.0.0/docker-compose.prod.yml +83 -0
- maskguard-1.0.0/docker-compose.yml +65 -0
- maskguard-1.0.0/docs/APPLICATION_TalentAP.md +69 -0
- maskguard-1.0.0/docs/ARCHITECTURE.md +134 -0
- maskguard-1.0.0/docs/DEMO_RUNBOOK.md +175 -0
- maskguard-1.0.0/docs/DEPLOYMENT.md +197 -0
- maskguard-1.0.0/docs/EVALUATION.md +139 -0
- maskguard-1.0.0/docs/GUIDE.md +1310 -0
- maskguard-1.0.0/docs/IMPLEMENTATION_REPORT.md +169 -0
- maskguard-1.0.0/docs/MaskGuard_Round1_Submission.pptx +0 -0
- maskguard-1.0.0/docs/PYPI.md +52 -0
- maskguard-1.0.0/docs/REFERENCE_RESEARCH.md +182 -0
- maskguard-1.0.0/docs/RELEASING.md +77 -0
- maskguard-1.0.0/docs/ROADMAP.md +26 -0
- maskguard-1.0.0/docs/demo.mp4 +0 -0
- maskguard-1.0.0/docs/demo_full.mp4 +0 -0
- maskguard-1.0.0/docs/design/PRIVACY_ACCOUNTING.md +1037 -0
- maskguard-1.0.0/docs/design/PRIVACY_ACCOUNTING_REVIEW_BRIEF.md +388 -0
- maskguard-1.0.0/docs/design/PRIVACY_ACCOUNTING_REVIEW_EVIDENCE.md +253 -0
- maskguard-1.0.0/docs/eval/dp.json +55 -0
- maskguard-1.0.0/docs/eval/scanner_holdout_20values.json +94 -0
- maskguard-1.0.0/docs/eval/scanner_holdout_5values.json +100 -0
- maskguard-1.0.0/docs/eval/textpii_t3_seeds401-403.json +61 -0
- maskguard-1.0.0/docs/eval/threat_sim.json +134 -0
- maskguard-1.0.0/docs/img/attacks.png +0 -0
- maskguard-1.0.0/docs/img/cli-attack-suite.png +0 -0
- maskguard-1.0.0/docs/img/cli-roles.png +0 -0
- maskguard-1.0.0/docs/img/cli-security-test.png +0 -0
- maskguard-1.0.0/docs/img/cli-threat.png +0 -0
- maskguard-1.0.0/docs/img/cli.png +0 -0
- maskguard-1.0.0/docs/img/control-room-audit.png +0 -0
- maskguard-1.0.0/docs/img/control-room-discovery.png +0 -0
- maskguard-1.0.0/docs/img/control-room-integrity.png +0 -0
- maskguard-1.0.0/docs/img/control-room-overview.png +0 -0
- maskguard-1.0.0/docs/img/control-room-playground.png +0 -0
- maskguard-1.0.0/docs/img/control-room-policy.png +0 -0
- maskguard-1.0.0/docs/img/demo-video.png +0 -0
- maskguard-1.0.0/docs/img/prod-api-403.png +0 -0
- maskguard-1.0.0/docs/img/prod-audit.png +0 -0
- maskguard-1.0.0/docs/img/prod-d11.png +0 -0
- maskguard-1.0.0/docs/img/prod-refuses-unsafe.png +0 -0
- maskguard-1.0.0/docs/img/prod-selftest-refused.png +0 -0
- maskguard-1.0.0/docs/img/prod-status.png +0 -0
- maskguard-1.0.0/docs/img/review-dp-findings.png +0 -0
- maskguard-1.0.0/docs/img/review-frozen.png +0 -0
- maskguard-1.0.0/docs/img/roles.png +0 -0
- maskguard-1.0.0/docs/img/scanner.png +0 -0
- maskguard-1.0.0/docs/img/threat.png +0 -0
- maskguard-1.0.0/docs/research/IMPROVEMENT_BACKLOG.md +32 -0
- maskguard-1.0.0/docs/research/REA_BASELINE_MASKGUARD.md +33 -0
- maskguard-1.0.0/docs/research/REA_EVIDENCE.md +263 -0
- maskguard-1.0.0/docs/research/REA_EXPERIMENT.md +286 -0
- maskguard-1.0.0/docs/research/REVIEW_RESPONSE.md +38 -0
- maskguard-1.0.0/docs/research/SECURITY_COMPARISON.md +154 -0
- maskguard-1.0.0/docs/research/rea_experiment/README.md +28 -0
- maskguard-1.0.0/docs/research/rea_experiment/anon_rules.sql +22 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/anon_so_readelf.txt +67 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/anon_so_strings_excerpt.txt +40 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/anon_so_symbols_excerpt.txt +60 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/ctas_bypass_repro.txt +62 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/rea_doctor.txt +146 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/rea_inspect_artifact.json +1 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/rea_process_capture.json +24 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/scenario_matrix.json +2347 -0
- maskguard-1.0.0/docs/research/rea_experiment/evidence/versions.txt +7 -0
- maskguard-1.0.0/docs/research/rea_experiment/fixture.sql +25 -0
- maskguard-1.0.0/docs/research/rea_experiment/harness/run.py +112 -0
- maskguard-1.0.0/docs/research/rea_experiment/harness/scenarios.py +154 -0
- maskguard-1.0.0/docs/research/rea_experiment/maskguard_overrides.yaml +9 -0
- maskguard-1.0.0/policies/default.yaml +66 -0
- maskguard-1.0.0/policies/overrides.yaml +4 -0
- maskguard-1.0.0/policies/users.demo.yaml +19 -0
- maskguard-1.0.0/postman/Local.postman_environment.json +22 -0
- maskguard-1.0.0/postman/README.md +53 -0
- maskguard-1.0.0/postman/Smart-Data-Masking.postman_collection.json +2475 -0
- maskguard-1.0.0/postman/build_collection.py +226 -0
- maskguard-1.0.0/pyproject.toml +77 -0
- maskguard-1.0.0/scripts/ui_smoke.js +42 -0
- maskguard-1.0.0/src/maskguard/__init__.py +7 -0
- maskguard-1.0.0/src/maskguard/api.py +561 -0
- maskguard-1.0.0/src/maskguard/attacks.py +187 -0
- maskguard-1.0.0/src/maskguard/audit.py +102 -0
- maskguard-1.0.0/src/maskguard/auth.py +75 -0
- maskguard-1.0.0/src/maskguard/backends.py +425 -0
- maskguard-1.0.0/src/maskguard/cli.py +1113 -0
- maskguard-1.0.0/src/maskguard/client.py +132 -0
- maskguard-1.0.0/src/maskguard/config.py +235 -0
- maskguard-1.0.0/src/maskguard/dashboard.py +242 -0
- maskguard-1.0.0/src/maskguard/dp.py +76 -0
- maskguard-1.0.0/src/maskguard/gateway.py +125 -0
- maskguard-1.0.0/src/maskguard/integrity.py +172 -0
- maskguard-1.0.0/src/maskguard/masks.py +51 -0
- maskguard-1.0.0/src/maskguard/ml/__init__.py +0 -0
- maskguard-1.0.0/src/maskguard/ml/features.py +187 -0
- maskguard-1.0.0/src/maskguard/ml/model.py +130 -0
- maskguard-1.0.0/src/maskguard/ml/pii_lgbm.json +131 -0
- maskguard-1.0.0/src/maskguard/ml/pii_lgbm.txt.gz +0 -0
- maskguard-1.0.0/src/maskguard/ml/synth.py +379 -0
- maskguard-1.0.0/src/maskguard/ml/threat_benign_windows.npz +0 -0
- maskguard-1.0.0/src/maskguard/naive.py +39 -0
- maskguard-1.0.0/src/maskguard/pgwire.py +313 -0
- maskguard-1.0.0/src/maskguard/pia.py +121 -0
- maskguard-1.0.0/src/maskguard/policy.py +275 -0
- maskguard-1.0.0/src/maskguard/rewriter.py +302 -0
- maskguard-1.0.0/src/maskguard/scanner.py +190 -0
- maskguard-1.0.0/src/maskguard/seed.py +91 -0
- maskguard-1.0.0/src/maskguard/service.py +334 -0
- maskguard-1.0.0/src/maskguard/textpii.py +97 -0
- maskguard-1.0.0/src/maskguard/threat.py +301 -0
- maskguard-1.0.0/src/maskguard/threat_sim.py +157 -0
- maskguard-1.0.0/src/maskguard/web/app.css +276 -0
- maskguard-1.0.0/src/maskguard/web/app.js +968 -0
- maskguard-1.0.0/src/maskguard/web/favicon.svg +1 -0
- maskguard-1.0.0/src/maskguard/web/index.html +47 -0
- maskguard-1.0.0/tests/__init__.py +0 -0
- maskguard-1.0.0/tests/conftest.py +57 -0
- maskguard-1.0.0/tests/test_api_v1.py +220 -0
- maskguard-1.0.0/tests/test_attacks.py +131 -0
- maskguard-1.0.0/tests/test_cli.py +162 -0
- maskguard-1.0.0/tests/test_client.py +51 -0
- maskguard-1.0.0/tests/test_dashboard_ui.py +44 -0
- maskguard-1.0.0/tests/test_dp.py +104 -0
- maskguard-1.0.0/tests/test_dp_findings.py +123 -0
- maskguard-1.0.0/tests/test_ml_scanner.py +78 -0
- maskguard-1.0.0/tests/test_platform.py +156 -0
- maskguard-1.0.0/tests/test_policy_integrity.py +137 -0
- maskguard-1.0.0/tests/test_production.py +605 -0
- maskguard-1.0.0/tests/test_proxy.py +86 -0
- maskguard-1.0.0/tests/test_scanner.py +45 -0
- maskguard-1.0.0/tests/test_textpii.py +77 -0
- maskguard-1.0.0/tests/test_threat.py +94 -0
- maskguard-1.0.0/uv.lock +2992 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# DEVELOPMENT settings (synthetic demo data). For production see deploy/production.env.example and docs/DEPLOYMENT.md.
|
|
2
|
+
# Copy to .env (never commit .env) and export before running, e.g. set -a; source .env; set +a
|
|
3
|
+
# Windows PowerShell: Get-Content .env | ForEach-Object { if ($_ -match '^([^#=]+)=(.*)$') { Set-Item "env:$($matches[1])" $matches[2] } }
|
|
4
|
+
|
|
5
|
+
# Database: sqlite:///data/bank.db | postgresql://user:pw@host:5432/bank | mysql://user:pw@host:3306/bank
|
|
6
|
+
MASKGUARD_DB=sqlite:///data/bank.db
|
|
7
|
+
|
|
8
|
+
# Required. Key for analyst HMAC tokens: at least 16 random bytes, e.g. `python -c "import secrets;print(secrets.token_hex(32))"`
|
|
9
|
+
MASKGUARD_HMAC_KEY=
|
|
10
|
+
# Recommended. Signs session tokens; without it tokens are invalidated on every restart.
|
|
11
|
+
MASKGUARD_JWT_SECRET=
|
|
12
|
+
|
|
13
|
+
# development (default) | production. Any other value is refused. Production refuses to start unless the user store,
|
|
14
|
+
# secrets, database account and network settings are safe (docs/DEPLOYMENT.md).
|
|
15
|
+
MASKGUARD_ENV=development
|
|
16
|
+
# 1 = one-click demo identities (admin.ann, support.sam, analyst.ali, auditor.aud). Never in production.
|
|
17
|
+
MASKGUARD_DEMO=1
|
|
18
|
+
|
|
19
|
+
MASKGUARD_POLICY=policies/default.yaml
|
|
20
|
+
MASKGUARD_USERS=policies/users.demo.yaml
|
|
21
|
+
MASKGUARD_OVERRIDES=policies/overrides.yaml
|
|
22
|
+
MASKGUARD_AUDIT=data/audit.jsonl
|
|
23
|
+
MASKGUARD_REGISTRY=data/registry.yaml
|
|
24
|
+
MASKGUARD_SCAN_INTERVAL=300
|
|
25
|
+
|
|
26
|
+
# CLI only: talk to a running API instead of the in-process engine
|
|
27
|
+
# MASKGUARD_API=http://127.0.0.1:8000
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
services:
|
|
10
|
+
postgres:
|
|
11
|
+
image: postgres:16
|
|
12
|
+
env: {POSTGRES_PASSWORD: maskguard, POSTGRES_DB: bank}
|
|
13
|
+
ports: ["5432:5432"]
|
|
14
|
+
options: --health-cmd "pg_isready -U postgres" --health-interval 2s --health-retries 30
|
|
15
|
+
mysql:
|
|
16
|
+
image: mysql:8.4
|
|
17
|
+
env: {MYSQL_ROOT_PASSWORD: maskguard, MYSQL_DATABASE: bank}
|
|
18
|
+
ports: ["3306:3306"]
|
|
19
|
+
options: --health-cmd "mysqladmin ping -h 127.0.0.1 -pmaskguard" --health-interval 3s --health-retries 40
|
|
20
|
+
env:
|
|
21
|
+
MASKGUARD_HMAC_KEY: ci-only-hmac-key
|
|
22
|
+
MASKGUARD_JWT_SECRET: ci-only-jwt-secret-0123456789-0123456789
|
|
23
|
+
MASKGUARD_TEST_PG: postgresql://postgres:maskguard@127.0.0.1:5432/bank
|
|
24
|
+
MASKGUARD_TEST_MYSQL: mysql://root:maskguard@127.0.0.1:3306/bank
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: astral-sh/setup-uv@v6
|
|
28
|
+
- run: sudo apt-get update && sudo apt-get install -y postgresql-client
|
|
29
|
+
- run: uv sync
|
|
30
|
+
- name: Tests on SQLite, PostgreSQL and MySQL
|
|
31
|
+
run: uv run pytest -q
|
|
32
|
+
- name: Attack suite must report zero leaks
|
|
33
|
+
run: uv run maskguard attack -u analyst.ali -p analyst123
|
|
34
|
+
- name: Security regression (attack suite per role + integrity proof)
|
|
35
|
+
run: uv run maskguard test
|
|
36
|
+
- uses: actions/setup-node@v4
|
|
37
|
+
with: {node-version: 20}
|
|
38
|
+
- name: Postman collection against a live API (Newman)
|
|
39
|
+
# Start the API from the synced venv, not `uv run`: a live `uv run` holds uv's cache lock, and setup-uv's
|
|
40
|
+
# post-job `uv cache prune` then waits on it until it times out and fails the job. Stop it on exit too.
|
|
41
|
+
run: |
|
|
42
|
+
MASKGUARD_DB=sqlite:///$RUNNER_TEMP/newman.db MASKGUARD_AUDIT=$RUNNER_TEMP/a.jsonl MASKGUARD_REGISTRY=$RUNNER_TEMP/r.yaml \
|
|
43
|
+
.venv/bin/maskguard serve --port 8000 > $RUNNER_TEMP/api.log 2>&1 &
|
|
44
|
+
API_PID=$!
|
|
45
|
+
trap 'kill $API_PID 2>/dev/null || true' EXIT
|
|
46
|
+
for i in $(seq 1 60); do curl -sf http://127.0.0.1:8000/health && break; sleep 1; done
|
|
47
|
+
npx -y newman@6 run postman/Smart-Data-Masking.postman_collection.json -e postman/Local.postman_environment.json \
|
|
48
|
+
--reporters cli,junit --reporter-junit-export newman.xml
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI when a version tag (v1.0.0, v1.0.1, …) is pushed. Uses PyPI Trusted Publishing: PyPI trusts this
|
|
4
|
+
# repository's workflow directly, so no API token is stored anywhere. One-time setup is in docs/RELEASING.md.
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags: ["v*"]
|
|
8
|
+
workflow_dispatch: # manual run: builds and smoke-tests, publishes only for a tag
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: astral-sh/setup-uv@v6
|
|
16
|
+
- name: Tag matches the package version
|
|
17
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
18
|
+
run: test "${GITHUB_REF_NAME#v}" = "$(uv version --short)"
|
|
19
|
+
- name: Build wheel and sdist
|
|
20
|
+
run: uv build
|
|
21
|
+
- name: Install the wheel in a clean environment and run it from an empty folder
|
|
22
|
+
run: |
|
|
23
|
+
uv venv /tmp/smoke
|
|
24
|
+
VIRTUAL_ENV=/tmp/smoke uv pip install dist/*.whl
|
|
25
|
+
cd "$(mktemp -d)"
|
|
26
|
+
MASKGUARD_HMAC_KEY=release-smoke-key /tmp/smoke/bin/maskguard status
|
|
27
|
+
MASKGUARD_HMAC_KEY=release-smoke-key /tmp/smoke/bin/maskguard compare "SELECT name, ssn FROM users LIMIT 1" --roles admin,support
|
|
28
|
+
# production must refuse the demo user store bundled in the package (exit code 4)
|
|
29
|
+
set +e
|
|
30
|
+
MASKGUARD_ENV=production MASKGUARD_JWT_SECRET="$(openssl rand -hex 32)" MASKGUARD_HMAC_KEY="$(openssl rand -hex 32)" \
|
|
31
|
+
MASKGUARD_DB=postgresql://x@127.0.0.1:1/x /tmp/smoke/bin/maskguard status
|
|
32
|
+
test $? -eq 4
|
|
33
|
+
- uses: actions/upload-artifact@v4
|
|
34
|
+
with: {name: dist, path: dist/}
|
|
35
|
+
|
|
36
|
+
publish:
|
|
37
|
+
needs: build
|
|
38
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
environment: pypi
|
|
41
|
+
permissions:
|
|
42
|
+
id-token: write # lets PyPI verify this workflow (Trusted Publishing)
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/download-artifact@v4
|
|
45
|
+
with: {name: dist, path: dist/}
|
|
46
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 && rm -rf /var/lib/apt/lists/*
|
|
3
|
+
RUN pip install --no-cache-dir uv==0.8.22
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
COPY pyproject.toml uv.lock README.md ./
|
|
6
|
+
COPY src ./src
|
|
7
|
+
RUN uv sync --frozen --no-dev
|
|
8
|
+
COPY policies ./policies
|
|
9
|
+
COPY bench ./bench
|
|
10
|
+
COPY postman ./postman
|
|
11
|
+
ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1
|
|
12
|
+
EXPOSE 8000 8501
|
|
13
|
+
CMD ["maskguard", "serve", "--host", "0.0.0.0", "--port", "8000"]
|
maskguard-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
maskguard-1.0.0/Makefile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export MASKGUARD_HMAC_KEY ?= dev-only-hmac-key-change-me
|
|
2
|
+
export MASKGUARD_JWT_SECRET ?= dev-only-jwt-secret-change-me-0123456789
|
|
3
|
+
|
|
4
|
+
.PHONY: install test test-pg bench dashboard api scan attack postman demo up down
|
|
5
|
+
|
|
6
|
+
install:
|
|
7
|
+
uv sync
|
|
8
|
+
|
|
9
|
+
test:
|
|
10
|
+
uv run pytest -q
|
|
11
|
+
|
|
12
|
+
test-pg: ## needs a running Postgres, e.g. `docker compose up -d postgres`
|
|
13
|
+
MASKGUARD_TEST_PG=postgresql://maskguard:maskguard@127.0.0.1:5432/bank uv run pytest -q
|
|
14
|
+
|
|
15
|
+
bench:
|
|
16
|
+
uv run python bench/overhead.py
|
|
17
|
+
|
|
18
|
+
dashboard:
|
|
19
|
+
uv run maskguard dashboard
|
|
20
|
+
|
|
21
|
+
api:
|
|
22
|
+
uv run maskguard serve
|
|
23
|
+
|
|
24
|
+
scan:
|
|
25
|
+
uv run maskguard scan
|
|
26
|
+
|
|
27
|
+
attack:
|
|
28
|
+
uv run maskguard attack -u analyst.ali -p analyst123
|
|
29
|
+
|
|
30
|
+
postman: ## API must be running on :8000
|
|
31
|
+
npx -y newman@6 run postman/Smart-Data-Masking.postman_collection.json -e postman/Local.postman_environment.json
|
|
32
|
+
|
|
33
|
+
demo: ## interactive security console
|
|
34
|
+
uv run maskguard
|
|
35
|
+
|
|
36
|
+
up:
|
|
37
|
+
docker compose up --build
|
|
38
|
+
|
|
39
|
+
down:
|
|
40
|
+
docker compose down
|
maskguard-1.0.0/NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
MaskGuard
|
|
2
|
+
Copyright 2026 G. Harshith, G. Praneeth, D. Mandeep and K. Surya Srinivas
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
MaskGuard's code, synthetic training data generator and trained models are original work. The external benchmark
|
|
7
|
+
used for evaluation (bharat-pii-bench) is run separately and is not included in this repository.
|
maskguard-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: maskguard
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: AI-powered PII discovery and query-time, role-based masking gateway for PostgreSQL, MySQL and SQLite
|
|
5
|
+
Project-URL: Homepage, https://github.com/hotaro6754/mask
|
|
6
|
+
Project-URL: Documentation, https://github.com/hotaro6754/mask/blob/claude/zealous-bell-me62fn/docs/GUIDE.md
|
|
7
|
+
Project-URL: Source, https://github.com/hotaro6754/mask
|
|
8
|
+
Author: G. Harshith, G. Praneeth, D. Mandeep, K. Surya Srinivas
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: aadhaar,data-masking,dpdp,gateway,mysql,pii,postgresql,privacy,security
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
15
|
+
Classifier: Intended Audience :: Information Technology
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Database
|
|
24
|
+
Classifier: Topic :: Security
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: faker
|
|
27
|
+
Requires-Dist: fastapi>=0.143.0
|
|
28
|
+
Requires-Dist: joblib>=1.6.0
|
|
29
|
+
Requires-Dist: lightgbm>=4.7.0
|
|
30
|
+
Requires-Dist: numpy>=2.2.6
|
|
31
|
+
Requires-Dist: pandas>=2.3.3
|
|
32
|
+
Requires-Dist: psycopg[binary]>=3.3.6
|
|
33
|
+
Requires-Dist: pyjwt>=2.15.1
|
|
34
|
+
Requires-Dist: pymysql>=1.2.3
|
|
35
|
+
Requires-Dist: python-stdnum
|
|
36
|
+
Requires-Dist: pyyaml
|
|
37
|
+
Requires-Dist: rich>=13
|
|
38
|
+
Requires-Dist: scikit-learn>=1.7.2
|
|
39
|
+
Requires-Dist: sqlglot
|
|
40
|
+
Requires-Dist: streamlit>=1.65.0
|
|
41
|
+
Requires-Dist: typer>=0.12
|
|
42
|
+
Requires-Dist: uvicorn>=0.54.0
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# MaskGuard
|
|
46
|
+
|
|
47
|
+
**AI-powered PII discovery and query-time, role-based masking for PostgreSQL, MySQL and SQLite.**
|
|
48
|
+
|
|
49
|
+
MaskGuard is a gateway between people and the database. It finds sensitive columns by looking at their values (a
|
|
50
|
+
LightGBM classifier plus checksum validators for Aadhaar, PAN, GSTIN, cards, IBAN and more). It rewrites every query
|
|
51
|
+
so the database itself returns only what the caller's role may see. It watches for probing, and records every
|
|
52
|
+
decision in a hash-chained audit log. Stored data never changes.
|
|
53
|
+
|
|
54
|
+
| Role | Sees |
|
|
55
|
+
|---|---|
|
|
56
|
+
| Admin | real values |
|
|
57
|
+
| Support | partial masks: `4111-XXXX-XXXX-1111`, `XXX-XX-6789`, `r***@bank.in`, rounded balances |
|
|
58
|
+
| Analyst | keyed tokens (joinable, not reversible); no individual balances |
|
|
59
|
+
| Auditor | `REDACTED`, plus the audit log, policies and integrity proofs |
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
## Install and try it
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install maskguard
|
|
67
|
+
export MASKGUARD_HMAC_KEY=dev-only-hmac-key-change-me # Windows PowerShell: $env:MASKGUARD_HMAC_KEY="..."
|
|
68
|
+
maskguard # console with synthetic demo data (created in ./data/)
|
|
69
|
+
maskguard compare "SELECT name, ssn, phone FROM users LIMIT 2" --roles admin,support,analyst,auditor
|
|
70
|
+
maskguard serve # REST API + Control Room at http://127.0.0.1:8000/ui/
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Demo logins: `admin.ann`, `support.sam`, `analyst.ali` and `auditor.aud`, each with password `<role>123`. Data,
|
|
74
|
+
the audit log and the scanner registry are written to `./data/` in the folder you run it from.
|
|
75
|
+
|
|
76
|
+
To use your own database, set `MASKGUARD_DB` (`postgresql://…` or `mysql://…`). For real data, run in production
|
|
77
|
+
mode (`MASKGUARD_ENV=production`): it refuses to start on any unsafe setting.
|
|
78
|
+
|
|
79
|
+
## Results
|
|
80
|
+
|
|
81
|
+
- **PII discovery:** 0.965 F1 with misleading column names and 5 sample values per column; the benchmark baseline
|
|
82
|
+
scores 0.844.
|
|
83
|
+
- **Attack suite:** 0 of 17 bypass and inference attacks leak, against 14–15 of 17 for output-only masking.
|
|
84
|
+
- **Tests:** 476 tests on SQLite, PostgreSQL 16 and MySQL 8.4.
|
|
85
|
+
- **Latency:** about 8 ms added per query.
|
|
86
|
+
|
|
87
|
+
## Learn more
|
|
88
|
+
|
|
89
|
+
- [README and screenshots](https://github.com/hotaro6754/mask/blob/claude/zealous-bell-me62fn/README.md)
|
|
90
|
+
- [Beginner's guide](https://github.com/hotaro6754/mask/blob/claude/zealous-bell-me62fn/docs/GUIDE.md): every term,
|
|
91
|
+
with diagrams and step-by-step workflows
|
|
92
|
+
- [Deployment guide](https://github.com/hotaro6754/mask/blob/claude/zealous-bell-me62fn/docs/DEPLOYMENT.md)
|
|
93
|
+
- [8-minute walkthrough video](https://github.com/hotaro6754/mask/blob/claude/zealous-bell-me62fn/docs/demo_full.mp4)
|
|
94
|
+
|
|
95
|
+
Noisy analyst aggregates are experimental and refused in production until an independent privacy review. Licensed
|
|
96
|
+
under Apache-2.0.
|