Skip to content

Commit

Permalink
feat: Add the origin field to the output format of syftjson (anchore#…
Browse files Browse the repository at this point in the history
…1327)

* moved the relevant fields to the Metadata field

Signed-off-by: Asaf Greenholts <[email protected]>

* added metadata types

Signed-off-by: Asaf Greenholts <[email protected]>

* Added hashes to metadata of packge-lock.json and Pipfile.lock

Signed-off-by: Asaf Greenholts <[email protected]>

* move package metadata types to "pkg" package

Signed-off-by: Alex Goodman <[email protected]>

* re-generate json schema to include new npm, python, and binary metadatas

Signed-off-by: Alex Goodman <[email protected]>

Signed-off-by: Asaf Greenholts <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Co-authored-by: Alex Goodman <[email protected]>
  • Loading branch information
TupleType and wagoodman authored Jan 12, 2023
1 parent 3772ae0 commit 7096d98
Show file tree
Hide file tree
Showing 13 changed files with 595 additions and 314 deletions.
45 changes: 26 additions & 19 deletions schema/json/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,33 @@ can be extended to include specific package metadata struct shapes in the future
// This should represent all possible metadatas represented in the pkg.Package.Metadata field (an interface{}).
// When a new package metadata definition is created it will need to be manually added here. The variable name does
// not matter as long as it is exported.

// TODO: this should be generated from reflection of whats in the pkg package
type artifactMetadataContainer struct {
Apk pkg.ApkMetadata
Alpm pkg.AlpmMetadata
Dpkg pkg.DpkgMetadata
Gem pkg.GemMetadata
Java pkg.JavaMetadata
Npm pkg.NpmPackageJSONMetadata
Python pkg.PythonPackageMetadata
Rpm pkg.RpmMetadata
Cargo pkg.CargoPackageMetadata
Go pkg.GolangMetadata
Php pkg.PhpComposerJSONMetadata
Dart pkg.DartPubMetadata
Dotnet pkg.DotnetDepsMetadata
Portage pkg.PortageMetadata
Conan pkg.ConanMetadata
ConanLock pkg.ConanLockMetadata
KbPackage pkg.KbPackageMetadata
Hackage pkg.HackageMetadata
SwiftCocopods pkg.CocoapodsMetadata
Alpm pkg.AlpmMetadata
Apk pkg.ApkMetadata
Binary pkg.BinaryMetadata
Cocopods pkg.CocoapodsMetadata
Conan pkg.ConanMetadata
ConanLock pkg.ConanLockMetadata
Dart pkg.DartPubMetadata
Dotnet pkg.DotnetDepsMetadata
Dpkg pkg.DpkgMetadata
Gem pkg.GemMetadata
Go pkg.GolangMetadata
Hackage pkg.HackageMetadata
Java pkg.JavaMetadata
KbPackage pkg.KbPackageMetadata
NpmPackage pkg.NpmPackageJSONMetadata
NpmPackageLock pkg.NpmPackageLockJSONMetadata
MixLock pkg.MixLockMetadata
Php pkg.PhpComposerJSONMetadata
Portage pkg.PortageMetadata
PythonPackage pkg.PythonPackageMetadata
PythonPipfilelock pkg.PythonPipfileLockMetadata
Rebar pkg.RebarLockMetadata
Rpm pkg.RpmMetadata
RustCargo pkg.CargoPackageMetadata
}

func main() {
Expand Down
113 changes: 113 additions & 0 deletions schema/json/schema-6.1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@
"files"
]
},
"BinaryMetadata": {
"properties": {
"classifier": {
"type": "string"
},
"realPath": {
"type": "string"
},
"virtualPath": {
"type": "string"
}
},
"type": "object",
"required": [
"classifier",
"realPath",
"virtualPath"
]
},
"CargoPackageMetadata": {
"properties": {
"name": {
Expand Down Expand Up @@ -766,6 +785,29 @@
},
"type": "object"
},
"MixLockMetadata": {
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"pkgHash": {
"type": "string"
},
"pkgHashExt": {
"type": "string"
}
},
"type": "object",
"required": [
"name",
"version",
"pkgHash",
"pkgHashExt"
]
},
"NpmPackageJSONMetadata": {
"properties": {
"name": {
Expand Down Expand Up @@ -814,6 +856,21 @@
"private"
]
},
"NpmPackageLockJSONMetadata": {
"properties": {
"resolved": {
"type": "string"
},
"integrity": {
"type": "string"
}
},
"type": "object",
"required": [
"resolved",
"integrity"
]
},
"Package": {
"properties": {
"id": {
Expand Down Expand Up @@ -869,6 +926,9 @@
{
"$ref": "#/$defs/ApkMetadata"
},
{
"$ref": "#/$defs/BinaryMetadata"
},
{
"$ref": "#/$defs/CargoPackageMetadata"
},
Expand Down Expand Up @@ -905,9 +965,15 @@
{
"$ref": "#/$defs/KbPackageMetadata"
},
{
"$ref": "#/$defs/MixLockMetadata"
},
{
"$ref": "#/$defs/NpmPackageJSONMetadata"
},
{
"$ref": "#/$defs/NpmPackageLockJSONMetadata"
},
{
"$ref": "#/$defs/PhpComposerJSONMetadata"
},
Expand All @@ -917,6 +983,12 @@
{
"$ref": "#/$defs/PythonPackageMetadata"
},
{
"$ref": "#/$defs/PythonPipfileLockMetadata"
},
{
"$ref": "#/$defs/RebarLockMetadata"
},
{
"$ref": "#/$defs/RpmMetadata"
}
Expand Down Expand Up @@ -1291,6 +1363,47 @@
"sitePackagesRootPath"
]
},
"PythonPipfileLockMetadata": {
"properties": {
"hashes": {
"items": {
"type": "string"
},
"type": "array"
},
"index": {
"type": "string"
}
},
"type": "object",
"required": [
"hashes",
"index"
]
},
"RebarLockMetadata": {
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"pkgHash": {
"type": "string"
},
"pkgHashExt": {
"type": "string"
}
},
"type": "object",
"required": [
"name",
"version",
"pkgHash",
"pkgHashExt"
]
},
"Relationship": {
"properties": {
"parent": {
Expand Down
Loading

0 comments on commit 7096d98

Please sign in to comment.