Skip to content

Commit

Permalink
render nuclei-templates release (#4082)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar authored Aug 23, 2023
1 parent fd2ae8d commit e146c89
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions v2/cmd/nuclei/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/gologger/levels"
"github.com/projectdiscovery/interactsh/pkg/client"
"github.com/projectdiscovery/nuclei/v2/internal/installer"
"github.com/projectdiscovery/nuclei/v2/internal/runner"
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
Expand Down Expand Up @@ -340,6 +341,11 @@ on extensive configurability, massive extensibility and ease of use.`)

gologger.DefaultLogger.SetTimestamp(options.Timestamp, levels.LevelDebug)

if options.Silent {
// hide release notes if silent mode is enabled
installer.HideReleaseNotes = true
}

if options.LeaveDefaultPorts {
http.LeaveDefaultPorts = true
}
Expand Down
18 changes: 18 additions & 0 deletions v2/internal/installer/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strconv"
"strings"

"github.com/charmbracelet/glamour"
"github.com/olekukonko/tablewriter"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
Expand All @@ -29,6 +30,7 @@ const (
var (
HideProgressBar = true
HideUpdateChangesTable = false
HideReleaseNotes = false
)

// TemplateUpdateResults contains the results of template update
Expand Down Expand Up @@ -105,6 +107,7 @@ func (t *TemplateManager) installTemplatesAt(dir string) error {
if err != nil {
return errorutil.NewWithErr(err).Msgf("failed to install templates at %s", dir)
}

// write templates to disk
if err := t.writeTemplatesToDisk(ghrd, dir); err != nil {
return errorutil.NewWithErr(err).Msgf("failed to write templates to disk at %s", dir)
Expand Down Expand Up @@ -313,6 +316,21 @@ func (t *TemplateManager) writeTemplatesToDisk(ghrd *updateutils.GHReleaseDownlo
return errorutil.NewWithErr(err).Msgf("failed to write nuclei templates index")
}

if !HideReleaseNotes {
output := ghrd.Latest.GetBody()
// adjust colors for both dark / light terminal themes
r, err := glamour.NewTermRenderer(glamour.WithAutoStyle())
if err != nil {
gologger.Error().Msgf("markdown rendering not supported: %v", err)
}
if rendered, err := r.Render(output); err == nil {
output = rendered
} else {
gologger.Error().Msg(err.Error())
}
gologger.Print().Msgf("\n%v\n\n", output)
}

// after installation, create and write checksums to .checksum file
return t.writeChecksumFileInDir(dir)
}
Expand Down

0 comments on commit e146c89

Please sign in to comment.