zerochat 10.45.0__tar.gz → 10.47.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.
Potentially problematic release.
This version of zerochat might be problematic. Click here for more details.
- {zerochat-10.45.0/zerochat.egg-info → zerochat-10.47.0}/PKG-INFO +1 -1
- {zerochat-10.45.0 → zerochat-10.47.0}/pyproject.toml +1 -1
- {zerochat-10.45.0 → zerochat-10.47.0/zerochat.egg-info}/PKG-INFO +1 -1
- {zerochat-10.45.0 → zerochat-10.47.0}/zerochat.py +53 -7
- {zerochat-10.45.0 → zerochat-10.47.0}/LICENSE +0 -0
- {zerochat-10.45.0 → zerochat-10.47.0}/README.md +0 -0
- {zerochat-10.45.0 → zerochat-10.47.0}/setup.cfg +0 -0
- {zerochat-10.45.0 → zerochat-10.47.0}/zerochat.egg-info/SOURCES.txt +0 -0
- {zerochat-10.45.0 → zerochat-10.47.0}/zerochat.egg-info/dependency_links.txt +0 -0
- {zerochat-10.45.0 → zerochat-10.47.0}/zerochat.egg-info/entry_points.txt +0 -0
- {zerochat-10.45.0 → zerochat-10.47.0}/zerochat.egg-info/top_level.txt +0 -0
|
@@ -1164,7 +1164,7 @@ def parse_nonneg_int(value, label: str, default: int = 0) -> int:
|
|
|
1164
1164
|
|
|
1165
1165
|
|
|
1166
1166
|
|
|
1167
|
-
SOURCE_BACKEND_VERSION = "10.
|
|
1167
|
+
SOURCE_BACKEND_VERSION = "10.47.0"
|
|
1168
1168
|
|
|
1169
1169
|
|
|
1170
1170
|
def _read_source_version(filename: str) -> str | None:
|
|
@@ -4089,6 +4089,12 @@ MODERN_USER_AGENTS = (
|
|
|
4089
4089
|
DEFAULT_USER_AGENT = MODERN_USER_AGENTS[0]
|
|
4090
4090
|
|
|
4091
4091
|
|
|
4092
|
+
def sets_user_agent(config: dict) -> bool:
|
|
4093
|
+
"""Solo los motores de Playwright llevan el User-Agent de ZeroChat: los navegadores instalados y el
|
|
4094
|
+
del usuario son navegadores reales y actualizados que envían el suyo."""
|
|
4095
|
+
return config["mode"] == "own" and config["engine"] in OWN_BROWSER_ENGINES
|
|
4096
|
+
|
|
4097
|
+
|
|
4092
4098
|
def own_browser_profile_dir(engine: str) -> Path:
|
|
4093
4099
|
return get_data_dir() / "playwright" / "profile" / engine
|
|
4094
4100
|
|
|
@@ -4117,7 +4123,7 @@ def validate_browser_config(raw) -> dict:
|
|
|
4117
4123
|
if not isinstance(config["extensionToken"], str) or not _EXTENSION_TOKEN.match(config["extensionToken"]):
|
|
4118
4124
|
raise ValueError("extensionToken debe tener hasta 256 letras, cifras, guiones o guiones bajos")
|
|
4119
4125
|
config["userAgent"] = _validate_user_agent(config["userAgent"])
|
|
4120
|
-
if config["userAgentMode"] == "custom" and not config["userAgent"]:
|
|
4126
|
+
if sets_user_agent(config) and config["userAgentMode"] == "custom" and not config["userAgent"]:
|
|
4121
4127
|
raise ValueError("userAgent es obligatorio cuando userAgentMode es custom")
|
|
4122
4128
|
return config
|
|
4123
4129
|
|
|
@@ -4182,8 +4188,7 @@ def playwright_launch_args(config: dict, user_agent: str | None = None) -> list[
|
|
|
4182
4188
|
args = ["--browser=chrome", "--isolated", f"--executable-path={executable}"]
|
|
4183
4189
|
else:
|
|
4184
4190
|
args = [f"--browser={config['engine']}", "--isolated"]
|
|
4185
|
-
|
|
4186
|
-
if user_agent:
|
|
4191
|
+
if user_agent and sets_user_agent(config):
|
|
4187
4192
|
args.append(f"--user-agent={user_agent}")
|
|
4188
4193
|
if config["headless"]:
|
|
4189
4194
|
args.append("--headless")
|
|
@@ -8600,8 +8605,10 @@ class AccessController:
|
|
|
8600
8605
|
return None
|
|
8601
8606
|
if decision == "allow_server_always" and not challenge.get("serverId"):
|
|
8602
8607
|
return None
|
|
8603
|
-
pattern = self._validate_command_pattern(decision, command_pattern, challenge)
|
|
8604
8608
|
rules = self._validate_directory_rules([directory_rule]) if directory_rule else []
|
|
8609
|
+
if rules and command_pattern:
|
|
8610
|
+
raise ValueError("Una decisión lleva un patrón de comando o una regla de carpeta, no los dos.")
|
|
8611
|
+
pattern = None if rules else self._validate_command_pattern(decision, command_pattern, challenge)
|
|
8605
8612
|
challenges.pop(challenge_id)
|
|
8606
8613
|
self._record_decision(challenge, decision, pattern, rules, context)
|
|
8607
8614
|
return challenge
|
|
@@ -8635,6 +8642,9 @@ class AccessController:
|
|
|
8635
8642
|
regla de directorio se escriben en una sola transacción y un error de persistencia se propaga.
|
|
8636
8643
|
"""
|
|
8637
8644
|
tool, server_name, server_id = challenge["toolName"], challenge["serverName"], challenge["serverId"]
|
|
8645
|
+
if rules:
|
|
8646
|
+
# Una regla de carpeta es toda la decisión: no autoriza además la herramienta fuera de esa carpeta.
|
|
8647
|
+
decision, pattern = "", None
|
|
8638
8648
|
if decision == "allow_session":
|
|
8639
8649
|
self._allow_for_session(context, tool, server_name, pattern)
|
|
8640
8650
|
permanent = decision in ("allow_project", "allow_always", "allow_server_always")
|
|
@@ -8774,6 +8784,8 @@ class AccessController:
|
|
|
8774
8784
|
f"El comando usa sintaxis de shell que no se puede validar por partes: {raw_command}", None)
|
|
8775
8785
|
patterns = self._command_patterns(view)
|
|
8776
8786
|
cwd, by_rule, uncovered = ctx.workspace_dir, False, []
|
|
8787
|
+
# Rutas que dejan sin cubrir un subcomando; None si alguno pide permiso por otra causa ($, ~, órdenes globales).
|
|
8788
|
+
outside: list[str] | None = []
|
|
8777
8789
|
for operator, segment in segments:
|
|
8778
8790
|
directory = cd_target(segment)
|
|
8779
8791
|
if directory is not None:
|
|
@@ -8792,6 +8804,12 @@ class AccessController:
|
|
|
8792
8804
|
by_rule = True
|
|
8793
8805
|
else:
|
|
8794
8806
|
uncovered.append(segment)
|
|
8807
|
+
refs = command_outside_references(segment)
|
|
8808
|
+
if refs is None or outside is None:
|
|
8809
|
+
outside = None
|
|
8810
|
+
else:
|
|
8811
|
+
outside += [target for target in (self._command_target(cwd, ref) for ref in refs)
|
|
8812
|
+
if not self.evaluate_directory_rule("RW", target, view["directoryRules"], ctx)["allowed"]]
|
|
8795
8813
|
if not uncovered:
|
|
8796
8814
|
return POLICY_ALLOW, "directory_rule_allow" if by_rule else "command_pattern_allow", "", None
|
|
8797
8815
|
reason, details = (
|
|
@@ -8799,7 +8817,30 @@ class AccessController:
|
|
|
8799
8817
|
if patterns
|
|
8800
8818
|
else ("command_outside_directory_rules", "El comando accede a recursos globales o rutas fuera de las reglas de directorio.")
|
|
8801
8819
|
)
|
|
8802
|
-
|
|
8820
|
+
offer = self._command_folder_offer(raw_command, outside, view, ctx) if outside else None
|
|
8821
|
+
return POLICY_ASK, reason, details, offer or command_rule_offer(uncovered)
|
|
8822
|
+
|
|
8823
|
+
def _command_folder_offer(self, raw_command: str, targets: list[str], view: dict, ctx: SecurityContext) -> dict | None:
|
|
8824
|
+
"""
|
|
8825
|
+
Regla RW sobre la carpeta común de las rutas que faltan, solo si con ella el comando entero pasaría y la
|
|
8826
|
+
carpeta está dentro de la personal (nunca ella entera, una oculta como .ssh ni las del sistema): un nombre de
|
|
8827
|
+
fichero que cambia cada día no cabe en un patrón de comando, y la carpeta sí se puede conceder en el proyecto.
|
|
8828
|
+
"""
|
|
8829
|
+
folders = []
|
|
8830
|
+
for target in targets:
|
|
8831
|
+
resolved = ctx.resolve_path(target)
|
|
8832
|
+
if resolved is None:
|
|
8833
|
+
return None
|
|
8834
|
+
folders.append(resolved if resolved.is_dir() else resolved.parent)
|
|
8835
|
+
common = Path(os.path.commonpath(folders))
|
|
8836
|
+
home = Path.home().resolve()
|
|
8837
|
+
if home not in common.parents or any(part.startswith(".") for part in common.relative_to(home).parts):
|
|
8838
|
+
return None
|
|
8839
|
+
rule = f"RW:{normalize_directory_path(str(common))}/**"
|
|
8840
|
+
widened = {**view, "directoryRules": [*view["directoryRules"], rule]}
|
|
8841
|
+
if self._evaluate_command(raw_command, widened, ctx)[0] != POLICY_ALLOW:
|
|
8842
|
+
return None
|
|
8843
|
+
return {"type": "directory", "access": "RW", "directoryRule": rule}
|
|
8803
8844
|
|
|
8804
8845
|
def _evaluate_path(self, tool_name: str, access: str, path: str, view: dict, ctx: SecurityContext) -> tuple[str, str, str, dict | None]:
|
|
8805
8846
|
"""Herramientas integradas de ficheros: reglas de directorio del proyecto."""
|
|
@@ -11841,6 +11882,11 @@ class ZeroChatServerHandler(BaseHTTPRequestHandler):
|
|
|
11841
11882
|
if self._send_json_response(200, response_payload) and not quiet:
|
|
11842
11883
|
self._log_res(200, log_detail, (time.monotonic() - t0) * 1000, error_info=error_info)
|
|
11843
11884
|
|
|
11885
|
+
def _capture_browser_user_agent(self, grant):
|
|
11886
|
+
"""Solo un navegador autenticado da el User-Agent real: el runner de Node manda el de su fetch ("node")."""
|
|
11887
|
+
if grant.kind != "runner":
|
|
11888
|
+
capture_frontend_user_agent(self.headers.get("User-Agent", ""))
|
|
11889
|
+
|
|
11844
11890
|
def do_POST(self):
|
|
11845
11891
|
t0 = time.monotonic()
|
|
11846
11892
|
safe_path = sanitize_log_path(self.path)
|
|
@@ -11854,7 +11900,6 @@ class ZeroChatServerHandler(BaseHTTPRequestHandler):
|
|
|
11854
11900
|
self._log_res(403, safe_path, (time.monotonic() - t0) * 1000, f"Origen no permitido: '{origin}'")
|
|
11855
11901
|
return
|
|
11856
11902
|
|
|
11857
|
-
capture_frontend_user_agent(self.headers.get("User-Agent", ""))
|
|
11858
11903
|
mark_browser_active()
|
|
11859
11904
|
grant = self._resolve_grant()
|
|
11860
11905
|
# Una ejecución solo atiende a su runner: ni el token diario ni sesiones remotas, ni zerochat/login.
|
|
@@ -11872,6 +11917,7 @@ class ZeroChatServerHandler(BaseHTTPRequestHandler):
|
|
|
11872
11917
|
"error": {"code": -32000, "message": "Unauthorized: invalid or missing session token"}
|
|
11873
11918
|
}, safe_path, t0, "Token de sesión ausente o inválido")
|
|
11874
11919
|
return
|
|
11920
|
+
self._capture_browser_user_agent(grant)
|
|
11875
11921
|
|
|
11876
11922
|
req = self._read_rpc_request(safe_path, t0)
|
|
11877
11923
|
if req is None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|