mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 23:46:35 +01:00
Parse donet dependency trees (#2143)
* add dependency information for .NET pkgs Signed-off-by: Benji Visser <benji@093b.org> * update pkg coverage directory test Signed-off-by: Benji Visser <benji@093b.org> * reverse dependsOn relationship Signed-off-by: Benji Visser <benji@093b.org> * update root pkg parsing Signed-off-by: Benji Visser <benji@093b.org> * add comments about the test relationships represented Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add docs around relationship sorting functions + update test helpers Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Benji Visser <benji@093b.org> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
co-authored by
Alex Goodman
parent
7732cd3b48
commit
fe7a417fb2
@@ -1,6 +1,8 @@
|
||||
package dotnet
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/anchore/packageurl-go"
|
||||
@@ -9,13 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func newDotnetDepsPackage(nameVersion string, lib dotnetDepsLibrary, locations ...file.Location) *pkg.Package {
|
||||
if lib.Type != "package" {
|
||||
return nil
|
||||
}
|
||||
|
||||
fields := strings.Split(nameVersion, "/")
|
||||
name := fields[0]
|
||||
version := fields[1]
|
||||
name, version := extractNameAndVersion(nameVersion)
|
||||
|
||||
m := pkg.DotnetDepsMetadata{
|
||||
Name: name,
|
||||
@@ -41,6 +37,27 @@ func newDotnetDepsPackage(nameVersion string, lib dotnetDepsLibrary, locations .
|
||||
return p
|
||||
}
|
||||
|
||||
func getDepsJSONFilePrefix(p string) string {
|
||||
r := regexp.MustCompile(`([^\/]+)\.deps\.json$`)
|
||||
match := r.FindStringSubmatch(p)
|
||||
if len(match) > 1 {
|
||||
return match[1]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func extractNameAndVersion(nameVersion string) (name, version string) {
|
||||
fields := strings.Split(nameVersion, "/")
|
||||
name = fields[0]
|
||||
version = fields[1]
|
||||
return
|
||||
}
|
||||
|
||||
func createNameAndVersion(name, version string) (nameVersion string) {
|
||||
nameVersion = fmt.Sprintf("%s/%s", name, version)
|
||||
return
|
||||
}
|
||||
|
||||
func packageURL(m pkg.DotnetDepsMetadata) string {
|
||||
var qualifiers packageurl.Qualifiers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user