Skip to content

GitLab Repositories with dots result in wrong paths for the SARIF converter #10

@SeWieland

Description

@SeWieland

return uri.MakeRelativeUri(begin.ResultFile.Uri).ToString().Replace("//", "\\");

If the project path contains any dots, e.g.: /builds/my_group/ns.myproject the roslynator converter correctly transforms the root paths.

However the Sarif Converters make use of the MakeRelativeUri function, which will treat the string wrong.

I suggest using something more robust like

var uri = new Uri(pathRoot);
var absolutePath = begin.ResultFile.Uri.LocalPath;
var rootPath = uri.LocalPath;

if (absolutePath.StartsWith(rootPath))
{
   return absolutePath.Substring(rootPath.Length).Replace("//", "\\");
}

return begin.ResultFile.Uri.MakeRelativeUri(uri).ToString().Replace("//", "\\");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions