// VulnerabilitiesV3 scans the given repo and tag using the clair v3 API.
180367
func (c *Clair) VulnerabilitiesV3(ctx context.Context, r *registry.Registry, repo, tag string) (VulnerabilityReport, error) {
	report := VulnerabilityReport{
		RegistryURL:     r.Domain,
		Repo:            repo,
		Tag:             tag,
		Date:            time.Now().Local().Format(time.RFC1123),
		VulnsBySeverity: make(map[string][]Vulnerability),
	}

	layers, reportName, err := c.getLayers(ctx, r, repo, tag, false)
	if err != nil {
		return report, fmt.Errorf("getting filtered layers failed: %v", err)
	}

	if len(layers) == 0 {
		fmt.Printf("No need to analyse image %s:%s as there is no non-empty layer", repo, tag)
		return report, nil
	}

	report.Name = reportName

	clairLayers := []*clairpb.PostAncestryRequest_PostLayer{}
	for i := len(layers) - 1; i >= 0; i-- {
		// Form the clair layer.
		l, err := c.NewClairV3Layer(ctx, r, repo, layers[i])
		if err != nil {
			return report, err
		}

		// Append the layer.
		clairLayers = append(clairLayers, l)
	}

	// Post the ancestry.
	if err := c.PostAncestry(ctx, reportName, clairLayers); err != nil {
		return report, fmt.Errorf("posting ancestry failed: %v", err)
	}

	// Get the ancestry.
	vl, err := c.GetAncestry(ctx, reportName)
	if err != nil {
		return report, err
	}

	if vl == nil {
		return report, errors.New("ancestry response was nil")
	}

	// Get the vulns.
	for _, l := range vl.GetLayers() {
		for _, f := range l.GetDetectedFeatures() {
			for _, v := range f.GetVulnerabilities() {
				report.Vulns = append(report.Vulns, Vulnerability{
					Name:          v.Name,
					NamespaceName: v.NamespaceName,
					Description:   v.Description,
					Link:          v.Link,
					Severity:      v.Severity,
					Metadata:      map[string]interface{}{v.Metadata: ""},
					FixedBy:       v.FixedBy,
				})
			}
		}
	}

	vulnsBy := func(sev string, store map[string][]Vulnerability) []Vulnerability {
		items, found := store[sev]
		if !found {
			items = make([]Vulnerability, 0)
			store[sev] = items
		}
		return items
	}

	// Group by severity.
	for _, v := range report.Vulns {
		sevRow := vulnsBy(v.Severity, report.VulnsBySeverity)
		report.VulnsBySeverity[v.Severity] = append(sevRow, v)
	}

	// calculate number of bad vulns
	report.BadVulns = len(report.VulnsBySeverity["High"]) + len(report.VulnsBySeverity["Critical"]) + len(report.VulnsBySeverity["Defcon1"])

	return report, nil
}
1223211
func NewInsecureServingOptions() *genericoptions.DeprecatedInsecureServingOptionsWithLoopback {
	o := genericoptions.DeprecatedInsecureServingOptions{
		BindAddress: net.ParseIP("127.0.0.1"),
		BindPort:    8080,
	}
	return o.WithLoopback()
}
625131
func (c *Connect) IsSecure() (bool, error) {
	var err C.virError
	result := C.virConnectIsSecureWrapper(c.ptr, &err)
	if result == -1 {
		return false, makeError(&err)
	}
	if result == 1 {
		return true, nil
	}
	return false, nil
}
614991
func VersionTagHandler(ctx *tagContext) error {
	ctx.col.IsVersion = true
	ctx.col.Default = "1"
	return nil
}
854087
func (c *Connect) GetCapabilities() (string, error) {
	var err C.virError
	str := C.virConnectGetCapabilitiesWrapper(c.ptr, &err)
	if str == nil {
		return "", makeError(&err)
	}
	capabilities := C.GoString(str)
	C.free(unsafe.Pointer(str))
	return capabilities, nil
}
1094760
func (o *Generator) NewV3(namespace Implementation, names ...interface{}) UUID {
	id := UUID{}
	id.unmarshal(digest(md5.New(), namespace.Bytes(), names...))
	id.setRFC4122Version(VersionThree)
	return id
}
404673
func WithInsecure(insecure bool) Option {
	return func(c *config) {
		c.tracerOptions.Collector.Plaintext = insecure
	}
}
319880
func (r Hardware_SecurityModule750) GetVirtualLicenses() (resp []datatypes.Software_VirtualLicense, err error) {
	err = r.Session.DoRequest("SoftLayer_Hardware_SecurityModule750", "getVirtualLicenses", nil, &r.Options, &resp)
	return
}
378648
func (d *Domain) GetSecurityLabelList() ([]SecurityLabel, error) {
	var clabels *C.virSecurityLabel

	var err C.virError
	ret := C.virDomainGetSecurityLabelListWrapper(d.ptr, (*C.virSecurityLabelPtr)(unsafe.Pointer(&clabels)), &err)
	if ret == -1 {
		return []SecurityLabel{}, makeError(&err)
	}

	labels := make([]SecurityLabel, ret)
	for i := 0; i < int(ret); i++ {
		var clabel *C.virSecurityLabel
		clabel = (*C.virSecurityLabel)(unsafe.Pointer(uintptr(unsafe.Pointer(clabels)) + (unsafe.Sizeof(*clabel) * uintptr(i))))
		labels[i] = SecurityLabel{
			Label:     C.GoString((*C.char)(unsafe.Pointer(&clabel.label))),
			Enforcing: clabel.enforcing == 1,
		}
	}

	return labels, nil
}
683005
func (v *NFSVolume) Snapshot(label, message string, tags []string) (err error) {
	return ErrNotSupported
}
796854
func GetRelease(repoID int64, tagName string) (*Release, error) {
	isExist, err := IsReleaseExist(repoID, tagName)
	if err != nil {
		return nil, err
	} else if !isExist {
		return nil, ErrReleaseNotExist{0, tagName}
	}

	r := &Release{RepoID: repoID, LowerTagName: strings.ToLower(tagName)}
	if _, err = x.Get(r); err != nil {
		return nil, fmt.Errorf("Get: %v", err)
	}

	return r, r.LoadAttributes()
}
710362
func (pk *PublicKeyV3) VerifyKeySignatureV3(signed *PublicKeyV3, sig *SignatureV3) (err error) {
	h, err := keySignatureHash(pk, signed, sig.Hash)
	if err != nil {
		return err
	}
	return pk.VerifySignatureV3(h, sig)
}
390324
func Secure(tls ...*tls.Config) Option {
	return func(o *Options) error {
		o.Secure = true
		// Use of variadic just simplifies testing scenarios. We only take the first one.
		if len(tls) > 1 {
			return ErrMultipleTLSConfigs
		}
		if len(tls) == 1 {
			o.TLSConfig = tls[0]
		}
		return nil
	}
}
558298
func (c *Context) SecureJSON(code int, obj interface{}) {
	c.Render(code, render.SecureJSON{Prefix: c.engine.secureJsonPrefix, Data: obj})
}
868710
func NewV3(ns *UUID, name []byte) (u *UUID, err error) {
	if ns == nil {
		err = errors.New("Invalid namespace UUID")
		return
	}
	u = new(UUID)
	// Set all bits to MD5 hash generated from namespace and name.
	u.setBytesFromHash(md5.New(), ns[:], name)
	u.setVariant(ReservedRFC4122)
	u.setVersion(3)
	return
}
277048
func (engine *Engine) SecureJsonPrefix(prefix string) *Engine {
	engine.secureJsonPrefix = prefix
	return engine
}
849534
func (d *Domain) UndefineFlags(flags DomainUndefineFlagsValues) error {
	var err C.virError
	result := C.virDomainUndefineFlagsWrapper(d.ptr, C.uint(flags), &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}