vericto 0.2.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.
Files changed (54) hide show
  1. vericto-0.2.0/.gitignore +12 -0
  2. vericto-0.2.0/CHANGELOG.md +93 -0
  3. vericto-0.2.0/LICENSE +93 -0
  4. vericto-0.2.0/PKG-INFO +541 -0
  5. vericto-0.2.0/README.md +495 -0
  6. vericto-0.2.0/SECURITY.md +55 -0
  7. vericto-0.2.0/examples/airflow_local_settings.py +18 -0
  8. vericto-0.2.0/examples/any_dbapi_driver.py +18 -0
  9. vericto-0.2.0/examples/dbt_github_actions.yml +33 -0
  10. vericto-0.2.0/examples/langchain_sql_agent.py +26 -0
  11. vericto-0.2.0/examples/snowflake_quickstart.py +35 -0
  12. vericto-0.2.0/examples/sqlalchemy_any_engine.py +25 -0
  13. vericto-0.2.0/examples/sqlite_quickstart.py +23 -0
  14. vericto-0.2.0/pyproject.toml +124 -0
  15. vericto-0.2.0/src/vericto/__init__.py +55 -0
  16. vericto-0.2.0/src/vericto/__main__.py +18 -0
  17. vericto-0.2.0/src/vericto/_agent.py +153 -0
  18. vericto-0.2.0/src/vericto/_version.py +1 -0
  19. vericto-0.2.0/src/vericto/airflow/__init__.py +221 -0
  20. vericto-0.2.0/src/vericto/airflow/policy.py +85 -0
  21. vericto-0.2.0/src/vericto/ci_api.py +343 -0
  22. vericto-0.2.0/src/vericto/dbapi.py +211 -0
  23. vericto-0.2.0/src/vericto/dbt.py +710 -0
  24. vericto-0.2.0/src/vericto/dialects.py +37 -0
  25. vericto-0.2.0/src/vericto/errors.py +123 -0
  26. vericto-0.2.0/src/vericto/evaluator.py +30 -0
  27. vericto-0.2.0/src/vericto/guard.py +276 -0
  28. vericto-0.2.0/src/vericto/langchain.py +233 -0
  29. vericto-0.2.0/src/vericto/llamaindex.py +118 -0
  30. vericto-0.2.0/src/vericto/placeholders.py +169 -0
  31. vericto-0.2.0/src/vericto/py.typed +0 -0
  32. vericto-0.2.0/src/vericto/runtime_api.py +283 -0
  33. vericto-0.2.0/src/vericto/sanitize.py +118 -0
  34. vericto-0.2.0/src/vericto/snowflake.py +112 -0
  35. vericto-0.2.0/src/vericto/sqlalchemy.py +81 -0
  36. vericto-0.2.0/src/vericto/sqlite.py +135 -0
  37. vericto-0.2.0/src/vericto/verdict.py +172 -0
  38. vericto-0.2.0/tests/__init__.py +0 -0
  39. vericto-0.2.0/tests/conftest.py +133 -0
  40. vericto-0.2.0/tests/fixtures/dbt/jaffle/target/compiled/jaffle/models/staging/stg_customers.sql +5 -0
  41. vericto-0.2.0/tests/fixtures/dbt/jaffle/target/manifest.json +154 -0
  42. vericto-0.2.0/tests/live/__init__.py +0 -0
  43. vericto-0.2.0/tests/live/test_snowflake_live.py +194 -0
  44. vericto-0.2.0/tests/live/test_sqlite_live.py +178 -0
  45. vericto-0.2.0/tests/test_airflow.py +409 -0
  46. vericto-0.2.0/tests/test_dbt.py +503 -0
  47. vericto-0.2.0/tests/test_guard.py +220 -0
  48. vericto-0.2.0/tests/test_langchain.py +220 -0
  49. vericto-0.2.0/tests/test_llamaindex.py +177 -0
  50. vericto-0.2.0/tests/test_placeholders.py +66 -0
  51. vericto-0.2.0/tests/test_runtime_api.py +194 -0
  52. vericto-0.2.0/tests/test_snowflake.py +190 -0
  53. vericto-0.2.0/tests/test_sqlalchemy.py +88 -0
  54. vericto-0.2.0/tests/test_sqlite.py +115 -0
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .mypy_cache/
5
+ .ruff_cache/
6
+ .pytest_cache/
7
+ .coverage
8
+ htmlcov/
9
+ build/
10
+ dist/
11
+ *.egg-info/
12
+ .DS_Store
@@ -0,0 +1,93 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] - 2026-10-16
10
+
11
+ Integrations for LangChain, LlamaIndex, dbt and Airflow, each a thin layer over
12
+ the guard. Nothing changes for 0.1.0 code.
13
+
14
+ ### Added
15
+
16
+ - `vericto[langchain]`: `vericto.langchain.VerictoSQLDatabase`, a
17
+ `langchain_community` `SQLDatabase` whose queries (and table-info sample rows)
18
+ are checked; a blocked query returns an explanation with the rule and the
19
+ suggested fix to the agent (`on_block="return"`, default) or raises
20
+ (`on_block="raise"`). Masked queries run rewritten. Plus
21
+ `VerictoCheckSQLTool`, a check-only tool.
22
+ - `vericto[llamaindex]`: `vericto.llamaindex.VerictoSQLDatabase` for
23
+ `NLSQLTableQueryEngine` / `SQLTableRetrieverQueryEngine`, same behaviour.
24
+ - `vericto[dbt]`: the `vericto-dbt check` command (also
25
+ `python -m vericto dbt check`). It reads `target/manifest.json` after
26
+ `dbt compile`, checks compiled models, snapshots and hooks with the CI-check
27
+ API (`POST /api/v1/ci/check-key`, monthly CI-check allowance), maps the
28
+ adapter to the dialect, prints a table or writes JSON / SARIF, and exits as
29
+ vericto-cli does (`--fail-on blocked|flagged|any`). It honours the workspace's
30
+ `sanitized` telemetry mode with a port of vericto-cli's literal sanitizer.
31
+ - `vericto[airflow]`: `vericto.airflow.VerictoSQLExecuteQueryOperator` and the
32
+ cluster policy `vericto.airflow.policy.guard_sql_tasks`. Both check the rendered
33
+ SQL, statement by statement, before any of it runs. A block fails the task
34
+ without retries (`VerictoTaskBlocked`). The dialect comes from the connection
35
+ type or from `vericto_dialect` in the connection extra. Tested on Airflow 3.3.2
36
+ and 2.11.2.
37
+ - `vericto.sqlalchemy.is_instrumented(engine)`.
38
+ - `vericto.ci_api.CiCheckClient`, a client for the CI-check API.
39
+
40
+ - `tests/live/test_sqlite_live.py`: an opt-in end-to-end test of
41
+ `vericto.sqlite` against a real Runtime API (allowed statements, UPSERT, the
42
+ SQLite rules VERICTO-098/099/100/101, DELETE without WHERE, scripts with a
43
+ blocked statement). Skipped unless `VERICTO_LIVE_SQLITE=1` and the
44
+ `VERICTO_*` variables are set; see "Live tests" in the README.
45
+
46
+ ### Changed
47
+
48
+ - `copy.deepcopy` of a `Vericto` guard returns the same guard, so frameworks
49
+ that deep-copy the objects holding it (Airflow operators) keep working.
50
+
51
+ - Documentation: the Vericto server now evaluates the `sqlite` dialect
52
+ (vericto-engine 4.1.0; `GET /api/v1/meta/config` lists it), so
53
+ `vericto.sqlite` and SQLAlchemy/LangChain/LlamaIndex/Airflow on SQLite work
54
+ against it. The 0.1.0 known limitation no longer applies to such servers.
55
+ Unchanged behaviour: the wrappers still ask `/meta/config` and raise
56
+ `VerictoUnsupportedDialect`, before any SQL runs, against a server that does
57
+ not list `sqlite`.
58
+
59
+ ## [0.1.0] - never published
60
+
61
+ First release: Vericto checks in front of Python database drivers, evaluated by
62
+ the Vericto Runtime API (`POST /api/v1/proxy/query`).
63
+
64
+ ### Added
65
+
66
+ - `Vericto` guard: raises `VerictoBlocked` on BLOCKED, runs the masked
67
+ `rewritten_query` for sensitive columns, logs FLAGGED / MONITORED / allowed
68
+ PARSE_ERROR verdicts and passes every verdict to `on_verdict`.
69
+ - Fail mode per guard: `closed` (default) raises `VerictoUnavailable` when
70
+ Vericto cannot answer; `open` runs the statement and emits
71
+ `VerictoFailOpenWarning`. Configuration errors are never failed open.
72
+ - `RuntimeApiEvaluator`: `VERICTO_*` environment configuration as in vericto-cli,
73
+ HTTPS-only key handling, timeouts, retries with backoff on 5xx / 429 rate
74
+ limits, `VerictoQuotaExceeded` for the monthly quota, and dialect discovery
75
+ through `GET /api/v1/meta/config`.
76
+ - `Evaluator` protocol, so an embedded evaluator can be added later.
77
+ - Wrappers: `vericto.snowflake` (`execute`, `executemany`, `execute_async`,
78
+ `execute_string`, `execute_stream`), `vericto.sqlite` (a `sqlite3.Connection`
79
+ subclass; `execute`, `executemany`, `executescript`), `vericto.sqlalchemy`
80
+ (`before_cursor_execute` for any dialect) and the generic `vericto.wrap` for
81
+ DB-API drivers.
82
+ - Scripts are evaluated statement by statement before the first one runs.
83
+ - `%s` / `%(name)s` placeholders are evaluated as the dialect's own placeholders;
84
+ parameter values are never sent.
85
+ - Optional verdict cache (off by default).
86
+
87
+ ### Known limitations
88
+
89
+ - The Vericto engine does not evaluate the `sqlite` dialect yet: the SQLite
90
+ wrappers raise `VerictoUnsupportedDialect` until the server lists it.
91
+
92
+ [0.2.0]: https://github.com/vericto/vericto-python/releases/tag/v0.2.0
93
+ [0.1.0]: https://github.com/vericto/vericto-python/releases/tag/v0.1.0
vericto-0.2.0/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor's trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.
72
+
73
+ ## Definitions
74
+
75
+ The "licensor" is the entity offering these terms, and the "software" is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ "you" refers to the individual or entity agreeing to these terms.
80
+
81
+ "your company" is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that organization.
84
+ "control" means ownership of substantially all the assets of an entity, or the
85
+ power to direct its management and policies by vote, contract, or otherwise.
86
+ Control can be direct or indirect.
87
+
88
+ "your licenses" are all the licenses granted to you for the software under these
89
+ terms.
90
+
91
+ "use" means anything you do with the software requiring one of your licenses.
92
+
93
+ "trademark" means trademarks, service marks, and similar rights.