-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create
osvschema
go bindings package (#292)
This migrates some of the "schema" based types that currently live in `osv-scanner` over to here since they're related to the underlying OSV schema rather than the scanner specifically. Notably to help avoid dependency cycles we now have a dedicated `constants` package whose sole responsibility is to house types and constants for representing enums defined in the schema with no logic whatsoever; this will ensure that this package is always a leaf in the dependency tree, preventing circular dependencies in libraries (which notably we have now in the current `osv-scanner/models` package). This also introduces an `ecosystem` package which houses our concept of an parsed ecosystem as implicitly defined in the spec - that is, a struct made up of an ecosystem name and an optional suffix. Note the underlying `Ecosystem` type actually lives in `constants` which might seem weird at first but 1. prevents cycles as mentioned above, and 2. avoids the weird `ecosystem.Ecosystem` situation. Currently this is being introduced as a port from `osv-scanner` - the fact that there are missing constants will be addressed in a follow-up pull request, along with other changes such as updating the `validation/schema.json` and (hopefully) creating some automation to help keep everything in sync. --------- Signed-off-by: Gareth Jones <[email protected]>
- Loading branch information
Showing
3 changed files
with
102 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/ossf/osv-schema/bindings/go | ||
|
||
go 1.22.7 |
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,78 @@ | ||
package osvschema | ||
|
||
type Ecosystem string | ||
|
||
const ( | ||
EcosystemAlmaLinux Ecosystem = "AlmaLinux" | ||
EcosystemAlpine Ecosystem = "Alpine" | ||
EcosystemAndroid Ecosystem = "Android" | ||
EcosystemBioconductor Ecosystem = "Bioconductor" | ||
EcosystemBitnami Ecosystem = "Bitnami" | ||
EcosystemConanCenter Ecosystem = "ConanCenter" | ||
EcosystemCRAN Ecosystem = "CRAN" | ||
EcosystemCratesIO Ecosystem = "crates.io" | ||
EcosystemDebian Ecosystem = "Debian" | ||
EcosystemGitHubActions Ecosystem = "GitHub Actions" | ||
EcosystemGo Ecosystem = "Go" | ||
EcosystemHex Ecosystem = "Hex" | ||
EcosystemLinux Ecosystem = "Linux" | ||
EcosystemMaven Ecosystem = "Maven" | ||
EcosystemNPM Ecosystem = "npm" | ||
EcosystemNuGet Ecosystem = "NuGet" | ||
EcosystemOSSFuzz Ecosystem = "OSS-Fuzz" | ||
EcosystemPackagist Ecosystem = "Packagist" | ||
EcosystemPhotonOS Ecosystem = "Photon OS" | ||
EcosystemPub Ecosystem = "Pub" | ||
EcosystemPyPI Ecosystem = "PyPI" | ||
EcosystemRedHat Ecosystem = "Red Hat" | ||
EcosystemRockyLinux Ecosystem = "Rocky Linux" | ||
EcosystemRubyGems Ecosystem = "RubyGems" | ||
EcosystemSwiftURL Ecosystem = "SwiftURL" | ||
EcosystemUbuntu Ecosystem = "Ubuntu" | ||
) | ||
|
||
type SeverityType string | ||
|
||
const ( | ||
SeverityCVSSV2 SeverityType = "CVSS_V2" | ||
SeverityCVSSV3 SeverityType = "CVSS_V3" | ||
SeverityCVSSV4 SeverityType = "CVSS_V4" | ||
) | ||
|
||
type RangeType string | ||
|
||
const ( | ||
RangeSemVer RangeType = "SEMVER" | ||
RangeEcosystem RangeType = "ECOSYSTEM" | ||
RangeGit RangeType = "GIT" | ||
) | ||
|
||
type ReferenceType string | ||
|
||
const ( | ||
ReferenceAdvisory ReferenceType = "ADVISORY" | ||
ReferenceArticle ReferenceType = "ARTICLE" | ||
ReferenceDetection ReferenceType = "DETECTION" | ||
ReferenceDiscussion ReferenceType = "DISCUSSION" | ||
ReferenceReport ReferenceType = "REPORT" | ||
ReferenceFix ReferenceType = "FIX" | ||
ReferenceIntroduced ReferenceType = "INTRODUCED" | ||
ReferencePackage ReferenceType = "PACKAGE" | ||
ReferenceEvidence ReferenceType = "EVIDENCE" | ||
ReferenceWeb ReferenceType = "WEB" | ||
) | ||
|
||
type CreditType string | ||
|
||
const ( | ||
CreditFinder CreditType = "FINDER" | ||
CreditReporter CreditType = "REPORTER" | ||
CreditAnalyst CreditType = "ANALYST" | ||
CreditCoordinator CreditType = "COORDINATOR" | ||
CreditRemediationDeveloper CreditType = "REMEDIATION_DEVELOPER" //nolint:gosec | ||
CreditRemediationReviewer CreditType = "REMEDIATION_REVIEWER" //nolint:gosec | ||
CreditRemediationVerifier CreditType = "REMEDIATION_VERIFIER" //nolint:gosec | ||
CreditTool CreditType = "TOOL" | ||
CreditSponsor CreditType = "SPONSOR" | ||
CreditOther CreditType = "OTHER" | ||
) |