Projects STRLCPY Osmedeus Commits 6d49707f
🤬
  • Update some function to use to the new template engine

  • Loading...
  • j3ssie committed 1 year ago
    6d49707f
    1 parent 13614d59
  • ■ ■ ■ ■ ■ ■
    core/parse.go
    skipped 33 lines
    34 34   variable[k] = v
    35 35   }
    36 36   if tpl, err := pongo2.FromString(format); err == nil {
    37  - 
    38 37   out, ok := tpl.Execute(variable)
    39  - 
    40 38   if ok == nil {
    41 39   return out
    42 40   }
    skipped 281 lines
  • ■ ■ ■ ■ ■ ■
    execution/clean.go
    skipped 1 lines
    2 2   
    3 3  import (
    4 4   "bufio"
    5  - "bytes"
    6 5   "fmt"
     6 + "github.com/flosch/pongo2/v6"
    7 7   "github.com/spf13/cast"
    8  - "html/template"
    9 8   "net/url"
    10 9   "os"
    11 10   "path"
    skipped 404 lines
    416 415   return
    417 416   }
    418 417   
    419  - data := struct {
    420  - Vulnerabilities []Vulnerability
    421  - CurrentDay string
    422  - Version string
    423  - Title string
    424  - Src string
    425  - }{
    426  - Title: "Nuclei Summary Report",
    427  - Vulnerabilities: vulns,
    428  - CurrentDay: utils.GetCurrentDay(),
    429  - Version: libs.VERSION,
    430  - Src: path.Base(src),
    431  - }
    432  - 
    433 418   // read template file
    434 419   tmpl := utils.GetFileContent(templateFile)
    435  - if tmpl == "" {
     420 + if strings.TrimSpace(tmpl) == "" {
    436 421   utils.WarnF("empty template data: %v", templateFile)
    437 422   return
    438 423   }
    439 424   
    440  - t := template.Must(template.New("").Parse(tmpl))
    441  - buf := &bytes.Buffer{}
    442  - err := t.Execute(buf, data)
     425 + variable := make(map[string]interface{})
     426 + variable["Title"] = "Nuclei Summary Report"
     427 + variable["Vulnerabilities"] = vulns
     428 + variable["CurrentDay"] = utils.GetCurrentDay()
     429 + variable["Version"] = libs.VERSION
     430 + variable["Src"] = filepath.Base(src)
     431 + 
     432 + tpl, err := pongo2.FromString(tmpl)
    443 433   if err != nil {
    444 434   utils.WarnF("error render data: %v", err)
    445 435   return
    446 436   }
    447  - result := buf.String()
    448  - 
    449  - utils.DebugF("Writing Nuclei HTML report to: %v", dest)
    450  - utils.WriteToFile(dest, result)
     437 + out, ok := tpl.Execute(variable)
     438 + if ok == nil {
     439 + utils.DebugF("Writing Nuclei HTML report to: %v", dest)
     440 + utils.WriteToFile(dest, out)
     441 + }
    451 442  }
    452 443   
    453 444  // CleanJSONHttpx get to get formatted report
    skipped 82 lines
Please wait...
Page is in error, reload to recover