-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.go
62 lines (48 loc) · 1.24 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Copyright 2019 Adevinta
*/
package main
import (
"context"
"github.com/sirupsen/logrus"
check "github.com/adevinta/vulcan-check-sdk"
"github.com/adevinta/vulcan-check-sdk/helpers"
checkstate "github.com/adevinta/vulcan-check-sdk/state"
)
var (
checkName = "vulcan-dmarc"
logger = check.NewCheckLog(checkName)
)
func main() {
run := func(ctx context.Context, target, assetType, optJSON string, state checkstate.State) (err error) {
logger.WithFields(logrus.Fields{
"domain": target,
}).Debug("requesting domain")
isReachable, err := helpers.IsReachable(target, assetType, nil)
if err != nil {
logger.Warnf("Can not check asset reachability: %v", err)
}
if !isReachable {
return checkstate.ErrAssetUnreachable
}
// Only test DMARC if the domain have a MX entry on DNS
if !checkMX(target) {
return nil
}
dmarc := DMARC{target: target}
if dmarc.parse(target) {
dmarc.evaluate()
}
if len(dmarc.vulnerabilities) > 0 {
for _, vulnerability := range dmarc.vulnerabilities {
state.AddVulnerabilities(vulnerability)
}
}
logger.WithFields(logrus.Fields{
"dmarc_response": dmarc,
}).Debug("response recieved")
return nil
}
c := check.NewCheckFromHandler(checkName, run)
c.RunAndServe()
}