zeroshot-sdk 0.0.1__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.
- zeroshot_sdk-0.0.1/.env +1 -0
- zeroshot_sdk-0.0.1/PKG-INFO +60 -0
- zeroshot_sdk-0.0.1/README.md +38 -0
- zeroshot_sdk-0.0.1/pyproject.toml +38 -0
- zeroshot_sdk-0.0.1/src/zeroshot_sdk/__init__.py +13 -0
- zeroshot_sdk-0.0.1/src/zeroshot_sdk/auth.py +127 -0
- zeroshot_sdk-0.0.1/src/zeroshot_sdk/cli.py +575 -0
- zeroshot_sdk-0.0.1/src/zeroshot_sdk/client.py +206 -0
- zeroshot_sdk-0.0.1/src/zeroshot_sdk/config.py +49 -0
- zeroshot_sdk-0.0.1/uv.lock +1600 -0
zeroshot_sdk-0.0.1/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ZEROSHOT_API_KEY=
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zeroshot-sdk
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: ZeroShot SDK - AI System Testing CLI and Client Library
|
|
5
|
+
Author: Lab42 Team
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ai,llm,red-teaming,sdk,security,testing
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Security
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: httpx>=0.25
|
|
18
|
+
Requires-Dist: rich>=13.0
|
|
19
|
+
Requires-Dist: toml>=0.10
|
|
20
|
+
Requires-Dist: typer>=0.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# ZeroShot SDK
|
|
24
|
+
|
|
25
|
+
Official SDK for ZeroShot - AI Security Testing Platform.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install zeroshot-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Login (stores API key locally)
|
|
37
|
+
zeroshot auth login
|
|
38
|
+
|
|
39
|
+
# Run a scan
|
|
40
|
+
zeroshot scan --target http://target-url
|
|
41
|
+
|
|
42
|
+
# View results
|
|
43
|
+
zeroshot scans list
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Python Usage
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from zeroshot_sdk import ZeroShotClient
|
|
50
|
+
|
|
51
|
+
client = ZeroShotClient(api_key="zsk_...")
|
|
52
|
+
|
|
53
|
+
# Run a scan
|
|
54
|
+
result = client.scan(
|
|
55
|
+
target="http://target-url",
|
|
56
|
+
categories=["jailbreak", "prompt_injection"],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
print(f"Found {result['vulnerabilities_found']} vulnerabilities")
|
|
60
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# ZeroShot SDK
|
|
2
|
+
|
|
3
|
+
Official SDK for ZeroShot - AI Security Testing Platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install zeroshot-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Login (stores API key locally)
|
|
15
|
+
zeroshot auth login
|
|
16
|
+
|
|
17
|
+
# Run a scan
|
|
18
|
+
zeroshot scan --target http://target-url
|
|
19
|
+
|
|
20
|
+
# View results
|
|
21
|
+
zeroshot scans list
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Python Usage
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from zeroshot_sdk import ZeroShotClient
|
|
28
|
+
|
|
29
|
+
client = ZeroShotClient(api_key="zsk_...")
|
|
30
|
+
|
|
31
|
+
# Run a scan
|
|
32
|
+
result = client.scan(
|
|
33
|
+
target="http://target-url",
|
|
34
|
+
categories=["jailbreak", "prompt_injection"],
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
print(f"Found {result['vulnerabilities_found']} vulnerabilities")
|
|
38
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "zeroshot-sdk"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "ZeroShot SDK - AI System Testing CLI and Client Library"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = {text = "MIT"}
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Lab42 Team"}
|
|
10
|
+
]
|
|
11
|
+
keywords = ["ai", "security", "testing", "llm", "red-teaming", "sdk"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Topic :: Security",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
dependencies = [
|
|
24
|
+
"httpx>=0.25",
|
|
25
|
+
"typer>=0.9",
|
|
26
|
+
"rich>=13.0",
|
|
27
|
+
"toml>=0.10",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
zeroshot = "zeroshot_sdk.cli:app"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["hatchling"]
|
|
35
|
+
build-backend = "hatchling.build"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["src/zeroshot_sdk"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ZeroShot SDK - AI Security Testing Client.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from zeroshot_sdk.config import API_URL, API_KEY, get_api_url, get_api_key, get_headers
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.0"
|
|
10
|
+
__all__ = ["API_URL", "API_KEY", "get_api_url", "get_api_key", "get_headers"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ZeroShot SDK - API Key management.
|
|
3
|
+
|
|
4
|
+
Stores credentials in ~/.zeroshot/config.toml
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Optional
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
import toml
|
|
13
|
+
except ImportError:
|
|
14
|
+
toml = None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
CONFIG_DIR = Path.home() / ".zeroshot"
|
|
18
|
+
CONFIG_FILE = CONFIG_DIR / "config.toml"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_config_path() -> Path:
|
|
22
|
+
"""Get the config file path."""
|
|
23
|
+
return CONFIG_FILE
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def ensure_config_dir():
|
|
27
|
+
"""Ensure the config directory exists."""
|
|
28
|
+
CONFIG_DIR.mkdir(exist_ok=True)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def load_config() -> dict:
|
|
32
|
+
"""Load configuration from file."""
|
|
33
|
+
if not CONFIG_FILE.exists():
|
|
34
|
+
return {}
|
|
35
|
+
|
|
36
|
+
if toml is None:
|
|
37
|
+
# Fallback: simple key=value parsing
|
|
38
|
+
config = {}
|
|
39
|
+
with open(CONFIG_FILE) as f:
|
|
40
|
+
for line in f:
|
|
41
|
+
line = line.strip()
|
|
42
|
+
if "=" in line and not line.startswith("#"):
|
|
43
|
+
key, value = line.split("=", 1)
|
|
44
|
+
config[key.strip()] = value.strip().strip('"')
|
|
45
|
+
return config
|
|
46
|
+
|
|
47
|
+
with open(CONFIG_FILE) as f:
|
|
48
|
+
return toml.load(f)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def save_config(config: dict):
|
|
52
|
+
"""Save configuration to file."""
|
|
53
|
+
ensure_config_dir()
|
|
54
|
+
|
|
55
|
+
if toml is None:
|
|
56
|
+
# Fallback: simple key=value format
|
|
57
|
+
with open(CONFIG_FILE, "w") as f:
|
|
58
|
+
for key, value in config.items():
|
|
59
|
+
f.write(f'{key} = "{value}"\n')
|
|
60
|
+
else:
|
|
61
|
+
with open(CONFIG_FILE, "w") as f:
|
|
62
|
+
toml.dump(config, f)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def get_api_key() -> Optional[str]:
|
|
66
|
+
"""
|
|
67
|
+
Get the stored API key.
|
|
68
|
+
|
|
69
|
+
Checks:
|
|
70
|
+
1. ZEROSHOT_API_KEY environment variable
|
|
71
|
+
2. ~/.zeroshot/config.toml
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
API key string or None if not found
|
|
75
|
+
"""
|
|
76
|
+
# Check environment variable first
|
|
77
|
+
env_key = os.environ.get("ZEROSHOT_API_KEY")
|
|
78
|
+
if env_key:
|
|
79
|
+
return env_key
|
|
80
|
+
|
|
81
|
+
# Check config file
|
|
82
|
+
config = load_config()
|
|
83
|
+
return config.get("api_key")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def save_api_key(api_key: str):
|
|
87
|
+
"""
|
|
88
|
+
Save API key to config file.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
api_key: The API key to save (zsk_...)
|
|
92
|
+
"""
|
|
93
|
+
config = load_config()
|
|
94
|
+
config["api_key"] = api_key
|
|
95
|
+
save_config(config)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def get_api_url() -> str:
|
|
99
|
+
"""
|
|
100
|
+
Get the API base URL.
|
|
101
|
+
|
|
102
|
+
Checks:
|
|
103
|
+
1. ZEROSHOT_API_URL environment variable
|
|
104
|
+
2. ~/.zeroshot/config.toml
|
|
105
|
+
3. Default: https://api.0eroshot.com
|
|
106
|
+
"""
|
|
107
|
+
# Check environment variable
|
|
108
|
+
env_url = os.environ.get("ZEROSHOT_API_URL")
|
|
109
|
+
if env_url:
|
|
110
|
+
return env_url
|
|
111
|
+
|
|
112
|
+
# Check config file
|
|
113
|
+
config = load_config()
|
|
114
|
+
return config.get("api_url", "https://api.0eroshot.com")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def save_api_url(api_url: str):
|
|
118
|
+
"""Save API URL to config file."""
|
|
119
|
+
config = load_config()
|
|
120
|
+
config["api_url"] = api_url
|
|
121
|
+
save_config(config)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def clear_config():
|
|
125
|
+
"""Clear all stored configuration."""
|
|
126
|
+
if CONFIG_FILE.exists():
|
|
127
|
+
CONFIG_FILE.unlink()
|