Skip to content

Commit

Permalink
changed download location parsing to sanitize better
Browse files Browse the repository at this point in the history
  • Loading branch information
Amitla Vannikumar committed Oct 15, 2023
1 parent 7448596 commit 8331bbf
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;

using System.Linq;
using PackageUrl;

public class VcpkgComponent : TypedComponent
Expand All @@ -20,9 +21,11 @@ public VcpkgComponent(string spdxid, string name, string version, string triplet
this.Triplet = triplet;
this.Description = description;
this.DownloadLocation = downloadLocation;
var locationArr = downloadLocation.Split('/');
this.GitRepositoryOwner = locationArr[3];
this.GitRepositoryName = locationArr[4].Split('@')[0];

if (downloadLocation.ToLower().Contains("https://github.com/"))
{
this.SetGitRepoProperties();
}
}

public string SPDXID { get; set; }
Expand All @@ -31,10 +34,6 @@ public VcpkgComponent(string spdxid, string name, string version, string triplet

public string DownloadLocation { get; set; }

public string GitRepositoryOwner { get; set; }

public string GitRepositoryName { get; set; }

public string Triplet { get; set; }

public string Version { get; set; }
Expand All @@ -43,8 +42,23 @@ public VcpkgComponent(string spdxid, string name, string version, string triplet

public int PortVersion { get; set; }

public string GitRepositoryOwner { get; set; }

public string GitRepositoryName { get; set; }

public override ComponentType Type => ComponentType.Vcpkg;

private void SetGitRepoProperties()
{
/* example download locations
* "git+https://github.com/leethomason/tinyxml2@9.0.0"
* "git+https://github.com/Microsoft/vcpkg#ports/nlohmann-json"
*/
var locationArr = this.DownloadLocation.Split('/');
this.GitRepositoryOwner = locationArr[2];
this.GitRepositoryName = locationArr[3].TakeWhile(ch => char.IsLetterOrDigit(ch)).ToString();
}

public override string Id

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / verify (ubuntu-latest)

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / CocoaPods

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Gradle

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / verify (windows-latest)

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Go

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / verify (macos-latest)

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Maven

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / NPM

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / NuGet

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Pip

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Pnpm

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Poetry

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Ruby

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Rust

A property should not follow a method

Check failure on line 62 in src/Microsoft.ComponentDetection.Contracts/TypedComponent/VcpkgComponent.cs

View workflow job for this annotation

GitHub Actions / Yarn

A property should not follow a method
{
get
Expand Down

0 comments on commit 8331bbf

Please sign in to comment.