gdp-rs 0.1.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.
- gdp_rs-0.1.0/Cargo.lock +137 -0
- gdp_rs-0.1.0/Cargo.toml +34 -0
- gdp_rs-0.1.0/LICENSE +21 -0
- gdp_rs-0.1.0/PKG-INFO +78 -0
- gdp_rs-0.1.0/README.md +43 -0
- gdp_rs-0.1.0/bindings/python/Cargo.toml +21 -0
- gdp_rs-0.1.0/bindings/python/LICENSE +21 -0
- gdp_rs-0.1.0/bindings/python/README.md +43 -0
- gdp_rs-0.1.0/bindings/python/src/lib.rs +3 -0
- gdp_rs-0.1.0/bindings/python/src/py/fault.rs +19 -0
- gdp_rs-0.1.0/bindings/python/src/py/mod.rs +75 -0
- gdp_rs-0.1.0/bindings/python/src/py/objects.rs +239 -0
- gdp_rs-0.1.0/bindings/python/tests/proofs/test_contracts.py +363 -0
- gdp_rs-0.1.0/bindings/python/tests/proofs/test_fastapi.py +142 -0
- gdp_rs-0.1.0/bindings/python/tests/test_lint.py +164 -0
- gdp_rs-0.1.0/bindings/python/tests/test_package.py +57 -0
- gdp_rs-0.1.0/bindings/python/tests/test_typing.py +84 -0
- gdp_rs-0.1.0/crates/gdp/Cargo.toml +11 -0
- gdp_rs-0.1.0/crates/gdp/LICENSE +21 -0
- gdp_rs-0.1.0/crates/gdp/examples/authorization.rs +63 -0
- gdp_rs-0.1.0/crates/gdp/examples/bench_core.rs +190 -0
- gdp_rs-0.1.0/crates/gdp/src/lib.rs +8 -0
- gdp_rs-0.1.0/crates/gdp/src/runtime.rs +172 -0
- gdp_rs-0.1.0/crates/gdp/src/typed.rs +154 -0
- gdp_rs-0.1.0/crates/gdp/tests/compile.rs +53 -0
- gdp_rs-0.1.0/crates/gdp/tests/contracts.rs +120 -0
- gdp_rs-0.1.0/crates/gdp/tests/ui/escape_name.rs +5 -0
- gdp_rs-0.1.0/crates/gdp/tests/ui/escape_proof.rs +8 -0
- gdp_rs-0.1.0/crates/gdp/tests/ui/forge.rs +7 -0
- gdp_rs-0.1.0/crates/gdp/tests/ui/missing_proof.rs +9 -0
- gdp_rs-0.1.0/crates/gdp/tests/ui/wrong_kind.rs +13 -0
- gdp_rs-0.1.0/crates/gdp/tests/ui/wrong_project.rs +11 -0
- gdp_rs-0.1.0/pyproject.toml +52 -0
- gdp_rs-0.1.0/python/gdp/__init__.py +36 -0
- gdp_rs-0.1.0/python/gdp/_gdp.pyi +118 -0
- gdp_rs-0.1.0/python/gdp/contracts.py +130 -0
- gdp_rs-0.1.0/python/gdp/lint.py +247 -0
- gdp_rs-0.1.0/python/gdp/py.typed +0 -0
gdp_rs-0.1.0/Cargo.lock
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "gdp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
|
|
9
|
+
[[package]]
|
|
10
|
+
name = "gdp-python"
|
|
11
|
+
version = "0.1.0"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"gdp",
|
|
14
|
+
"pyo3",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "heck"
|
|
19
|
+
version = "0.5.0"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "libc"
|
|
25
|
+
version = "0.2.190"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "once_cell"
|
|
31
|
+
version = "1.21.4"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "portable-atomic"
|
|
37
|
+
version = "1.15.0"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
40
|
+
|
|
41
|
+
[[package]]
|
|
42
|
+
name = "proc-macro2"
|
|
43
|
+
version = "1.0.107"
|
|
44
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
46
|
+
dependencies = [
|
|
47
|
+
"unicode-ident",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[[package]]
|
|
51
|
+
name = "pyo3"
|
|
52
|
+
version = "0.29.3"
|
|
53
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
54
|
+
checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655"
|
|
55
|
+
dependencies = [
|
|
56
|
+
"libc",
|
|
57
|
+
"once_cell",
|
|
58
|
+
"portable-atomic",
|
|
59
|
+
"pyo3-build-config",
|
|
60
|
+
"pyo3-ffi",
|
|
61
|
+
"pyo3-macros",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[[package]]
|
|
65
|
+
name = "pyo3-build-config"
|
|
66
|
+
version = "0.29.3"
|
|
67
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
68
|
+
checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb"
|
|
69
|
+
dependencies = [
|
|
70
|
+
"target-lexicon",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
[[package]]
|
|
74
|
+
name = "pyo3-ffi"
|
|
75
|
+
version = "0.29.3"
|
|
76
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
77
|
+
checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330"
|
|
78
|
+
dependencies = [
|
|
79
|
+
"libc",
|
|
80
|
+
"pyo3-build-config",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[[package]]
|
|
84
|
+
name = "pyo3-macros"
|
|
85
|
+
version = "0.29.3"
|
|
86
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
+
checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6"
|
|
88
|
+
dependencies = [
|
|
89
|
+
"proc-macro2",
|
|
90
|
+
"pyo3-macros-backend",
|
|
91
|
+
"quote",
|
|
92
|
+
"syn",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[[package]]
|
|
96
|
+
name = "pyo3-macros-backend"
|
|
97
|
+
version = "0.29.3"
|
|
98
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
+
checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3"
|
|
100
|
+
dependencies = [
|
|
101
|
+
"heck",
|
|
102
|
+
"proc-macro2",
|
|
103
|
+
"quote",
|
|
104
|
+
"syn",
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
[[package]]
|
|
108
|
+
name = "quote"
|
|
109
|
+
version = "1.0.47"
|
|
110
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
111
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
112
|
+
dependencies = [
|
|
113
|
+
"proc-macro2",
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
[[package]]
|
|
117
|
+
name = "syn"
|
|
118
|
+
version = "2.0.119"
|
|
119
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
120
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
121
|
+
dependencies = [
|
|
122
|
+
"proc-macro2",
|
|
123
|
+
"quote",
|
|
124
|
+
"unicode-ident",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
[[package]]
|
|
128
|
+
name = "target-lexicon"
|
|
129
|
+
version = "0.13.5"
|
|
130
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
131
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
132
|
+
|
|
133
|
+
[[package]]
|
|
134
|
+
name = "unicode-ident"
|
|
135
|
+
version = "1.0.26"
|
|
136
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
137
|
+
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
gdp_rs-0.1.0/Cargo.toml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "3"
|
|
3
|
+
members = ["crates/gdp", "bindings/python"]
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
edition = "2024"
|
|
8
|
+
rust-version = "1.90"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
repository = "https://github.com/cloudthinker-ai/proofbound"
|
|
11
|
+
|
|
12
|
+
[workspace.lints.rust]
|
|
13
|
+
unsafe_code = "forbid"
|
|
14
|
+
unused_crate_dependencies = "deny"
|
|
15
|
+
|
|
16
|
+
[workspace.lints.clippy]
|
|
17
|
+
allow_attributes_without_reason = "deny"
|
|
18
|
+
dbg_macro = "deny"
|
|
19
|
+
expect_used = "deny"
|
|
20
|
+
mem_forget = "deny"
|
|
21
|
+
panic = "deny"
|
|
22
|
+
todo = "deny"
|
|
23
|
+
undocumented_unsafe_blocks = "deny"
|
|
24
|
+
unimplemented = "deny"
|
|
25
|
+
unwrap_used = "deny"
|
|
26
|
+
|
|
27
|
+
[profile.dev]
|
|
28
|
+
opt-level = 0
|
|
29
|
+
|
|
30
|
+
[profile.release]
|
|
31
|
+
opt-level = 3
|
|
32
|
+
lto = true
|
|
33
|
+
codegen-units = 1
|
|
34
|
+
panic = "unwind"
|
gdp_rs-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Guillermo Rauch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
gdp_rs-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gdp-rs
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Classifier: Programming Language :: Rust
|
|
12
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Classifier: Topic :: Security
|
|
15
|
+
Requires-Dist: pytest>=8,<10 ; extra == 'test'
|
|
16
|
+
Requires-Dist: ruff>=0.11,<1 ; extra == 'test'
|
|
17
|
+
Requires-Dist: mypy>=1.15,<2 ; extra == 'test'
|
|
18
|
+
Requires-Dist: pyrefly>=1.3.1,<2 ; extra == 'test'
|
|
19
|
+
Requires-Dist: fastapi>=0.141.1,<1 ; extra == 'test'
|
|
20
|
+
Requires-Dist: httpx2>=2.13.1,<3 ; extra == 'test'
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Summary: Rust-backed proof contracts for Python authorization boundaries
|
|
24
|
+
Keywords: authorization,proof-contracts,rust,gdp
|
|
25
|
+
Author: CloudThinker AI
|
|
26
|
+
License-Expression: MIT
|
|
27
|
+
Requires-Python: >=3.11
|
|
28
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
29
|
+
Project-URL: Documentation, https://github.com/cloudthinker-ai/proofbound/blob/main/docs/python.md
|
|
30
|
+
Project-URL: Homepage, https://github.com/cloudthinker-ai/proofbound
|
|
31
|
+
Project-URL: Issues, https://github.com/cloudthinker-ai/proofbound/issues
|
|
32
|
+
Project-URL: Security, https://github.com/cloudthinker-ai/proofbound/blob/main/SECURITY.md
|
|
33
|
+
Project-URL: Source, https://github.com/cloudthinker-ai/proofbound
|
|
34
|
+
|
|
35
|
+
# Proofbound for Python
|
|
36
|
+
|
|
37
|
+
Rust-backed authorization contracts. The extension creates opaque names and proofs;
|
|
38
|
+
the Python decorator checks them before a sensitive function runs.
|
|
39
|
+
|
|
40
|
+
Proofbound is an early project with an evolving API. The Python distribution is
|
|
41
|
+
`gdp-rs`, the import package is `gdp`, and the linter command is `gdp-lint`.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install gdp-rs==0.1.0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
CPython 3.11–3.14 is tested. Release wheels support Linux x64/ARM64 (glibc 2.17+),
|
|
50
|
+
macOS ARM64 (11+) and Windows x64. Wheel installation does not require Rust;
|
|
51
|
+
building from source requires Rust 1.90 or newer.
|
|
52
|
+
|
|
53
|
+
## How it works
|
|
54
|
+
|
|
55
|
+
A trusted application module performs the real permission or entitlement check,
|
|
56
|
+
then issues a proof for named arguments. A sensitive function declares the proof
|
|
57
|
+
it requires using `@requires`. Before the body runs, Rust verifies the exact
|
|
58
|
+
issuer, ordered subject identities and active scope.
|
|
59
|
+
|
|
60
|
+
Equal raw IDs named separately have different identities. Type hints and the
|
|
61
|
+
AST linter add checks for accidental misuse. The library does not decide your
|
|
62
|
+
policy, prevent permission revocation or make a check and write atomic. Python
|
|
63
|
+
code running in the same process can bypass a decorator; this is not a sandbox.
|
|
64
|
+
|
|
65
|
+
See the [Python API](https://github.com/cloudthinker-ai/proofbound/blob/main/docs/python.md),
|
|
66
|
+
[guarantee matrix](https://github.com/cloudthinker-ai/proofbound/blob/main/docs/guarantees.md)
|
|
67
|
+
and [executable SQLite example](https://github.com/cloudthinker-ai/proofbound/tree/main/examples/python).
|
|
68
|
+
The [repository README](https://github.com/cloudthinker-ai/proofbound) includes
|
|
69
|
+
trusted checker and protected function examples.
|
|
70
|
+
|
|
71
|
+
## Attribution
|
|
72
|
+
|
|
73
|
+
Inspired by Guillermo Rauch's MIT-licensed
|
|
74
|
+
[gdp-ts](https://github.com/rauchg/gdp-ts), Matt Noonan's
|
|
75
|
+
[Ghosts of Departed Proofs](https://kataskeue.com/gdp.pdf), and Ollie Charles's
|
|
76
|
+
[Who Authorized These Ghosts!?](https://blog.ocharles.org.uk/posts/2019-08-09-who-authorized-these-ghosts.html).
|
|
77
|
+
The original copyright notice and MIT license are preserved in the distribution.
|
|
78
|
+
|
gdp_rs-0.1.0/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Proofbound for Python
|
|
2
|
+
|
|
3
|
+
Rust-backed authorization contracts. The extension creates opaque names and proofs;
|
|
4
|
+
the Python decorator checks them before a sensitive function runs.
|
|
5
|
+
|
|
6
|
+
Proofbound is an early project with an evolving API. The Python distribution is
|
|
7
|
+
`gdp-rs`, the import package is `gdp`, and the linter command is `gdp-lint`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install gdp-rs==0.1.0
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
CPython 3.11–3.14 is tested. Release wheels support Linux x64/ARM64 (glibc 2.17+),
|
|
16
|
+
macOS ARM64 (11+) and Windows x64. Wheel installation does not require Rust;
|
|
17
|
+
building from source requires Rust 1.90 or newer.
|
|
18
|
+
|
|
19
|
+
## How it works
|
|
20
|
+
|
|
21
|
+
A trusted application module performs the real permission or entitlement check,
|
|
22
|
+
then issues a proof for named arguments. A sensitive function declares the proof
|
|
23
|
+
it requires using `@requires`. Before the body runs, Rust verifies the exact
|
|
24
|
+
issuer, ordered subject identities and active scope.
|
|
25
|
+
|
|
26
|
+
Equal raw IDs named separately have different identities. Type hints and the
|
|
27
|
+
AST linter add checks for accidental misuse. The library does not decide your
|
|
28
|
+
policy, prevent permission revocation or make a check and write atomic. Python
|
|
29
|
+
code running in the same process can bypass a decorator; this is not a sandbox.
|
|
30
|
+
|
|
31
|
+
See the [Python API](https://github.com/cloudthinker-ai/proofbound/blob/main/docs/python.md),
|
|
32
|
+
[guarantee matrix](https://github.com/cloudthinker-ai/proofbound/blob/main/docs/guarantees.md)
|
|
33
|
+
and [executable SQLite example](https://github.com/cloudthinker-ai/proofbound/tree/main/examples/python).
|
|
34
|
+
The [repository README](https://github.com/cloudthinker-ai/proofbound) includes
|
|
35
|
+
trusted checker and protected function examples.
|
|
36
|
+
|
|
37
|
+
## Attribution
|
|
38
|
+
|
|
39
|
+
Inspired by Guillermo Rauch's MIT-licensed
|
|
40
|
+
[gdp-ts](https://github.com/rauchg/gdp-ts), Matt Noonan's
|
|
41
|
+
[Ghosts of Departed Proofs](https://kataskeue.com/gdp.pdf), and Ollie Charles's
|
|
42
|
+
[Who Authorized These Ghosts!?](https://blog.ocharles.org.uk/posts/2019-08-09-who-authorized-these-ghosts.html).
|
|
43
|
+
The original copyright notice and MIT license are preserved in the distribution.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "gdp-python"
|
|
3
|
+
version.workspace = true
|
|
4
|
+
edition.workspace = true
|
|
5
|
+
rust-version.workspace = true
|
|
6
|
+
license.workspace = true
|
|
7
|
+
repository.workspace = true
|
|
8
|
+
publish = false
|
|
9
|
+
description = "Python adapter for the GDP Rust proof-contract core"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
|
|
12
|
+
[lib]
|
|
13
|
+
name = "_gdp"
|
|
14
|
+
crate-type = ["cdylib", "rlib"]
|
|
15
|
+
|
|
16
|
+
[lints]
|
|
17
|
+
workspace = true
|
|
18
|
+
|
|
19
|
+
[dependencies]
|
|
20
|
+
gdp = { path = "../../crates/gdp" }
|
|
21
|
+
pyo3 = { version = "0.29", features = ["abi3-py311", "extension-module"] }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Guillermo Rauch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Proofbound for Python
|
|
2
|
+
|
|
3
|
+
Rust-backed authorization contracts. The extension creates opaque names and proofs;
|
|
4
|
+
the Python decorator checks them before a sensitive function runs.
|
|
5
|
+
|
|
6
|
+
Proofbound is an early project with an evolving API. The Python distribution is
|
|
7
|
+
`gdp-rs`, the import package is `gdp`, and the linter command is `gdp-lint`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install gdp-rs==0.1.0
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
CPython 3.11–3.14 is tested. Release wheels support Linux x64/ARM64 (glibc 2.17+),
|
|
16
|
+
macOS ARM64 (11+) and Windows x64. Wheel installation does not require Rust;
|
|
17
|
+
building from source requires Rust 1.90 or newer.
|
|
18
|
+
|
|
19
|
+
## How it works
|
|
20
|
+
|
|
21
|
+
A trusted application module performs the real permission or entitlement check,
|
|
22
|
+
then issues a proof for named arguments. A sensitive function declares the proof
|
|
23
|
+
it requires using `@requires`. Before the body runs, Rust verifies the exact
|
|
24
|
+
issuer, ordered subject identities and active scope.
|
|
25
|
+
|
|
26
|
+
Equal raw IDs named separately have different identities. Type hints and the
|
|
27
|
+
AST linter add checks for accidental misuse. The library does not decide your
|
|
28
|
+
policy, prevent permission revocation or make a check and write atomic. Python
|
|
29
|
+
code running in the same process can bypass a decorator; this is not a sandbox.
|
|
30
|
+
|
|
31
|
+
See the [Python API](https://github.com/cloudthinker-ai/proofbound/blob/main/docs/python.md),
|
|
32
|
+
[guarantee matrix](https://github.com/cloudthinker-ai/proofbound/blob/main/docs/guarantees.md)
|
|
33
|
+
and [executable SQLite example](https://github.com/cloudthinker-ai/proofbound/tree/main/examples/python).
|
|
34
|
+
The [repository README](https://github.com/cloudthinker-ai/proofbound) includes
|
|
35
|
+
trusted checker and protected function examples.
|
|
36
|
+
|
|
37
|
+
## Attribution
|
|
38
|
+
|
|
39
|
+
Inspired by Guillermo Rauch's MIT-licensed
|
|
40
|
+
[gdp-ts](https://github.com/rauchg/gdp-ts), Matt Noonan's
|
|
41
|
+
[Ghosts of Departed Proofs](https://kataskeue.com/gdp.pdf), and Ollie Charles's
|
|
42
|
+
[Who Authorized These Ghosts!?](https://blog.ocharles.org.uk/posts/2019-08-09-who-authorized-these-ghosts.html).
|
|
43
|
+
The original copyright notice and MIT license are preserved in the distribution.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
use std::panic::{AssertUnwindSafe, catch_unwind};
|
|
2
|
+
|
|
3
|
+
#[derive(Debug, PartialEq, Eq)]
|
|
4
|
+
pub(super) struct Fault;
|
|
5
|
+
|
|
6
|
+
pub(super) fn contain<T>(operation: impl FnOnce() -> T) -> Result<T, Fault> {
|
|
7
|
+
catch_unwind(AssertUnwindSafe(operation)).map_err(|_| Fault)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
#[cfg(test)]
|
|
11
|
+
mod tests {
|
|
12
|
+
use super::{Fault, contain};
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
fn rust_faults_are_contained_without_their_payload() {
|
|
16
|
+
assert_eq!(contain(|| 7), Ok(7));
|
|
17
|
+
assert_eq!(contain(|| panic!("internal engine failure")), Err(Fault));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
mod fault;
|
|
2
|
+
mod objects;
|
|
3
|
+
|
|
4
|
+
use gdp::runtime::ProofError;
|
|
5
|
+
use pyo3::exceptions::{PyPermissionError, PyRuntimeError, PyValueError};
|
|
6
|
+
use pyo3::prelude::*;
|
|
7
|
+
use pyo3::types::PyTuple;
|
|
8
|
+
|
|
9
|
+
use objects::{Named, Names, Proof, ProofKind, Prover};
|
|
10
|
+
|
|
11
|
+
pyo3::create_exception!(_gdp, AuthorizationError, PyPermissionError);
|
|
12
|
+
|
|
13
|
+
pub(super) fn contain_fault<T>(operation: impl FnOnce() -> PyResult<T>) -> PyResult<T> {
|
|
14
|
+
fault::contain(operation)
|
|
15
|
+
.map_err(|_| PyRuntimeError::new_err("Rust proof engine internal fault"))?
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
pub(super) fn authorization_error(error: ProofError) -> PyErr {
|
|
19
|
+
AuthorizationError::new_err(error.to_string())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#[pyfunction]
|
|
23
|
+
fn name(value: Py<PyAny>) -> Named {
|
|
24
|
+
Named::new(value, gdp::runtime::Name::fresh())
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[pyfunction]
|
|
28
|
+
#[pyo3(signature = (*values))]
|
|
29
|
+
fn names(values: &Bound<'_, PyTuple>) -> PyResult<Names> {
|
|
30
|
+
contain_fault(|| Names::new(values))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#[pyfunction]
|
|
34
|
+
#[pyo3(signature = (kind, *, tag=None))]
|
|
35
|
+
fn define_proof(kind: &str, tag: Option<Py<PyAny>>) -> PyResult<Prover> {
|
|
36
|
+
let _ = tag;
|
|
37
|
+
contain_fault(|| {
|
|
38
|
+
Ok(Prover::new(gdp::runtime::Prover::new(kind).map_err(
|
|
39
|
+
|error| PyValueError::new_err(error.to_string()),
|
|
40
|
+
)?))
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#[pymodule]
|
|
45
|
+
fn _gdp(module: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
46
|
+
module.add("INTERFACE_VERSION", 1)?;
|
|
47
|
+
module.add(
|
|
48
|
+
"AuthorizationError",
|
|
49
|
+
module.py().get_type::<AuthorizationError>(),
|
|
50
|
+
)?;
|
|
51
|
+
module.add_class::<Named>()?;
|
|
52
|
+
module.add_class::<Names>()?;
|
|
53
|
+
module.add_class::<Proof>()?;
|
|
54
|
+
module.add_class::<ProofKind>()?;
|
|
55
|
+
module.add_class::<Prover>()?;
|
|
56
|
+
module.add_function(wrap_pyfunction!(name, module)?)?;
|
|
57
|
+
module.add_function(wrap_pyfunction!(names, module)?)?;
|
|
58
|
+
module.add_function(wrap_pyfunction!(define_proof, module)?)?;
|
|
59
|
+
module.add(
|
|
60
|
+
"__all__",
|
|
61
|
+
[
|
|
62
|
+
"INTERFACE_VERSION",
|
|
63
|
+
"AuthorizationError",
|
|
64
|
+
"Named",
|
|
65
|
+
"Names",
|
|
66
|
+
"Proof",
|
|
67
|
+
"ProofKind",
|
|
68
|
+
"Prover",
|
|
69
|
+
"name",
|
|
70
|
+
"names",
|
|
71
|
+
"define_proof",
|
|
72
|
+
],
|
|
73
|
+
)?;
|
|
74
|
+
Ok(())
|
|
75
|
+
}
|