Skip to content

Commit 1ed6401

Browse files
authored
Fix: Plugin System Sandbox Bypass and git clone URL Bypass. Updated versioning as well. (#40)
2 parents 6b4979f + 771301e commit 1ed6401

4 files changed

Lines changed: 30 additions & 5 deletions

File tree

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pyspector
3-
version = 0.1.6
3+
version = 0.1.7
44

55
[options]
66
package_dir=

src/pyspector/_rust_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "_rust_core"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
edition = "2021"
55

66
[lib]

src/pyspector/cli.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .triage import run_triage_tui
1515
from .plugin_system import get_plugin_manager, PluginSecurity
1616
import requests
17+
from urllib.parse import urlparse
1718

1819
# Import the Rust core from its new location
1920
try:
@@ -268,7 +269,7 @@ def cli():
268269
__/> / \
269270
"""
270271
click.echo(click.style(banner))
271-
click.echo("Version: 0.1.6\n")
272+
click.echo("Version: 0.1.7\n")
272273
click.echo("Made with <3 by github.com/ParzivalHack\n")
273274
note = get_startup_note()
274275
click.echo(click.style(f"{note}\n", fg="bright_black", italic=True))
@@ -362,6 +363,16 @@ def run_scan_command(
362363

363364
# Repo scan
364365
if params["repo_url"]:
366+
try:
367+
_parsed = urlparse(params["repo_url"])
368+
_hostname = _parsed.hostname or ""
369+
except Exception:
370+
_hostname = ""
371+
372+
if _hostname not in ("github.com", "gitlab.com"):
373+
raise click.BadParameter(
374+
"URL must be a public GitHub or GitLab repository. "
375+
)
365376
with tempfile.TemporaryDirectory() as temp_dir:
366377
click.echo(f"[*] Cloning '{params['repo_url']}' into temporary directory...")
367378
subprocess.run(
@@ -435,8 +446,16 @@ def run_scan_command(
435446

436447
if repo_url:
437448
# Handle Git URL cloning
438-
if not ("github.com" in repo_url or "gitlab.com" in repo_url):
439-
raise click.BadParameter("URL must be a public GitHub or GitLab repository.")
449+
try:
450+
_parsed = urlparse(repo_url)
451+
_hostname = _parsed.hostname or ""
452+
except Exception:
453+
_hostname = ""
454+
455+
if _hostname not in ("github.com", "gitlab.com"):
456+
raise click.BadParameter(
457+
"URL must be a public GitHub or GitLab repository. "
458+
)
440459

441460
with tempfile.TemporaryDirectory() as temp_dir:
442461
click.echo(f"[*] Cloning '{repo_url}' into temporary directory...")

src/pyspector/plugin_system.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ def validate_plugin_code(plugin_path: Path) -> tuple[bool, str]:
143143
"exec",
144144
"compile",
145145
"__import__",
146+
"vars",
147+
"getattr",
146148
"os.system",
147149
"os.popen",
148150
"subprocess.Popen",
@@ -184,6 +186,10 @@ def resolve_name(node: ast.AST) -> Optional[str]:
184186
attrs.append(base)
185187
attrs.reverse()
186188
return ".".join(attrs)
189+
if isinstance(node, ast.Call):
190+
inner = resolve_name(node.func)
191+
if inner:
192+
return inner
187193
return None
188194

189195
class Analyzer(ast.NodeVisitor):

0 commit comments

Comments
 (0)