diff --git a/src/AritfactoryUploader.UTest/PackageUploadHelperTest.cs b/src/AritfactoryUploader.UTest/PackageUploadHelperTest.cs index f6f91dce..d751d2a4 100644 --- a/src/AritfactoryUploader.UTest/PackageUploadHelperTest.cs +++ b/src/AritfactoryUploader.UTest/PackageUploadHelperTest.cs @@ -412,6 +412,7 @@ public async Task GetSrcRepoDetailsForPyPiOrConanPackages_WhenPypiRepoExists_Ret Value = "Reponame" }; List properties = new List() { repoNameProperty }; + await Task.Delay(5000); var item = new Component { Purl = "pypi://example-package", @@ -421,14 +422,14 @@ public async Task GetSrcRepoDetailsForPyPiOrConanPackages_WhenPypiRepoExists_Ret }; AqlProperty pypiNameProperty = new AqlProperty { - key = "pypi.normalized.name", - value = "pypi component" + Key = "pypi.normalized.name", + Value = "pypi component" }; AqlProperty pypiVersionProperty = new AqlProperty { - key = "pypi.version", - value = "1.0.0" + Key = "pypi.version", + Value = "1.0.0" }; List propertys = new List { pypiNameProperty, pypiVersionProperty }; //GetInternalComponentDataByRepo @@ -439,7 +440,7 @@ public async Task GetSrcRepoDetailsForPyPiOrConanPackages_WhenPypiRepoExists_Ret Repo = "pypi-repo", Path = "path/to/package", Name = "pypi component-1.0.0", - properties=propertys, + Properties=propertys, } }; var jFrogServiceMock = new Mock(); @@ -456,7 +457,7 @@ public async Task GetSrcRepoDetailsForPyPiOrConanPackages_WhenPypiRepoExists_Ret Assert.AreEqual("pypi-repo", result.Repo); Assert.AreEqual("path/to/package", result.Path); } - public async Task GetSrcRepoDetailsForPyPiOrConanPackages_WhenConanRepoExists_ReturnsArtifactoryRepoName() + public async static Task GetSrcRepoDetailsForPyPiOrConanPackages_WhenConanRepoExists_ReturnsArtifactoryRepoName() { // Arrange Property reponameProperty = new Property diff --git a/src/ArtifactoryUploader/PackageUploadHelper.cs b/src/ArtifactoryUploader/PackageUploadHelper.cs index 7a978037..afc9b576 100644 --- a/src/ArtifactoryUploader/PackageUploadHelper.cs +++ b/src/ArtifactoryUploader/PackageUploadHelper.cs @@ -1215,7 +1215,7 @@ public static async Task> GetNpmListOfComponentsFromRepo(string[ private static AqlResult GetArtifactoryRepoName(List aqlResultList, Component component) { string jfrogpackageName = GetFullNameOfComponent(component); - AqlResult repoName = aqlResultList.Find(x => x.properties.Any(p => p.key == "pypi.normalized.name" && p.value == jfrogpackageName) && x.properties.Any(p => p.key == "pypi.version" && p.value == component.Version)); + AqlResult repoName = aqlResultList.Find(x => x.Properties.Any(p => p.Key == "pypi.normalized.name" && p.Value == jfrogpackageName) && x.Properties.Any(p => p.Key == "pypi.version" && p.Value == component.Version)); return repoName; } @@ -1223,7 +1223,7 @@ private static AqlResult GetArtifactoryRepoName(List aqlResultList, C private static AqlResult GetNpmArtifactoryRepoName(List aqlResultList, Component component) { string jfrogpackageName = GetFullNameOfComponent(component); - AqlResult repoName = aqlResultList.Find(x => x.properties.Any(p => p.key == "npm.name" && p.value == jfrogpackageName) && x.properties.Any(p => p.key == "npm.version" && p.value == component.Version)); + AqlResult repoName = aqlResultList.Find(x => x.Properties.Any(p => p.Key == "npm.name" && p.Value == jfrogpackageName) && x.Properties.Any(p => p.Key == "npm.version" && p.Value == component.Version)); return repoName; } diff --git a/src/LCT.APICommunications/Model/AQL/AqlResult.cs b/src/LCT.APICommunications/Model/AQL/AqlResult.cs index 653ac7d3..016538aa 100644 --- a/src/LCT.APICommunications/Model/AQL/AqlResult.cs +++ b/src/LCT.APICommunications/Model/AQL/AqlResult.cs @@ -33,13 +33,13 @@ public class AqlResult [JsonProperty("sha256")] public string SHA256 { get; set; } - public List properties { get; set; } + public List Properties { get; set; } } public class AqlProperty { - public string key { get; set; } - public string value { get; set; } + public string Key { get; set; } + public string Value { get; set; } } } diff --git a/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs b/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs index 0e4137af..6211fe2d 100644 --- a/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs +++ b/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs @@ -29,32 +29,32 @@ public void GetJfrogArtifactoryRepoDetials_RepoPathFound_ReturnsAqlResultWithRep Mock cycloneDXBomParser = new Mock(); AqlProperty npmNameProperty = new AqlProperty { - key = "npm.name", - value = "component" + Key = "npm.name", + Value = "component" }; AqlProperty npmVersionProperty = new AqlProperty { - key = "npm.version", - value = "1.0.0" + Key = "npm.version", + Value = "1.0.0" }; AqlProperty npmNamePropert = new AqlProperty { - key = "npm.name", - value = "component" + Key = "npm.name", + Value = "component" }; AqlProperty npmVersionPropert = new AqlProperty { - key = "npm.version", - value = "2.0.0" + Key = "npm.version", + Value = "2.0.0" }; List propertys = new List { npmNameProperty, npmVersionProperty }; List property = new List { npmNamePropert, npmVersionPropert }; var aqlResultList = new List { - new AqlResult { Name = "component-1.0.0.tgz", Repo = "repo1", Path="path/to",properties=propertys }, - new AqlResult { Name = "component-2.0.0.tgz", Repo = "repo2", Path="path/to",properties = property } + new AqlResult { Name = "component-1.0.0.tgz", Repo = "repo1", Path="path/to",Properties=propertys }, + new AqlResult { Name = "component-2.0.0.tgz", Repo = "repo2", Path="path/to",Properties = property } }; var bomHelperMock = new Mock(); var component = new Component { Name = "component", Version = "1.0.0" }; @@ -79,32 +79,32 @@ public void GetJfrogArtifactoryRepoDetials_RepoPathNotFound_ReturnsAqlResultWith Mock cycloneDXBomParser = new Mock(); AqlProperty npmNameProperty = new AqlProperty { - key = "npm.name", - value = "component" + Key = "npm.name", + Value = "component" }; AqlProperty npmVersionProperty = new AqlProperty { - key = "npm.version", - value = "1.0.0" + Key = "npm.version", + Value = "1.0.0" }; AqlProperty npmNamePropert = new AqlProperty { - key = "npm.name", - value = "component" + Key = "npm.name", + Value = "component" }; AqlProperty npmVersionPropert = new AqlProperty { - key = "npm.version", - value = "2.0.0" + Key = "npm.version", + Value = "2.0.0" }; List propertys = new List { npmNameProperty, npmVersionProperty }; List property = new List { npmNamePropert, npmVersionPropert }; var aqlResultList = new List { - new AqlResult { Name = "component-1.0.0.tgz", Repo = "repo1",properties=propertys }, - new AqlResult { Name = "component-2.0.0.tgz", Repo = "repo2",properties=property } + new AqlResult { Name = "component-1.0.0.tgz", Repo = "repo1",Properties=propertys }, + new AqlResult { Name = "component-2.0.0.tgz", Repo = "repo2",Properties=property } }; var component = new Component { Name = "component", Version = "3.0.0" }; var bomHelperMock = new Mock(); @@ -136,14 +136,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData_Succes CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlProperty npmNameProperty = new AqlProperty { - key = "npm.name", - value = "animations" + Key = "npm.name", + Value = "animations" }; AqlProperty npmVersionProperty = new AqlProperty { - key = "npm.version", - value = "1.0.0" + Key = "npm.version", + Value = "1.0.0" }; List propertys = new List { npmNameProperty, npmVersionProperty }; AqlResult aqlResult = new() @@ -151,7 +151,7 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData_Succes Name = "animations-1.0.0.tgz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties = propertys + Properties = propertys }; List results = new List() { aqlResult }; @@ -185,14 +185,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData2_Succe CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlProperty npmNameProperty = new AqlProperty { - key = "npm.name", - value = "animations" + Key = "npm.name", + Value = "animations" }; AqlProperty npmVersionProperty = new AqlProperty { - key = "npm.version", - value = "1.0.0" + Key = "npm.version", + Value = "1.0.0" }; List propertys = new List { npmNameProperty, npmVersionProperty }; AqlResult aqlResult = new() @@ -200,7 +200,7 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData2_Succe Name = "animations-common_license-1.0.0.tgz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties = propertys + Properties = propertys }; List results = new List() { aqlResult }; @@ -236,14 +236,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData3_Succe CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlProperty npmNameProperty = new AqlProperty { - key = "npm.name", - value = "animations" + Key = "npm.name", + Value = "animations" }; AqlProperty npmVersionProperty = new AqlProperty { - key = "npm.version", - value = "1.0.0" + Key = "npm.version", + Value = "1.0.0" }; List propertys = new List { npmNameProperty, npmVersionProperty }; AqlResult aqlResult = new() @@ -251,7 +251,7 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData3_Succe Name = "animations-common-1.0.0.tgz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties = propertys + Properties = propertys }; List results = new List() { aqlResult }; @@ -288,14 +288,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData_SuccessFully() appSettings.Npm = new Common.Model.Config() { JfrogNpmRepoList = reooListArr }; AqlProperty npmNameProperty = new AqlProperty { - key = "npm.name", - value = "animations" + Key = "npm.name", + Value = "animations" }; AqlProperty npmVersionProperty = new AqlProperty { - key = "npm.version", - value = "1.0.0" + Key = "npm.version", + Value = "1.0.0" }; List propertys = new List { npmNameProperty, npmVersionProperty }; AqlResult aqlResult = new() @@ -303,7 +303,7 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData_SuccessFully() Name = "animations-common-1.0.0.tgz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties = propertys + Properties = propertys }; List results = new List() { aqlResult }; @@ -341,14 +341,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData2_SuccessFully( appSettings.Npm = new Common.Model.Config() { JfrogNpmRepoList = reooListArr }; AqlProperty npmNameProperty = new AqlProperty { - key = "npm.name", - value = "animations" + Key = "npm.name", + Value = "animations" }; AqlProperty npmVersionProperty = new AqlProperty { - key = "npm.version", - value = "1.0.0" + Key = "npm.version", + Value = "1.0.0" }; List propertys = new List { npmNameProperty, npmVersionProperty }; AqlResult aqlResult = new() @@ -356,7 +356,7 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData2_SuccessFully( Name = "animations-common-1.0.0.tgz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties = propertys + Properties = propertys }; List results = new List() { aqlResult }; diff --git a/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs b/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs index e0f37e17..489af68c 100644 --- a/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs @@ -206,14 +206,14 @@ public async Task IdentificationOfInternalComponents_Python_ReturnsComponentData CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlProperty pypiNameProperty = new AqlProperty { - key = "pypi.normalized.name", - value = "cachy" + Key = "pypi.normalized.name", + Value = "cachy" }; AqlProperty pypiVersionProperty = new AqlProperty { - key = "pypi.version", - value = "0.3.0" + Key = "pypi.version", + Value = "0.3.0" }; List propertys = new List { pypiNameProperty, pypiVersionProperty }; @@ -222,7 +222,7 @@ public async Task IdentificationOfInternalComponents_Python_ReturnsComponentData Name = "cachy-0.3.0.tar.gz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties=propertys + Properties=propertys }; List results = new List() { aqlResult }; @@ -257,14 +257,14 @@ public async Task IdentificationOfInternalComponents_Python_ReturnsComponentData CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlProperty pypiNameProperty = new AqlProperty { - key = "pypi.normalized.name", - value = "cachy" + Key = "pypi.normalized.name", + Value = "cachy" }; AqlProperty pypiVersionProperty = new AqlProperty { - key = "pypi.version", - value = "0.3.0" + Key = "pypi.version", + Value = "0.3.0" }; List propertys = new List { pypiNameProperty, pypiVersionProperty }; @@ -273,7 +273,7 @@ public async Task IdentificationOfInternalComponents_Python_ReturnsComponentData Name = "cachy-1.3.0.tar.gz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties=propertys + Properties=propertys }; List results = new List() { aqlResult }; @@ -309,14 +309,14 @@ public async Task GetJfrogRepoDetailsOfAComponentForPython_ReturnsWithData_Succe appSettings.Python = new Config() { JfrogPythonRepoList = reooListArr }; AqlProperty pypiNameProperty = new AqlProperty { - key = "pypi.normalized.name", - value = "html5lib" + Key = "pypi.normalized.name", + Value = "html5lib" }; AqlProperty pypiVersionProperty = new AqlProperty { - key = "pypi.version", - value = "1.1" + Key = "pypi.version", + Value = "1.1" }; List propertys = new List { pypiNameProperty, pypiVersionProperty }; AqlResult aqlResult = new() @@ -324,7 +324,7 @@ public async Task GetJfrogRepoDetailsOfAComponentForPython_ReturnsWithData_Succe Name = "html5lib-1.1.tar.gz", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties=propertys + Properties=propertys }; List results = new List() { aqlResult }; @@ -361,14 +361,14 @@ public async Task GetJfrogRepoDetailsOfAComponentForPython_ReturnsWithData2_Succ appSettings.Python = new Config() { JfrogPythonRepoList = reooListArr }; AqlProperty pypiNameProperty = new AqlProperty { - key = "pypi.normalized.name", - value = "html5lib" + Key = "pypi.normalized.name", + Value = "html5lib" }; AqlProperty pypiVersionProperty = new AqlProperty { - key = "pypi.version", - value = "1.1" + Key = "pypi.version", + Value = "1.1" }; List propertys = new List { pypiNameProperty, pypiVersionProperty }; AqlResult aqlResult = new() @@ -376,7 +376,7 @@ public async Task GetJfrogRepoDetailsOfAComponentForPython_ReturnsWithData2_Succ Name = "html5lib-1.1-py2.py3-none-any.whl", Path = "@testfolder/-/folder", Repo = "internalrepo1", - properties=propertys + Properties=propertys }; List results = new List() { aqlResult }; diff --git a/src/LCT.PackageIdentifier/NpmProcessor.cs b/src/LCT.PackageIdentifier/NpmProcessor.cs index 6b653f0e..c6c2c151 100644 --- a/src/LCT.PackageIdentifier/NpmProcessor.cs +++ b/src/LCT.PackageIdentifier/NpmProcessor.cs @@ -416,7 +416,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.properties.Any(p => p.key == "npm.name" && p.value == jfrogpackageName) && x.properties.Any(p => p.key == "npm.version" && p.value == component.Version)); + var hashes = aqlResultList.FirstOrDefault(x => x.Properties.Any(p => p.Key == "npm.name" && p.Value == jfrogpackageName) && x.Properties.Any(p => p.Key == "npm.version" && p.Value == component.Version)); string jfrogRepoPath = string.Empty; AqlResult finalRepoData = GetJfrogArtifactoryRepoDetials(aqlResultList, component, bomhelper, out jfrogRepoPath); Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoName, Value = finalRepoData.Repo }; @@ -620,7 +620,7 @@ private static bool IsInternalNpmComponent( List aqlResultList, Component component, IBomHelper bomHelper) { string jfrogcomponentName = bomHelper.GetFullNameOfComponent(component); - if (aqlResultList.Exists(x => x.properties.Any(p => p.key == "npm.name" && p.value == jfrogcomponentName) && x.properties.Any(p => p.key == "npm.version" && p.value == component.Version))) + if (aqlResultList.Exists(x => x.Properties.Any(p => p.Key == "npm.name" && p.Value == jfrogcomponentName) && x.Properties.Any(p => p.Key == "npm.version" && p.Value == component.Version))) { return true; } @@ -637,7 +637,7 @@ public AqlResult GetJfrogArtifactoryRepoDetials(List aqlResultList, jfrogRepoPath = Dataconstant.JfrogRepoPathNotFound; string jfrogpackageName = bomHelper.GetFullNameOfComponent(component); - var aqlResults = aqlResultList.FindAll(x => x.properties.Any(p => p.key == "npm.name" && p.value == jfrogpackageName) && x.properties.Any(p => p.key == "npm.version" && p.value == component.Version)); + var aqlResults = aqlResultList.FindAll(x => x.Properties.Any(p => p.Key == "npm.name" && p.Value == jfrogpackageName) && x.Properties.Any(p => p.Key == "npm.version" && p.Value == component.Version)); string repoName = CommonIdentiferHelper.GetRepodetailsFromPerticularOrder(aqlResults); diff --git a/src/LCT.PackageIdentifier/PythonProcessor.cs b/src/LCT.PackageIdentifier/PythonProcessor.cs index df50ad27..b325b15c 100644 --- a/src/LCT.PackageIdentifier/PythonProcessor.cs +++ b/src/LCT.PackageIdentifier/PythonProcessor.cs @@ -361,7 +361,7 @@ public async Task IdentificationOfInternalComponents(Co private static bool IsInternalPythonComponent(List aqlResultList, Component component, IBomHelper bomHelper) { string jfrogcomponentName = bomHelper.GetFullNameOfComponent(component); - if (aqlResultList.Exists(x => x.properties.Any(p => p.key == "pypi.normalized.name" && p.value == jfrogcomponentName) && x.properties.Any(p => p.key == "pypi.version" && p.value == component.Version))) + if (aqlResultList.Exists(x => x.Properties.Any(p => p.Key == "pypi.normalized.name" && p.Value == jfrogcomponentName) && x.Properties.Any(p => p.Key == "pypi.version" && p.Value == component.Version))) { return true; } @@ -375,7 +375,7 @@ private static string GetJfrogNameOfPypiComponent(string name, string version, L string nameVerison = string.Empty; - nameVerison = aqlResultList.FirstOrDefault(x => x.properties.Any(p => p.key == "pypi.normalized.name" && p.value == name) && x.properties.Any(p => p.key == "pypi.version" && p.value == version))?.Name ?? string.Empty; + nameVerison = aqlResultList.FirstOrDefault(x => x.Properties.Any(p => p.Key == "pypi.normalized.name" && p.Value == name) && x.Properties.Any(p => p.Key == "pypi.version" && p.Value == version))?.Name ?? string.Empty; if (string.IsNullOrEmpty(nameVerison)) { nameVerison = Dataconstant.PackageNameNotFoundInJfrog; } return nameVerison; @@ -396,7 +396,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.properties.Any(p => p.key == "pypi.normalized.name" && p.value == component.Name) && x.properties.Any(p => p.key == "pypi.version" && p.value == component.Version)); + var hashes = aqlResultList.FirstOrDefault(x => x.Properties.Any(p => p.Key == "pypi.normalized.name" && p.Value == component.Name) && x.Properties.Any(p => p.Key == "pypi.version" && p.Value == component.Version)); Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoName, Value = repoName }; Property fileNameProperty = new() { Name = Dataconstant.Cdx_Siemensfilename, Value = jfrogPackageNameWhlExten };