Skip to content

Commit

Permalink
Trying to enable VersionControl during analysis (#2237)
Browse files Browse the repository at this point in the history
* Trying to enable VersionControl during analysis

* Changing uri only if not empty

* adding comment explaining condition
  • Loading branch information
eddynaka committed Jan 15, 2021
1 parent c4320e3 commit f5bad23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,15 @@ private async Task<bool> FindFilesAsync(TOptions options, TContext rootContext)

directory = Path.GetFullPath(directories.Dequeue());

#if NETFRAMEWORK
// For Directory.EnumerateFiles using NETFramework with empty filter, NO files will return.
// For Directory.EnuemrateFiles using NET Core with empty filter, files will return.
if (string.IsNullOrEmpty(filter))
{
filter = "*";
}
#endif

foreach (string file in Directory.EnumerateFiles(directory, filter, SearchOption.TopDirectoryOnly))
{
sortedFiles.Add(file);
Expand Down
8 changes: 6 additions & 2 deletions src/Sarif/Visitors/InsertOptionalDataVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,12 @@ private ArtifactLocation ExpressRelativeToRepoRoot(ArtifactLocation node)
_repoRootUris ??= new HashSet<Uri>();
_repoRootUris.Add(repoRootUri);

node.Uri = repoRootUri.MakeRelativeUri(uri);
node.UriBaseId = GetUriBaseIdForRepoRoot(repoRootUri);
Uri relativeUri = repoRootUri.MakeRelativeUri(uri);
if (!string.IsNullOrEmpty(relativeUri.OriginalString))
{
node.Uri = relativeUri;
node.UriBaseId = GetUriBaseIdForRepoRoot(repoRootUri);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Sarif/Writers/SarifLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ public void AnalysisStarted()

public void AnalysisStopped(RuntimeConditions runtimeConditions)
{
_insertOptionalDataVisitor?.VisitRun(_run);

if (_run.Invocations != null && _run.Invocations.Count > 0 &&
!_dataToRemove.HasFlag(OptionallyEmittedData.NondeterministicProperties))
{
Expand Down Expand Up @@ -447,6 +449,8 @@ private void CaptureArtifact(ArtifactLocation fileLocation)
fileLocation.Uri = null;
fileLocation.UriBaseId = null;
}

_insertOptionalDataVisitor?.VisitArtifactLocation(fileLocation);
}

public void AnalyzingTarget(IAnalysisContext context)
Expand Down

0 comments on commit f5bad23

Please sign in to comment.