From 43c501c1dc41da270ad85dc31e664198a8069131 Mon Sep 17 00:00:00 2001 From: Brian Wakenshaw <36340167+BriWak@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:23:30 +0100 Subject: [PATCH] BDOG-3252: Add extra links to leak detection leaks page to show how to resolve leaks --- .../leakdetection/LeakDetectionController.scala | 13 +++++++------ .../leakdetection/LeakDetectionService.scala | 4 ++++ .../view/LeakDetectionLeaksPage.scala.html | 17 +++++++++-------- conf/application.conf | 5 ++++- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionController.scala b/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionController.scala index af4a8ba43..9395d8ef6 100644 --- a/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionController.scala +++ b/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionController.scala @@ -104,12 +104,13 @@ class LeakDetectionController @Inject()( ) .async { implicit request => for - isAuthorised <- auth.authorised(None, Retrieval.hasPredicate(leaksPermission(repository, "READ"))) - report <- leakDetectionService.report(repository, branch) - leaks <- leakDetectionService.reportLeaks(report.id) - warnings <- leakDetectionService.reportWarnings(report.id) - resolutionUrl = leakDetectionService.resolutionUrl - yield Ok(leaksPage(report, report.exclusions, leaks, warnings, resolutionUrl, isAuthorised)) + isAuthorised <- auth.authorised(None, Retrieval.hasPredicate(leaksPermission(repository, "READ"))) + report <- leakDetectionService.report(repository, branch) + leaks <- leakDetectionService.reportLeaks(report.id) + warnings <- leakDetectionService.reportWarnings(report.id) + resolutionUrl = leakDetectionService.resolutionUrl + removeSensitiveInfoUrl = leakDetectionService.removeSensitiveInfoUrl + yield Ok(leaksPage(report, report.exclusions, leaks, warnings, resolutionUrl, removeSensitiveInfoUrl, isAuthorised)) } def reportExemptions(repository: String, branch: String): Action[AnyContent] = diff --git a/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionService.scala b/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionService.scala index 72571f464..ed3752c22 100644 --- a/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionService.scala +++ b/app/uk/gov/hmrc/cataloguefrontend/leakdetection/LeakDetectionService.scala @@ -35,6 +35,10 @@ class LeakDetectionService @Inject() ( def resolutionUrl: String = configuration .get[String]("leakDetection.resolution.url") + + def removeSensitiveInfoUrl: String = + configuration + .get[String]("leakDetection.removeSensitiveInfo.url") def urlIfLeaksFound(repoName: String)(using HeaderCarrier): Future[Option[String]] = repositoriesWithLeaks().map: reposWithLeaks => diff --git a/app/uk/gov/hmrc/cataloguefrontend/leakdetection/view/LeakDetectionLeaksPage.scala.html b/app/uk/gov/hmrc/cataloguefrontend/leakdetection/view/LeakDetectionLeaksPage.scala.html index 250a9b4ee..4627beb74 100644 --- a/app/uk/gov/hmrc/cataloguefrontend/leakdetection/view/LeakDetectionLeaksPage.scala.html +++ b/app/uk/gov/hmrc/cataloguefrontend/leakdetection/view/LeakDetectionLeaksPage.scala.html @@ -19,14 +19,15 @@ @this() -@(report : LeakDetectionReport, - exemptions : Map[String, Int], - unresolvedLeaks : Seq[LeakDetectionLeaksByRule], - warnings : Seq[LeakDetectionWarning], - leakResolutionUrl: String, - isAuthorised : Boolean +@(report : LeakDetectionReport, + exemptions : Map[String, Int], + unresolvedLeaks : Seq[LeakDetectionLeaksByRule], + warnings : Seq[LeakDetectionWarning], + leakResolutionUrl : String, + removeSensitiveInfoUrl: String, + isAuthorised : Boolean )(implicit - request : RequestHeader + request : RequestHeader ) @standard_layout(s"Leak detection report", active = "health") { @@ -96,7 +97,7 @@
Exemptions

Unresolved leaks

@if(isAuthorised) {
- Please click here to find out how to resolve the leaks + Please click here to find out how to resolve the leaks. Further information on how to remove sensitive information from GitHub can be found here.
@LeakDetectionLeaks(unresolvedLeaks, "Violations") } else { diff --git a/conf/application.conf b/conf/application.conf index 96ae3df65..0a9ce0077 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -199,7 +199,10 @@ whats-running-where { max-memory = 32768.0 #The threshold of memory across instances and slots, for which the RGBA alpha value will be at its maximum. Any slotsAndInstancesToMemory values above this will be bounded to this figure. } -leakDetection.resolution.url = "https://confluence.tools.tax.service.gov.uk/x/Qm-pBQ" +leakDetection { + resolution.url = "https://confluence.tools.tax.service.gov.uk/x/Qm-pBQ" + removeSensitiveInfo.url = "https://confluence.tools.tax.service.gov.uk/display/SEC/Remove+sensitive+data+from+a+Git+repository" +} telemetry.templates { metrics = "http://metrics.${env}.local/${service}"