func discoverFormat()

in pkg/utils/file.go [63:85]


func discoverFormat(c *gabs.Container) types.SourceFormat {
	if c == nil {
		return types.SourceFormatUnknown
	}

	// grype
	d := c.Search("descriptor", "name")
	if d.Exists() && d.Data() != nil && d.Data().(string) == "grype" {
		return types.SourceFormatGrypeJSON
	}

	// trivy
	if c.ExistsP("SchemaVersion") && c.ExistsP("Results") {
		return types.SourceFormatTrivyJSON
	}

	// snyk
	if c.Search("vulnerabilities").Exists() && c.Search("applications").Exists() {
		return types.SourceFormatSnykJSON
	}

	return types.SourceFormatUnknown
}