Initial commit
This commit is contained in:
commit
9a5bbb0e93
23 changed files with 1847 additions and 0 deletions
36
checker/rules_records.go
Normal file
36
checker/rules_records.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package checker
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
)
|
||||
|
||||
// hasRecordsRule reports whether the TLSAs service declares any TLSA record
|
||||
// at all. Without records there is nothing for DANE to validate.
|
||||
type hasRecordsRule struct{}
|
||||
|
||||
func (r *hasRecordsRule) Name() string { return "dane.has_records" }
|
||||
func (r *hasRecordsRule) Description() string {
|
||||
return "Verifies that at least one TLSA record is declared on the service."
|
||||
}
|
||||
|
||||
func (r *hasRecordsRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
|
||||
rc := loadRuleContext(ctx, obs)
|
||||
if rc.err != nil {
|
||||
return []sdk.CheckState{observationErrorState(rc.err)}
|
||||
}
|
||||
if len(rc.data.Targets) == 0 {
|
||||
return []sdk.CheckState{{
|
||||
Status: sdk.StatusUnknown,
|
||||
Code: "dane_no_records",
|
||||
Message: "No TLSA records declared on this service.",
|
||||
}}
|
||||
}
|
||||
return []sdk.CheckState{{
|
||||
Status: sdk.StatusOK,
|
||||
Code: "dane_has_records_ok",
|
||||
Message: "TLSA records are declared for all bound endpoints.",
|
||||
Meta: map[string]any{"endpoints": len(rc.data.Targets)},
|
||||
}}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue