-
Notifications
You must be signed in to change notification settings - Fork 6
/
service.go
70 lines (62 loc) · 2.48 KB
/
service.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
63
64
65
66
67
68
69
70
/*
Copyright 2021 Adevinta
*/
package service
import (
"github.com/go-kit/kit/log"
"github.com/adevinta/vulcan-api/pkg/api"
"github.com/adevinta/vulcan-api/pkg/jwt"
"github.com/adevinta/vulcan-api/pkg/reports"
"github.com/adevinta/vulcan-api/pkg/scanengine"
"github.com/adevinta/vulcan-api/pkg/schedule"
"github.com/adevinta/vulcan-api/pkg/tickets"
"github.com/adevinta/vulcan-api/pkg/vulnerabilitydb"
metrics "github.com/adevinta/vulcan-metrics-client"
)
// AWSAccounts defines the services realted to AWS Accounts required by the
// Vulcan API.
type AWSAccounts interface {
Name(AccountID string) (string, error)
}
// vulcanitoService implements VulcanitoService
type vulcanitoService struct {
jwtConfig jwt.Config
db api.VulcanitoStore
logger log.Logger
programScheduler schedule.ScanScheduler
scanEngineConfig scanengine.Config
reportsConfig reports.Config
vulndbClient vulnerabilitydb.Client
vulcantrackerClient tickets.Client
reportsClient *reports.Client
metricsClient metrics.Client
awsAccounts AWSAccounts
allowedTrackerTeams []string // feature flag.
DNSHostnameValidation bool
}
//go:generate impl -output logging.go -stub templates/logging/impl.tmpl -header templates/logging/header.tmpl "middleware loggingMiddleware" api.VulcanitoService
//go:generate gofmt -w logging.go
// New returns a basic Service with all of the expected middlewares wired in.
func New(logger log.Logger, db api.VulcanitoStore, jwtConfig jwt.Config,
scanEngineConfig scanengine.Config, programScheduler schedule.ScanScheduler, reportsConfig reports.Config,
vulndbClient vulnerabilitydb.Client, vulcantrackerClient tickets.Client, reportsClient *reports.Client,
metricsClient metrics.Client, awsAccounts AWSAccounts, allowedTrackerTeams []string, DNSHostnameValidation bool) api.VulcanitoService {
var svc api.VulcanitoService
{
svc = vulcanitoService{db: db,
jwtConfig: jwtConfig,
logger: logger,
scanEngineConfig: scanEngineConfig,
programScheduler: programScheduler,
reportsConfig: reportsConfig,
vulndbClient: vulndbClient,
vulcantrackerClient: vulcantrackerClient,
reportsClient: reportsClient,
metricsClient: metricsClient,
awsAccounts: awsAccounts,
allowedTrackerTeams: allowedTrackerTeams,
DNSHostnameValidation: DNSHostnameValidation,
}
}
return LoggingMiddleware(logger)(svc)
}