Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-26838

Utility API to check if a file is physically inside a given directory

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core

      Commonly need to verify that file paths provided by a user are really relative and do not refer to locations outside a workspace or the like. Should have something in Util along the lines of

      public static boolean isInside(File root, File f) throws IOException {
          String path = f.getCanonicalPath();
          String rootPath = root.getCanonicalPath();
          return path.equals(rootPath) || path.startsWith(rootPath + File.separatorChar);
      }
      

      and a matching method in FilePath.

          [JENKINS-26838] Utility API to check if a file is physically inside a given directory

          Jesse Glick created issue -
          Jesse Glick made changes -
          Link New: This issue is blocking SECURITY-162 [ SECURITY-162 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 161012 ] New: JNJira + In-Review [ 180545 ]
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-44657 [ JENKINS-44657 ]
          Jesse Glick made changes -
          Link New: This issue relates to SECURITY-2518 [ SECURITY-2518 ]

            Unassigned Unassigned
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: