Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-5026

Use of symbolic links are not fully supported in source directories

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0, 4.1
    • Fix Version/s: 4.2
    • Component/s: Scanner
    • Labels:
      None

      Description

      Here are the steps to reproduce this issue :

      • Start from a basic JavaScript project containing only one source directory 'src'
      • Execute an analysis -> OK
      • Add a new directory in the 'src' directory which is a symbolic link to a directory located outside of the project. This directory must also contain some JavaScript files
      • Execute an analysis -> KO

      This issue occurs because SonarQube tries for each source file to determine the path relative to the root project directory. When reaching a source file contained in a linked directory located outside of the project, this relative path is null.

      Technical details

      Here is a sum-up of java.io.File behavior, assuming that directory /tmp/bar links to /tmp/foo :

      • when File#isAbsolute() is true (because instantiated with absolute path) :
        // file is physically in /tmp/foo
        File foo = new File("/tmp/foo/index.txt");
        File bar = new File("/tmp/bar/index.txt");
        
        • File#getAbsolutePath() returns the path without resolving symbolic links
          • foo.getAbsolutePath() is /tmp/foo/index.txt
          • bar.getAbsolutePath() is /tmp/bar/index.txt
          • foo.getPath() is equal to foo.getAbsolutePath()
          • warning - note that the absolute path is not normalized: new File("/tmp/foo/../foo/index.txt").getAbsolutePath() is /tmp/foo/../foo/index.txt
        • File#getCanonicalPath() returns the path with resolution of links
          • foo.getCanonicalPath() is /tmp/foo/index.txt
          • bar.getCanonicalPath() is /tmp/foo/index.txt
      • when File#isRelative() is true :
        // file is physically in /tmp/foo. Program is started from /tmp
        File foo = new File("foo/index.txt");
        File bar = new File("bar/index.txt");
        
        • File#getAbsolutePath() returns the absolute path without resolving symbolic links
          • foo.getAbsolutePath() is /tmp/foo/index.txt
          • bar.getAbsolutePath() is /tmp/bar/index.txt
          • foo.getPath() is foo/index.txt
          • warning - note that absolute path is not normalized: new File("foo/../foo/index.txt").getAbsolutePath() is /tmp/foo/../foo/index.txt
        • File#getCanonicalPath() returns the path with resolution of link
          • foo.getCanonicalPath() is /tmp/foo/index.txt
          • bar.getCanonicalPath() is /tmp/foo/index.txt

      For this reason files should be indexed by their normalized absolute path. Plugins should take care of the distinction between absolute and canonical path, for example when reading external reports.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              simon.brandhof Simon Brandhof (Inactive)
              Reporter:
              freddy.mallet Freddy Mallet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: