Skip to content

Commit

Permalink
don't write missing screenshots to index file
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir committed May 26, 2023
1 parent bd4a4b0 commit fae5bab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ func (r *Runner) RunEnumeration() {
indexData := fmt.Sprintf("%s %s (%d %s)\n", resp.StoredResponsePath, resp.URL, resp.StatusCode, http.StatusText(resp.StatusCode))
_, _ = indexFile.WriteString(indexData)
}
if indexScreenshotFile != nil {
if indexScreenshotFile != nil && resp.ScreenshotPath != "" {
indexData := fmt.Sprintf("%s %s (%d %s)\n", resp.ScreenshotPath, resp.URL, resp.StatusCode, http.StatusText(resp.StatusCode))
_, _ = indexScreenshotFile.WriteString(indexData)
}
Expand Down Expand Up @@ -1680,12 +1680,12 @@ retry:
headlessBody string
)
if scanopts.Screenshot {
screenshotPath = fileutilz.AbsPathOrDefault(filepath.Join(screenshotBaseDir, screenshotResponseFile))
var err error
screenshotBytes, headlessBody, err = r.browser.ScreenshotWithBody(fullURL, r.hp.Options.Timeout)
if err != nil {
gologger.Warning().Msgf("Could not take screenshot '%s': %s", fullURL, err)
} else {
screenshotPath = fileutilz.AbsPathOrDefault(filepath.Join(screenshotBaseDir, screenshotResponseFile))
_ = fileutil.CreateFolder(screenshotBaseDir)
err := os.WriteFile(screenshotPath, screenshotBytes, 0644)
if err != nil {
Expand Down

0 comments on commit fae5bab

Please sign in to comment.