Skip to content

Commit 0707d99

Browse files
authored
Revert "Move Go With Replace Detector to the Standard Go Detector" (#1198)
* Revert "go detector (#1194)" This reverts commit 39058c5. * Update ServiceCollectionExtensions.cs * Update ServiceCollectionExtensions.cs
1 parent 683f30e commit 0707d99

File tree

6 files changed

+1101
-91
lines changed

6 files changed

+1101
-91
lines changed

src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs

+4-15
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public GoComponentDetector(
5050

5151
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Go };
5252

53-
public override int Version => 8;
53+
public override int Version => 7;
5454

5555
protected override Task<IObservable<ProcessRequest>> OnPrepareDetectionAsync(
5656
IObservable<ProcessRequest> processRequests, IDictionary<string, string> detectorArgs)
@@ -282,7 +282,6 @@ private async Task ParseGoModFileAsync(
282282
GoGraphTelemetryRecord goGraphTelemetryRecord)
283283
{
284284
using var reader = new StreamReader(file.Stream);
285-
var startString = "require ";
286285

287286
// There can be multiple require( ) sections in go 1.17+. loop over all of them.
288287
while (!reader.EndOfStream)
@@ -298,9 +297,9 @@ private async Task ParseGoModFileAsync(
298297

299298
// In go >= 1.17, direct dependencies are listed as "require x/y v1.2.3", and transitive dependencies
300299
// are listed in the require () section
301-
if (line.StartsWith(startString))
300+
if (line.StartsWith("require "))
302301
{
303-
this.TryRegisterDependencyFromModLine(line[startString.Length..], singleFileComponentRecorder);
302+
this.TryRegisterDependencyFromModLine(line[8..], singleFileComponentRecorder);
304303
}
305304

306305
line = await reader.ReadLineAsync();
@@ -444,15 +443,7 @@ private void RecordBuildDependencies(string goListOutput, ISingleFileComponentRe
444443
continue;
445444
}
446445

447-
GoComponent goComponent;
448-
if (dependency.Replace != null)
449-
{
450-
goComponent = new GoComponent(dependency.Replace.Path, dependency.Replace.Version);
451-
}
452-
else
453-
{
454-
goComponent = new GoComponent(dependency.Path, dependency.Version);
455-
}
446+
var goComponent = new GoComponent(dependency.Path, dependency.Version);
456447

457448
if (dependency.Indirect)
458449
{
@@ -492,7 +483,5 @@ private class GoBuildModule
492483
public string Version { get; set; }
493484

494485
public bool Indirect { get; set; }
495-
496-
public GoBuildModule Replace { get; set; }
497486
}
498487
}

0 commit comments

Comments
 (0)