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

updated constants #163

Merged
merged 1 commit into from
Oct 3, 2022
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
64 changes: 61 additions & 3 deletions spdx/common/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,66 @@

package common

// *Type is the enumerable of ReferenceType
// Constants for various string types
const (
Cpe23Type string = "cpe23Type"
PurlType string = "purl"
// F.2 Security types
TypeSecurityCPE23Type string = "cpe23Type"
TypeSecurityCPE22Type string = "cpe22Type"
TypeSecurityAdvisory string = "advisory"
TypeSecurityFix string = "fix"
TypeSecurityUrl string = "url"
TypeSecuritySwid string = "swid"

// F.3 Package-Manager types
TypePackageManagerMavenCentral string = "maven-central"
TypePackageManagerNpm string = "npm"
TypePackageManagerNuGet string = "nuget"
TypePackageManagerBower string = "bower"
TypePackageManagerPURL string = "purl"

// 11.1 Relationship field types
TypeRelationshipDescribe string = "DESCRIBES"
TypeRelationshipDescribeBy string = "DESCRIBED_BY"
TypeRelationshipContains string = "CONTAINS"
TypeRelationshipContainedBy string = "CONTAINED_BY"
TypeRelationshipDependsOn string = "DEPENDS_ON"
TypeRelationshipDependencyOf string = "DEPENDENCY_OF"
TypeRelationshipBuildDependencyOf string = "BUILD_DEPENDENCY_OF"
TypeRelationshipDevDependencyOf string = "DEV_DEPENDENCY_OF"
TypeRelationshipOptionalDependencyOf string = "OPTIONAL_DEPENDENCY_OF"
TypeRelationshipProvidedDependencyOf string = "PROVIDED_DEPENDENCY_OF"
TypeRelationshipTestDependencyOf string = "TEST_DEPENDENCY_OF"
TypeRelationshipRuntimeDependencyOf string = "RUNTIME_DEPENDENCY_OF"
TypeRelationshipExampleOf string = "EXAMPLE_OF"
TypeRelationshipGenerates string = "GENERATES"
TypeRelationshipGeneratedFrom string = "GENERATED_FROM"
TypeRelationshipAncestorOf string = "ANCESTOR_OF"
TypeRelationshipDescendantOf string = "DESCENDANT_OF"
TypeRelationshipVariantOf string = "VARIANT_OF"
TypeRelationshipDistributionArtifact string = "DISTRIBUTION_ARTIFACT"
TypeRelationshipPatchFor string = "PATCH_FOR"
TypeRelationshipPatchApplied string = "PATCH_APPLIED"
TypeRelationshipCopyOf string = "COPY_OF"
TypeRelationshipFileAdded string = "FILE_ADDED"
TypeRelationshipFileDeleted string = "FILE_DELETED"
TypeRelationshipFileModified string = "FILE_MODIFIED"
TypeRelationshipExpandedFromArchive string = "EXPANDED_FROM_ARCHIVE"
TypeRelationshipDynamicLink string = "DYNAMIC_LINK"
TypeRelationshipStaticLink string = "STATIC_LINK"
TypeRelationshipDataFileOf string = "DATA_FILE_OF"
TypeRelationshipTestCaseOf string = "TEST_CASE_OF"
TypeRelationshipBuildToolOf string = "BUILD_TOOL_OF"
TypeRelationshipDevToolOf string = "DEV_TOOL_OF"
TypeRelationshipTestOf string = "TEST_OF"
TypeRelationshipTestToolOf string = "TEST_TOOL_OF"
TypeRelationshipDocumentationOf string = "DOCUMENTATION_OF"
TypeRelationshipOptionalComponentOf string = "OPTIONAL_COMPONENT_OF"
TypeRelationshipMetafileOf string = "METAFILE_OF"
TypeRelationshipPackageOf string = "PACKAGE_OF"
TypeRelationshipAmends string = "AMENDS"
TypeRelationshipPrerequisiteFor string = "PREREQUISITE_FOR"
TypeRelationshipHasPrerequisite string = "HAS_PREREQUISITE"
TypeRelationshipRequirementDescriptionFor string = "REQUIREMENT_DESCRIPTION_FOR"
TypeRelationshipSpecificationFor string = "SPECIFICATION_FOR"
TypeRelationshipOther string = "OTHER"
)
6 changes: 3 additions & 3 deletions tvloader/parser2v1/parse_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func TestParser2_1CanParsePackageTags(t *testing.T) {
// Package External References and Comments
ref1 := "SECURITY cpe23Type cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
ref1Category := "SECURITY"
ref1Type := common.Cpe23Type
ref1Type := common.TypeSecurityCPE23Type
ref1Locator := "cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
ref1Comment := "this is comment #1"
ref2 := "OTHER LocationRef-acmeforge acmecorp/acmenator/4.1.3alpha"
Expand Down Expand Up @@ -1025,7 +1025,7 @@ func TestCanCheckAndExtractExcludesFilenameAndCode(t *testing.T) {
func TestCanExtractPackageExternalReference(t *testing.T) {
ref1 := "SECURITY cpe23Type cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
category := "SECURITY"
refType := common.Cpe23Type
refType := common.TypeSecurityCPE23Type
location := "cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"

gotCategory, gotRefType, gotLocation, err := extractPackageExternalReference(ref1)
Expand All @@ -1046,7 +1046,7 @@ func TestCanExtractPackageExternalReference(t *testing.T) {
func TestCanExtractPackageExternalReferenceWithExtraWhitespace(t *testing.T) {
ref1 := " SECURITY \t cpe23Type cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:* \t "
category := "SECURITY"
refType := common.Cpe23Type
refType := common.TypeSecurityCPE23Type
location := "cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"

gotCategory, gotRefType, gotLocation, err := extractPackageExternalReference(ref1)
Expand Down