-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: add parlay as tool during enrichments #94
Draft
mcombuechen
wants to merge
1
commit into
main
Choose a base branch
from
82-tool-entry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package utils | ||
|
||
// This value gets set at build time | ||
var version string | ||
|
||
func GetVersion() string { | ||
return version | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* © 2024 Snyk Limited All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package sbom | ||
|
||
import ( | ||
cdx "github.com/CycloneDX/cyclonedx-go" | ||
"github.com/spdx/tools-golang/spdx" | ||
) | ||
|
||
func AddParlayWatermark(doc *SBOMDocument, version string) { | ||
switch bom := doc.BOM.(type) { | ||
case *cdx.BOM: | ||
addCDXTool(bom, "parlay", version) | ||
case *spdx.Document: | ||
addSPDXTool(bom, "parlay", version) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* © 2024 Snyk Limited All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package sbom | ||
|
||
import ( | ||
"testing" | ||
|
||
cdx "github.com/CycloneDX/cyclonedx-go" | ||
"github.com/spdx/tools-golang/spdx" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAddParlayWatermark_CycloneDX(t *testing.T) { | ||
doc, err := DecodeSBOMDocument([]byte(`{ | ||
"bomFormat": "CycloneDX", | ||
"specVersion": "1.6" | ||
}`)) | ||
require.NoError(t, err) | ||
|
||
AddParlayWatermark(doc, "0.0.0") | ||
|
||
bom, ok := doc.BOM.(*cdx.BOM) | ||
require.True(t, ok) | ||
|
||
require.NotNil(t, bom.Metadata.Tools.Components) | ||
require.Len(t, *bom.Metadata.Tools.Components, 1) | ||
tool := (*bom.Metadata.Tools.Components)[0] | ||
assert.Equal(t, "application", string(tool.Type)) | ||
assert.Equal(t, "parlay", tool.Name) | ||
assert.Equal(t, "0.0.0", tool.Version) | ||
assert.Equal(t, "Snyk", tool.Publisher) | ||
} | ||
|
||
func TestAddParlayWatermark_SPDX(t *testing.T) { | ||
doc, err := DecodeSBOMDocument([]byte(`{ | ||
"spdxVersion": "SPDX-2.3", | ||
"SPDXID": "SPDXRef-DOCUMENT" | ||
}`)) | ||
require.NoError(t, err) | ||
|
||
AddParlayWatermark(doc, "0.0.0") | ||
|
||
bom, ok := doc.BOM.(*spdx.Document) | ||
require.True(t, ok) | ||
|
||
assert.Contains(t, bom.CreationInfo.Creators, spdx.Creator{Creator: "parlay", CreatorType: "Tool"}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check if
name
(andversion
for the components) already exists? I assume we don't want to clutter the tools array withparlay
multiple times if the users runs different enrichers sequentially