Skip to content

Commit

Permalink
add timeout for downloading binary & templates
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Oct 25, 2023
1 parent c58d29f commit 5c6cc18
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/nuclei/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/projectdiscovery/nuclei/v3/pkg/utils/monitor"
errorutil "github.com/projectdiscovery/utils/errors"
fileutil "github.com/projectdiscovery/utils/file"
updateutils "github.com/projectdiscovery/utils/update"
)

var (
Expand Down Expand Up @@ -158,6 +159,10 @@ func main() {
}

func readConfig() *goflags.FlagSet {

// when true updates nuclei binary to latest version
var updateNucleiBinary bool

flagSet := goflags.NewFlagSet()
flagSet.CaseSensitive = true
flagSet.SetDescription(`Nuclei is a fast, template based vulnerability scanner focusing
Expand Down Expand Up @@ -342,7 +347,7 @@ on extensive configurability, massive extensibility and ease of use.`)
)

flagSet.CreateGroup("update", "Update",
flagSet.CallbackVarP(runner.NucleiToolUpdateCallback, "update", "up", "update nuclei engine to the latest released version"),
flagSet.BoolVarP(&updateNucleiBinary, "update", "up", false, "update nuclei engine to the latest released version"),
flagSet.BoolVarP(&options.UpdateTemplates, "update-templates", "ut", false, "update nuclei-templates to latest released version"),
flagSet.StringVarP(&options.NewTemplatesDirectory, "update-template-dir", "ud", "", "custom directory to install / update nuclei-templates"),
flagSet.CallbackVarP(disableUpdatesCallback, "disable-update-check", "duc", "disable automatic nuclei/templates update check"),
Expand Down Expand Up @@ -412,6 +417,14 @@ Additional documentation is available at: https://docs.nuclei.sh/getting-started
installer.HideReleaseNotes = false
}

if options.Timeout > 30 {
// default github binary/template download timeout is 30 sec
updateutils.DownloadUpdateTimeout = time.Duration(options.Timeout) * time.Second
}
if updateNucleiBinary {
runner.NucleiToolUpdateCallback()
}

if options.LeaveDefaultPorts {
http.LeaveDefaultPorts = true
}
Expand Down

0 comments on commit 5c6cc18

Please sign in to comment.