xoras-agent-framework 2.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.
- xoras_agent_framework-2.0.0/LICENSE +21 -0
- xoras_agent_framework-2.0.0/PKG-INFO +130 -0
- xoras_agent_framework-2.0.0/README.md +112 -0
- xoras_agent_framework-2.0.0/examples/01_basic_agent.py +29 -0
- xoras_agent_framework-2.0.0/examples/02_secure_code_evaluator.py +31 -0
- xoras_agent_framework-2.0.0/pyproject.toml +29 -0
- xoras_agent_framework-2.0.0/setup.cfg +4 -0
- xoras_agent_framework-2.0.0/setup.py +3 -0
- xoras_agent_framework-2.0.0/tests/test_ast_security.py +47 -0
- xoras_agent_framework-2.0.0/tests/test_runtime.py +42 -0
- xoras_agent_framework-2.0.0/tests/test_signer.py +27 -0
- xoras_agent_framework-2.0.0/xoras/__init__.py +23 -0
- xoras_agent_framework-2.0.0/xoras/ast_security.py +141 -0
- xoras_agent_framework-2.0.0/xoras/cli.py +211 -0
- xoras_agent_framework-2.0.0/xoras/config.py +102 -0
- xoras_agent_framework-2.0.0/xoras/orchestrator.py +69 -0
- xoras_agent_framework-2.0.0/xoras/runtime.py +157 -0
- xoras_agent_framework-2.0.0/xoras/signer.py +64 -0
- xoras_agent_framework-2.0.0/xoras_agent_framework.egg-info/PKG-INFO +130 -0
- xoras_agent_framework-2.0.0/xoras_agent_framework.egg-info/SOURCES.txt +22 -0
- xoras_agent_framework-2.0.0/xoras_agent_framework.egg-info/dependency_links.txt +1 -0
- xoras_agent_framework-2.0.0/xoras_agent_framework.egg-info/entry_points.txt +2 -0
- xoras_agent_framework-2.0.0/xoras_agent_framework.egg-info/requires.txt +2 -0
- xoras_agent_framework-2.0.0/xoras_agent_framework.egg-info/top_level.txt +9 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 XORAS Systems LLC
|
|
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 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,130 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xoras-agent-framework
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Enterprise Multi-Agent Runtime & AST Security Governance Framework
|
|
5
|
+
Author-email: XORAS Systems LLC <engineering@xoras.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Topic :: Security
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: pyyaml>=6.0
|
|
16
|
+
Requires-Dist: cryptography>=41.0.0
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# XORAS Agentic Environment & Governance Framework v2.0
|
|
20
|
+
|
|
21
|
+
[](https://xoras.ai)
|
|
22
|
+
[](LICENSE)
|
|
23
|
+
[](#ast-static-security-gating)
|
|
24
|
+
[](#testing)
|
|
25
|
+
|
|
26
|
+
**XORAS Agentic Environment & Governance Framework** is an enterprise-grade multi-agent runtime, dynamic AST security scanner, and cryptographic provenance platform developed by **XORAS Systems LLC**.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Key Features
|
|
31
|
+
|
|
32
|
+
- **AST Static Security Gating (`env-integrity-sentry`)**: Real-time Abstract Syntax Tree parsing and secret scanning that intercepts dangerous code injections (`eval`, `exec`, `subprocess shell=True`) and credential leaks prior to execution.
|
|
33
|
+
- **Cryptographic Trace Receipts (`xoras.evidence.v1`)**: Every agent state transition and tool invocation generates an Ed25519 / HMAC SHA-256 signed JSON-L trace receipt for 100% zero-falsification audit trails.
|
|
34
|
+
- **Swarm Agent Orchestrator**: Multi-agent state graph pipeline coordinating **Architect**, **Engineer**, and **Auditor** roles with consensus gating and fallback remediation.
|
|
35
|
+
- **Zero-Drift Specification (`.xorasrules` & `xoras.env.yaml`)**: Standardized environment rules, role permissions, memory hierarchies, and workspace boundary controls.
|
|
36
|
+
- **Interactive Web Dashboard & Product Landing Page**: Embedded web UI serving live trace logs, AST playgrounds, and product metrics (`xoras serve`).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Architecture Overview
|
|
41
|
+
|
|
42
|
+
```mermaid
|
|
43
|
+
flowchart TD
|
|
44
|
+
UserRequest["User / Trigger Payload"] --> SwarmOrchestrator["Swarm Orchestrator (Architect)"]
|
|
45
|
+
SwarmOrchestrator --> ASTEngine["AST Security Engine (Auditor)"]
|
|
46
|
+
|
|
47
|
+
ASTEngine -- "Pass (Safety Score = 1.0)" --> RuntimeHarness["XORAS Runtime Harness (Engineer)"]
|
|
48
|
+
ASTEngine -- "Fail (Restricted Token)" --> RejectReceipt["Log Rejection & Signed Receipt"]
|
|
49
|
+
|
|
50
|
+
RuntimeHarness --> ToolExec["Subprocess / File I/O Sandbox"]
|
|
51
|
+
ToolExec --> EvidenceSigner["Cryptographic Signer (HMAC / Ed25519)"]
|
|
52
|
+
EvidenceSigner --> JSONLTrace["xoras_agent_traces.jsonl"]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Quickstart & Installation
|
|
58
|
+
|
|
59
|
+
### 1. Install Package
|
|
60
|
+
```bash
|
|
61
|
+
pip install xoras-agent-framework
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 2. Initialize Governance Environment
|
|
65
|
+
```bash
|
|
66
|
+
xoras init
|
|
67
|
+
```
|
|
68
|
+
This generates `.xorasrules` and `xoras.env.yaml` in your workspace root.
|
|
69
|
+
|
|
70
|
+
### 3. Scan Scripts for AST Violations
|
|
71
|
+
```bash
|
|
72
|
+
xoras scan my_script.py
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4. Run Scripts in Isolated Sandbox
|
|
76
|
+
```bash
|
|
77
|
+
xoras run my_script.py
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 5. Serve Interactive Web Dashboard
|
|
81
|
+
```bash
|
|
82
|
+
xoras serve --port 8080
|
|
83
|
+
```
|
|
84
|
+
Open `http://localhost:8080` to view the live product landing page and interactive AST playground.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Python API Usage
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from xoras import XORASAgentEnvironment, SwarmOrchestrator
|
|
92
|
+
|
|
93
|
+
# Initialize environment
|
|
94
|
+
env = XORASAgentEnvironment(config_path="xoras.env.yaml")
|
|
95
|
+
|
|
96
|
+
# Run multi-agent orchestrator pipeline
|
|
97
|
+
orchestrator = SwarmOrchestrator(env=env)
|
|
98
|
+
result = orchestrator.run_pipeline(
|
|
99
|
+
task_description="Deploy verified configuration file",
|
|
100
|
+
code_payload='{"status": "active", "version": "2.0.0"}',
|
|
101
|
+
target_path="artifacts/deploy_config.json"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
print("Pipeline Success:", result["success"])
|
|
105
|
+
print("Trace Signature:", result["last_signature"])
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Testing
|
|
111
|
+
|
|
112
|
+
Run the automated test suite:
|
|
113
|
+
```bash
|
|
114
|
+
PYTHONPATH=. pytest tests/
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Documentation
|
|
120
|
+
|
|
121
|
+
- [AST Security Gating Specification](docs/architecture/AST_SECURITY_GATING.md)
|
|
122
|
+
- [Cryptographic Provenance Receipts](docs/architecture/CRYPTOGRAPHIC_PROVENANCE.md)
|
|
123
|
+
- [API Reference](docs/API_REFERENCE.md)
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
Distributed under the MIT Enterprise License. See `LICENSE` for details.
|
|
130
|
+
© 2026 XORAS Systems LLC. All rights reserved.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# XORAS Agentic Environment & Governance Framework v2.0
|
|
2
|
+
|
|
3
|
+
[](https://xoras.ai)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](#ast-static-security-gating)
|
|
6
|
+
[](#testing)
|
|
7
|
+
|
|
8
|
+
**XORAS Agentic Environment & Governance Framework** is an enterprise-grade multi-agent runtime, dynamic AST security scanner, and cryptographic provenance platform developed by **XORAS Systems LLC**.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Key Features
|
|
13
|
+
|
|
14
|
+
- **AST Static Security Gating (`env-integrity-sentry`)**: Real-time Abstract Syntax Tree parsing and secret scanning that intercepts dangerous code injections (`eval`, `exec`, `subprocess shell=True`) and credential leaks prior to execution.
|
|
15
|
+
- **Cryptographic Trace Receipts (`xoras.evidence.v1`)**: Every agent state transition and tool invocation generates an Ed25519 / HMAC SHA-256 signed JSON-L trace receipt for 100% zero-falsification audit trails.
|
|
16
|
+
- **Swarm Agent Orchestrator**: Multi-agent state graph pipeline coordinating **Architect**, **Engineer**, and **Auditor** roles with consensus gating and fallback remediation.
|
|
17
|
+
- **Zero-Drift Specification (`.xorasrules` & `xoras.env.yaml`)**: Standardized environment rules, role permissions, memory hierarchies, and workspace boundary controls.
|
|
18
|
+
- **Interactive Web Dashboard & Product Landing Page**: Embedded web UI serving live trace logs, AST playgrounds, and product metrics (`xoras serve`).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Architecture Overview
|
|
23
|
+
|
|
24
|
+
```mermaid
|
|
25
|
+
flowchart TD
|
|
26
|
+
UserRequest["User / Trigger Payload"] --> SwarmOrchestrator["Swarm Orchestrator (Architect)"]
|
|
27
|
+
SwarmOrchestrator --> ASTEngine["AST Security Engine (Auditor)"]
|
|
28
|
+
|
|
29
|
+
ASTEngine -- "Pass (Safety Score = 1.0)" --> RuntimeHarness["XORAS Runtime Harness (Engineer)"]
|
|
30
|
+
ASTEngine -- "Fail (Restricted Token)" --> RejectReceipt["Log Rejection & Signed Receipt"]
|
|
31
|
+
|
|
32
|
+
RuntimeHarness --> ToolExec["Subprocess / File I/O Sandbox"]
|
|
33
|
+
ToolExec --> EvidenceSigner["Cryptographic Signer (HMAC / Ed25519)"]
|
|
34
|
+
EvidenceSigner --> JSONLTrace["xoras_agent_traces.jsonl"]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quickstart & Installation
|
|
40
|
+
|
|
41
|
+
### 1. Install Package
|
|
42
|
+
```bash
|
|
43
|
+
pip install xoras-agent-framework
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Initialize Governance Environment
|
|
47
|
+
```bash
|
|
48
|
+
xoras init
|
|
49
|
+
```
|
|
50
|
+
This generates `.xorasrules` and `xoras.env.yaml` in your workspace root.
|
|
51
|
+
|
|
52
|
+
### 3. Scan Scripts for AST Violations
|
|
53
|
+
```bash
|
|
54
|
+
xoras scan my_script.py
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 4. Run Scripts in Isolated Sandbox
|
|
58
|
+
```bash
|
|
59
|
+
xoras run my_script.py
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 5. Serve Interactive Web Dashboard
|
|
63
|
+
```bash
|
|
64
|
+
xoras serve --port 8080
|
|
65
|
+
```
|
|
66
|
+
Open `http://localhost:8080` to view the live product landing page and interactive AST playground.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Python API Usage
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from xoras import XORASAgentEnvironment, SwarmOrchestrator
|
|
74
|
+
|
|
75
|
+
# Initialize environment
|
|
76
|
+
env = XORASAgentEnvironment(config_path="xoras.env.yaml")
|
|
77
|
+
|
|
78
|
+
# Run multi-agent orchestrator pipeline
|
|
79
|
+
orchestrator = SwarmOrchestrator(env=env)
|
|
80
|
+
result = orchestrator.run_pipeline(
|
|
81
|
+
task_description="Deploy verified configuration file",
|
|
82
|
+
code_payload='{"status": "active", "version": "2.0.0"}',
|
|
83
|
+
target_path="artifacts/deploy_config.json"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
print("Pipeline Success:", result["success"])
|
|
87
|
+
print("Trace Signature:", result["last_signature"])
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Testing
|
|
93
|
+
|
|
94
|
+
Run the automated test suite:
|
|
95
|
+
```bash
|
|
96
|
+
PYTHONPATH=. pytest tests/
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
- [AST Security Gating Specification](docs/architecture/AST_SECURITY_GATING.md)
|
|
104
|
+
- [Cryptographic Provenance Receipts](docs/architecture/CRYPTOGRAPHIC_PROVENANCE.md)
|
|
105
|
+
- [API Reference](docs/API_REFERENCE.md)
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
Distributed under the MIT Enterprise License. See `LICENSE` for details.
|
|
112
|
+
© 2026 XORAS Systems LLC. All rights reserved.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
XORAS Agentic Framework — Basic Agent Example
|
|
4
|
+
Demonstrates environment initialization, tool execution, and signed trace receipts.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from xoras import XORASAgentEnvironment
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
print("=== XORAS Agent Framework — Basic Agent Example ===")
|
|
11
|
+
env = XORASAgentEnvironment(config_path="xoras.env.yaml")
|
|
12
|
+
|
|
13
|
+
# Execute a safe file write tool
|
|
14
|
+
result = env.execute_tool(
|
|
15
|
+
agent_name="Engineer",
|
|
16
|
+
tool_name="file_write",
|
|
17
|
+
args={
|
|
18
|
+
"path": "artifacts/basic_agent_output.json",
|
|
19
|
+
"content": '{"message": "Hello from XORAS Agent Framework v2.0", "status": "active"}'
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
print("\nExecution Result:")
|
|
24
|
+
print("Success:", result.get("success"))
|
|
25
|
+
print("Path:", result.get("path"))
|
|
26
|
+
print("Receipt Signature:", result.get("receipt_signature"))
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
main()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
XORAS Agentic Framework — AST Code Security Evaluator
|
|
4
|
+
Demonstrates AST static analysis and rejection of unsafe dynamic code snippets.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from xoras import ASTSecurityEngine
|
|
8
|
+
|
|
9
|
+
def evaluate_snippets():
|
|
10
|
+
engine = ASTSecurityEngine()
|
|
11
|
+
|
|
12
|
+
snippets = [
|
|
13
|
+
("Safe Data Handler", "def process(x):\n return x.strip().lower()\n"),
|
|
14
|
+
("Dynamic Eval Snippet", "eval('import os; os.system(\"ls\")')\n"),
|
|
15
|
+
("Unsafe Subprocess", "import subprocess\nsubprocess.Popen('rm -rf /tmp', shell=True)\n"),
|
|
16
|
+
("Hardcoded API Key", "AWS_SECRET_ACCESS_KEY = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'\n")
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
print("=== XORAS AST Security Evaluator Demo ===")
|
|
20
|
+
for title, code in snippets:
|
|
21
|
+
res = engine.scan_code(code)
|
|
22
|
+
print(f"\n[Snippet]: {title}")
|
|
23
|
+
print(f"Status: {'SAFE [PASSED]' if res.is_safe else 'UNSAFE [REJECTED]'}")
|
|
24
|
+
print(f"Safety Score: {res.safety_score * 100:.1f}%")
|
|
25
|
+
if res.violations:
|
|
26
|
+
print("Violations:", res.violations)
|
|
27
|
+
if res.secrets_detected:
|
|
28
|
+
print("Secrets:", res.secrets_detected)
|
|
29
|
+
|
|
30
|
+
if __name__ == "__main__":
|
|
31
|
+
evaluate_snippets()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "xoras-agent-framework"
|
|
7
|
+
version = "2.0.0"
|
|
8
|
+
description = "Enterprise Multi-Agent Runtime & AST Security Governance Framework"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "XORAS Systems LLC", email = "engineering@xoras.ai" }]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"pyyaml>=6.0",
|
|
15
|
+
"cryptography>=41.0.0",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 5 - Production/Stable",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Topic :: Security",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
xoras = "xoras.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["."]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unit tests for XORAS AST Security Engine.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
from xoras.ast_security import ASTSecurityEngine
|
|
7
|
+
|
|
8
|
+
def test_ast_safe_code():
|
|
9
|
+
engine = ASTSecurityEngine()
|
|
10
|
+
code = """
|
|
11
|
+
def calculate_sum(a, b):
|
|
12
|
+
return a + b
|
|
13
|
+
|
|
14
|
+
print(calculate_sum(10, 20))
|
|
15
|
+
"""
|
|
16
|
+
result = engine.scan_code(code)
|
|
17
|
+
assert result.is_safe is True
|
|
18
|
+
assert result.safety_score == 1.0
|
|
19
|
+
assert len(result.violations) == 0
|
|
20
|
+
|
|
21
|
+
def test_ast_forbidden_eval():
|
|
22
|
+
engine = ASTSecurityEngine()
|
|
23
|
+
code = """
|
|
24
|
+
x = 10
|
|
25
|
+
eval("print(x)")
|
|
26
|
+
"""
|
|
27
|
+
result = engine.scan_code(code)
|
|
28
|
+
assert result.is_safe is False
|
|
29
|
+
assert any("eval()" in v for v in result.violations)
|
|
30
|
+
|
|
31
|
+
def test_ast_forbidden_exec():
|
|
32
|
+
engine = ASTSecurityEngine()
|
|
33
|
+
code = """
|
|
34
|
+
exec("import os; os.system('ls')")
|
|
35
|
+
"""
|
|
36
|
+
result = engine.scan_code(code)
|
|
37
|
+
assert result.is_safe is False
|
|
38
|
+
assert any("exec()" in v for v in result.violations)
|
|
39
|
+
|
|
40
|
+
def test_ast_secret_leak_detection():
|
|
41
|
+
engine = ASTSecurityEngine()
|
|
42
|
+
code = """
|
|
43
|
+
AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
|
44
|
+
"""
|
|
45
|
+
result = engine.scan_code(code)
|
|
46
|
+
assert result.is_safe is False
|
|
47
|
+
assert len(result.secrets_detected) > 0
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unit tests for XORAS Agentic Runtime & Orchestrator.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from xoras.runtime import XORASAgentEnvironment
|
|
7
|
+
from xoras.orchestrator import SwarmOrchestrator
|
|
8
|
+
|
|
9
|
+
def test_runtime_file_write_and_read():
|
|
10
|
+
env = XORASAgentEnvironment(config_path="xoras.env.yaml")
|
|
11
|
+
write_res = env.execute_tool("Engineer", "file_write", {
|
|
12
|
+
"path": "artifacts/test_artifact.json",
|
|
13
|
+
"content": '{"version": "2.0.0", "status": "active"}'
|
|
14
|
+
})
|
|
15
|
+
assert write_res["success"] is True
|
|
16
|
+
assert "receipt_signature" in write_res
|
|
17
|
+
|
|
18
|
+
read_res = env.execute_tool("Engineer", "file_read", {
|
|
19
|
+
"path": "artifacts/test_artifact.json"
|
|
20
|
+
})
|
|
21
|
+
assert read_res["success"] is True
|
|
22
|
+
assert "active" in read_res["content"]
|
|
23
|
+
|
|
24
|
+
def test_runtime_ast_rejection():
|
|
25
|
+
env = XORASAgentEnvironment(config_path="xoras.env.yaml")
|
|
26
|
+
unsafe_res = env.execute_tool("Engineer", "file_write", {
|
|
27
|
+
"path": "artifacts/bad.py",
|
|
28
|
+
"content": 'eval("print(\'unsafe\')")'
|
|
29
|
+
})
|
|
30
|
+
assert unsafe_res["success"] is False
|
|
31
|
+
assert "blocked by XORAS AST security" in unsafe_res["error"]
|
|
32
|
+
|
|
33
|
+
def test_swarm_orchestrator_pipeline():
|
|
34
|
+
orch = SwarmOrchestrator()
|
|
35
|
+
res = orch.run_pipeline(
|
|
36
|
+
task_description="Deploy secure configuration manifest",
|
|
37
|
+
code_payload='{"config": "valid_json"}',
|
|
38
|
+
target_path="artifacts/swarm_output.json"
|
|
39
|
+
)
|
|
40
|
+
assert res["success"] is True
|
|
41
|
+
assert res["stage"] == "COMPLETED"
|
|
42
|
+
assert res["safety_score"] == 1.0
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unit tests for XORAS Cryptographic Signer.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from xoras.signer import CryptographicSigner
|
|
6
|
+
|
|
7
|
+
def test_evidence_receipt_signing_and_verification():
|
|
8
|
+
signer = CryptographicSigner()
|
|
9
|
+
payload = {"path": "test.txt", "content": "hello world"}
|
|
10
|
+
receipt = signer.sign_receipt("Engineer", "file_write", payload, "SUCCESS")
|
|
11
|
+
|
|
12
|
+
assert receipt.version == "xoras.evidence.v1"
|
|
13
|
+
assert receipt.organization == "XORAS Systems LLC"
|
|
14
|
+
assert receipt.status == "SUCCESS"
|
|
15
|
+
assert receipt.signature is not None
|
|
16
|
+
|
|
17
|
+
# Verify signature mathematically
|
|
18
|
+
assert signer.verify_receipt(receipt) is True
|
|
19
|
+
|
|
20
|
+
def test_evidence_receipt_tamper_rejection():
|
|
21
|
+
signer = CryptographicSigner()
|
|
22
|
+
payload = {"path": "test.txt", "content": "hello world"}
|
|
23
|
+
receipt = signer.sign_receipt("Engineer", "file_write", payload, "SUCCESS")
|
|
24
|
+
|
|
25
|
+
# Tamper with status
|
|
26
|
+
receipt.status = "FAILED"
|
|
27
|
+
assert signer.verify_receipt(receipt) is False
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
XORAS Systems LLC — Agentic Environment & Governance Framework
|
|
3
|
+
Enterprise-grade multi-agent runtime, AST static security gating, and cryptographic provenance receipts.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "2.0.0"
|
|
7
|
+
__author__ = "XORAS Systems LLC"
|
|
8
|
+
|
|
9
|
+
from .config import XORASConfig
|
|
10
|
+
from .ast_security import ASTSecurityEngine, ASTScanResult
|
|
11
|
+
from .signer import CryptographicSigner, EvidenceReceipt
|
|
12
|
+
from .runtime import XORASAgentEnvironment
|
|
13
|
+
from .orchestrator import SwarmOrchestrator
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"XORASConfig",
|
|
17
|
+
"ASTSecurityEngine",
|
|
18
|
+
"ASTScanResult",
|
|
19
|
+
"CryptographicSigner",
|
|
20
|
+
"EvidenceReceipt",
|
|
21
|
+
"XORASAgentEnvironment",
|
|
22
|
+
"SwarmOrchestrator",
|
|
23
|
+
]
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""
|
|
2
|
+
XORAS Systems LLC — AST Security Engine & Secret Scanner
|
|
3
|
+
Performs strict Abstract Syntax Tree (AST) static analysis and entropy secret detection.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import ast
|
|
7
|
+
import re
|
|
8
|
+
from dataclasses import dataclass, field
|
|
9
|
+
from typing import List, Dict, Any, Optional
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class ASTScanResult:
|
|
13
|
+
is_safe: bool
|
|
14
|
+
violations: List[str] = field(default_factory=list)
|
|
15
|
+
secrets_detected: List[str] = field(default_factory=list)
|
|
16
|
+
safety_score: float = 1.0
|
|
17
|
+
nodes_analyzed: int = 0
|
|
18
|
+
|
|
19
|
+
class ASTSecurityVisitor(ast.NodeVisitor):
|
|
20
|
+
def __init__(self):
|
|
21
|
+
self.violations: List[str] = []
|
|
22
|
+
self.nodes_analyzed: int = 0
|
|
23
|
+
|
|
24
|
+
# Unsafe call names
|
|
25
|
+
self.forbidden_calls = {
|
|
26
|
+
"eval": "Dynamic evaluation via eval() is strictly prohibited by XORAS AST Guardrails.",
|
|
27
|
+
"exec": "Dynamic execution via exec() is strictly prohibited by XORAS AST Guardrails.",
|
|
28
|
+
"compile": "Dynamic compilation via compile() is prohibited in agent runtime.",
|
|
29
|
+
"__import__": "Dynamic import via __import__ is prohibited.",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Unsafe module imports
|
|
33
|
+
self.dangerous_modules = {
|
|
34
|
+
"ctypes": "Raw memory manipulation via ctypes is restricted.",
|
|
35
|
+
"pty": "Pseudo-terminal creation via pty is prohibited.",
|
|
36
|
+
"code": "Interactive interpreter via code module is restricted."
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def visit(self, node):
|
|
40
|
+
self.nodes_analyzed += 1
|
|
41
|
+
super().visit(node)
|
|
42
|
+
|
|
43
|
+
def visit_Call(self, node):
|
|
44
|
+
# Inspect function call names
|
|
45
|
+
func_name = None
|
|
46
|
+
if isinstance(node.func, ast.Name):
|
|
47
|
+
func_name = node.func.id
|
|
48
|
+
elif isinstance(node.func, ast.Attribute):
|
|
49
|
+
func_name = node.func.attr
|
|
50
|
+
|
|
51
|
+
if func_name in self.forbidden_calls:
|
|
52
|
+
self.violations.append(f"Line {getattr(node, 'lineno', '?')}: {self.forbidden_calls[func_name]}")
|
|
53
|
+
|
|
54
|
+
# Check os.system / subprocess.Popen with unsafe args
|
|
55
|
+
if isinstance(node.func, ast.Attribute) and isinstance(node.func.value, ast.Name):
|
|
56
|
+
module_name = node.func.value.id
|
|
57
|
+
if module_name == "os" and func_name in ("system", "popen", "execv", "execl"):
|
|
58
|
+
# Inspect string argument if available
|
|
59
|
+
if node.args and isinstance(node.args[0], ast.Constant):
|
|
60
|
+
arg_val = str(node.args[0].value)
|
|
61
|
+
if "rm -rf" in arg_val or "sudo " in arg_val or "> /dev/" in arg_val:
|
|
62
|
+
self.violations.append(f"Line {getattr(node, 'lineno', '?')}: High-risk shell command in os.{func_name}: '{arg_val}'")
|
|
63
|
+
elif module_name == "subprocess" and func_name in ("Popen", "call", "run"):
|
|
64
|
+
# Check shell=True kwargs
|
|
65
|
+
for keyword in node.keywords:
|
|
66
|
+
if keyword.arg == "shell" and isinstance(keyword.value, ast.Constant) and keyword.value.value is True:
|
|
67
|
+
self.violations.append(f"Line {getattr(node, 'lineno', '?')}: Subprocess invocation with shell=True is restricted under XORAS AST policy.")
|
|
68
|
+
|
|
69
|
+
self.generic_visit(node)
|
|
70
|
+
|
|
71
|
+
def visit_Import(self, node):
|
|
72
|
+
for alias in node.names:
|
|
73
|
+
if alias.name in self.dangerous_modules:
|
|
74
|
+
self.violations.append(f"Line {getattr(node, 'lineno', '?')}: {self.dangerous_modules[alias.name]}")
|
|
75
|
+
self.generic_visit(node)
|
|
76
|
+
|
|
77
|
+
def visit_ImportFrom(self, node):
|
|
78
|
+
if node.module in self.dangerous_modules:
|
|
79
|
+
self.violations.append(f"Line {getattr(node, 'lineno', '?')}: {self.dangerous_modules[node.module]}")
|
|
80
|
+
self.generic_visit(node)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ASTSecurityEngine:
|
|
84
|
+
SECRET_PATTERNS = [
|
|
85
|
+
(r'(?i)(?:aws_access_key_id|aws_secret_access_key|api_key|secret_key|private_key)\s*[:=]\s*["\']([^"\']{8,})["\']', "Hardcoded API / Secret Key"),
|
|
86
|
+
(r'AKIA[0-9A-Z]{16}', "AWS Access Key ID"),
|
|
87
|
+
(r'sk_live_[0-9a-zA-Z]{24,}', "Stripe Live API Key"),
|
|
88
|
+
(r'sk-(?:proj-)?[a-zA-Z0-9_-]{32,}', "OpenAI API Key"),
|
|
89
|
+
(r'sk-ant-[a-zA-Z0-9_-]{32,}', "Anthropic API Key"),
|
|
90
|
+
(r'AIzaSy[0-9a-zA-Z_-]{33}', "Google Gemini API Key"),
|
|
91
|
+
(r'xox[baprs]-[0-9a-zA-Z]{10,48}', "Slack OAuth / Bot Token"),
|
|
92
|
+
(r'ghp_[0-9a-zA-Z]{36}', "GitHub Personal Access Token"),
|
|
93
|
+
(r'-----BEGIN\s+(?:RSA|EC|OPENSSH|PRIVATE)\s+KEY-----', "Private Cryptographic Key Block"),
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
def __init__(self, strict_mode: bool = True):
|
|
97
|
+
self.strict_mode = strict_mode
|
|
98
|
+
|
|
99
|
+
def scan_code(self, code_snippet: str) -> ASTScanResult:
|
|
100
|
+
"""Parses python AST syntax tree and runs regex secret scanning."""
|
|
101
|
+
violations: List[str] = []
|
|
102
|
+
secrets_detected: List[str] = []
|
|
103
|
+
|
|
104
|
+
# 1. Secret scanning across raw code
|
|
105
|
+
for pattern, desc in self.SECRET_PATTERNS:
|
|
106
|
+
matches = re.findall(pattern, code_snippet)
|
|
107
|
+
if matches:
|
|
108
|
+
secrets_detected.append(f"Secret Leak Warning: Detected {desc} pattern in code payload.")
|
|
109
|
+
violations.append(f"Secret Scanner: High-entropy token matching '{desc}' found.")
|
|
110
|
+
|
|
111
|
+
# 2. Syntax validation & AST parsing
|
|
112
|
+
nodes_analyzed = 0
|
|
113
|
+
try:
|
|
114
|
+
tree = ast.parse(code_snippet)
|
|
115
|
+
visitor = ASTSecurityVisitor()
|
|
116
|
+
visitor.visit(tree)
|
|
117
|
+
violations.extend(visitor.violations)
|
|
118
|
+
nodes_analyzed = visitor.nodes_analyzed
|
|
119
|
+
except SyntaxError as e:
|
|
120
|
+
# If not python syntax (e.g. bash script), fallback to regex heuristic scanner
|
|
121
|
+
nodes_analyzed = len(code_snippet.splitlines())
|
|
122
|
+
forbidden_heuristics = [
|
|
123
|
+
(r'\beval\s*\(', "Dynamic eval() invocation"),
|
|
124
|
+
(r'\bexec\s*\(', "Dynamic exec() invocation"),
|
|
125
|
+
(r'rm\s+-rf\s+/', "Destructive root filesystem command 'rm -rf /'"),
|
|
126
|
+
(r':\(\)\{\s*:\|:&\s*\};:', "Fork bomb pattern"),
|
|
127
|
+
]
|
|
128
|
+
for pat, msg in forbidden_heuristics:
|
|
129
|
+
if re.search(pat, code_snippet):
|
|
130
|
+
violations.append(f"Heuristic AST Fallback Violation: Detected forbidden pattern '{msg}'")
|
|
131
|
+
|
|
132
|
+
is_safe = len(violations) == 0
|
|
133
|
+
safety_score = max(0.0, 1.0 - (len(violations) * 0.35))
|
|
134
|
+
|
|
135
|
+
return ASTScanResult(
|
|
136
|
+
is_safe=is_safe,
|
|
137
|
+
violations=violations,
|
|
138
|
+
secrets_detected=secrets_detected,
|
|
139
|
+
safety_score=round(safety_score, 4),
|
|
140
|
+
nodes_analyzed=nodes_analyzed
|
|
141
|
+
)
|