Skip to content

Commit 1b00c0b

Browse files
committed
plugins/cvelib: new plugin for CVE Services API
The CVE Services API allows CVE Numbering Authorities (CNAs) to reserve, publish, and manage CVE IDs. This plugin sets the environment variables required to use the reference cvelib implementation of the API. See also: https://www.cve.org/AllResources/CveServices https://github.com/RedHatProductSecurity/cvelib https://vulnogram.github.io/cve5/#cvePortal
1 parent d36189b commit 1b00c0b

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

plugins/cvelib/api_key.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package cvelib
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/importer"
6+
"github.com/1Password/shell-plugins/sdk/provision"
7+
"github.com/1Password/shell-plugins/sdk/schema"
8+
"github.com/1Password/shell-plugins/sdk/schema/credname"
9+
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
10+
)
11+
12+
func APIKey() schema.CredentialType {
13+
return schema.CredentialType{
14+
Name: credname.APIKey,
15+
DocsURL: sdk.URL("https://github.com/RedHatProductSecurity/cvelib"),
16+
ManagementURL: sdk.URL("https://vulnogram.github.io/cve5/#cvePortal"),
17+
Fields: []schema.CredentialField{
18+
{
19+
Name: fieldname.User,
20+
MarkdownDescription: "User to authenticate to CVE Services API (CVE user).",
21+
},
22+
{
23+
Name: fieldname.Organization,
24+
MarkdownDescription: "Organization to authenticate to CVE Services API (CNA short name).",
25+
},
26+
{
27+
Name: fieldname.APIKey,
28+
MarkdownDescription: "API Key used to authenticate to CVE Services API (CNA API key).",
29+
Secret: true,
30+
Composition: &schema.ValueComposition{
31+
Length: 36,
32+
Charset: schema.Charset{
33+
Lowercase: true,
34+
Digits: true,
35+
},
36+
},
37+
},
38+
},
39+
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
40+
Importer: importer.TryAll(
41+
importer.TryEnvVarPair(defaultEnvVarMapping),
42+
)}
43+
}
44+
45+
var defaultEnvVarMapping = map[string]sdk.FieldName{
46+
"CVE_USER": fieldname.User,
47+
"CVE_ORG": fieldname.Organization,
48+
"CVE_API_KEY": fieldname.APIKey,
49+
}

plugins/cvelib/cve.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cvelib
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/needsauth"
6+
"github.com/1Password/shell-plugins/sdk/schema"
7+
"github.com/1Password/shell-plugins/sdk/schema/credname"
8+
)
9+
10+
func CVEServicesAPICLI() schema.Executable {
11+
return schema.Executable{
12+
Name: "CVE Services API CLI",
13+
Runs: []string{"cve"},
14+
DocsURL: sdk.URL("https://github.com/RedHatProductSecurity/cvelib"),
15+
NeedsAuth: needsauth.IfAll(
16+
needsauth.NotForHelpOrVersion(),
17+
needsauth.NotWithoutArgs(),
18+
),
19+
Uses: []schema.CredentialUsage{
20+
{
21+
Name: credname.APIKey,
22+
},
23+
},
24+
}
25+
}

plugins/cvelib/plugin.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cvelib
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/schema"
6+
)
7+
8+
func New() schema.Plugin {
9+
return schema.Plugin{
10+
Name: "cvelib",
11+
Platform: schema.PlatformInfo{
12+
Name: "CVE Services",
13+
Homepage: sdk.URL("https://www.cve.org/AllResources/CveServices"),
14+
},
15+
Credentials: []schema.CredentialType{
16+
APIKey(),
17+
},
18+
Executables: []schema.Executable{
19+
CVEServicesAPICLI(),
20+
},
21+
}
22+
}

0 commit comments

Comments
 (0)