Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Normation/rudder-plugins
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 917530b5fd8d2ef6a390a90ecd2d524df447439a
Choose a base ref
..
head repository: Normation/rudder-plugins
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6df43c9f28a575796c6cf806811f823cef555c24
Choose a head ref
Showing with 1 addition and 22 deletions.
  1. +1 −22 ...rc/main/scala/com/normation/plugins/openscappolicies/extension/OpenScapNodeDetailsExtension.scala
Original file line number Diff line number Diff line change
@@ -38,10 +38,8 @@
package com.normation.plugins.openscappolicies.extension

import better.files.File
import com.normation.errors.PureResult
import com.normation.plugins.PluginExtensionPoint
import com.normation.plugins.PluginStatus
import com.normation.plugins.openscappolicies.OpenscapPoliciesLoggerPure
import com.normation.plugins.openscappolicies.OpenScapReport
import com.normation.plugins.openscappolicies.services.OpenScapReportReader
import com.normation.plugins.openscappolicies.services.ReportSanitizer
@@ -56,7 +54,6 @@ import net.liftweb.http.SHtml
import net.liftweb.http.js.JsCmds.Run
import net.liftweb.util.CssSel
import net.liftweb.util.Helpers.*
import org.jsoup.Jsoup
import scala.reflect.ClassTag
import scala.xml.NodeSeq
import zio.ZIO
@@ -150,7 +147,7 @@ class OpenScapNodeDetailsExtension(

def frameContent(file: File, report: OpenScapReport): CssSel = {
import report.*
val sanitizedReport = renderReport(file, report.content)
val sanitizedReport = ReportSanitizer.sanitizeHTMLReport(report.content)
val baseName = s"OpenSCAP report for ${hostname} (${nodeId.value})"

"iframe [srcdoc]" #> sanitizedReport &
@@ -167,24 +164,6 @@ class OpenScapNodeDetailsExtension(

}

private def renderReport(file: File, content: String): String = {
PureResult
.attempt(Jsoup.parse(content))
.toIO
.tap(doc => {
OpenscapPoliciesLoggerPure.trace(
s"OpenSCAP report parsed at ${file.pathAsString} : " ++ doc.html().take(1_000)
)
})
.map(ReportSanitizer.sanitizeHTMLReport)
.tapError(err => {
OpenscapPoliciesLoggerPure.warn(
s"OpenSCAP report file ${file.pathAsString} could not be loaded into safe HTML: ${err.fullMsg}"
)
})
.runNow
}

private def downloadReportButton(fileName: String, bytes: Array[Byte], sanitized: Boolean) = {
val base64 = Base64.getEncoder().encodeToString(bytes)
val download = Run(