{"record":{"id":"ea0a9335aa7b73d2","repo":"NationalSecurityAgency/ghidra","slug":"unsupported-protocol","errorCode":null,"errorMessage":"Unsupported protocol: {}","messagePattern":"Unsupported protocol: (.+?)","errorType":"validation","errorClass":"MalformedURLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java","lineNumber":162,"sourceCode":"\t * @param bsimURL  URL supplied by the user\n\t * @param async true if database commits should be synchronous\n\t * @return the database client\n\t * @throws MalformedURLException if there's a problem creating the elastic database\n\t */\n\tpublic static FunctionDatabase buildClient(URL bsimURL, boolean async)\n\t\t\tthrows MalformedURLException {\n\n\t\tString protocol = bsimURL.getProtocol();\n\t\tif (protocol.equals(\"postgresql\")) {\n\t\t\treturn new PostgresFunctionDatabase(bsimURL, async);\n\t\t}\n\t\tif (protocol.equals(\"https\") || protocol.equals(\"elastic\")) {\n\t\t\treturn new ElasticDatabase(bsimURL);\n\t\t}\n\t\tif (\"file\".equals(protocol)) {\n\t\t\treturn new H2FileFunctionDatabase(bsimURL);\n\t\t}\n\t\tthrow new MalformedURLException(\"Unsupported protocol: \" + protocol);\n\t}\n}\n","sourceCodeStart":144,"sourceCodeEnd":165,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java#L144-L165","documentation":"BSimClientFactory.buildClient() dispatches on the URL protocol to construct the correct FunctionDatabase implementation (PostgresFunctionDatabase for postgresql, ElasticDatabase for https/elastic, H2FileFunctionDatabase for file). If none match, MalformedURLException is thrown. Note: checkBSimServerURL accepts the same four protocols, so reaching this throw typically means buildClient was called without prior URL validation, or the URL was modified after validation.","triggerScenarios":"Calling BSimClientFactory.buildClient(bsimURL, async) where bsimURL.getProtocol() is not postgresql, https, elastic, or file. This should not happen if checkBSimServerURL was called first, but can occur if buildClient is called directly with an unvalidated URL.","commonSituations":"Direct call to buildClient bypassing checkBSimServerURL; URL protocol changed between validation and client construction (race/bug); a new protocol was added to checkBSimServerURL but no corresponding database implementation exists in buildClient; code path that constructs the URL dynamically without validation.","solutions":["Always call checkBSimServerURL(url) (or deriveBSimURL) before buildClient to validate the protocol.","Ensure the URL protocol is one of: postgresql, https, elastic, file.","If you extended checkBSimServerURL to accept a new protocol, also add the corresponding database construction branch in buildClient.","Audit code paths that call buildClient directly to ensure they validate first."],"exampleFix":"// before\nFunctionDatabase db = BSimClientFactory.buildClient(url, true); // unvalidated\n//\n// after — validate first\nBSimClientFactory.checkBSimServerURL(url);\nFunctionDatabase db = BSimClientFactory.buildClient(url, true);","handlingStrategy":"validation","validationCode":"// Always validate before building the client\nBSimClientFactory.checkBSimServerURL(bsimURL);\n// Now safe to build — protocols validated\nFunctionDatabase db = BSimClientFactory.buildClient(bsimURL, async);","typeGuard":null,"tryCatchPattern":"try {\n    FunctionDatabase db = BSimClientFactory.buildClient(url, true);\n} catch (MalformedURLException e) {\n    if (e.getMessage().startsWith(\"Unsupported protocol\")) {\n        // URL was not validated — call checkBSimServerURL first\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always call checkBSimServerURL(url) or deriveBSimURL(urlString) before buildClient.","If extending checkBSimServerURL to accept a new protocol, add the matching branch in buildClient.","Treat buildClient as a private/dispatch method — callers should go through the validated entry points.","Add a unit test that verifies every protocol accepted by checkBSimServerURL is handled by buildClient."],"tags":["bsim","url-validation","protocol","database-client","api-contract"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}