diff --git a/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java b/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java index ae24e0c3..468abd58 100644 --- a/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java +++ b/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java @@ -179,8 +179,7 @@ public String generateCommandLineComment( long licenseDetected = prohibitedLicenses + restrictedLicenses + unreviewedLicenses; if (licenseDetected > 0) { - commentBuilder.append( - "Potential license problem(s) detected: " + licenseDetected + "\n"); + commentBuilder.append("Potential license issues detected: " + licenseDetected + "\n"); if (prohibitedLicenses > 0) { commentBuilder.append(" - Prohibited license(s): " + prohibitedLicenses + "\n"); } @@ -248,6 +247,247 @@ public static void saveHTMLToFile(String htmlContent, String filePath) { } } + /** + * Generates a comment to the pull request for publication to the VCS. + * + * @param scanResults the results of the license scan + * @param conflicts a list of license conflicts found during the scan + * @param webhookConfig configuration related to the repository and webhook + * @param vcs the string representation of the version control system + * @return the code of the generated VCS comment + */ + public String generatePullRequestComment( + List scanResults, + List> conflicts, + LPVSQueue webhookConfig, + LPVSVcs vcs) { + + StringBuilder commitCommentBuilder = new StringBuilder(); + commitCommentBuilder.append("**Detected Licenses:**\n\n"); + + Map> detectedLicenseInfo = + groupScanResultsForLicenseTable(scanResults); + long prohibitedLicenses = getDetectedLicenseCountByType(detectedLicenseInfo, prohibited); + long restrictedLicenses = getDetectedLicenseCountByType(detectedLicenseInfo, restricted); + long unreviewedLicenses = getDetectedLicenseCountByType(detectedLicenseInfo, unreviewed); + long licenseDetected = prohibitedLicenses + restrictedLicenses + unreviewedLicenses; + + if (licenseDetected > 0) { + commitCommentBuilder.append("Potential license issues detected:\n"); + if (prohibitedLicenses > 0) { + commitCommentBuilder.append( + " - Prohibited license(s): " + prohibitedLicenses + "\n"); + } + if (restrictedLicenses > 0) { + commitCommentBuilder.append( + " - Restricted license(s): " + restrictedLicenses + "\n"); + } + if (unreviewedLicenses > 0) { + commitCommentBuilder.append( + " - Unreviewed license(s): " + unreviewedLicenses + "\n"); + } + } else { + commitCommentBuilder.append("No license problems detected.\n"); + } + if (scanResults != null && !scanResults.isEmpty()) { + commitCommentBuilder + .append("\n") + .append(generateLicenseTable(detectedLicenseInfo, webhookConfig, vcs)) + .append("\n"); + } + commitCommentBuilder.append("\n"); + commitCommentBuilder.append("**Detected License Conflicts:**\n\n"); + if (conflicts != null && !conflicts.isEmpty()) { + commitCommentBuilder.append( + "Potential license conflict(s) detected: " + conflicts.size() + "\n"); + commitCommentBuilder + .append("\n") + .append(generateLicenseConflictsTable(conflicts, vcs)) + .append("\n"); + } else { + commitCommentBuilder.append("No license conflicts detected.\n"); + } + commitCommentBuilder.append("\n"); + + return commitCommentBuilder.toString(); + } + + /** + * Generates an HTML code of the license table to pull request comments + * + * @param detectedLicenseInfo grouped scan results by license SPDX ID and access type, component name and vendor + * @param webhookConfig configuration related to the repository and webhook + * @param vcs the string representation of the version control system + * @return the HTML code of the generated license table + */ + private String generateLicenseTable( + Map> detectedLicenseInfo, LPVSQueue webhookConfig, LPVSVcs vcs) { + if (vcs != null && vcs.equals(LPVSVcs.GITHUB)) { + return "
" + + "\n" + + "" + + "Detailed description of detected licenses" + + "\n" + + "" + + "\n" + + generateLicenseTableHTML(detectedLicenseInfo, webhookConfig, vcs) + + "\n" + + "
"; + } + return generateLicenseTableMD(detectedLicenseInfo, webhookConfig, vcs); + } + + /** + * Generates an HTML code of the license conflicts table to pull request comments + * + * @param conflicts a list of license conflicts found during the scan + * @param vcs the string representation of the version control system + * @return the code of the generated license conflicts table + */ + private String generateLicenseConflictsTable( + List> conflicts, LPVSVcs vcs) { + if (vcs != null && vcs.equals(LPVSVcs.GITHUB)) { + return "
" + + "\n" + + "" + + "Detailed description of detected license conflicts" + + "\n" + + "" + + "\n" + + generateLicenseConflictsTableHTML(conflicts) + + "\n" + + "
"; + } + return generateLicenseConflictsTableMD(conflicts); + } + + /** + * Generates an MD code of the license table to pull request comments + * + * @param detectedLicenseInfo grouped scan results by license SPDX ID and access type, component name and vendor + * @param webhookConfig configuration related to the repository and webhook + * @param vcs the string representation of the version control system + * @return the MD code of the generated license table + */ + private String generateLicenseTableMD( + Map> detectedLicenseInfo, LPVSQueue webhookConfig, LPVSVcs vcs) { + StringBuilder mdBuilder = new StringBuilder(); + mdBuilder + .append("|License Type / Explanation") + .append("|License SPDX ID") + .append("|Vendor / Component") + .append("|Version") + .append("|Repository File Path") + .append("|Component File Path") + .append("|Matched Lines") + .append("|Match Value|") + .append("\n") + .append("|-|-|-|-|-|-|-|-|") + .append("\n"); + // Prohibited licenses + addBlockOfTableForLicenseTypeMD( + mdBuilder, detectedLicenseInfo, prohibited, webhookConfig, vcs); + // Restricted licenses + addBlockOfTableForLicenseTypeMD( + mdBuilder, detectedLicenseInfo, restricted, webhookConfig, vcs); + // Unreviewed licenses + addBlockOfTableForLicenseTypeMD( + mdBuilder, detectedLicenseInfo, unreviewed, webhookConfig, vcs); + // Permitted licenses + addBlockOfTableForLicenseTypeMD( + mdBuilder, detectedLicenseInfo, permitted, webhookConfig, vcs); + + return mdBuilder.toString(); + } + + /** + * Generates the license conflicts table MD content. + * + * @param conflicts a list of license conflicts + * @return the MD content for the license conflicts table + */ + private String generateLicenseConflictsTableMD( + List> conflicts) { + StringBuilder mdBuilder = new StringBuilder(); + mdBuilder + .append("|Conflict>") + .append("|Explanation|") + .append("\n") + .append("|-|-|") + .append("\n"); + + for (LPVSLicenseService.Conflict conflict : conflicts) { + mdBuilder + .append("|") + .append(conflict.l1) + .append(" and ") + .append(conflict.l2) + .append("|") + .append(getExplanationForLicenseConflict(conflict.l1, conflict.l2)) + .append("|") + .append("\n"); + } + return mdBuilder.toString(); + } + + /** + * Generates an MD code of the license conflicts table to pull request comments + * + * @param mdBuilder the StringBuilder object to which the MD content will be appended + * @param detectedLicenseInfo grouped scan results by license SPDX ID and access type, component name and vendor + * @param webhookConfig configuration related to the repository and webhook + * @param vcs the string representation of the version control system + */ + private void addBlockOfTableForLicenseTypeMD( + StringBuilder mdBuilder, + Map> detectedLicenseInfo, + String type, + LPVSQueue webhookConfig, + LPVSVcs vcs) { + long detectedLicenseCountByType = getDetectedLicenseCountByType(detectedLicenseInfo, type); + if (detectedLicenseCountByType > 0) { + // license spdx id + Map> licenseSpdxIds = + (Map>) detectedLicenseInfo.get(type).elements; + for (String licenseSpdxId : licenseSpdxIds.keySet()) { + // vendor + component + Map> componentAndVendor = + (Map>) licenseSpdxIds.get(licenseSpdxId).elements; + for (String componentInfo : componentAndVendor.keySet()) { + // file info + List fileInfos = + (List) componentAndVendor.get(componentInfo).elements; + for (LPVSFile fileInfo : fileInfos) { + mdBuilder + .append("|") + .append(type) + .append(" / ") + .append(getExplanationForLicenseType(type)) + .append("|") + .append(licenseSpdxId) + .append("|") + .append(componentInfo.split(":::")[0]) + .append(" (") + .append(componentInfo.split(":::")[1]) + .append(")") + .append("|") + .append(fileInfo.getComponentVersion()) + .append("|") + .append(fileInfo.getFilePath()) + .append("|") + .append(fileInfo.getComponentFilePath()) + .append("|") + .append(getMatchedLinesAsLink(webhookConfig, fileInfo, vcs)) + .append("|") + .append(fileInfo.getSnippetMatch()) + .append("|") + .append("\n"); + } + } + } + } + } + /** * Generates the license conflicts table HTML content. * diff --git a/src/main/java/com/lpvs/service/LPVSGitHubService.java b/src/main/java/com/lpvs/service/LPVSGitHubService.java index f5bd5563..6422f590 100644 --- a/src/main/java/com/lpvs/service/LPVSGitHubService.java +++ b/src/main/java/com/lpvs/service/LPVSGitHubService.java @@ -10,11 +10,11 @@ import com.lpvs.entity.LPVSQueue; import com.lpvs.entity.enums.LPVSPullRequestStatus; import com.lpvs.entity.enums.LPVSVcs; +import com.lpvs.entity.report.LPVSReportBuilder; import com.lpvs.repository.LPVSDetectedLicenseRepository; import com.lpvs.repository.LPVSLicenseConflictRepository; import com.lpvs.repository.LPVSLicenseRepository; import com.lpvs.repository.LPVSPullRequestRepository; -import com.lpvs.util.LPVSCommentUtil; import com.lpvs.util.LPVSFileUtil; import com.lpvs.util.LPVSPayloadUtil; import lombok.extern.slf4j.Slf4j; @@ -176,7 +176,7 @@ public void setPendingCheck(LPVSQueue webhookConfig) { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException | IllegalArgumentException e) { log.error("Can't authorize setPendingCheck(): " + e.getMessage()); } @@ -200,7 +200,7 @@ public void setErrorCheck(LPVSQueue webhookConfig) { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException | IllegalArgumentException e) { log.error("Can't authorize setErrorCheck(): " + e.getMessage()); } @@ -243,31 +243,19 @@ public void commentResults( GHCommitState.SUCCESS, null, "Files are not found", - "[License Pre-Validation Service]"); + "[LPVS]"); return; } boolean hasProhibitedOrRestricted = false; boolean hasConflicts = false; - String commitComment = ""; + LPVSReportBuilder reportBuilder = new LPVSReportBuilder(null); + String commitComment = + reportBuilder.generatePullRequestComment( + scanResults, conflicts, webhookConfig, LPVSVcs.GITHUB); - if (scanResults != null && scanResults.size() != 0) { - commitComment = "**Detected licenses:**\n\n\n"; + if (scanResults != null && !scanResults.isEmpty()) { for (LPVSFile file : scanResults) { - commitComment += "**File:** " + file.getFilePath() + "\n"; - commitComment += "**License(s):** " + file.convertLicensesToString(LPVSVcs.GITHUB); - commitComment += - "**Component:** " - + file.getComponentName() - + " (" - + file.getComponentFilePath() - + ")\n"; - commitComment += - "**Matched Lines:** " - + LPVSCommentUtil.getMatchedLinesAsLink( - webhookConfig, file, LPVSVcs.GITHUB) - + "\n"; - commitComment += "**Snippet Match:** " + file.getSnippetMatch() + "\n\n\n\n"; for (LPVSLicense license : file.getLicenses()) { LPVSDetectedLicense detectedIssue = new LPVSDetectedLicense(); detectedIssue.setPullRequest(lpvsPullRequest); @@ -297,13 +285,9 @@ public void commentResults( } } - StringBuilder commitCommentBuilder = new StringBuilder(); - if (conflicts != null && conflicts.size() > 0) { + if (conflicts != null && !conflicts.isEmpty()) { hasConflicts = true; - commitCommentBuilder.append("**Detected license conflicts:**\n\n\n"); - commitCommentBuilder.append("
    "); for (LPVSLicenseService.Conflict conflict : conflicts) { - commitCommentBuilder.append("
  • " + conflict.l1 + " and " + conflict.l2 + "
  • "); LPVSDetectedLicense detectedIssue = new LPVSDetectedLicense(); detectedIssue.setPullRequest(lpvsPullRequest); Long l1 = @@ -330,40 +314,29 @@ public void commentResults( detectedIssue.setIssue(true); lpvsDetectedLicenseRepository.saveAndFlush(detectedIssue); } - commitCommentBuilder.append("
"); } - if (null != webhookConfig.getHubLink()) { - commitCommentBuilder.append( - "\n\n######

Check the validation details at the [link]("); - commitCommentBuilder.append(webhookConfig.getHubLink()); - commitCommentBuilder.append(")

"); - } - commitComment += commitCommentBuilder.toString(); if (hasProhibitedOrRestricted || hasConflicts) { lpvsPullRequest.setStatus(LPVSPullRequestStatus.ISSUES_DETECTED.toString()); pullRequestRepository.save(lpvsPullRequest); pullRequest.comment( - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" - + commitComment); + "**\\[LPVS\\]** Potential license issues detected \n\n" + commitComment); repository.createCommitStatus( webhookConfig.getHeadCommitSHA(), GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } else { lpvsPullRequest.setStatus(LPVSPullRequestStatus.COMPLETED.toString()); pullRequestRepository.save(lpvsPullRequest); - pullRequest.comment( - "**\\[License Pre-Validation Service\\]** No license issue detected \n\n" - + commitComment); + pullRequest.comment("**\\[LPVS\\]** No license issue detected \n\n" + commitComment); repository.createCommitStatus( webhookConfig.getHeadCommitSHA(), GHCommitState.SUCCESS, null, - "No license issue detected", - "[License Pre-Validation Service]"); + "No license issues detected", + "[LPVS]"); } } diff --git a/src/main/resources/templates/report_single_scan.html b/src/main/resources/templates/report_single_scan.html index 64860931..b58e3f3b 100644 --- a/src/main/resources/templates/report_single_scan.html +++ b/src/main/resources/templates/report_single_scan.html @@ -90,7 +90,7 @@

