rename analyse to analyze
This commit is contained in:
parent
fec01ae1ee
commit
afd0d46d04
@ -20,13 +20,13 @@ clairctl can be used for Docker Hub and self-hosted Registry
|
||||
# Command
|
||||
|
||||
```
|
||||
Analyse your docker image with Clair, directly from your registry.
|
||||
Analyze your docker image with Clair, directly from your registry.
|
||||
|
||||
Usage:
|
||||
clairctl [command]
|
||||
|
||||
Available Commands:
|
||||
analyse Analyse Docker image
|
||||
analyze Analyze Docker image
|
||||
health Get Health of clairctl and underlying services
|
||||
login Log in to a Docker registry
|
||||
logout Log out from a Docker registry
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
"github.com/coreos/clair/api/v1"
|
||||
)
|
||||
|
||||
//Analyse get Analysis os specified layer
|
||||
func Analyse(id string) (v1.LayerEnvelope, error) {
|
||||
//Analyze get Analysis os specified layer
|
||||
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)
|
@ -15,16 +15,16 @@ type ReportConfig struct {
|
||||
}
|
||||
|
||||
//ReportAsHTML report analysis as HTML
|
||||
func ReportAsHTML(analyses ImageAnalysis) (string, error) {
|
||||
func ReportAsHTML(analyzes ImageAnalysis) (string, error) {
|
||||
asset, err := Asset("templates/analysis-template.html")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("accessing template: %v", err)
|
||||
}
|
||||
|
||||
templte := template.Must(template.New("analysis-template").Parse(string(asset)))
|
||||
|
||||
|
||||
var doc bytes.Buffer
|
||||
err = templte.Execute(&doc, analyses)
|
||||
err = templte.Execute(&doc, analyzes)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("rendering HTML report: %v", err)
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -13,7 +13,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const analyseTplt = `
|
||||
const analyzeTplt = `
|
||||
Image: {{.String}}
|
||||
{{.Layers | len}} layers found
|
||||
{{$ia := .}}
|
||||
@ -21,20 +21,20 @@ Image: {{.String}}
|
||||
{{end}}
|
||||
`
|
||||
|
||||
var analyseCmd = &cobra.Command{
|
||||
Use: "analyse IMAGE",
|
||||
Short: "Analyse Docker image",
|
||||
Long: `Analyse a Docker image with Clair, against Ubuntu, Red hat and Debian vulnerabilities databases`,
|
||||
var analyzeCmd = &cobra.Command{
|
||||
Use: "analyze IMAGE",
|
||||
Short: "Analyze Docker image",
|
||||
Long: `Analyze a Docker image with Clair, against Ubuntu, Red hat and Debian vulnerabilities databases`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if len(args) != 1 {
|
||||
fmt.Printf("clairctl: \"analyse\" requires a minimum of 1 argument")
|
||||
fmt.Printf("clairctl: \"analyze\" requires a minimum of 1 argument")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ia := analyse(args[0])
|
||||
ia := analyze(args[0])
|
||||
|
||||
err := template.Must(template.New("analysis").Parse(analyseTplt)).Execute(os.Stdout, ia)
|
||||
err := template.Must(template.New("analysis").Parse(analyzeTplt)).Execute(os.Stdout, ia)
|
||||
if err != nil {
|
||||
fmt.Println(errInternalError)
|
||||
logrus.Fatalf("rendering analysis: %v", err)
|
||||
@ -42,7 +42,7 @@ var analyseCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func analyse(imageName string) clair.ImageAnalysis {
|
||||
func analyze(imageName string) clair.ImageAnalysis {
|
||||
var err error
|
||||
var image docker.Image
|
||||
|
||||
@ -71,12 +71,12 @@ func analyse(imageName string) clair.ImageAnalysis {
|
||||
}
|
||||
}
|
||||
|
||||
return docker.Analyse(image)
|
||||
return docker.Analyze(image)
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(analyseCmd)
|
||||
analyseCmd.Flags().BoolVarP(&docker.IsLocal, "local", "l", false, "Use local images")
|
||||
analyseCmd.Flags().StringP("priority", "p", "Low", "Vulnerabilities priority [Low, Medium, High, Critical]")
|
||||
viper.BindPFlag("clair.priority", analyseCmd.Flags().Lookup("priority"))
|
||||
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"))
|
||||
}
|
@ -23,11 +23,11 @@ var reportCmd = &cobra.Command{
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
analyses := analyse(args[0])
|
||||
imageName := strings.Replace(analyses.ImageName, "/", "-", -1) + "-" + analyses.Tag
|
||||
analyzes := analyze(args[0])
|
||||
imageName := strings.Replace(analyzes.ImageName, "/", "-", -1) + "-" + analyzes.Tag
|
||||
switch clair.Report.Format {
|
||||
case "html":
|
||||
html, err := clair.ReportAsHTML(analyses)
|
||||
html, err := clair.ReportAsHTML(analyzes)
|
||||
if err != nil {
|
||||
fmt.Println(errInternalError)
|
||||
logrus.Fatalf("generating HTML report: %v", err)
|
||||
@ -39,7 +39,7 @@ var reportCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
case "json":
|
||||
json, err := xstrings.ToIndentJSON(analyses)
|
||||
json, err := xstrings.ToIndentJSON(analyzes)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(errInternalError)
|
||||
|
@ -31,7 +31,7 @@ var logLevel string
|
||||
// RootCmd represents the base command when called without any subcommands
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "clairctl",
|
||||
Short: "Analyse your docker image with Clair, directly from your registry or local images.",
|
||||
Short: "Analyze your docker image with Clair, directly from your registry or local images.",
|
||||
Long: ``,
|
||||
// Uncomment the following line if your bare application
|
||||
// has an action associated with it:
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"github.com/coreos/clair/cmd/clairctl/xstrings"
|
||||
)
|
||||
|
||||
//Analyse return Clair Image analysis
|
||||
func Analyse(image Image) clair.ImageAnalysis {
|
||||
//Analyze return Clair Image analysis
|
||||
func Analyze(image Image) clair.ImageAnalysis {
|
||||
c := len(image.FsLayers)
|
||||
res := []v1.LayerEnvelope{}
|
||||
|
||||
@ -16,7 +16,7 @@ func Analyse(image Image) clair.ImageAnalysis {
|
||||
l := image.FsLayers[c-i-1].BlobSum
|
||||
lShort := xstrings.Substr(l, 0, 12)
|
||||
|
||||
if a, err := clair.Analyse(l); err != nil {
|
||||
if a, err := clair.Analyze(l); err != nil {
|
||||
logrus.Infof("analysing layer [%v] %d/%d: %v", lShort, i+1, c, err)
|
||||
} else {
|
||||
logrus.Infof("analysing layer [%v] %d/%d", lShort, i+1, c)
|
||||
|
Loading…
Reference in New Issue
Block a user