Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mblaschke committed Nov 19, 2019
1 parent 9f4b1d0 commit 9d734bb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ type (
ConfigProjectCommon struct {
Name string `yaml:"name"`
Filter ConfigProjectCommonFilter `yaml:"filter"`
Mark []string `yaml:"mark"`
Mark []string `yaml:"mark"`

Cve ConfigProjectCommonCve `yaml:"cve"`
}

ConfigProjectCommonCve struct {
Vendor string
Vendor string
Product string
}

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ var opts struct {
ScrapeTimeGithub *time.Duration `long:"scrape-time.github" env:"SCRAPE_TIME_GITHUB" description:"Scrape time for Github (time.duration)"`

// github
GithubPersonalAccessToken *string `long:"github.personalaccesstoken" env:"GITHUB_PERSONALACCESSTOKEN" description:"GitHub personal access token"`
GithubScrapeWait time.Duration `long:"github.scrape-wait" env:"GITHUB_SCRAPEWAIT" description:"Wait number between project waits" default:"2s"`
GithubPerPage int `long:"github.perpage" env:"GITHUB_PERPAGE" description:"Number of results fetched from GitHub" default:"50"`
GithubPersonalAccessToken *string `long:"github.personalaccesstoken" env:"GITHUB_PERSONALACCESSTOKEN" description:"GitHub personal access token"`
GithubScrapeWait time.Duration `long:"github.scrape-wait" env:"GITHUB_SCRAPEWAIT" description:"Wait number between project waits" default:"2s"`
GithubPerPage int `long:"github.perpage" env:"GITHUB_PERPAGE" description:"Number of results fetched from GitHub" default:"50"`
}

func main() {
Expand Down
11 changes: 5 additions & 6 deletions metrics_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ type (
MetricsCollectorDocker struct {
CollectorProcessorGeneral

client map[string]*registry.Registry
client map[string]*registry.Registry
cveClient *CveClient

prometheus struct {
release *prometheus.GaugeVec
release *prometheus.GaugeVec
releaseCve *prometheus.GaugeVec
}
}
Expand Down Expand Up @@ -123,7 +123,6 @@ func (m *MetricsCollectorDocker) collectProject(ctx context.Context, callback ch
}
}


if imageTags, err := client.Tags(project.Image); err == nil {

natsort.Sort(imageTags)
Expand Down Expand Up @@ -156,9 +155,9 @@ func (m *MetricsCollectorDocker) collectProject(ctx context.Context, callback ch
}

releaseMetrics.AddTime(prometheus.Labels{
"name": project.Name,
"image": project.Image,
"tag": tag,
"name": project.Name,
"image": project.Image,
"tag": tag,
"marked": boolToString(project.IsReleaseMarked(tag)),
}, createdDate)
}
Expand Down
6 changes: 3 additions & 3 deletions metrics_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ type (
MetricsCollectorGithub struct {
CollectorProcessorGeneral

client *github.Client
client *github.Client
cveClient *CveClient

prometheus struct {
release *prometheus.GaugeVec
release *prometheus.GaugeVec
releaseCve *prometheus.GaugeVec
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func (m *MetricsCollectorGithub) collectProject(ctx context.Context, callback ch
"name": project.Name,
"project": project.Project,
"release": releaseVersion,
"marked": boolToString(project.IsReleaseMarked(releaseVersion)),
"marked": boolToString(project.IsReleaseMarked(releaseVersion)),
}, release.GetCreatedAt().Time)

if cveReport != nil {
Expand Down
36 changes: 18 additions & 18 deletions service-cve.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (

type (
CveClient struct {
restClient *resty.Client
restClient *resty.Client
}

CveResponse struct {
response *resty.Response

conf ConfigProjectCommonCve

report *CveResponseReport
report *CveResponseReport
vulneratbilityVersions map[string][]CveResponseReportResultShort
}

Expand All @@ -27,47 +27,47 @@ type (
}

CveResponseReportResultShort struct {
Id string
Id string
Cvss float64
}

CveResponseReportResult struct {
Id string

Modified string
Modified string
Published string

Assigner string
Cvss float64
CvssTime string `json:"cvss-time"`
Assigner string
Cvss float64
CvssTime string `json:"cvss-time"`
CvssVector string `json:"cvss-vector"`
Cwe string
Cwe string

Access struct {
Authentication string
Complexity string
Vector string
Complexity string
Vector string
}

Impact struct {
Availability string
Availability string
Confidentiality string
Integrity string
Integrity string
}

References []string
Summary string
Summary string

VulnerableConfiguration []string `json:"vulnerable_configuration"`
VulnerableConfiguration []string `json:"vulnerable_configuration"`
VulnerableConfigurationCpe2_2 []string `json:"vulnerable_configuration_cpe_2_2"`
VulnerableProduct []string `json:"vulnerable_product"`
VulnerableProduct []string `json:"vulnerable_product"`
}
)

func NewCveClient() *CveClient {
c := &CveClient{}
c.restClient = resty.New()
c.restClient.SetHeader("User-Agent", "apprelease-exporter/" + Version)
c.restClient.SetHeader("User-Agent", "apprelease-exporter/"+Version)
c.restClient.SetHostURL("https://cve.circl.lu/")
c.restClient.SetHeader("Accept", "application/json")

Expand Down Expand Up @@ -95,7 +95,7 @@ func (c *CveClient) GetCveReport(conf ConfigProjectCommonCve) (*CveResponse, err
return r, nil
}

func (c *CveResponse) parseResponse(resp *resty.Response) (error) {
func (c *CveResponse) parseResponse(resp *resty.Response) error {
confVendor := strings.ToLower(c.conf.Vendor)
confProduct := strings.ToLower(c.conf.Product)

Expand All @@ -117,7 +117,7 @@ func (c *CveResponse) parseResponse(resp *resty.Response) (error) {

if lineVendor == confVendor && lineProduct == confProduct {
shortReport := CveResponseReportResultShort{
Id: report.Id,
Id: report.Id,
Cvss: report.Cvss,
}

Expand Down

0 comments on commit 9d734bb

Please sign in to comment.