readers

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Overview

Package readers implements the various supported package manifest reader. It defines an independent contract for implementing and reading packages from one or more package manifest files. For more details, refer TDD

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GithubOrgReaderConfig added in v1.4.0

type GithubOrgReaderConfig struct {
	OrganizationURL string
	IncludeArchived bool
	MaxRepositories int
}

type PackageManifestHandlerFn added in v1.4.0

type PackageManifestHandlerFn func(*models.PackageManifest, PackageReader) error

type PackageManifestReader

type PackageManifestReader interface {
	Name() string
	EnumManifests(func(*models.PackageManifest, PackageReader) error) error
}

Contract for implementing package manifest readers such as lockfile parser, SBOM parser etc. Reader should stop enumeration and return error if handler returns an error

func NewDirectoryReader added in v1.0.0

func NewDirectoryReader(path string,
	exclusions []string) (PackageManifestReader, error)

NewDirectoryReader creates a PackageManifestReader that can scan a directory for package manifests while honoring exclusion rules. This reader will log and ignore parser failure. But it will fail in case the manifest handler returns an error. Exclusion strings are treated as regex patterns and applied on the absolute file path discovered while talking the directory.

func NewGithubOrgReader added in v1.4.0

func NewGithubOrgReader(client *github.Client,
	config *GithubOrgReaderConfig) (PackageManifestReader, error)

NewGithubOrgReader creates a PackageManifestReader which enumerates a Github org, identifying repositories and scanning them using [githubReader]

func NewGithubReader added in v1.3.0

func NewGithubReader(client *github.Client,
	github_urls []string,
	lockfileAs string) (PackageManifestReader, error)

NewGithubReader creates a PackageManifestReader that can be used to read one or more `github_urls` interpreted as `lockfileAs`. When `lockfileAs` is empty the parser auto-detects the format based on file name. This reader fails and returns an error on first error encountered while parsing github_urls

func NewJsonDumpReader added in v1.0.0

func NewJsonDumpReader(path string) (PackageManifestReader, error)

NewJsonDumpReader creates a PackageManifestReader to read JSON dumps from the given directory path. The JSON files in the directory must be generated with `--json-dump-dir` scan option. This reader will fail on first error while scanning and loading JSON manifests from file

func NewLockfileReader added in v1.0.0

func NewLockfileReader(lockfiles []string, lockfileAs string) (PackageManifestReader, error)

NewLockfileReader creates a PackageManifestReader that can be used to read one or more `lockfiles` interpreted as `lockfileAs`. When `lockfileAs` is empty the parser auto-detects the format based on file name. This reader fails and returns an error on first error encountered while parsing lockfiles

func NewPurlReader added in v1.3.0

func NewPurlReader(purl string) (PackageManifestReader, error)

type PackageReader

type PackageReader interface {
	EnumPackages(func(*models.Package) error) error
}

Contract for implementing a package reader. Enumerator should fail and return error if handler fails

func NewManifestModelReader

func NewManifestModelReader(manifest *models.PackageManifest) PackageReader

NewManifestModelReader creates a PackageReader for a manifest model that enforces global exceptions policy to ignore packages based on policy It returns a PackageReader that can be used to enumerate all packages in the given manifest.

Jump to

Keyboard shortcuts

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