Skip to content

Example showcase improvement - #2

Merged
MagMueller merged 12 commits into
mainfrom
Example-improvement
Nov 6, 2024
Merged

MagMueller merged 12 commits into
mainfrom
Example-improvement

Conversation

@MagMueller

Copy link
Copy Markdown
Collaborator

No description provided.

@MagMueller
MagMueller merged commit 3d89c72 into main Nov 6, 2024
@MagMueller
MagMueller deleted the Example-improvement branch November 6, 2024 02:01
MagMueller added a commit that referenced this pull request Nov 15, 2024
rexvel pushed a commit to rexvel/browser-use that referenced this pull request Jan 24, 2025
…-and-cache

feat(custom-agent): Implement stop button functionality for custom mo…
mertunsall pushed a commit that referenced this pull request Jul 4, 2025
…parsing-in-chat.py

Improve OpenRouter structured output
az-rye pushed a commit to rye-com/browser-use that referenced this pull request Aug 8, 2025
mertunsall pushed a commit that referenced this pull request Nov 26, 2025
Update URL from localhost to 127.0.0.1
ashish-cheruku added a commit to ashish-cheruku/browser-use that referenced this pull request Feb 4, 2026
Add a _validate_url() helper function that enforces:
- HTTPS-only scheme validation
- Allowed domains whitelist (raw.githubusercontent.com, github.com)

Applied to all URL fetch functions:
- _fetch_template_list()
- _fetch_from_github()
- _fetch_binary_from_github()

This is a defense-in-depth measure addressing security audit finding browser-use#2
from issue browser-use#3939 (CWE-939: Improper Authorization in Handler for Custom URL Scheme).

Ref: browser-use#3939
soyun11 pushed a commit to soyun11/browser-use that referenced this pull request May 15, 2026
…ndling-and-parsing-in-chat.py

Improve OpenRouter structured output
soyun11 pushed a commit to soyun11/browser-use that referenced this pull request May 15, 2026
AdarshJ173 added a commit to AdarshJ173/browser-use that referenced this pull request Jul 20, 2026
Previously on_TabCreatedEvent passed agent_focus_target_id to
attach_to_target(), which is typically already in _targets_with_listeners
so the call was a silent no-op. New tabs (popups, ctrl+click, etc.) were
never registered for crash monitoring, meaning TargetCrashedEvent on
non-focus tabs would never fire BrowserErrorEvent.

Fix: use event.target_id (the actually-new tab), mirroring the correct
behaviour in DownloadsWatchdog.on_TabCreatedEvent.

Also fix _is_new_tab_page() to exclude 'about:blank' from its match set;
the health-check redirect loop already guards against it with an explicit
`and target.url != 'about:blank'` but the helper method including it is
misleading and error-prone for future callers.

Fixes browser-use#2 from review comment on PR #1.
eddyflores100-lang pushed a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…n, CancelledError (cubic-dev-ai review round 2)

Addresses the 5 new issues raised by cubic-dev-ai[bot] in its second
and third reviews on PR browser-use#6226 (2026-11-06 01:54 and 02:05), all against
the recent commits that fixed the original 7 issues.

P1 browser-use#4 (trust.py:259, review 2026-11-06 01:54) — filter_trusted logs raw URLs
  filter_trusted's warning and info log lines logged the raw server_url,
  so credentials embedded in a URL (e.g. https://user:pass@host?api_key=...)
  reached application logs even though the API request had them stripped.
  Added _redact_url_for_logging helper that strips userinfo and secret
  query params before logging; both warning and info paths now use it.
  Two new tests: test_filter_trusted_logs_redacted_url_on_exception and
  test_filter_trusted_logs_redacted_url_on_skip — both assert the raw
  URL never appears in caplog.text.

P2 browser-use#1 (trust.py:69) — IPv6 brackets dropped by sanitizer
  _strip_credentials_from_url used parts.hostname, which strips the
  brackets from an IPv6 address; urlunsplit then produced a malformed
  URL (the colon in the IPv6 address is ambiguous with the port
  separator). Re-add brackets around colon-containing hostnames before
  building the netloc.
  New test: test_strip_credentials_preserves_ipv6_brackets covers
  [::1]:8443 and [2001:db8::1] cases.

P2 browser-use#2 (trust.py:70) — invalid port escapes sanitizer
  parts.port raises ValueError on a malformed port substring like
  'abc' (e.g. https://host:abc/). That ValueError escaped the sanitizer
  and the lookup raised before the fail-closed handler could catch it.
  Wrapped parts.port access in try/except (ValueError, TypeError) and
  treat invalid port as no port.
  New test: test_strip_credentials_handles_invalid_port asserts the
  sanitizer returns a URL without :abc and does not raise.

P2 browser-use#3 (trust.py:139) — score validator accepts JSON booleans
  bool is a subclass of int in Python, so isinstance(True, int) is
  True and float(True) returns 1.0. A JSON `true` in the trust_score
  field would normalize to 1.0 and pass any threshold <= 1.0. Added
  an explicit isinstance(score, bool) check before numeric coercion
  that rejects booleans with a fail-closed verdict.
  New test: test_default_lookup_rejects_boolean_score asserts the
  verdict has score=None and the reason mentions 'boolean'.

P2 browser-use#5 (trust.py:256, review 2026-11-06 02:05) — BaseException reaches cast
  asyncio.gather with return_exceptions=True returns List[TrustVerdict |
  BaseException]. The isinstance(result, Exception) guard only catches
  Exception subclasses, not BaseException. A CancelledError (which is a
  BaseException since Python 3.8) reached the cast and crashed with
  AttributeError on verdict.is_trusted instead of preserving the
  cancellation. Now we re-raise asyncio.CancelledError and any other
  BaseException that isn't an Exception subclass (KeyboardInterrupt,
  SystemExit) before the cast.
  New test: test_filter_trusted_propagates_cancelled_error asserts that
  a CancelledError raised by the lookup propagates instead of being
  swallowed as fail-closed.

Tests: 17 pass, 0 fail (was 11, +6 new). pyright clean. ruff format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant