ocean-basket-protocol 2.3.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.
- ocean_basket_protocol-2.3.0/LICENSE +47 -0
- ocean_basket_protocol-2.3.0/PKG-INFO +566 -0
- ocean_basket_protocol-2.3.0/README.md +513 -0
- ocean_basket_protocol-2.3.0/obp/__init__.py +292 -0
- ocean_basket_protocol-2.3.0/obp/_rust_bridge.py +81 -0
- ocean_basket_protocol-2.3.0/obp/cli.py +214 -0
- ocean_basket_protocol-2.3.0/obp/config.py +139 -0
- ocean_basket_protocol-2.3.0/obp/core.py +694 -0
- ocean_basket_protocol-2.3.0/obp/exceptions.py +55 -0
- ocean_basket_protocol-2.3.0/obp/honeypot.py +397 -0
- ocean_basket_protocol-2.3.0/obp/input_sanitizer.py +346 -0
- ocean_basket_protocol-2.3.0/obp/leakguard.py +425 -0
- ocean_basket_protocol-2.3.0/obp/log_sanitizer.py +353 -0
- ocean_basket_protocol-2.3.0/obp/middleware.py +183 -0
- ocean_basket_protocol-2.3.0/obp/rate_limiter.py +351 -0
- ocean_basket_protocol-2.3.0/obp/secrets_manager.py +240 -0
- ocean_basket_protocol-2.3.0/obp/secure_audit.py +491 -0
- ocean_basket_protocol-2.3.0/obp/session.py +653 -0
- ocean_basket_protocol-2.3.0/obp/timeline.py +267 -0
- ocean_basket_protocol-2.3.0/obp/tls_context.py +274 -0
- ocean_basket_protocol-2.3.0/obp/tpm.py +255 -0
- ocean_basket_protocol-2.3.0/obp/trap_engine.py +776 -0
- ocean_basket_protocol-2.3.0/ocean_basket_protocol.egg-info/PKG-INFO +566 -0
- ocean_basket_protocol-2.3.0/ocean_basket_protocol.egg-info/SOURCES.txt +33 -0
- ocean_basket_protocol-2.3.0/ocean_basket_protocol.egg-info/dependency_links.txt +1 -0
- ocean_basket_protocol-2.3.0/ocean_basket_protocol.egg-info/entry_points.txt +2 -0
- ocean_basket_protocol-2.3.0/ocean_basket_protocol.egg-info/requires.txt +34 -0
- ocean_basket_protocol-2.3.0/ocean_basket_protocol.egg-info/top_level.txt +1 -0
- ocean_basket_protocol-2.3.0/pyproject.toml +143 -0
- ocean_basket_protocol-2.3.0/setup.cfg +4 -0
- ocean_basket_protocol-2.3.0/setup.py +14 -0
- ocean_basket_protocol-2.3.0/tests/test_new_features.py +294 -0
- ocean_basket_protocol-2.3.0/tests/test_new_modules.py +269 -0
- ocean_basket_protocol-2.3.0/tests/test_obp.py +1116 -0
- ocean_basket_protocol-2.3.0/tests/test_security.py +467 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 🐚 Ocean Basket Protocol (OBP)
|
|
2
|
+
# Proprietary License - All Rights Reserved
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Ocean Basket Protocol Authors
|
|
5
|
+
All Rights Reserved.
|
|
6
|
+
|
|
7
|
+
## LICENSE TERMS
|
|
8
|
+
|
|
9
|
+
This software is proprietary and confidential. Unauthorized copying, distribution,
|
|
10
|
+
modification, or any use of this software, via any medium, is strictly prohibited.
|
|
11
|
+
|
|
12
|
+
### Permitted Use
|
|
13
|
+
This software may only be used by:
|
|
14
|
+
1. Licensed Ocean Basket Protocol subscribers in good standing
|
|
15
|
+
2. Authorized developers with valid OBP API keys
|
|
16
|
+
|
|
17
|
+
### Restrictions
|
|
18
|
+
- ❌ NO redistribution
|
|
19
|
+
- ❌ NO modification
|
|
20
|
+
- ❌ NO commercial use without license
|
|
21
|
+
- ❌ NO open source embedding
|
|
22
|
+
- ❌ NO reverse engineering
|
|
23
|
+
|
|
24
|
+
### Commercial Licensing
|
|
25
|
+
To obtain a commercial license, contact:
|
|
26
|
+
- Email: licensing@oceanbasketprotocol.com
|
|
27
|
+
- Website: https://oceanbasketprotocol.com/license
|
|
28
|
+
|
|
29
|
+
### WARNING
|
|
30
|
+
This software is protected by copyright law and international treaties.
|
|
31
|
+
Violators will be prosecuted to the fullest extent of the law.
|
|
32
|
+
|
|
33
|
+
THE SOFTWARE IS PROVIDED UNDER THIS PROPRIETARY LICENSE AGREEMENT.
|
|
34
|
+
NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
|
35
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
36
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 🛡️ OBP PROTECTS ITSELF FROM THEFT 🛡️
|
|
41
|
+
|
|
42
|
+
Every copy of OBP includes self-protection mechanisms that verify:
|
|
43
|
+
- Valid license status
|
|
44
|
+
- Authorized execution environment
|
|
45
|
+
- Compliance with license terms
|
|
46
|
+
|
|
47
|
+
Attempting to circumvent these protections is a violation of law.
|
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ocean-basket-protocol
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: Physics-inspired self-protecting security framework
|
|
5
|
+
Author-email: OBP Authors <obp@example.com>
|
|
6
|
+
License: PROPRIETARY
|
|
7
|
+
Project-URL: Homepage, https://github.com/ocean-basket-protocol/ocean-basket-protocol
|
|
8
|
+
Project-URL: Documentation, https://github.com/ocean-basket-protocol/ocean-basket-protocol#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/ocean-basket-protocol/ocean-basket-protocol
|
|
10
|
+
Project-URL: Issues, https://github.com/ocean-basket-protocol/ocean-basket-protocol/issues
|
|
11
|
+
Keywords: security,protection,secrets,leak-detection,leakguard,honeypot,attribution,self-protection,runtime-protection,secret-scanning,secrets-management,vault-alternative,anti-patching,memory-protection,context-awareness,entropy-analysis,decoy,deception,traps,attribution,TPM,HSM,cryptography,secure-audit,self-healing,physics-inspired,viscosity,steam-burn
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: Other/Proprietary License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: rich>=13.0
|
|
26
|
+
Requires-Dist: matplotlib>=3.8
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Requires-Dist: cryptography>=42.0
|
|
29
|
+
Provides-Extra: rust
|
|
30
|
+
Requires-Dist: maturin>=1.0; extra == "rust"
|
|
31
|
+
Provides-Extra: geoip
|
|
32
|
+
Requires-Dist: geoip2>=4.7; extra == "geoip"
|
|
33
|
+
Provides-Extra: redis
|
|
34
|
+
Requires-Dist: redis>=5.0; extra == "redis"
|
|
35
|
+
Provides-Extra: vault
|
|
36
|
+
Requires-Dist: hvac>=1.1; extra == "vault"
|
|
37
|
+
Provides-Extra: aws
|
|
38
|
+
Requires-Dist: boto3>=1.34; extra == "aws"
|
|
39
|
+
Provides-Extra: full
|
|
40
|
+
Requires-Dist: geoip2>=4.7; extra == "full"
|
|
41
|
+
Requires-Dist: redis>=5.0; extra == "full"
|
|
42
|
+
Requires-Dist: hvac>=1.1; extra == "full"
|
|
43
|
+
Requires-Dist: boto3>=1.34; extra == "full"
|
|
44
|
+
Provides-Extra: dev
|
|
45
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
46
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
47
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
48
|
+
Requires-Dist: pytest-mock>=3.11.0; extra == "dev"
|
|
49
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
50
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
51
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
52
|
+
Dynamic: license-file
|
|
53
|
+
|
|
54
|
+
# 🌊 Ocean Basket Protocol (OBP)
|
|
55
|
+
|
|
56
|
+
**Physics-inspired self-protecting security framework.**
|
|
57
|
+
|
|
58
|
+
*You can't carry the ocean in a basket. The ocean protects itself.*
|
|
59
|
+
|
|
60
|
+
[](bindings/rust/)
|
|
61
|
+
[](bindings/typescript/)
|
|
62
|
+
[](bindings/go/)
|
|
63
|
+
[](obp/)
|
|
64
|
+
[](LICENSE)
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Overview
|
|
69
|
+
|
|
70
|
+
Ocean Basket Protocol is a production-ready Python framework that implements physics-inspired protection mechanisms for sensitive operations. Using metaphors from fluid dynamics and thermodynamics, OBP provides layered security through:
|
|
71
|
+
|
|
72
|
+
- **Viscosity Control**: Execution flow resistance based on trust level
|
|
73
|
+
- **Steam Burn**: Active computational resistance in untrusted contexts
|
|
74
|
+
- **LeakGuard**: Real-time secret detection in function arguments AND return values
|
|
75
|
+
- **Context Awareness**: Hardware/environment fingerprinting
|
|
76
|
+
- **Self-Protection**: OBP protects its own critical components
|
|
77
|
+
- **Anti-Patching**: Detects attempts to disable OBP protections
|
|
78
|
+
- **Memory Protection**: Warns about memory scraping attacks
|
|
79
|
+
- **Log Sanitization**: Automatic redaction of secrets in output
|
|
80
|
+
- **Trap Engine**: Turn attackers into targets with active attribution
|
|
81
|
+
|
|
82
|
+
## Features
|
|
83
|
+
|
|
84
|
+
- 🔒 **Multi-Mode Protection**: Graceful, Defensive, and Paranoid modes
|
|
85
|
+
- 🔍 **Secret Detection**: Pattern matching + entropy analysis for 30+ secret types
|
|
86
|
+
- 🎯 **Return Value Scanning**: Prevents secrets from leaking in API responses
|
|
87
|
+
- 🚫 **Anti-Patching**: Detects tampering with OBP's internal components
|
|
88
|
+
- 📝 **Log Sanitization**: Automatic redaction in print() and logging output
|
|
89
|
+
- 💾 **Memory Protection**: Warns about memory scraping and side-channel attacks
|
|
90
|
+
- 🎭 **Trap Engine**: Feed decoys, harvest attacker intel, real-time alerting
|
|
91
|
+
- 📊 **Audit Timeline**: Visual logging of all protection events
|
|
92
|
+
- 🐳 **Docker Ready**: Standard and air-gapped deployment options
|
|
93
|
+
- 🧪 **Fully Tested**: Comprehensive test suite with pytest
|
|
94
|
+
- ⚡ **Production Ready**: Singleton pattern, thread-safe, minimal dependencies
|
|
95
|
+
|
|
96
|
+
## New in v2.3
|
|
97
|
+
|
|
98
|
+
### Return Value Scanning
|
|
99
|
+
Prevents secrets from leaking in API responses, database queries, and function returns.
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from obp import obp, OBPConfig, ProtectionMode
|
|
103
|
+
|
|
104
|
+
config = OBPConfig(
|
|
105
|
+
mode=ProtectionMode.DEFENSIVE,
|
|
106
|
+
scan_return=True # NEW: Scan return values
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
@obp.protect(config)
|
|
110
|
+
def get_api_key():
|
|
111
|
+
return {"key": "sk_live_xxx..."} # Automatically redacted!
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Anti-Patching Protection
|
|
115
|
+
Detects attempts to disable OBP by patching critical methods or replacing the singleton.
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from obp import AntiPatchProtection
|
|
119
|
+
|
|
120
|
+
# Check if OBP has been tampered with
|
|
121
|
+
violations = AntiPatchProtection.check_integrity()
|
|
122
|
+
if violations:
|
|
123
|
+
print("OBP INTEGRITY COMPROMISED!")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Memory Protection Awareness
|
|
127
|
+
Warns about potential memory-based attacks.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from obp import MemoryProtection
|
|
131
|
+
|
|
132
|
+
warnings = MemoryProtection.check_environment()
|
|
133
|
+
for warning in warnings:
|
|
134
|
+
print(f"SECURITY WARNING: {warning}")
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Log Sanitization
|
|
138
|
+
Automatic redaction of secrets in print() and logging output.
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from obp import enable_log_sanitization
|
|
142
|
+
|
|
143
|
+
enable_log_sanitization()
|
|
144
|
+
|
|
145
|
+
print(f"Token: ghp_abcdefgh...") # Output: Token: [SECRET_REDACTED]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Expanded Secret Patterns
|
|
149
|
+
Detects secrets from HuggingFace, OpenAI, Anthropic, and more:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from obp import LeakGuard
|
|
153
|
+
|
|
154
|
+
leakguard = LeakGuard()
|
|
155
|
+
# HuggingFace tokens
|
|
156
|
+
leakguard.scan("hf_abcdefghijklmnopqrstuvwxyz12345678")
|
|
157
|
+
# OpenAI API keys
|
|
158
|
+
leakguard.scan("sk-abcdefghijklmnopqrstuvwxyz1234567890")
|
|
159
|
+
# Anthropic keys
|
|
160
|
+
leakguard.scan("sk-ant-api03-abcdefghijklmnopqrstuvwxyz")
|
|
161
|
+
# Database URLs with credentials
|
|
162
|
+
leakguard.scan("postgresql://user:password@host/db")
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Security Hardening (v2.0)
|
|
166
|
+
|
|
167
|
+
OBP now includes enterprise-grade security features:
|
|
168
|
+
|
|
169
|
+
### 🛡️ TPM Integration
|
|
170
|
+
Hardware-backed cryptographic signing for OBP artifacts.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from obp import TPMManager, TPMConfig
|
|
174
|
+
|
|
175
|
+
config = TPMConfig(use_tpm=True, allow_software_fallback=True)
|
|
176
|
+
tpm = TPMManager(config)
|
|
177
|
+
|
|
178
|
+
# Generate and sign artifacts
|
|
179
|
+
key_id = tpm.generate_key("my_key")
|
|
180
|
+
signature = tpm.sign(key_id, b"critical_data")
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 🎭 Active Honeypots
|
|
184
|
+
Active deception system that tracks and analyzes attackers.
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from obp import HoneypotManager, HoneypotType, HoneypotConfig
|
|
188
|
+
|
|
189
|
+
config = HoneypotConfig(enabled=True, track_attempts=True)
|
|
190
|
+
hp = HoneypotManager(config)
|
|
191
|
+
|
|
192
|
+
# Create decoy API keys
|
|
193
|
+
decoy_id = hp.create_decoy("Production API Key", HoneypotType.API)
|
|
194
|
+
|
|
195
|
+
# When attacker accesses it
|
|
196
|
+
value = hp.get_decoy(decoy_id, attacker_id="attacker_ip")
|
|
197
|
+
|
|
198
|
+
# Get attacker analysis
|
|
199
|
+
report = hp.get_attacker_report()
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### 🔐 Secure Audit Logging
|
|
203
|
+
Tamper-evident, cryptographically-signed audit logs.
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from obp import SecureAuditLogger, SecureAuditConfig, LogLevel
|
|
207
|
+
|
|
208
|
+
config = SecureAuditConfig(
|
|
209
|
+
log_dir="/var/log/obp",
|
|
210
|
+
encrypt_logs=True,
|
|
211
|
+
sign_entries=True
|
|
212
|
+
)
|
|
213
|
+
audit = SecureAuditLogger(config)
|
|
214
|
+
|
|
215
|
+
# Log security events
|
|
216
|
+
audit.log(
|
|
217
|
+
event_type="LEAK_DETECTED",
|
|
218
|
+
message="Secret detected in function call",
|
|
219
|
+
level=LogLevel.SECURITY,
|
|
220
|
+
security_event=True
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
# Verify integrity
|
|
224
|
+
result = audit.verify_integrity()
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 🔑 Session Hijacking Protection
|
|
228
|
+
Comprehensive session security with anomaly detection.
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
from obp import SessionHijackingProtection, SessionFingerprint, SessionConfig
|
|
232
|
+
|
|
233
|
+
config = SessionConfig(
|
|
234
|
+
session_timeout=1800,
|
|
235
|
+
require_fresh_fingerprint=True,
|
|
236
|
+
check_geo_velocity=True
|
|
237
|
+
)
|
|
238
|
+
session = SessionHijackingProtection(config)
|
|
239
|
+
|
|
240
|
+
# Create session
|
|
241
|
+
fingerprint = SessionFingerprint(
|
|
242
|
+
user_agent="Browser/1.0",
|
|
243
|
+
ip_address="192.168.1.100",
|
|
244
|
+
platform="Linux"
|
|
245
|
+
)
|
|
246
|
+
token, refresh = session.create_session("user_123", fingerprint, "192.168.1.100")
|
|
247
|
+
|
|
248
|
+
# Validate - detects hijacking attempts
|
|
249
|
+
status, sess = session.validate_session(token, fingerprint, "192.168.1.100")
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 🎯 Trap Engine - Attribution & Deception (v2.2)
|
|
253
|
+
|
|
254
|
+
**Turn attackers into targets.** Trap Engine feeds convincing decoy data while silently harvesting attacker intelligence and generating court-admissible forensic evidence.
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
from obp import trap_engine, configure_trap_engine, TrapLevel
|
|
258
|
+
|
|
259
|
+
# Configure with real-time alerting
|
|
260
|
+
configure_trap_engine(
|
|
261
|
+
trap_level='active',
|
|
262
|
+
slack_webhook='https://hooks.slack.com/services/XXX',
|
|
263
|
+
log_dir='/var/log/obp/forensics'
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
# When attacker accesses "sensitive" data
|
|
267
|
+
decoy_data, evidence_ids = trap_engine.activate_trap(
|
|
268
|
+
attacker_id='203.0.113.50',
|
|
269
|
+
data_requested='api_keys',
|
|
270
|
+
decoy_data='sk_live_fake_key_xxxxx'
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
# Attacker thinks they got real data ✅
|
|
274
|
+
# You get: IP, geo, ISP, user agent, fingerprints ✅
|
|
275
|
+
# Evidence logged for law enforcement ✅
|
|
276
|
+
|
|
277
|
+
# Generate full investigation report
|
|
278
|
+
report = trap_engine.generate_investigation_report(attacker_ip)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**What gets harvested:**
|
|
282
|
+
- IP address, geolocation, ISP, ASN
|
|
283
|
+
- Tor/VPN/Proxy detection
|
|
284
|
+
- Browser fingerprint
|
|
285
|
+
- User agent & headers
|
|
286
|
+
- All accessed endpoints
|
|
287
|
+
- Session timing & behavior
|
|
288
|
+
|
|
289
|
+
**Alert Channels:**
|
|
290
|
+
- Slack, Webhook, Email, Syslog, File
|
|
291
|
+
|
|
292
|
+
**Trap Levels:**
|
|
293
|
+
| Level | Behavior |
|
|
294
|
+
|-------|----------|
|
|
295
|
+
| PASSIVE | Monitor only |
|
|
296
|
+
| SUBTLE | Return decoys silently |
|
|
297
|
+
| ACTIVE | Harvest + alert (default) |
|
|
298
|
+
| AGGRESSIVE | Full attribution |
|
|
299
|
+
|
|
300
|
+
## Installation
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Standard installation
|
|
304
|
+
pip install -e .
|
|
305
|
+
|
|
306
|
+
# With development dependencies
|
|
307
|
+
pip install -e ".[dev]"
|
|
308
|
+
|
|
309
|
+
# With Rust support (for high-performance steam burn)
|
|
310
|
+
pip install -e ".[rust]"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Quick Start
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
from obp import obp, OBPConfig, ProtectionMode, render_timeline
|
|
317
|
+
|
|
318
|
+
# Configure protection
|
|
319
|
+
config = OBPConfig(
|
|
320
|
+
viscosity=0.8,
|
|
321
|
+
max_temperature=0.9,
|
|
322
|
+
mode=ProtectionMode.DEFENSIVE,
|
|
323
|
+
enable_leakguard=True
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
# Protect sensitive functions
|
|
327
|
+
@obp.protect(config)
|
|
328
|
+
def sensitive_trading_logic(api_key: str, amount: float):
|
|
329
|
+
"""This function is now protected by OBP."""
|
|
330
|
+
return {"profit": amount * 1.15, "status": "executed"}
|
|
331
|
+
|
|
332
|
+
# Execute (LeakGuard will protect if API key is exposed)
|
|
333
|
+
result = sensitive_trading_logic("dummy_key_123", 1000.0)
|
|
334
|
+
|
|
335
|
+
# View audit timeline
|
|
336
|
+
render_timeline(obp.audit_log)
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Protection Modes
|
|
340
|
+
|
|
341
|
+
| Mode | On Secret Detected | On Untrusted Context |
|
|
342
|
+
|------|-------------------|---------------------|
|
|
343
|
+
| **GRACEFUL** | Returns decoy value | Applies viscosity delay |
|
|
344
|
+
| **DEFENSIVE** | Returns decoy value | Applies viscosity + steam burn |
|
|
345
|
+
| **PARANOID** | Raises exception | Applies viscosity + steam burn + reversion |
|
|
346
|
+
|
|
347
|
+
## LeakGuard Detection
|
|
348
|
+
|
|
349
|
+
LeakGuard automatically detects common secret patterns:
|
|
350
|
+
|
|
351
|
+
- GitHub tokens (`ghp_`, `github_pat_`)
|
|
352
|
+
- Stripe keys (`sk_live_`, `sk_test_`)
|
|
353
|
+
- AWS keys (`AKIA...`)
|
|
354
|
+
- Google API keys (`AIza...`)
|
|
355
|
+
- Private key headers
|
|
356
|
+
- JWT tokens
|
|
357
|
+
- High-entropy strings (configurable threshold)
|
|
358
|
+
|
|
359
|
+
```python
|
|
360
|
+
# LeakGuard in action
|
|
361
|
+
@obp.protect(OBPConfig(enable_leakguard=True))
|
|
362
|
+
def process_payment(card_number: str):
|
|
363
|
+
# If "sk_live_" or high-entropy string detected...
|
|
364
|
+
# OBP returns decoy instead of executing
|
|
365
|
+
pass
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## Self-Protection
|
|
369
|
+
|
|
370
|
+
OBP protects its own critical methods:
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
# Critical methods are protected using the same framework
|
|
374
|
+
@obp.protect(OBPConfig(mode=ProtectionMode.DEFENSIVE, viscosity=0.6))
|
|
375
|
+
def _protected_generate_fingerprint():
|
|
376
|
+
return obp._generate_context_fingerprint()
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## Configuration
|
|
380
|
+
|
|
381
|
+
```python
|
|
382
|
+
from obp import OBPConfig, ProtectionMode, ReversionSpeed
|
|
383
|
+
|
|
384
|
+
config = OBPConfig(
|
|
385
|
+
viscosity=0.75, # 0.0 (free) -> 1.0 (slow)
|
|
386
|
+
max_temperature=0.85, # Steam burn intensity
|
|
387
|
+
mode=ProtectionMode.DEFENSIVE,
|
|
388
|
+
enable_leakguard=True,
|
|
389
|
+
resonance_sensitivity=0.6,
|
|
390
|
+
reversion_speed=ReversionSpeed.GRACEFUL,
|
|
391
|
+
entropy_threshold=4.5, # For high-entropy secret detection
|
|
392
|
+
steam_burn_iterations=50_000
|
|
393
|
+
)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Examples
|
|
397
|
+
|
|
398
|
+
### Basic Usage
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
python examples/basic.py
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Self-Protection Demo
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
python examples/self_protected.py
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Testing
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
# Run core tests
|
|
414
|
+
pytest tests/test_obp.py -v
|
|
415
|
+
|
|
416
|
+
# Run security hardening tests
|
|
417
|
+
pytest tests/test_security.py -v
|
|
418
|
+
|
|
419
|
+
# Run all tests with coverage
|
|
420
|
+
pytest tests/ --cov=obp --cov-report=html
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## Docker Deployment
|
|
424
|
+
|
|
425
|
+
### Standard Deployment
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
docker build -f docker/Dockerfile -t obp:latest .
|
|
429
|
+
docker run obp:latest
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Air-Gapped Deployment
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
# Download dependencies on connected machine
|
|
436
|
+
pip download -r requirements.txt -d wheels/
|
|
437
|
+
|
|
438
|
+
# Build air-gapped image
|
|
439
|
+
docker build -f docker/airgapped.Dockerfile -t obp:airgapped .
|
|
440
|
+
|
|
441
|
+
# Run in isolated environment
|
|
442
|
+
docker run --network=none obp:airgapped
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## Project Structure
|
|
446
|
+
|
|
447
|
+
```
|
|
448
|
+
ocean-basket-protocol/
|
|
449
|
+
├── pyproject.toml # Package configuration (with maturin/Rust)
|
|
450
|
+
├── README.md # This file
|
|
451
|
+
├── LICENSE # PROPRIETARY - All Rights Reserved
|
|
452
|
+
├── obp/ # Python implementation
|
|
453
|
+
│ ├── __init__.py # Package exports
|
|
454
|
+
│ ├── core.py # OBP singleton & decorator
|
|
455
|
+
│ ├── config.py # Configuration classes
|
|
456
|
+
│ ├── leakguard.py # Secret detection
|
|
457
|
+
│ ├── exceptions.py # Custom exceptions
|
|
458
|
+
│ ├── timeline.py # Visual timeline renderer
|
|
459
|
+
│ ├── tpm.py # TPM integration
|
|
460
|
+
│ ├── honeypot.py # Active honeypots
|
|
461
|
+
│ ├── trap_engine.py # 🎯 Attribution & Deception
|
|
462
|
+
│ ├── secure_audit.py # Secure audit logging
|
|
463
|
+
│ ├── session.py # Session hijacking protection
|
|
464
|
+
│ ├── rate_limiter.py # Rate limiting
|
|
465
|
+
│ ├── secrets_manager.py # Secrets manager integration
|
|
466
|
+
│ └── _rust_bridge.py # Rust core bridge
|
|
467
|
+
├── bindings/ # Multi-language bindings
|
|
468
|
+
│ ├── rust/ # Rust + PyO3 high-performance core
|
|
469
|
+
│ ├── typescript/ # TypeScript/JavaScript
|
|
470
|
+
│ └── go/ # Go implementation
|
|
471
|
+
├── examples/ # Usage examples
|
|
472
|
+
│ ├── basic.py
|
|
473
|
+
│ └── self_protected.py
|
|
474
|
+
├── tests/ # Test suite
|
|
475
|
+
│ ├── test_obp.py
|
|
476
|
+
│ └── test_security.py
|
|
477
|
+
├── docs/ # Documentation
|
|
478
|
+
│ └── architecture.md
|
|
479
|
+
├── web_app.py # 🌊 Live test UI
|
|
480
|
+
└── docker/ # Docker configurations
|
|
481
|
+
├── Dockerfile
|
|
482
|
+
└── airgapped.Dockerfile
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
## API Reference
|
|
486
|
+
|
|
487
|
+
### Core Classes
|
|
488
|
+
|
|
489
|
+
- `OBP`: Main singleton class
|
|
490
|
+
- `OBPConfig`: Configuration dataclass
|
|
491
|
+
- `ProtectionMode`: Enum (GRACEFUL, DEFENSIVE, PARANOID)
|
|
492
|
+
- `ReversionSpeed`: Enum (GRACEFUL, IMMEDIATE)
|
|
493
|
+
|
|
494
|
+
### Components
|
|
495
|
+
|
|
496
|
+
- `LeakGuard`: Secret detection engine
|
|
497
|
+
- `render_timeline()`: Visual timeline renderer
|
|
498
|
+
- `get_timeline_stats()`: Audit statistics
|
|
499
|
+
|
|
500
|
+
### Exceptions
|
|
501
|
+
|
|
502
|
+
- `OceanBasketError`: Base exception
|
|
503
|
+
- `LeakDetectedError`: Secret detected
|
|
504
|
+
- `ReversionError`: Reversion triggered
|
|
505
|
+
|
|
506
|
+
## Security Considerations
|
|
507
|
+
|
|
508
|
+
- Context fingerprinting is for runtime verification (use TPM for cryptographic signing)
|
|
509
|
+
- Decoy values are not active honeypots
|
|
510
|
+
- Audit logs should be secured in production
|
|
511
|
+
- Consider additional hardening for sensitive deployments
|
|
512
|
+
|
|
513
|
+
## Performance
|
|
514
|
+
|
|
515
|
+
Typical overhead per protected call:
|
|
516
|
+
- **GRACEFUL**: ~0.5ms baseline
|
|
517
|
+
- **DEFENSIVE**: ~5-50ms (depending on viscosity)
|
|
518
|
+
- **PARANOID**: ~5-50ms + potential exception
|
|
519
|
+
|
|
520
|
+
## Contributing
|
|
521
|
+
|
|
522
|
+
Contributions welcome! Please see CONTRIBUTING.md for guidelines.
|
|
523
|
+
|
|
524
|
+
## Competitive Analysis
|
|
525
|
+
|
|
526
|
+
OBP occupies a unique position as the **only runtime protection framework** with self-healing capabilities. See [docs/COMPETITIVE_ANALYSIS.md](docs/COMPETITIVE_ANALYSIS.md) for a detailed comparison with:
|
|
527
|
+
|
|
528
|
+
- **Vault Solutions**: HashiCorp Vault, AWS Secrets Manager, GCP Secret Manager, Azure Key Vault
|
|
529
|
+
- **Secret Scanners**: Gitleaks, TruffleHog, Secretlint
|
|
530
|
+
- **Secrets Injection**: Docker Secrets, envchain, Mozilla SOPS
|
|
531
|
+
- **Runtime Security**: Bandit, PyTanche, Python-dotenv Security
|
|
532
|
+
|
|
533
|
+
### Key Differentiators
|
|
534
|
+
|
|
535
|
+
| Feature | OBP | Vault | Scanners |
|
|
536
|
+
|---------|-----|-------|----------|
|
|
537
|
+
| Runtime Protection | ✅ | ❌ | ❌ |
|
|
538
|
+
| Self-Protection | ✅ | ❌ | ❌ |
|
|
539
|
+
| Return Value Scanning | ✅ | ❌ | ❌ |
|
|
540
|
+
| Zero Infrastructure | ✅ | ❌ | ✅ |
|
|
541
|
+
| Python-native | ✅ | Via SDK | Partial |
|
|
542
|
+
|
|
543
|
+
## Roadmap
|
|
544
|
+
|
|
545
|
+
See [docs/COMPETITIVE_ANALYSIS.md](docs/COMPETITIVE_ANALYSIS.md) for planned features including:
|
|
546
|
+
- ML-based anomaly detection
|
|
547
|
+
- HSM/TPM 2.0 integration
|
|
548
|
+
- Kubernetes operator
|
|
549
|
+
- SIEM connectors
|
|
550
|
+
- Quantum-resistant cryptography
|
|
551
|
+
|
|
552
|
+
## License
|
|
553
|
+
|
|
554
|
+
**PROPRIETARY - All Rights Reserved**
|
|
555
|
+
|
|
556
|
+
Copyright (c) 2024 Ocean Basket Protocol Authors
|
|
557
|
+
|
|
558
|
+
This software is proprietary and confidential. Unauthorized copying, distribution, or modification is strictly prohibited.
|
|
559
|
+
|
|
560
|
+
To obtain a commercial license, contact: licensing@oceanbasketprotocol.com
|
|
561
|
+
|
|
562
|
+
See [LICENSE](LICENSE) file for full terms.
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
*The ocean protects itself. 🐚🛡️🌊*
|