|
163 | 163 | {"name":"browser","version":"0.1.0-alpha2","interface":{"category":"Engineering"}} |
164 | 164 | JSON |
165 | 165 | cat > "$resources_dir/plugins/openai-bundled/plugins/browser/scripts/browser-client.mjs" <<'JS' |
166 | | -function lu(e){let t=globalThis.nodeRepl?.env[e];return typeof t=="string"?t:void 0}function th(){let e=import.meta.__codexNativePipe;return e==null||typeof e.createConnection!="function"?null:e}var I2=new Set(["about:blank"]);function Gb(e){if(I2.has(e))return!0;let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}class Uf{async fetchBlocked(e){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`Browser Use cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)}}var Cb=kE(hV.platform()),EV=()=>_P()==="win32"?TV():CV(),CV=async()=>(await yP(Cb)).map(e=>wP.resolve(Cb,e)),TV=async()=>[];export function setupAtlasRuntime() {} |
| 166 | +function lu(e){let t=globalThis.nodeRepl?.env[e];return typeof t=="string"?t:void 0}function th(){let e=import.meta.__codexNativePipe;return e==null||typeof e.createConnection!="function"?null:e}var I2=new Set(["about:blank"]);function Gb(e){if(I2.has(e))return!0;let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}class Uf{async fetchBlocked(e,t){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`${t} cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)}}var Cb=kE(hV.platform()),EV=()=>_P()==="win32"?TV():CV(),CV=async()=>(await yP(Cb)).map(e=>wP.resolve(Cb,e)),TV=async()=>[];export function setupAtlasRuntime() {} |
167 | 167 | JS |
168 | 168 | } |
169 | 169 |
|
@@ -7020,6 +7020,120 @@ for (const [key, value] of Object.entries(expected)) { |
7020 | 7020 | NODE |
7021 | 7021 | } |
7022 | 7022 |
|
| 7023 | +test_browser_use_site_status_allowlist_fallback_patch_behavior() { |
| 7024 | + info "Checking Browser Use site_status allowlist fallback patch behavior" |
| 7025 | + local workspace="$TMP_DIR/browser-site-status-allowlist-fallback" |
| 7026 | + local client="$workspace/browser-client.mjs" |
| 7027 | + local first_patch="$workspace/browser-client.first-patch.mjs" |
| 7028 | + local output_log="$workspace/output.log" |
| 7029 | + |
| 7030 | + mkdir -p "$workspace" |
| 7031 | + cat > "$client" <<'JS' |
| 7032 | +var fetchImpl;function F(e,t){return fetchImpl(e,t)}function G(e){return e}function H(e){return e.blocked===!0}var policy={async fetchBlocked(e,t){let s=await F(e.endpoint,{method:"GET"});if(!s.ok)throw new Error(G(`${t} cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await s.json();return H(n)}}; |
| 7033 | +JS |
| 7034 | + |
| 7035 | + ( |
| 7036 | + warn() { echo "[WARN] $*" >&2; } |
| 7037 | + info() { echo "[INFO] $*" >&2; } |
| 7038 | + # shellcheck disable=SC1091 |
| 7039 | + source "$REPO_DIR/scripts/lib/bundled-plugins.sh" |
| 7040 | + patch_browser_use_site_status_allowlist_fallback "$client" |
| 7041 | + cp "$client" "$first_patch" |
| 7042 | + patch_browser_use_site_status_allowlist_fallback "$client" |
| 7043 | + ) >"$output_log" 2>&1 |
| 7044 | + |
| 7045 | + cmp -s "$first_patch" "$client" || fail "Expected Browser Use site_status fallback patch to be byte-identical on second application" |
| 7046 | + assert_occurrence_count "$client" "codexLinuxSiteStatusAllowlistFallback" 1 |
| 7047 | + assert_not_contains "$client" "console.warn" |
| 7048 | + assert_not_contains "$output_log" "Could not find Browser Use site_status allowlist fallback insertion point" |
| 7049 | + |
| 7050 | + node - "$client" <<'NODE' |
| 7051 | +const assert = require("node:assert/strict"); |
| 7052 | +const fs = require("node:fs"); |
| 7053 | +const vm = require("node:vm"); |
| 7054 | + |
| 7055 | +const client = process.argv[2]; |
| 7056 | +const source = fs.readFileSync(client, "utf8"); |
| 7057 | +const warnings = []; |
| 7058 | +const context = { |
| 7059 | + console: { |
| 7060 | + warn(...args) { |
| 7061 | + warnings.push(args); |
| 7062 | + }, |
| 7063 | + }, |
| 7064 | +}; |
| 7065 | +vm.createContext(context); |
| 7066 | +vm.runInContext(source, context); |
| 7067 | + |
| 7068 | +const matchingUrl = { |
| 7069 | + endpoint: "http://127.0.0.1/aura/site_status?url=https%3A%2F%2Fexample.com", |
| 7070 | + displayUrl: "https://example.com/", |
| 7071 | +}; |
| 7072 | +const otherUrl = { |
| 7073 | + endpoint: "http://127.0.0.1/aura/other", |
| 7074 | + displayUrl: "https://example.com/", |
| 7075 | +}; |
| 7076 | + |
| 7077 | +(async () => { |
| 7078 | + const allowlistError = new Error("native ALLOWLIST is unavailable"); |
| 7079 | + context.fetchImpl = async () => { |
| 7080 | + throw allowlistError; |
| 7081 | + }; |
| 7082 | + assert.strictEqual(await context.policy.fetchBlocked(matchingUrl, "Chrome"), false); |
| 7083 | + |
| 7084 | + await assert.rejects( |
| 7085 | + context.policy.fetchBlocked(otherUrl, "Chrome"), |
| 7086 | + (error) => error === allowlistError, |
| 7087 | + ); |
| 7088 | + |
| 7089 | + const otherError = new Error("native policy is unavailable"); |
| 7090 | + context.fetchImpl = async () => { |
| 7091 | + throw otherError; |
| 7092 | + }; |
| 7093 | + await assert.rejects( |
| 7094 | + context.policy.fetchBlocked(matchingUrl, "Chrome"), |
| 7095 | + (error) => error === otherError, |
| 7096 | + ); |
| 7097 | + |
| 7098 | + context.fetchImpl = async () => ({ ok: false }); |
| 7099 | + await assert.rejects( |
| 7100 | + context.policy.fetchBlocked(matchingUrl, "Chrome"), |
| 7101 | + (error) => error.message === "Chrome cannot determine if https://example.com/ is allowed. Please try again later or use another source.", |
| 7102 | + ); |
| 7103 | + |
| 7104 | + const jsonError = new Error("invalid site_status JSON"); |
| 7105 | + context.fetchImpl = async () => ({ |
| 7106 | + ok: true, |
| 7107 | + json: async () => { |
| 7108 | + throw jsonError; |
| 7109 | + }, |
| 7110 | + }); |
| 7111 | + await assert.rejects( |
| 7112 | + context.policy.fetchBlocked(matchingUrl, "Chrome"), |
| 7113 | + (error) => error === jsonError, |
| 7114 | + ); |
| 7115 | + |
| 7116 | + let fetchedEndpoint; |
| 7117 | + let fetchedMethod; |
| 7118 | + context.fetchImpl = async (endpoint, options) => { |
| 7119 | + fetchedEndpoint = endpoint; |
| 7120 | + fetchedMethod = options.method; |
| 7121 | + return { |
| 7122 | + ok: true, |
| 7123 | + json: async () => ({ blocked: true }), |
| 7124 | + }; |
| 7125 | + }; |
| 7126 | + assert.strictEqual(await context.policy.fetchBlocked(matchingUrl, "Chrome"), true); |
| 7127 | + assert.strictEqual(fetchedEndpoint, matchingUrl.endpoint); |
| 7128 | + assert.strictEqual(fetchedMethod, "GET"); |
| 7129 | + assert.strictEqual(warnings.length, 0); |
| 7130 | +})().catch((error) => { |
| 7131 | + console.error(error); |
| 7132 | + process.exitCode = 1; |
| 7133 | +}); |
| 7134 | +NODE |
| 7135 | +} |
| 7136 | + |
7023 | 7137 | test_browser_plugin_renamed_upstream_staging() { |
7024 | 7138 | info "Checking Browser plugin staging from renamed upstream resources" |
7025 | 7139 | local workspace="$TMP_DIR/browser-plugin-renamed" |
@@ -7710,7 +7824,7 @@ var Cb=kE(hV.platform()),EV=()=>_P()==="win32"?TV():CV(),CV=async()=>(await yP(C |
7710 | 7824 | function lu(e){let t=globalThis.nodeRepl?.env[e];return typeof t=="string"?t:void 0} |
7711 | 7825 | function Me(){let e=globalThis.nodeRepl;return e?.config==null?void 0:e} |
7712 | 7826 | import{platform as yT}from"node:os";function eh(){return"privileged native pipe bridge is not available; browser-client is not trusted"}function th(){let e=globalThis.nodeRepl?.nativePipe;return e==null||typeof e.createConnection!="function"?null:e}var ml=class e{constructor(t){this.socket=t}static async create(t){let r=th();if(r!=null){let n=await r.createConnection(t);return new e(n)}throw new Error(eh())}}; |
7713 | | -async fetchBlocked(e){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`Browser Use cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)} |
| 7827 | +async fetchBlocked(e,t){let r=await bS(e.endpoint,{method:"GET"});if(!r.ok)throw new Error(ae(`${t} cannot determine if ${e.displayUrl} is allowed. Please try again later or use another source.`));let n=await r.json();return TF(n)} |
7714 | 7828 | JS |
7715 | 7829 | cat > "$chrome_dir/scripts/check-native-host-manifest.js" <<'JS' |
7716 | 7830 | #!/usr/bin/env node |
@@ -10130,6 +10244,7 @@ main() { |
10130 | 10244 | test_bundled_plugin_system_computer_use_preserves_cosmic_helper_name |
10131 | 10245 | test_browser_use_node_repl_fallback_runtime |
10132 | 10246 | test_browser_use_file_url_policy_patch_behavior |
| 10247 | + test_browser_use_site_status_allowlist_fallback_patch_behavior |
10133 | 10248 | test_browser_plugin_renamed_upstream_staging |
10134 | 10249 | test_upstream_bundled_skills_staging |
10135 | 10250 | test_upstream_bundled_skills_validator_guards |
|
0 commit comments