nvd

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package datafeed provides NVD data feed synchronization for nvdsync.

Designed for https://nvd.nist.gov/vuln/data-feeds.

Copyright (c) Facebook, Inc. and its affiliates.

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.

Index

Constants

View Source
const Version = "1.0"

Version of nvdsync/datasync.

Variables

View Source
var SupportedCPE = map[string]CPE{
	"cpe-2.2.xml.gz":  cpe22xmlGz,
	"cpe-2.2.xml.zip": cpe22xmlZip,
	"cpe-2.3.xml.gz":  cpe23xmlGz,
	"cpe-2.3.xml.zip": cpe23xmlZip,
}

SupportedCPE contains all supported CPE data feeds indexed by name.

View Source
var SupportedCVE = map[string]CVE{
	"cve-1.2.xml.gz":   cve12xmlGz,
	"cve-1.2.xml.zip":  cve12xmlZip,
	"cve-2.0.xml.gz":   cve20xmlGz,
	"cve-2.0.xml.zip":  cve20xmlZip,
	"cve-1.0.json.gz":  cve10jsonGz,
	"cve-1.0.json.zip": cve10jsonZip,
	"cve-1.1.json.gz":  cve11jsonGz,
	"cve-1.1.json.zip": cve11jsonZip,
}

SupportedCVE contains all supported CVE feeds indexed by name.

Functions

func SetUserAgent

func SetUserAgent(ua string) error

SetUserAgent sets the value of User-Agent HTTP header for the client

func UserAgent

func UserAgent() string

UserAgent returns the value of User-Agent HTTP header used by the client

Types

type CPE

type CPE int

CPE defines the CPE data feed for synchronization.

func (CPE) Help

func (c CPE) Help() string

Help returns the CPE flag help.

func (*CPE) Set

func (c *CPE) Set(v string) error

Set implements the flag.Value interface.

func (CPE) String

func (c CPE) String() string

String implements the fmt.Stringer interface.

func (CPE) Sync

func (c CPE) Sync(ctx context.Context, src SourceConfig, localdir string) error

Sync synchronizes the CPE feed to a local directory.

type CVE

type CVE int

CVE defines the CVE data feed for synchronization.

func (CVE) Help

func (c CVE) Help() string

Help returns the CVE flag help.

func (*CVE) Set

func (c *CVE) Set(v string) error

Set implements the flag.Value interface.

func (CVE) String

func (c CVE) String() string

String implements the fmt.Stringer interface.

func (CVE) Sync

func (c CVE) Sync(ctx context.Context, src SourceConfig, localdir string) error

Sync synchronizes the CVE feed to a local directory.

type SourceConfig

type SourceConfig struct {
	Scheme      string `envconfig:"NVDSYNC_SCHEME" default:"https"`
	Host        string `envconfig:"NVDSYNC_HOST" default:"nvd.nist.gov"`
	CVEFeedPath string `envconfig:"NVDSYNC_CVE_FEED_PATH" default:"/feeds/{{.Encoding}}/cve/{{.Version}}/"`
	CPEFeedPath string `envconfig:"NVDSYNC_CPE_FEED_PATH" default:"/feeds/xml/cpe/dictionary/"`
}

SourceConfig is the configuration of the NVD data feed source.

func NewSourceConfig

func NewSourceConfig() *SourceConfig

NewSourceConfig creates and initializes a new SourceConfig with values from envconfig.

func (*SourceConfig) AddFlags

func (src *SourceConfig) AddFlags(fs *flag.FlagSet)

AddFlags adds SourceConfig flags to the given FlagSet.

type Sync

type Sync struct {
	Feeds    []Syncer
	Source   *SourceConfig
	LocalDir string
}

Sync provides full synchronization between remote and local data feeds.

func (Sync) Do

func (s Sync) Do(ctx context.Context) error

Do executes the synchronization.

type SyncError

type SyncError []string

SyncError accumulates errors occured during Sync.Do() call.

func (SyncError) Error

func (se SyncError) Error() string

Error implements error interface.

type Syncer

type Syncer interface {
	Sync(ctx context.Context, src SourceConfig, localdir string) error
}

Syncer is an abstract interface for data feed synchronizers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL