fusiontest 0.2.49__tar.gz → 0.2.53__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.
Files changed (77) hide show
  1. {fusiontest-0.2.49 → fusiontest-0.2.53}/PKG-INFO +1 -1
  2. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/evidence.py +23 -6
  3. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/reproduce.py +1 -0
  4. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/runner.py +25 -12
  5. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/secrets.py +6 -0
  6. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/discovery/goal_generator.py +8 -3
  7. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/discovery/intent.py +7 -4
  8. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest.egg-info/PKG-INFO +1 -1
  9. {fusiontest-0.2.49 → fusiontest-0.2.53}/pyproject.toml +1 -1
  10. {fusiontest-0.2.49 → fusiontest-0.2.53}/README.md +0 -0
  11. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/__init__.py +0 -0
  12. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/agent/__init__.py +0 -0
  13. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/agent/mcp_server.py +0 -0
  14. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/agent/verify.py +0 -0
  15. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/__init__.py +0 -0
  16. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/security.py +0 -0
  17. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/sites/shop/bugs.js +0 -0
  18. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/sites/shop/help.html +0 -0
  19. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/sites/shop/index.html +0 -0
  20. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/billing-security-spa.yaml +0 -0
  21. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/billing-security.yaml +0 -0
  22. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/diffs/order-retry.diff +0 -0
  23. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/diffs/sale-banner.diff +0 -0
  24. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/diffs/stock-check.diff +0 -0
  25. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/shop-bugs.yaml +0 -0
  26. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/shop-hard.yaml +0 -0
  27. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/shop-intent.yaml +0 -0
  28. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/shop.yaml +0 -0
  29. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/bench/suites/todomvc.yaml +0 -0
  30. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/cli.py +0 -0
  31. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/__init__.py +0 -0
  32. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/action_model.py +0 -0
  33. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/app_errors.py +0 -0
  34. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/bugs.py +0 -0
  35. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/goal_verifier.py +0 -0
  36. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/netguard.py +0 -0
  37. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/promise_checker.py +0 -0
  38. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/replay.py +0 -0
  39. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/screen_parser.py +0 -0
  40. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/shared_traces.py +0 -0
  41. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/core/tokens.py +0 -0
  42. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/demos/__init__.py +0 -0
  43. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/demos/fusiontest_dashboard.yaml +0 -0
  44. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/demos/github.yaml +0 -0
  45. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/demos/hacker_news.yaml +0 -0
  46. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/demos/httpbin.yaml +0 -0
  47. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/demos/todomvc.yaml +0 -0
  48. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/demos/wikipedia.yaml +0 -0
  49. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/desktop/__init__.py +0 -0
  50. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/desktop/macos_adapter.py +0 -0
  51. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/desktop/playwright_adapter.py +0 -0
  52. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/desktop/windows_adapter.py +0 -0
  53. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/discovery/__init__.py +0 -0
  54. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/guardrails/__init__.py +0 -0
  55. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/guardrails/engine.py +0 -0
  56. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/mobile/__init__.py +0 -0
  57. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/mobile/android_adapter.py +0 -0
  58. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/mobile/ios_adapter.py +0 -0
  59. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/reporting/__init__.py +0 -0
  60. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/reporting/reporter.py +0 -0
  61. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/security/__init__.py +0 -0
  62. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/security/browser_auth.py +0 -0
  63. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/security/checks.py +0 -0
  64. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/security/config.py +0 -0
  65. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/security/engine.py +0 -0
  66. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/security/findings.py +0 -0
  67. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/training/__init__.py +0 -0
  68. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/training/data_collector.py +0 -0
  69. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/training/dataset_builder.py +0 -0
  70. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest/training/trainer.py +0 -0
  71. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest.egg-info/SOURCES.txt +0 -0
  72. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest.egg-info/dependency_links.txt +0 -0
  73. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest.egg-info/entry_points.txt +0 -0
  74. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest.egg-info/not-zip-safe +0 -0
  75. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest.egg-info/requires.txt +0 -0
  76. {fusiontest-0.2.49 → fusiontest-0.2.53}/fusiontest.egg-info/top_level.txt +0 -0
  77. {fusiontest-0.2.49 → fusiontest-0.2.53}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusiontest
3
- Version: 0.2.49
3
+ Version: 0.2.53
4
4
  Summary: AI-powered UI testing for mobile and desktop — by FusionLeap.io
5
5
  Author-email: FusionLeap <hello@fusionleap.io>
6
6
  License: MIT
@@ -31,6 +31,7 @@ from __future__ import annotations
31
31
 
32
32
  import logging
33
33
  import os
34
+ import re
34
35
  import zipfile
35
36
  from dataclasses import dataclass, field
36
37
  from pathlib import Path
@@ -92,12 +93,28 @@ class GoalEvidence:
92
93
 