Report - License Pre-Validation Service (

Detected Licenses

- Potential license problem(s) detected: licenseDetected + Potential license issues detected: licenseDetected
  • Prohibited license(s): prohibitedLicenses
  • Restricted license(s): restrictedLicenses
  • diff --git a/src/test/java/com/lpvs/entity/report/LPVSReportBuilderTest.java b/src/test/java/com/lpvs/entity/report/LPVSReportBuilderTest.java index 54c0808c..057154b9 100644 --- a/src/test/java/com/lpvs/entity/report/LPVSReportBuilderTest.java +++ b/src/test/java/com/lpvs/entity/report/LPVSReportBuilderTest.java @@ -8,6 +8,8 @@ import com.lpvs.entity.LPVSFile; import com.lpvs.entity.LPVSLicense; +import com.lpvs.entity.LPVSQueue; +import com.lpvs.entity.enums.LPVSVcs; import com.lpvs.service.LPVSLicenseService; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.BeforeEach; @@ -332,25 +334,63 @@ void testReportCommentBuilder_LicenseDetectedNoConflicts() { List> conflicts = new ArrayList<>(); scanResults.add(createSampleFile("testPath1", "test1", "UNREVIEWED")); + scanResults.add(createSampleFile("testPath1", "test1", "PROHIBITED")); + scanResults.add(createSampleFile("testPath1", "test1", "RESTRICTED")); + scanResults.add(createSampleFile("testPath1", "test1", "PERMITTED")); String comment = reportBuilder.generateCommandLineComment("testPath1", scanResults, conflicts); assertNotNull(comment); + } + @Test + void testReportCommentBuilder_LicenseDetectedConflictsDetected() { + LPVSReportBuilder reportBuilder = new LPVSReportBuilder(null); + List scanResults = new ArrayList<>(); scanResults.add(createSampleFile("testPath1", "test1", "PROHIBITED")); - comment = reportBuilder.generateCommandLineComment("testPath1", scanResults, conflicts); + LPVSLicenseService.Conflict conflict_1 = + new LPVSLicenseService.Conflict<>("MIT", "Apache-2.0"); + List> conflicts = + List.of(conflict_1, conflict_1); + String comment = + reportBuilder.generateCommandLineComment("testPath1", scanResults, conflicts); assertNotNull(comment); + } - scanResults.add(createSampleFile("testPath1", "test1", "RESTRICTED")); - comment = reportBuilder.generateCommandLineComment("testPath1", scanResults, conflicts); + @Test + void testReportCommentBuilder_NoLicenseDetectedNoConflicts() { + LPVSReportBuilder reportBuilder = new LPVSReportBuilder(null); + String comment = reportBuilder.generateCommandLineComment("testPath1", null, null); assertNotNull(comment); + } + + @Test + void testGeneratePullRequestComment_LicenseDetectedNoConflicts() { + LPVSReportBuilder reportBuilder = new LPVSReportBuilder(null); + List scanResults = new ArrayList<>(); + List> conflicts = new ArrayList<>(); + + LPVSQueue webhookConfig = new LPVSQueue(); + webhookConfig.setPullRequestUrl("https://github.com/Samsung/LPVS/pull/1"); + webhookConfig.setRepositoryUrl("https://github.com/Samsung/LPVS"); + scanResults.add(createSampleFile("testPath1", "test1", "UNREVIEWED")); + scanResults.add(createSampleFile("testPath1", "test1", "PROHIBITED")); + scanResults.add(createSampleFile("testPath1", "test1", "RESTRICTED")); scanResults.add(createSampleFile("testPath1", "test1", "PERMITTED")); - comment = reportBuilder.generateCommandLineComment("testPath1", scanResults, conflicts); + + String comment = + reportBuilder.generatePullRequestComment( + scanResults, conflicts, webhookConfig, LPVSVcs.GITHUB); + assertNotNull(comment); + + comment = + reportBuilder.generatePullRequestComment( + scanResults, conflicts, webhookConfig, LPVSVcs.GERRIT); assertNotNull(comment); } @Test - void testReportCommentBuilder_LicenseDetectedConflictsDetected() { + void testGeneratePullRequestComment_LicenseDetectedConflictsDetected() { LPVSReportBuilder reportBuilder = new LPVSReportBuilder(null); List scanResults = new ArrayList<>(); scanResults.add(createSampleFile("testPath1", "test1", "PROHIBITED")); @@ -358,14 +398,28 @@ void testReportCommentBuilder_LicenseDetectedConflictsDetected() { new LPVSLicenseService.Conflict<>("MIT", "Apache-2.0"); List> conflicts = List.of(conflict_1, conflict_1); - String comment = reportBuilder.generateCommandLineComment("testPath1", null, null); + LPVSQueue webhookConfig = new LPVSQueue(); + webhookConfig.setPullRequestUrl("https://github.com/Samsung/LPVS/pull/1"); + webhookConfig.setRepositoryUrl("https://github.com/Samsung/LPVS"); + + String comment = + reportBuilder.generatePullRequestComment( + scanResults, conflicts, webhookConfig, LPVSVcs.GITHUB); + assertNotNull(comment); + + comment = + reportBuilder.generatePullRequestComment( + scanResults, conflicts, webhookConfig, LPVSVcs.GERRIT); assertNotNull(comment); } @Test - void testReportCommentBuilder_NoLicenseDetectedNoConflicts() { + void testGeneratePullRequestComment_NoLicenseDetectedNoConflicts() { LPVSReportBuilder reportBuilder = new LPVSReportBuilder(null); - String comment = reportBuilder.generateCommandLineComment("testPath1", null, null); + String comment = reportBuilder.generatePullRequestComment(null, null, null, LPVSVcs.GITHUB); + assertNotNull(comment); + + comment = reportBuilder.generatePullRequestComment(null, null, null, LPVSVcs.GERRIT); assertNotNull(comment); } } diff --git a/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java b/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java index 8d5854d0..968b23ae 100644 --- a/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java +++ b/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java @@ -1218,7 +1218,7 @@ void setUp() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1264,7 +1264,7 @@ public void testSetPendingCheck__ApiUrlAbsentNormalExecution() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetPendingCheck__ApiUrlAbsentNormalExecution.testSetPendingCheck__ApiUrlAbsentNormalExecution() error " @@ -1326,7 +1326,7 @@ void setUp() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1379,7 +1379,7 @@ public void testSetPendingCheck__ApiUrlPresentNormalExecution() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetPendingCheck__ApiUrlPresentNormalExecution.testSetPendingCheck__ApiUrlPresentNormalExecution() error " @@ -1542,7 +1542,7 @@ void setUp() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1588,7 +1588,7 @@ public void testSetErrorCheck__ApiUrlAbsentNormalExecution() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetErrorCheck__ApiUrlAbsentNormalExecution.testSetErrorCheck__ApiUrlAbsentNormalExecution() error " @@ -1650,7 +1650,7 @@ void setUp() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1703,7 +1703,7 @@ public void testSetErrorCheck__ApiUrlPresentNormalExecution() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetErrorCheck__ApiUrlPresentNormalExecution.testSetErrorCheck__ApiUrlPresentNormalExecution() error " @@ -2086,8 +2086,8 @@ public void testCommentResults__ScanResultsEmpty() throws Exception { commit_sha, GHCommitState.SUCCESS, null, - "No license issue detected", - "[License Pre-Validation Service]"); + "No license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ScanResultsEmpty.testCommentResults__ScanResultsEmpty() error " @@ -2141,13 +2141,7 @@ class TestCommentResults__ProhibitedPresentConflictsPresent { final String absolute_file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String snippet_type_1 = "snippet"; - final String snippet_match_1 = - "/**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n"; + final String snippet_match_1 = "15%"; final String matched_lines_1 = "1-6"; final String component_1 = "LPVS::Services"; final String component_file_path_1 = @@ -2169,23 +2163,28 @@ class TestCommentResults__ProhibitedPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" - + "**Detected licenses:**\n\n\n" - + "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n" - + "**License(s):** \n" - + "- PROHIBITED:\n" - + " : MIT\n" - + "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n" - + "**Matched Lines:** 1-6 \n" - + "**Snippet Match:** /**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n\n\n\n\n" - + "**Detected license conflicts:**\n\n\n" - + "
    • MIT and Apache-1.0
    " - + "\n\n######

    Check the validation details at the [link]()

    "; + "**\\[LPVS\\]** Potential license issues detected \n\n" + + "**Detected Licenses:**\n" + + "\n" + + "Potential license issues detected:\n" + + " - Prohibited license(s): 1\n" + + "\n" + + "
    \n" + + "Detailed description of detected licenses\n" + + "\n" + + "
    License Type / ExplanationLicense SPDX IDVendor / ComponentVersionRepository File PathComponent File PathMatched LinesMatch Value
    PROHIBITED / This license prohibits the use of the licensed code in certain contexts, such as commercial software development.MITnull / LPVS::Servicesnullsrc/main/java/com/lpvs/service/LPVSGitHubService.javasrc/main/java/com/lpvs/service/LPVSGitHubService.java1-6 15%
    \n" + + "
    \n" + + "\n" + + "**Detected License Conflicts:**\n" + + "\n" + + "Potential license conflict(s) detected: 1\n" + + "\n" + + "
    \n" + + "Detailed description of detected license conflicts\n" + + "\n" + + "
    ConflictExplanation
    MIT and Apache-1.0These two licenses are incompatible due to their conflicting terms and conditions. It is recommended to resolve this conflict by choosing either MIT or Apache-1.0 for the affected components.
    \n" + + "
    \n" + + "\n"; @BeforeEach void setUp() { @@ -2296,8 +2295,8 @@ public void testCommentResults__ProhibitedPresentConflictsPresent() throws Excep commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ProhibitedPresentConflictsPresent.testCommentResults__ProhibitedPresentConflictsPresent() error " @@ -2355,8 +2354,8 @@ public void testCommentResults__ProhibitedPresentConflictsPresentLicensePresent( commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ProhibitedPresentConflictsPresent.testCommentResults__ProhibitedPresentConflictsPresentLicensePresent() error " @@ -2416,8 +2415,8 @@ public void testCommentResults__ProhibitedPresentConflictsPresentLicensePresentA commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ProhibitedPresentConflictsPresent.testCommentResults__ProhibitedPresentConflictsPresentLicensePresentAlt() error " @@ -2470,30 +2469,25 @@ class TestCommentResults__EmptyPresentConflictsPresent { // `lpvs_file_1` LPVSFile lpvs_file_1; - final String file_url_1 = - "https://github.com/Samsung/LPVS/tree/main/src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String absolute_file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String snippet_type_1 = "snippet"; - final String snippet_match_1 = - "/**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n"; + final String snippet_match_1 = "30%"; final String matched_lines_1 = "1-6"; final String component_1 = "LPVS::Services"; final String component_file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String component_file_url_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; + final String component_vendor_1 = "vendor1"; + final String component_version_1 = "version_1"; + final String component_url_1 = "http://component/url"; // `lpvs_license_1` LPVSLicense lpvs_license_1; final String license_name_1 = "MIT License"; final String spdx_id_1 = "MIT"; final String spdx_id_2 = "GPL-2.0-only"; - final String access_1 = ""; + final String access_1 = "PERMITTED"; final String alternativeName_1 = ""; final String checklist_url_1 = "https://opensource.org/licenses/MIT"; @@ -2503,23 +2497,27 @@ class TestCommentResults__EmptyPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" - + "**Detected licenses:**\n\n\n" - + "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n" - + "**License(s):** \n" - + "- :\n" - + " : MIT\n" - + "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n" - + "**Matched Lines:** 1-6 \n" - + "**Snippet Match:** /**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n\n\n\n\n" - + "**Detected license conflicts:**\n\n\n" - + "
    • MIT and Apache-1.0
    " - + "\n\n######

    Check the validation details at the [link]()

    "; + "**\\[LPVS\\]** Potential license issues detected \n\n" + + "**Detected Licenses:**\n" + + "\n" + + "No license problems detected.\n" + + "\n" + + "
    \n" + + "Detailed description of detected licenses\n" + + "\n" + + "
    License Type / ExplanationLicense SPDX IDVendor / ComponentVersionRepository File PathComponent File PathMatched LinesMatch Value
    PERMITTED / This license permits free usage, modification, and distribution of the licensed code without any restrictions.MITvendor1 / LPVS::Servicesversion_1src/main/java/com/lpvs/service/LPVSGitHubService.javasrc/main/java/com/lpvs/service/LPVSGitHubService.java1-6 30%
    \n" + + "
    \n" + + "\n" + + "**Detected License Conflicts:**\n" + + "\n" + + "Potential license conflict(s) detected: 1\n" + + "\n" + + "
    \n" + + "Detailed description of detected license conflicts\n" + + "\n" + + "
    ConflictExplanation
    MIT and Apache-1.0These two licenses are incompatible due to their conflicting terms and conditions. It is recommended to resolve this conflict by choosing either MIT or Apache-1.0 for the affected components.
    \n" + + "
    \n" + + "\n"; @BeforeEach void setUp() { @@ -2588,9 +2586,9 @@ void setUp() { component_file_url_1, component_1, null, - null, - null, - null); + component_url_1, + component_version_1, + component_vendor_1); conflict_1 = new LPVSLicenseService.Conflict<>(conflict_1_l1, conflict_1_l2); when(mocked_lpvsLicenseRepository.findFirstBySpdxIdOrderByLicenseIdDesc(anyString())) @@ -2628,8 +2626,8 @@ public void testCommentResults__EmptyPresentConflictsPresent() throws Exception commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresent() error " @@ -2687,8 +2685,8 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresent() commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresent() error " @@ -2748,8 +2746,8 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt() commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt() error " @@ -2807,13 +2805,7 @@ class TestCommentResults__UnreviewedPresentConflictsPresent { final String file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String absolute_file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String snippet_type_1 = "snippet"; - final String snippet_match_1 = - "/**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n"; + final String snippet_match_1 = "50%"; final String matched_lines_1 = "1-6"; final String component_1 = "LPVS::Services"; final String component_file_path_1 = @@ -2836,23 +2828,28 @@ class TestCommentResults__UnreviewedPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" - + "**Detected licenses:**\n\n\n" - + "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n" - + "**License(s):** \n" - + "- UNREVIEWED:\n" - + " : MIT\n" - + "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n" - + "**Matched Lines:** 1-6 \n" - + "**Snippet Match:** /**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n\n\n\n\n" - + "**Detected license conflicts:**\n\n\n" - + "
    • MIT and Apache-1.0
    " - + "\n\n######

    Check the validation details at the [link]()

    "; + "**\\[LPVS\\]** Potential license issues detected \n\n" + + "**Detected Licenses:**\n" + + "\n" + + "Potential license issues detected:\n" + + " - Unreviewed license(s): 1\n" + + "\n" + + "
    \n" + + "Detailed description of detected licenses\n" + + "\n" + + "
    License Type / ExplanationLicense SPDX IDVendor / ComponentVersionRepository File PathComponent File PathMatched LinesMatch Value
    UNREVIEWED / This license has not been reviewed thoroughly and may contain unknown risks or limitations. It is recommended to review these licenses carefully before using the licensed code.MITnull / LPVS::Servicesnullsrc/main/java/com/lpvs/service/LPVSGitHubService.javasrc/main/java/com/lpvs/service/LPVSGitHubService.java1-6 50%
    \n" + + "
    \n" + + "\n" + + "**Detected License Conflicts:**\n" + + "\n" + + "Potential license conflict(s) detected: 1\n" + + "\n" + + "
    \n" + + "Detailed description of detected license conflicts\n" + + "\n" + + "
    ConflictExplanation
    MIT and Apache-1.0These two licenses are incompatible due to their conflicting terms and conditions. It is recommended to resolve this conflict by choosing either MIT or Apache-1.0 for the affected components.
    \n" + + "
    \n" + + "\n"; @BeforeEach void setUp() { @@ -2963,8 +2960,8 @@ public void testCommentResults__RestrictedPresentConflictsPresent() throws Excep commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error " @@ -3022,8 +3019,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent( commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error " @@ -3083,8 +3080,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error " @@ -3142,13 +3139,7 @@ class TestCommentResults__RestrictedPresentConflictsPresent { final String file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String absolute_file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String snippet_type_1 = "snippet"; - final String snippet_match_1 = - "/**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n"; + final String snippet_match_1 = "40%"; final String matched_lines_1 = "1-6"; final String component_1 = "LPVS::Services"; final String component_file_path_1 = @@ -3171,23 +3162,28 @@ class TestCommentResults__RestrictedPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" - + "**Detected licenses:**\n\n\n" - + "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n" - + "**License(s):** \n" - + "- RESTRICTED:\n" - + " : MIT\n" - + "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n" - + "**Matched Lines:** 1-6 \n" - + "**Snippet Match:** /**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n\n\n\n\n" - + "**Detected license conflicts:**\n\n\n" - + "
    • MIT and Apache-1.0
    " - + "\n\n######

    Check the validation details at the [link]()

    "; + "**\\[LPVS\\]** Potential license issues detected \n\n" + + "**Detected Licenses:**\n" + + "\n" + + "Potential license issues detected:\n" + + " - Restricted license(s): 1\n" + + "\n" + + "
    \n" + + "Detailed description of detected licenses\n" + + "\n" + + "
    License Type / ExplanationLicense SPDX IDVendor / ComponentVersionRepository File PathComponent File PathMatched LinesMatch Value
    RESTRICTED / This license required compliance with specific obligations. It is crucial to carefully review and adhere to these obligations before using the licensed code.MITnull / LPVS::Servicesnullsrc/main/java/com/lpvs/service/LPVSGitHubService.javasrc/main/java/com/lpvs/service/LPVSGitHubService.java1-6 40%
    \n" + + "
    \n" + + "\n" + + "**Detected License Conflicts:**\n" + + "\n" + + "Potential license conflict(s) detected: 1\n" + + "\n" + + "
    \n" + + "Detailed description of detected license conflicts\n" + + "\n" + + "
    ConflictExplanation
    MIT and Apache-1.0These two licenses are incompatible due to their conflicting terms and conditions. It is recommended to resolve this conflict by choosing either MIT or Apache-1.0 for the affected components.
    \n" + + "
    \n" + + "\n"; @BeforeEach void setUp() { @@ -3298,8 +3294,8 @@ public void testCommentResults__RestrictedPresentConflictsPresent() throws Excep commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error " @@ -3357,8 +3353,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent( commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error " @@ -3418,8 +3414,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error " @@ -3469,13 +3465,7 @@ class TestCommentResults__ProhibitedAbsentConflictsAbsent { final String file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String absolute_file_path_1 = "src/main/java/com/lpvs/service/LPVSGitHubService.java"; final String snippet_type_1 = "snippet"; - final String snippet_match_1 = - "/**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n"; + final String snippet_match_1 = "10%"; final String matched_lines_1 = "1-6"; final String component_1 = "LPVS::Services"; final String component_file_path_1 = @@ -3491,20 +3481,21 @@ class TestCommentResults__ProhibitedAbsentConflictsAbsent { final String checklist_url_1 = "https://opensource.org/licenses/MIT"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** No license issue detected \n\n" - + "**Detected licenses:**\n\n\n" - + "**File:** src/main/java/com/lpvs/service/LPVSGitHubService.java\n" - + "**License(s):** \n" - + "- PERMITTED:\n" - + " : MIT\n" - + "**Component:** LPVS::Services (src/main/java/com/lpvs/service/LPVSGitHubService.java)\n" - + "**Matched Lines:** 1-6 \n" - + "**Snippet Match:** /**\n" - + " * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved.\n" - + " *\n" - + " * Use of this source code is governed by a MIT license that can be\n" - + " * found in the LICENSE file.\n" - + " */\n\n\n\n\n"; + "**\\[LPVS\\]** No license issue detected \n\n" + + "**Detected Licenses:**\n" + + "\n" + + "No license problems detected.\n" + + "\n" + + "
    \n" + + "Detailed description of detected licenses\n" + + "\n" + + "
    License Type / ExplanationLicense SPDX IDVendor / ComponentVersionRepository File PathComponent File PathMatched LinesMatch Value
    PERMITTED / This license permits free usage, modification, and distribution of the licensed code without any restrictions.MITnull / LPVS::Servicesnullsrc/main/java/com/lpvs/service/LPVSGitHubService.javasrc/main/java/com/lpvs/service/LPVSGitHubService.java1-6 10%
    \n" + + "
    \n" + + "\n" + + "**Detected License Conflicts:**\n" + + "\n" + + "No license conflicts detected.\n" + + "\n"; @BeforeEach void setUp() { @@ -3605,8 +3596,8 @@ public void testCommentResults__ProhibitedAbsentConflictsAbsent() throws Excepti commit_sha, GHCommitState.SUCCESS, null, - "No license issue detected", - "[License Pre-Validation Service]"); + "No license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__ProhibitedAbsentConflictsAbsent.testCommentResults__ProhibitedAbsentConflictsAbsent() error "