8000 feat: Introduce new info error, silence some known issues by GermanCoding · Pull Request #131 · letsdebug/letsdebug · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ func main() {
os.Exit(1)
}

if len(probs) == 0 {
errorProbs := []letsdebug.Problem{}
for _, p := range probs {
if p.Severity != letsdebug.SeverityInfo && p.Severity != letsdebug.SeverityDebug {
errorProbs = append(errorProbs, p)
}
}

if len(errorProbs) == 0 {
fmt.Println("All OK!")
return
}
Expand Down
24 changes: 18 additions & 6 deletions generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import (
"encoding/pem"
"encoding/xml"
"errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"golang.org/x/net/idna"
"golang.org/x/text/unicode/norm"
"net"
"os"
"regexp"
"sort"
"strings"
"sync"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"golang.org/x/net/idna"
"golang.org/x/text/unicode/norm"

"github.com/eggsampler/acme/v3"

"fmt"
Expand Down Expand Up @@ -462,7 +463,7 @@ func statusioNotOperational(status string, updated time.Time) Problem {
Explanation: fmt.Sprintf(`The current status as reported by the Let's Encrypt status page is %s as at %v. `+
`Depending on the reported problem, this may affect certificate issuance. For more information, please visit the status page.`, status, updated),
Detail: "https://letsencrypt.status.io/",
Severity: SeverityWarning,
Severity: SeverityInfo,
}
}

Expand Down Expand Up @@ -787,12 +788,20 @@ func (c *acmeStagingChecker) Check(ctx *scanContext, domain string, method Valid

authz, err := c.client.FetchAuthorization(c.account, authzURL)
if err != nil {
unhandledError(err)
if p, stagingBroken := translateAcmeError(domain, err); p.Name != "" {
if stagingBroken {
stagingFailures.With(prometheus.Labels{"method": string(method)}).Inc()
}
probs = append(probs, p)
} else {
unhandledError(err)
}
return
}

chal, ok := authz.ChallengeMap[string(method)]
if !ok {
// TODO: we sometimes run into this if an authorization is reused
unhandledError(fmt.Errorf("Missing challenge method (want %v): %v", method, authz.ChallengeMap))
return
}
Expand Down Expand Up @@ -830,6 +839,9 @@ func translateAcmeError(domain string, err error) (problem Problem, stagingBroke
urn := strings.TrimPrefix(acmeErr.Type, "urn:ietf:params:acme:error:")
switch urn {
case "rejectedIdentifier", "unknownHost", "rateLimited", "caa", "dns", "connection":
if strings.Contains(acmeErr.Detail, "Service busy; retry later") {
return infoProblem("ServiceBusy", "The Let's Encrypt staging service refused our request for a test dry-run. The test outputs may not be accurate. Please retry the test at a later time.", "Let's Encrypt Staging Sever busy."), true
}
// Boulder can send error:dns when _acme-challenge is NXDOMAIN, which is
// equivalent to unauthorized
if strings.Contains(acmeErr.Detail, "NXDOMAIN looking up TXT") {
Expand Down
10 changes: 10 additions & 0 deletions problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Problem struct {
}

const (
SeverityInfo SeverityLevel = "Info" // Represents informational messages which are not necessarily a problem.
SeverityFatal SeverityLevel = "Fatal" // Represents a fatal error which will stop any further checks
SeverityError SeverityLevel = "Error"
SeverityWarning SeverityLevel = "Warning"
Expand Down Expand Up @@ -73,3 +74,12 @@ func debugProblem(name, message, detail string) Problem {
Severity: SeverityDebug,
}
}

func infoProblem(name, message, detail string) Problem {
return Problem{
Name: name,
Explanation: message,
Detail: detail,
Severity: SeverityInfo,
}
}
6 changes: 4 additions & 2 deletions web/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"database/sql/driver"
"embed"
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"log"
"sort"
"strings"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/lib/pq"

"encoding/json"
Expand Down Expand Up @@ -79,6 +80,7 @@ func (probs problems) Less(i, j int) bool {
type resultView struct {
Error string `json:"error,omitempty"`
Problems problems `json:"problems,omitempty"`
IsOk bool `json:"ok"`
}

func (rv *resultView) Scan(src interface{}) error {
Expand Down
11 changes: 9 additions & 2 deletions web/templates/layouts/results.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
color: #eee;
background: rgb(0, 77, 0);
}
.problem-Info, .problem-Info a, .problem-Info a:visited {
background: lightgray;
color: black;
}
.problem-Debug, .problem-Debug a, .problem-Debug a:visited {
background: lightskyblue;
color: black;
Expand Down Expand Up @@ -115,7 +119,8 @@
<p>Unfortunately something went wrong when running the test.</p>
<div class="error">{{ .Test.Result.Error }}</div>
</section>
{{ else if not .Test.Result.Problems }}
{{ else }}
{{ if .Test.Result.IsOk }}
<section class="results">
<div class="problem problem-OK">
<div class="problem-header">
Expand All @@ -130,7 +135,8 @@
</div>
</div>
</section>
{{ else }}
{{ end }}
{{ if gt (len .Test.Result.Problems) 0 }}
<section class="results">
{{ range $index, $problem := .Test.Result.Problems }}
<div class="problem problem-{{ $problem.Severity }}" id="{{ $problem.Name }}-{{ $problem.Severity }}">
Expand All @@ -146,6 +152,7 @@
{{ end }}
</section>
{{ end }}
{{ end }}
<section class="description">
<p class="times">Submitted <abbr title="{{ .Test.CreatedTimestamp }}">{{ .Test.SubmitTime }}</abbr>.
{{ if .Test.QueueDuration }}Sat in queue for {{ .Test.QueueDuration }}.{{ end }}
Expand Down
19 changes: 16 additions & 3 deletions web/work.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package web

import (
"encoding/json"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"log"
"sync/atomic"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/letsdebug/letsdebug"
)

Expand Down Expand Up @@ -56,8 +57,20 @@ func (s *server) work() {
HTTPExpectResponse: req.Options.HTTPExpectResponse,
HTTPRequestPath: req.Options.HTTPRequestPath,
})
isOk := false
if err == nil {
isOk = true
for _, p := range res {
if p.Severity != letsdebug.SeverityInfo && p.Severity != letsdebug.SeverityDebug {
isOk = false
break
}
}
} else {
isOk = false
}
testsRun.With(prometheus.Labels{"method": string(method)}).Inc()
result := resultView{Problems: res}
result := resultView{Problems: res, IsOk: isOk}
if err != nil {
testsFailed.With(prometheus.Labels{"method": string(method)}).Inc()
result.Error = err.Error()
Expand Down
0