Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CPE to cargo dependency metadata #187

Merged
merged 2 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cargo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ConfigMetadata struct {
}

type ConfigMetadataDependency struct {
CPE string `toml:"cpe" json:"cpe,omitempty"`
DeprecationDate *time.Time `toml:"deprecation_date" json:"deprecation_date,omitempty"`
ID string `toml:"id" json:"id,omitempty"`
Name string `toml:"name" json:"name,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions cargo/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func testConfig(t *testing.T, context spec.G, it spec.S) {
PrePackage: "some-pre-package-script.sh",
Dependencies: []cargo.ConfigMetadataDependency{
{
CPE: "some-cpe",
DeprecationDate: &deprecationDate,
ID: "some-dependency",
Name: "Some Dependency",
Expand Down Expand Up @@ -109,6 +110,7 @@ pre-package = "some-pre-package-script.sh"
some-dependency = "1.2.x"

[[metadata.dependencies]]
cpe = "some-cpe"
deprecation_date = "2020-06-01T00:00:00Z"
id = "some-dependency"
name = "Some Dependency"
Expand Down Expand Up @@ -200,6 +202,7 @@ some-dependency = "1.2.x"
key = "value"

[[metadata.dependencies]]
cpe = "some-cpe"
id = "some-dependency"
name = "Some Dependency"
sha256 = "shasum"
Expand Down Expand Up @@ -260,6 +263,7 @@ some-dependency = "1.2.x"
PrePackage: "some-pre-package-script.sh",
Dependencies: []cargo.ConfigMetadataDependency{
{
CPE: "some-cpe",
ID: "some-dependency",
Name: "Some Dependency",
SHA256: "shasum",
Expand Down
1 change: 1 addition & 0 deletions cargo/jam/internal/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func convertToCargoDependency(dependency Dependency, dependencyName string) carg
cargoDependency.DeprecationDate = &deprecationDate
}

cargoDependency.CPE = dependency.CPE
cargoDependency.ID = dependency.ID
cargoDependency.Name = dependencyName
cargoDependency.SHA256 = dependency.SHA256
Expand Down
3 changes: 3 additions & 0 deletions cargo/jam/internal/dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
Expect(err).NotTo(HaveOccurred())
Expect(dependencies).To(Equal([]cargo.ConfigMetadataDependency{
{
CPE: "cpe-notation",
ID: "some-dep",
Version: "1.0.0",
Stacks: []string{"some-stack"},
Expand All @@ -285,6 +286,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
SourceSHA256: "some-source-sha",
},
{
CPE: "cpe-notation",
ID: "some-dep",
Version: "1.1.2",
Stacks: []string{"some-stack-two"},
Expand All @@ -294,6 +296,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
SourceSHA256: "some-source-sha-two",
},
{
CPE: "cpe-notation",
ID: "some-dep",
Version: "1.5.6",
Stacks: []string{"some-stack-three"},
Expand Down
23 changes: 19 additions & 4 deletions cargo/jam/update_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
}
],
"source": "some-source",
"source_sha256": "some-source-sha"
"source_sha256": "some-source-sha",
"cpe": "node-cpe"
},
{
"name": "node",
Expand All @@ -67,7 +68,8 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
}
],
"source": "some-source",
"source_sha256": "some-source-sha"
"source_sha256": "some-source-sha",
"cpe": "node-cpe"
},
{
"name": "node",
Expand All @@ -80,7 +82,8 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
}
],
"source": "some-source",
"source_sha256": "some-source-sha"
"source_sha256": "some-source-sha",
"cpe": "node-cpe"
},
{
"name": "node",
Expand All @@ -93,7 +96,8 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
}
],
"source": "some-source",
"source_sha256": "some-source-sha"
"source_sha256": "some-source-sha",
"cpe": "node-cpe"
}]`)
}

Expand Down Expand Up @@ -122,6 +126,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
include-files = ["buildpack.toml"]

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand All @@ -132,6 +137,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
version = "1.2.3"

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand All @@ -142,6 +148,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
version = "2.1.1"

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand Down Expand Up @@ -200,6 +207,7 @@ api = "0.2"
include-files = ["buildpack.toml"]

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand All @@ -210,6 +218,7 @@ api = "0.2"
version = "1.3.5"

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand All @@ -220,6 +229,7 @@ api = "0.2"
version = "2.1.9"

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand Down Expand Up @@ -258,6 +268,7 @@ api = "0.2"
include-files = ["buildpack.toml"]

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand Down Expand Up @@ -310,6 +321,7 @@ api = "0.2"
include-files = ["buildpack.toml"]

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand Down Expand Up @@ -344,6 +356,7 @@ api = "0.2"
include-files = ["buildpack.toml"]

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand Down Expand Up @@ -396,6 +409,7 @@ api = "0.2"
include-files = ["buildpack.toml"]

[[metadata.dependencies]]
cpe = "node-cpe"
id = "node"
name = "Node Engine"
sha256 = "some-sha"
Expand Down Expand Up @@ -484,6 +498,7 @@ api = "0.2"
include-files = ["buildpack.toml"]

[[metadata.dependencies]]
cpe = "non-existent-cpe"
id = "non-existent"
sha256 = "some-sha"
source = "some-source"
Expand Down