{"record":{"id":"97d975c025078745","repo":"NationalSecurityAgency/ghidra","slug":"protocol-not-permissable-for-bsim-url","errorCode":null,"errorMessage":"Protocol not permissable for BSim URL","messagePattern":"Protocol not permissable for BSim URL","errorType":"validation","errorClass":"MalformedURLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java","lineNumber":54,"sourceCode":"\t * @throws URISyntaxException if the URL string cannot be parsed\n\t */\n\tpublic static URL buildURL(String urlString) throws MalformedURLException, URISyntaxException {\n\t\tURL url = new URI(urlString).toURL();\n\t\tcheckBSimServerURL(url);\n\t\treturn url;\n\t}\n\n\t/**\n\t * Validate BSim DB URL.\n\t * Acceptable protocols are  postgresql://  https://,  (or possibly http://) file:/\n\t * @param url BSim DB URL\n\t * @throws MalformedURLException if the URL string is not a support BSim DB URL\n\t */\n\tpublic static void checkBSimServerURL(URL url) throws MalformedURLException {\n\t\tString protocol = url.getProtocol();\n\t\tif (!protocol.equals(\"postgresql\") && !protocol.equals(\"https\") &&\n\t\t\t!protocol.equals(\"elastic\") && !protocol.equals(\"file\")) {\n\t\t\tthrow new MalformedURLException(\"Protocol not permissable for BSim URL\");\n\t\t}\n\t\tString path = url.getPath();\n\t\tif (path == null || path.length() == 0 || path.equals(\"/\")) {\n\t\t\tthrow new MalformedURLException(\"BSim URL missing DB name/path\");\n\t\t}\n\t\tif (!\"file\".equals(protocol) && path.indexOf('/', 1) >= 0) {\n\t\t\tthrow new MalformedURLException(\"BSim URL must specify exactly 1 path element\");\n\t\t}\n\t}\n\n\t/**\n\t * Construct the root URL to a specific BSim repository given a \"related\" URL.\n\t * The root URL will have an explicit protocol, a hostname + other mods (the authority), and 1 level of path\n\t *    this first level path indicates the particular repository being referenced on the host.\n\t * The \"related\" URL -url- can be an explicitly provided URL pointing to the BSim repository,\n\t *    possibly with additional path levels, which are simply stripped from the final root URL.\n\t * Alternately -url- can reference a ghidra server, as indicated by the \"ghidra\" protocol.\n\t *    In this case the true BSim URL is derived from ghidra URL in some way","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java#L36-L72","documentation":"BSimClientFactory.checkBSimServerURL() validates the URL protocol against the allowed set: postgresql, https, elastic, and file. Any other protocol causes MalformedURLException. This is the first validation gate for BSim URLs — the protocol must be one of the supported database backends.","triggerScenarios":"Calling checkBSimServerURL(url) (directly or via deriveBSimURL/buildClient) where url.getProtocol() returns a value not in {postgresql, https, elastic, file}. Note: the javadoc mentions http:// as 'possibly' supported, but the code does NOT accept plain 'http'.","commonSituations":"User provides an http:// URL thinking it's supported (the javadoc is misleading); typo in the protocol string; user provides a ghidra:// URL directly to checkBSimServerURL instead of going through deriveBSimURL; copy-paste of a URL from documentation that uses an unsupported scheme.","solutions":["Change the URL protocol to one of: postgresql://, https://, elastic://, or file:/.","If using http://, switch to https:// (plain http is not accepted despite the javadoc comment).","If using a ghidra:// URL, pass it through deriveBSimURL() instead of checkBSimServerURL() directly — deriveBSimURL handles ghidra URLs and converts them.","Double-check for protocol typos (e.g., postgreql instead of postgresql)."],"exampleFix":"// before\ncheckBSimServerURL(new URL(\"http://myhost/bsimdb\")); // throws\n//\n// after — use https (or postgresql/elastic/file)\ncheckBSimServerURL(new URL(\"https://myhost/bsimdb\"));","handlingStrategy":"validation","validationCode":"String protocol = url.getProtocol();\nif (!Set.of(\"postgresql\", \"https\", \"elastic\", \"file\").contains(protocol)) {\n    // Inform user of valid protocols; note that http is NOT supported\n    throw new IllegalArgumentException(\n        \"Protocol '\" + protocol + \"' not supported. Use postgresql, https, elastic, or file.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    BSimClientFactory.checkBSimServerURL(url);\n} catch (MalformedURLException e) {\n    if (e.getMessage().startsWith(\"Protocol not permissable\")) {\n        // prompt user to use a valid protocol\n    } else {\n        throw e;\n    }\n}","preventionTips":["Note that http:// is NOT supported despite the javadoc — always use https://.","Validate the URL protocol before passing to checkBSimServerURL.","Provide a protocol picker/dropdown in the UI rather than free text.","Document the four valid protocols prominently."],"tags":["bsim","url-validation","protocol","configuration"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}