93
94
 
94
95
  def clean_url(url: str) -> str:
95
- """The URL without query string, fragment or credentials."""
96
- parts = urlsplit(url)
97
- if not parts.scheme or not parts.hostname:
98
- return parts.path or url.split("?", 1)[0].split("#", 1)[0]
99
- host = parts.hostname + (f":{parts.port}" if parts.port else "")
100
- return f"{parts.scheme}://{host}{parts.path or '/'}"
96
+ """The URL without query string, fragment or credentials. Never raises."""
97
+ try:
98
+ parts = urlsplit(url)
99
+ host, port = parts.hostname, parts.port
100
+ except ValueError: # bad port, unclosed "[", …
101
+ return _clean_malformed(url)
102
+ if not parts.scheme or not host:
103
+ return parts.path or _clean_malformed(url)
104
+ host = f"[{host}]" if ":" in host else host
105
+ return f"{parts.scheme}://{host}{f':{port}' if port else ''}{parts.path or '/'}"
106
+
107
+
108
+ def _clean_malformed(url: str) -> str:
109
+ """clean_url for what urlsplit can't take apart, by text alone."""
110
+ head, sep, rest = url.partition("//")
111
+ if not sep:
112
+ head, rest = "", url
113
+ authority = re.match(r"[^/?#]*", rest).group()
114
+ tail = rest[len(authority):]
115
+ if "@" in tail: # maybe credentials holding "/" or "?": can't tell where they end
116
+ return f"{head}{sep}***"
117
+ return head + sep + authority.rpartition("@")[2] + re.split(r"[?#]", tail, maxsplit=1)[0]
101
118
 
102
119
 
103
120
  def clip(text: str) -> str:
@@ -28,6 +28,7 @@ class LogEntry:
28
28
  url: str = ""
29
29
  action: RecordedAction | None = None
30
30
  text: str = "" # in plain words, secrets masked: a step to reproduce
31
+ goal: str = "" # the goal (as written) it was part of: whose secrets it may type
31
32
 
32
33
 
33
34
  @dataclass
@@ -232,6 +232,7 @@ class RunnerConfig:
232
232
  # Keys are variable names, values are secret strings.
233
233
  # Env vars are also searched when a key is missing here, unless
234
234
  # secrets_allow_env is False (required for multi-tenant server runs).
235
+ # Either way, a goal can only type the ones its own text references.
235
236
  secrets: dict[str, str] = field(default_factory=dict)
236
237
  secrets_allow_env: bool = True
237
238
  # The model only ever sees {{VAR}} placeholders; real values are filled
@@ -730,7 +731,7 @@ class FusionTestRunner:
730
731
  logger.info(f" Backtracking (step {step_num})")
731
732
  self._backtrack(history)
732
733
  recorded.append(RecordedAction(action_type="back"))
733
- self._log.append(LogEntry(kind="action", action=recorded[-1], text="Go back"))
734
+ self._log.append(LogEntry(kind="action", action=recorded[-1], text="Go back", goal=_safe))
734
735
  break
735
736
 
736
737
  if gr.should_skip:
@@ -738,7 +739,7 @@ class FusionTestRunner:
738
739
  continue
739
740
 
740
741
  # 5. Execute the action, filling in any secrets
741
- exec_action, blocked = self._bind_secrets(gr.action, resolver)
742
+ exec_action, blocked = self._bind_secrets(gr.action, resolver, _safe)
742
743
  if blocked:
743
744
  logger.warning(f" {blocked}")
744
745
  step.success = False
@@ -760,7 +761,7 @@ class FusionTestRunner:
760
761
  safe_action_str = _redact(action_str)
761
762
  step.actions.append(safe_action_str) # stored — secrets masked
762
763
  action_text = _redact(_action_text(gr.action, elements))
