replace priority to severity
This commit is contained in:
parent
edd36db8dc
commit
dd970f8b06
@ -49,7 +49,6 @@ clair:
|
||||
port: 6060
|
||||
healthPort: 6061
|
||||
uri: http://clair
|
||||
priority: Low
|
||||
report:
|
||||
path: ./reports
|
||||
format: html
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
func Analyze(id string) (v1.LayerEnvelope, error) {
|
||||
|
||||
lURI := fmt.Sprintf("%v/layers/%v?vulnerabilities", uri, id)
|
||||
// lURI := fmt.Sprintf("%v/layers/%v/vulnerabilities?minimumPriority=%v", uri, id, priority)
|
||||
response, err := http.Get(lURI)
|
||||
if err != nil {
|
||||
return v1.LayerEnvelope{}, fmt.Errorf("analysing layer %v: %v", id, err)
|
||||
|
@ -1,18 +1,17 @@
|
||||
package clair
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/clair/api/v1"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/coreos/clair/cmd/clairctl/xstrings"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var uri string
|
||||
var priority string
|
||||
var healthPort int
|
||||
|
||||
//Report Reporting Config value
|
||||
@ -70,7 +69,7 @@ func (imageAnalysis ImageAnalysis) CountVulnerabilities(l v1.Layer) int {
|
||||
|
||||
// CountAllVulnerabilities Total count of vulnerabilities
|
||||
func (imageAnalysis ImageAnalysis) CountAllVulnerabilities() VulnerabiliesCounts {
|
||||
var result VulnerabiliesCounts;
|
||||
var result VulnerabiliesCounts
|
||||
result.Total = 0
|
||||
result.High = 0
|
||||
result.Medium = 0
|
||||
@ -95,7 +94,7 @@ func (imageAnalysis ImageAnalysis) CountAllVulnerabilities() VulnerabiliesCounts
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return result
|
||||
}
|
||||
|
||||
// Vulnerability : A vulnerability inteface
|
||||
@ -138,7 +137,7 @@ type Feature struct {
|
||||
|
||||
// Status give the healthy / unhealthy statut of a feature
|
||||
func (feature Feature) Status() bool {
|
||||
return len(feature.Vulnerabilities) == 0;
|
||||
return len(feature.Vulnerabilities) == 0
|
||||
}
|
||||
|
||||
// Weight git the weight of a featrure according to its vulnerabilities
|
||||
@ -211,7 +210,7 @@ func (imageAnalysis ImageAnalysis) SortLayers() []Layer {
|
||||
Link: v.Link,
|
||||
}
|
||||
|
||||
vulnerabilities = append(vulnerabilities, nv);
|
||||
vulnerabilities = append(vulnerabilities, nv)
|
||||
}
|
||||
|
||||
sort.Sort(VulnerabilitiesBySeverity(vulnerabilities))
|
||||
@ -222,7 +221,7 @@ func (imageAnalysis ImageAnalysis) SortLayers() []Layer {
|
||||
Vulnerabilities: vulnerabilities,
|
||||
}
|
||||
|
||||
features = append(features, nf);
|
||||
features = append(features, nf)
|
||||
}
|
||||
|
||||
sort.Sort(FeatureByVulnerabilities(features))
|
||||
@ -232,12 +231,12 @@ func (imageAnalysis ImageAnalysis) SortLayers() []Layer {
|
||||
Path: l.Layer.Path,
|
||||
Features: features,
|
||||
}
|
||||
layers = append(layers, nl);
|
||||
layers = append(layers, nl)
|
||||
}
|
||||
|
||||
sort.Sort(LayerByVulnerabilities(layers));
|
||||
sort.Sort(LayerByVulnerabilities(layers))
|
||||
|
||||
return layers;
|
||||
return layers
|
||||
}
|
||||
|
||||
// SortVulnerabilities get all vulnerabilities sorted by Severity
|
||||
@ -261,7 +260,7 @@ func (imageAnalysis ImageAnalysis) SortVulnerabilities() []Vulnerability {
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(VulnerabilitiesBySeverity(vulnerabilities));
|
||||
sort.Sort(VulnerabilitiesBySeverity(vulnerabilities))
|
||||
|
||||
return vulnerabilities
|
||||
}
|
||||
@ -282,7 +281,6 @@ func fmtURI(u string, port int) {
|
||||
//Config configure Clair from configFile
|
||||
func Config() {
|
||||
fmtURI(viper.GetString("clair.uri"), viper.GetInt("clair.port"))
|
||||
priority = viper.GetString("clair.priority")
|
||||
healthPort = viper.GetInt("clair.healthPort")
|
||||
Report.Path = viper.GetString("clair.report.path")
|
||||
Report.Format = viper.GetString("clair.report.format")
|
||||
|
@ -2,7 +2,6 @@ clair:
|
||||
port: 6060
|
||||
healthPort: 6061
|
||||
uri: http://clair
|
||||
priority: Low
|
||||
report:
|
||||
path: ./reports
|
||||
format: html
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"github.com/coreos/clair/cmd/clairctl/config"
|
||||
"github.com/coreos/clair/cmd/clairctl/docker"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const analyzeTplt = `
|
||||
@ -77,6 +76,4 @@ func analyze(imageName string) clair.ImageAnalysis {
|
||||
func init() {
|
||||
RootCmd.AddCommand(analyzeCmd)
|
||||
analyzeCmd.Flags().BoolVarP(&docker.IsLocal, "local", "l", false, "Use local images")
|
||||
analyzeCmd.Flags().StringP("priority", "p", "Low", "Vulnerabilities priority [Low, Medium, High, Critical]")
|
||||
viper.BindPFlag("clair.priority", analyzeCmd.Flags().Lookup("priority"))
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ type reportConfig struct {
|
||||
Path, Format string
|
||||
}
|
||||
type clairConfig struct {
|
||||
URI, Priority string
|
||||
URI string
|
||||
Port, HealthPort int
|
||||
Report reportConfig
|
||||
}
|
||||
@ -81,9 +81,7 @@ func Init(cfgFile string, logLevel string) {
|
||||
if viper.Get("clair.healthPort") == nil {
|
||||
viper.Set("clair.healthPort", "6061")
|
||||
}
|
||||
if viper.Get("clair.priority") == nil {
|
||||
viper.Set("clair.priority", "Low")
|
||||
}
|
||||
|
||||
if viper.Get("clair.report.path") == nil {
|
||||
viper.Set("clair.report.path", "reports")
|
||||
}
|
||||
@ -111,7 +109,6 @@ func values() config {
|
||||
URI: viper.GetString("clair.uri"),
|
||||
Port: viper.GetInt("clair.port"),
|
||||
HealthPort: viper.GetInt("clair.healthPort"),
|
||||
Priority: viper.GetString("clair.priority"),
|
||||
Report: reportConfig{
|
||||
Path: viper.GetString("clair.report.path"),
|
||||
Format: viper.GetString("clair.report.format"),
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
const defaultValues = `
|
||||
clair:
|
||||
uri: http://localhost
|
||||
priority: Low
|
||||
port: 6060
|
||||
healthport: 6061
|
||||
report:
|
||||
@ -31,7 +30,6 @@ clairctl:
|
||||
const customValues = `
|
||||
clair:
|
||||
uri: http://clair
|
||||
priority: High
|
||||
port: 6061
|
||||
healthport: 6062
|
||||
report:
|
||||
|
@ -2,7 +2,6 @@ clair:
|
||||
port: 6060
|
||||
healthPort: 6061
|
||||
uri: http://clair
|
||||
priority: Low
|
||||
report:
|
||||
path: ./reports
|
||||
format: html
|
||||
|
Loading…
Reference in New Issue
Block a user