{"record":{"id":"8eab4e4ad9a9144b","repo":"apache/hadoop","slug":"not-implemented-for-windows","errorCode":null,"errorMessage":"Not implemented for Windows","messagePattern":"Not implemented for Windows","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java","lineNumber":682,"sourceCode":"   * @param file The filename to convert\n   * @return The unix pathname\n   * @throws IOException on windows, there can be problems with the subprocess\n   */\n  public static String makeShellPath(File file) throws IOException {\n    return makeShellPath(file, false);\n  }\n\n  /**\n   * Convert a os-native filename to a path that works for the shell\n   * and avoids script injection attacks.\n   * @param file The filename to convert\n   * @return The unix pathname\n   * @throws IOException on windows, there can be problems with the subprocess\n   */\n  public static String makeSecureShellPath(File file) throws IOException {\n    if (Shell.WINDOWS) {\n      // Currently it is never called, but it might be helpful in the future.\n      throw new UnsupportedOperationException(\"Not implemented for Windows\");\n    } else {\n      return makeShellPath(file, false).replace(\"'\", \"'\\\\''\");\n    }\n  }\n\n  /**\n   * Convert a os-native filename to a path that works for the shell.\n   * @param file The filename to convert\n   * @param makeCanonicalPath\n   *          Whether to make canonical path for the file passed\n   * @return The unix pathname\n   * @throws IOException on windows, there can be problems with the subprocess\n   */\n  public static String makeShellPath(File file, boolean makeCanonicalPath)\n  throws IOException {\n    if (makeCanonicalPath) {\n      return makeShellPath(file.getCanonicalPath());\n    } else {","sourceCodeStart":664,"sourceCodeEnd":700,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java#L664-L700","documentation":"FileUtil.makeSecureShellPath(File) throws UnsupportedOperationException(\"Not implemented for Windows\") whenever Shell.WINDOWS is true. The method shell-escapes single quotes for POSIX shells (makeShellPath(file, false).replace(\"'\", \"'\\\\''\")), which has no correct Windows equivalent, so it refuses rather than producing an injectable string. The code comment states it is currently never called internally. It is a hard capability gap, not an environmental glitch.","triggerScenarios":"Invoking FileUtil.makeSecureShellPath(file) on any Windows host or Windows CI runner; library code paths that build bash command lines running under cygwin-class environments where Shell.WINDOWS is detected.","commonSituations":"Cross-platform tooling tested on Linux but deployed on Windows nodes; unit tests executing on Windows CI; shell-injection-hardening refactors that adopt this helper without platform gating.","solutions":["Guard the call: only invoke makeSecureShellPath when !Shell.WINDOWS, and use a Windows-safe quoting routine otherwise","Avoid shelling out on Windows entirely; use ProcessBuilder with an argument list (no shell string) which removes the need for shell escaping","If you must run a POSIX shell path, run the logic on a Linux host/container instead of the Windows node"],"exampleFix":"// before\nString safe = FileUtil.makeSecureShellPath(file); // throws on Windows\n\n// after\nString safe = !Shell.WINDOWS\n    ? FileUtil.makeSecureShellPath(file)\n    : \"\\\"\" + file.getAbsolutePath().replace(\"\\\"\", \"\\\"\\\"\") + \"\\\"\";","handlingStrategy":"validation","validationCode":"if (!Shell.WINDOWS) {\n  shellPath = FileUtil.makeSecureShellPath(file);\n} else {\n  // build argv for ProcessBuilder instead; no shell string to escape\n}","typeGuard":"static boolean supportsSecureShellPath() {\n  return !Shell.WINDOWS;\n}","tryCatchPattern":"try {\n  path = FileUtil.makeSecureShellPath(file);\n} catch (UnsupportedOperationException e) {\n  // Windows: fall back to ProcessBuilder argument-array invocation\n}","preventionTips":["Gate platform-specific shell helpers behind Shell.WINDOWS checks","Prefer ProcessBuilder argument lists over bash -c strings; it removes escaping entirely","Run POSIX-shell logic in Linux containers on Windows hosts"],"tags":["windows","unsupported-operation","shell-path","platform-limitation","fileutil"],"backgroundTag":"platform-not-supported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}