Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jritter committed Jun 9, 2024
2 parents 603f07b + 40f132c commit fb0de8b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ WORKDIR /opt/go
COPY --from=builder /build/scapinoculars .
# Copy the Go templates, but this time from the repository
COPY ./templates ./templates
# Copy CSS, so that the reports are beautiful in offline environments
ADD --chmod=644 https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css ./styles/
# We are using port 2112, also because why not
EXPOSE 2112
# We don't need root privileges, yay!
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const reportsOutputKey = "REPORT_OUTPUT_DIR"

var reportDir = ""
var reportOutputDir = ""
var pwd, _ = os.Getwd()

var reportData *reportdata.ReportData = &reportdata.ReportData{Reports: make(map[string]report.Report), Targets: []string{}, Profiles: []string{}}

Expand All @@ -36,7 +37,6 @@ func renderHandler(w http.ResponseWriter, r *http.Request) {
}

func indexHandler(w http.ResponseWriter, r *http.Request) {
pwd, _ := os.Getwd()
reportIndexTemplate, err := template.ParseFiles(pwd + "/templates/index.tmpl")
if err != nil {
log.Panicf("Could not open template file: %v", err)
Expand Down Expand Up @@ -305,6 +305,10 @@ func main() {
}()

http.HandleFunc("/", indexHandler)

styles := http.FileServer(http.Dir(pwd + "/styles"))
http.Handle("/styles/", http.StripPrefix("/styles/", styles))

reportserver := http.FileServer(http.Dir(reportOutputDir + "/"))
http.Handle("/reports/", http.StripPrefix("/reports/", reportserver))

Expand Down
2 changes: 1 addition & 1 deletion templates/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>OpenSCAP Reports</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<link rel="stylesheet" href="/styles/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
</head>
<body>
<!-- Fixed navbar -->
Expand Down

0 comments on commit fb0de8b

Please sign in to comment.