Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Add Chromium version detection and print warning when old version is …
Browse files Browse the repository at this point in the history
…used with known problems
  • Loading branch information
michenriksen committed Nov 23, 2018
1 parent 5e8dd36 commit 6d5b1d4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions agents/url_screenshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"os"
"os/exec"
"regexp"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -73,6 +75,23 @@ func (a *URLScreenshotter) locateChrome() {

if strings.Contains(strings.ToLower(a.chromePath), "chrome") {
a.session.Out.Warn("Using unreliable Google Chrome for screenshots. Install Chromium for better results.\n\n")
} else {
out, err := exec.Command(a.chromePath, "--version").Output()
if err != nil {
a.session.Out.Warn("An error occurred while trying to determine version of Chromium.\n\n")
return
}
version := string(out)
re := regexp.MustCompile(`(\d+)\.`)
match := re.FindStringSubmatch(version)
if len(match) <= 0 {
a.session.Out.Warn("Unable to determine version of Chromium. Screenshotting might be unreliable.\n\n")
return
}
majorVersion, _ := strconv.Atoi(match[1])
if majorVersion < 72 {
a.session.Out.Warn("An older version of Chromium is installed. Screenshotting of HTTPS URLs might be unreliable.\n\n")
}
}

a.session.Out.Debug("[%s] Located Chrome/Chromium binary at %s\n", a.ID(), a.chromePath)
Expand Down

0 comments on commit 6d5b1d4

Please sign in to comment.