veltra-agent 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.
@@ -0,0 +1,15 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: veltra-agent
3
+ Version: 0.1.0
4
+ Summary: Deterministic local security guardrail for autonomous software agents.
5
+ Author-email: Veltra AI Team <founders@veltra.ai>
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "veltra-agent"
7
+ version = "0.1.0"
8
+ description = "Deterministic local security guardrail for autonomous software agents."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "Apache-2.0"}
12
+ authors = [
13
+ {name = "Veltra AI Team", email = "founders@veltra.ai"}
14
+ ]
15
+ dependencies = []
16
+
17
+ [project.scripts]
18
+ veltra = "veltra_agent.cli:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ import pytest
2
+ from veltra_agent.guardrail import is_command_safe
3
+
4
+ def test_safe_command():
5
+ is_safe, _ = is_command_safe("echo 'Hello World'")
6
+ assert is_safe is True
7
+
8
+ def test_blocked_rf():
9
+ is_safe, reason = is_command_safe("rm -rf /")
10
+ assert is_safe is False
11
+ assert "forbidden pattern" in reason.lower()
12
+
13
+ def test_blocked_chaining():
14
+ is_safe, reason = is_command_safe("ls -la && rm -rf /tmp/dir")
15
+ assert is_safe is False
16
+ assert "forbidden pattern" in reason.lower() or "chain" in reason.lower()
@@ -0,0 +1,24 @@
1
+ import sys
2
+ import subprocess
3
+ from veltra_agent.guardrail import is_command_safe
4
+
5
+ def main():
6
+ if len(sys.argv) < 2:
7
+ print("Usage: veltra <command_to_run>")
8
+ print("Example: veltra \"git status\"")
9
+ sys.exit(1)
10
+
11
+ command = " ".join(sys.argv[1:])
12
+ print(f"[VELTRA INTERCEPTOR] Checking command: '{command}'")
13
+
14
+ is_safe, reason = is_command_safe(command)
15
+ if not is_safe:
16
+ print(f"❌ SECURITY VIOLATION: {reason}")
17
+ sys.exit(1)
18
+
19
+ print("✅ Passed security checks. Executing command...")
20
+ result = subprocess.run(command, shell=True)
21
+ sys.exit(result.returncode)
22
+
23
+ if __name__ == "__main__":
24
+ main()
@@ -0,0 +1,61 @@
1
+ import datetime
2
+ import json
3
+ import os
4
+ import re
5
+
6
+ DEFAULT_FORBIDDEN = [
7
+ r"rm\s+-rf\s+/",
8
+ r"rm\s+-rf\s+~",
9
+ r"mkfs",
10
+ r"dd\s+if=",
11
+ r":\(\)\{\s*:\|\:&\s*\};:",
12
+ r">\s*/dev/sd",
13
+ r"base64\s+-d"
14
+ ]
15
+
16
+ DEFAULT_CHAINED = [
17
+ r"&&",
18
+ r"\|\|",
19
+ r";"
20
+ ]
21
+
22
+ def load_config():
23
+ """Loads workspace veltra.config.json or defaults."""
24
+ config_file = "veltra.config.json"
25
+ if os.path.exists(config_file):
26
+ try:
27
+ with open(config_file, "r") as f:
28
+ data = json.load(f)
29
+ return data.get("forbidden_patterns", DEFAULT_FORBIDDEN), data.get("chained_patterns", DEFAULT_CHAINED)
30
+ except Exception:
31
+ pass
32
+ return DEFAULT_FORBIDDEN, DEFAULT_CHAINED
33
+
34
+ def log_audit_event(command: str, status: str, reason: str, log_file: str = "veltra_audit.log"):
35
+ """Logs security events with UTC timestamps."""
36
+ timestamp = datetime.datetime.now(datetime.timezone.utc).isoformat()
37
+ log_entry = f"[{timestamp}] STATUS={status} | CMD='{command}' | REASON='{reason}'\n"
38
+ with open(log_file, "a") as f:
39
+ f.write(log_entry)
40
+
41
+ def is_command_safe(command: str) -> tuple[bool, str]:
42
+ """Evaluates terminal commands against active workspace policy rules."""
43
+ forbidden_patterns, chained_patterns = load_config()
44
+
45
+ # Check 1: Forbidden destructive patterns
46
+ for pattern in forbidden_patterns:
47
+ if re.search(pattern, command):
48
+ reason = f"Blocked by Veltra Guardrail: Matches forbidden pattern '{pattern}'"
49
+ log_audit_event(command, status="BLOCKED", reason=reason)
50
+ return False, reason
51
+
52
+ # Check 2: Chained injection attacks
53
+ for pattern in chained_patterns:
54
+ if pattern in command and ("rm -rf" in command or "sudo" in command):
55
+ reason = f"Blocked by Veltra Guardrail: Matches unsafe command chain containing '{pattern}'"
56
+ log_audit_event(command, status="BLOCKED", reason=reason)
57
+ return False, reason
58
+
59
+ # Safe Command Passed
60
+ log_audit_event(command, status="ALLOWED", reason="Passed deterministic check")
61
+ return True, "Passed deterministic check"
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: veltra-agent
3
+ Version: 0.1.0
4
+ Summary: Deterministic local security guardrail for autonomous software agents.
5
+ Author-email: Veltra AI Team <founders@veltra.ai>
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ pyproject.toml
3
+ tests/test_guardrail.py
4
+ veltra_agent/cli.py
5
+ veltra_agent/guardrail.py
6
+ veltra_agent.egg-info/PKG-INFO
7
+ veltra_agent.egg-info/SOURCES.txt
8
+ veltra_agent.egg-info/dependency_links.txt
9
+ veltra_agent.egg-info/entry_points.txt
10
+ veltra_agent.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ veltra = veltra_agent.cli:main
@@ -0,0 +1 @@
1
+ veltra_agent