763
- self._log.append(LogEntry(kind="action", action=recorded[-1],
764
+ self._log.append(LogEntry(kind="action", action=recorded[-1], goal=_safe,
764
765
  text=step_text("action", action=action_text)))
765
766
  pending = (action_text, screen_text, len(self._log))
766
767
  self.guardrails.record_action(gr.action)
@@ -966,7 +967,7 @@ class FusionTestRunner:
966
967
  action = resolve_action(entry.action, elements)
967
968
  if action is None:
968
969
  return False
969
- exec_action, blocked = self._bind_secrets(action, resolver)
970
+ exec_action, blocked = self._bind_secrets(action, resolver, entry.goal)
970
971
  if blocked or not self.adapter.execute(exec_action, elements):
971
972
  return False
972
973
  return True
@@ -1113,7 +1114,7 @@ class FusionTestRunner:
1113
1114
  logger.info(" Reproduction stopped: %s %r is gone",
1114
1115
  entry.action.element_type, entry.action.element_label)
1115
1116
  break
1116
- exec_action, blocked = self._bind_secrets(action, resolver)
1117
+ exec_action, blocked = self._bind_secrets(action, resolver, entry.goal)
1117
1118
  if blocked or not adapter.execute(exec_action, elements):
1118
1119
  logger.info(" Reproduction stopped: %s failed", entry.action.action_type)
1119
1120
  break
@@ -1163,11 +1164,12 @@ class FusionTestRunner:
1163
1164
  if action is None:
1164
1165
  logger.info(f" Replay: element gone — {recorded.element_type} {recorded.element_label!r}")
1165
1166
  return None
1166
- exec_action, blocked = self._bind_secrets(action, resolver)
1167
+ # The trace may be old, edited or shared: this goal decides what it may type.
1168
+ exec_action, blocked = self._bind_secrets(action, resolver, safe_goal)
1167
1169
  if blocked or not self.adapter.execute(exec_action, elements):
1168
- logger.info(f" Replay: action failed — {action}")
1170
+ logger.info(f" Replay: {blocked or f'action failed — {action}'}")
1169
1171
  return None
1170
- self._log.append(LogEntry(kind="action", action=recorded, text=step_text(
1172
+ self._log.append(LogEntry(kind="action", action=recorded, goal=safe_goal, text=step_text(
1171
1173
  "action", action=resolver.redact(_action_text(action, elements)))))
1172
1174
  actions.append(resolver.redact(str(action)))
1173
1175
  if trace.actions:
@@ -1218,12 +1220,16 @@ class FusionTestRunner:
1218
1220
  logger.warning(f" Navigation failed: {e}")
1219
1221
 
1220
1222
  def _bind_secrets(
1221
- self, action: Action, resolver: SecretResolver | None
1223
+ self, action: Action, resolver: SecretResolver | None, goal: str
1222
1224
  ) -> tuple[Action, str | None]:
1223
1225
  """
1224
- Substitute {{VAR}} placeholders in a "type" action's value — when
1225
- secret_hosts is set, only if the current page's host is allowed for
1226
- every referenced secret.
1226
+ Substitute {{VAR}} placeholders in a "type" action's value — only ones
1227
+ *goal* (as its author wrote it) contains, and when secret_hosts is set,
1228
+ only if the current page's host is allowed for every referenced secret.
1229
+
1230
+ The action's text is the model's, and a page can talk the model into
1231
+ typing {{ANY_ENV_VAR}}: what a goal doesn't reference is never typed.
1232
+ Pass the goal as written, not the model's copy (its hint says {{NAME}}).
1227
1233
 
1228
1234
  Returns (action_to_execute, None), or (action, error) when blocked.
1229
1235
  Other action types are returned unchanged — placeholders stay literal.
@@ -1231,6 +1237,13 @@ class FusionTestRunner:
1231
1237
  names = SecretResolver.template_names(action.value or "")
1232
1238
  if not names or action.action_type != "type" or resolver is None:
1233
1239
  return action, None
1240
+ own = set(SecretResolver.placeholders(goal))
1241
+ for placeholder in SecretResolver.placeholders(action.value):
1242
+ if placeholder not in own:
1243
+ return action, (
1244
+ f"secret_not_in_goal: {placeholder} was not typed: this goal doesn't "
1245
+ f"reference it (a goal can only type the {{{{VAR}}}} placeholders in its own text)"
1246
+ )
1234
1247
  if self.config.secret_hosts is None:
1235
1248
  return replace(action, value=resolver.resolve(action.value)), None
1236
1249
 
@@ -109,6 +109,12 @@ class SecretResolver:
109
109
  """True if *text* contains any {{VAR}} placeholders."""
110
110
  return bool(_TEMPLATE_RE.search(text))
111
111
 
112
+ @staticmethod
113
+ def placeholders(text: str) -> list[str]:
114
+ """The placeholders in *text* as written, minus spaces ("{{EMAIL}}"), in
115
+ order of appearance. The runner types only those the goal contains too."""
116
+ return ["".join(m.group(0).split()) for m in _TEMPLATE_RE.finditer(text)]
117
+
112
118
  @staticmethod
113
119
  def template_names(text: str) -> list[str]:
114
120
  """Variable names referenced as {{VAR}} in *text*, in order of appearance."""
@@ -34,6 +34,7 @@ from fusiontest.core.action_model import (
34
34
  _is_ollama_reachable,
35
35
  )
36
36
  from fusiontest.core.replay import select_evidence
37
+ from fusiontest.core.secrets import SecretResolver
37
38
 
38
39
  logger = logging.getLogger(__name__)
39
40
 
@@ -221,7 +222,11 @@ def _derive_name(text: str) -> str:
221
222
 
222
223
 
223
224
  def _parse_goals(raw: str, max_goals: int, content: str) -> list[DiscoveredGoal]:
224
- """Parse the LLM's JSON and keep only goals whose evidence is in the content."""
225
+ """Parse the LLM's JSON and keep only goals whose evidence is in the content.
226
+
227
+ Goals with {{VAR}} placeholders are dropped: a goal may type the secrets it
228
+ references, and these are written from pages (untrusted), not by the user.
229
+ """
225
230
  raw = re.sub(r"^```[a-z]*\n?|\n?```$", "", raw.strip(), flags=re.M)
226
231
  try:
227
232
  data = json.loads(raw)
@@ -238,7 +243,7 @@ def _parse_goals(raw: str, max_goals: int, content: str) -> list[DiscoveredGoal]
238
243
  if not text:
239
244
  continue
240
245
  evidence = select_evidence([str(item.get("evidence", ""))], content, limit=1)
241
- if not evidence:
246
+ if not evidence or SecretResolver.placeholders(text):
242
247
  dropped.append(text)
243
248
  continue
244
249
  category = item.get("category", "happy_path")
@@ -261,7 +266,7 @@ def _parse_goals(raw: str, max_goals: int, content: str) -> list[DiscoveredGoal]
261
266
  break
262
267
 
263
268
  if dropped:
264
- logger.info("Dropped %d goal(s) not grounded in the site content: %s",
269
+ logger.info("Dropped %d goal(s) not grounded in the site content, or with {{VAR}} placeholders: %s",
265
270
  len(dropped), "; ".join(d[:60] for d in dropped))
266
271
  return goals
267
272
 
@@ -32,6 +32,7 @@ from fusiontest.core.action_model import (
32
32
  resolve_judge_backend,
33
33
  )
34
34
  from fusiontest.core.replay import select_evidence
35
+ from fusiontest.core.secrets import SecretResolver
35
36
  from fusiontest.discovery.goal_generator import (
36
37
  GoalGenerationError,
37
38
  SiteSnapshot,
@@ -64,7 +65,7 @@ class IntentPlan:
64
65
  # Set when the change has nothing to verify in the UI, with the model's reason.
65
66
  no_ui_change: str = ""
66
67
  backend_used: str = ""
67
- dropped: list[str] = field(default_factory=list) # goals grounded in neither
68
+ dropped: list[str] = field(default_factory=list) # grounded in neither, or naming secrets
68
69
 
69
70
 
70
71
  # ── The diff ──────────────────────────────────────────────────────────────────
@@ -165,7 +166,9 @@ def _parse(raw: str, max_goals: int, site: str, added: str) -> IntentPlan:
165
166
  quote = [str(item.get("evidence", ""))]
166
167
  on_site = select_evidence(quote, site, limit=1)
167
168
  in_diff = [] if on_site else select_evidence(quote, added, limit=1)
168
- if not on_site and not in_diff:
169
+ # A goal may type the secrets it references; the user didn't write this
170
+ # one, so (as in goal_generator) it can't reference any.
171
+ if (not on_site and not in_diff) or SecretResolver.placeholders(text):
169
172
  plan.dropped.append(text)
170
173
  continue
171
174
  plan.goals.append(IntentGoal(
@@ -180,7 +183,7 @@ def _parse(raw: str, max_goals: int, site: str, added: str) -> IntentPlan:
180
183
  if plan.goals:
181
184
  plan.no_ui_change = ""
182
185
  if plan.dropped:
183
- logger.info("Dropped %d intent goal(s) grounded in neither the site nor the diff: %s",
186
+ logger.info("Dropped %d intent goal(s) grounded in neither the site nor the diff, or naming secrets: %s",
184
187
  len(plan.dropped), "; ".join(d[:60] for d in plan.dropped))
185
188
  return plan
186
189
 
@@ -213,7 +216,7 @@ def goals_from_change(
213
216
  plan.backend_used = caller.last_backend
214
217
  if not plan.goals and not plan.no_ui_change:
215
218
  raise GoalGenerationError(
216
- "The model didn't propose any goals grounded in the site or the change."
219
+ "The model didn't propose any usable goals grounded in the site or the change."
217
220
  + (f" Dropped: {'; '.join(d[:80] for d in plan.dropped)}" if plan.dropped else ""))
218
221
  logger.info("Intent: %d goal(s) for %s via %s", len(plan.goals), snapshot.url,
219
222
  plan.backend_used)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusiontest
3
- Version: 0.2.49
3
+ Version: 0.2.53
4
4
  Summary: AI-powered UI testing for mobile and desktop — by FusionLeap.io
5
5
  Author-email: FusionLeap <hello@fusionleap.io>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fusiontest"
7
- version = "0.2.49"
7
+ version = "0.2.53"
8
8
  description = "AI-powered UI testing for mobile and desktop — by FusionLeap.io"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
File without changes
File without changes