resource

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResource

type BaseResource struct {
	// contains filtered or unexported fields
}

BaseResource is a mixin to handle some of the common resource related methods

func (*BaseResource) ID

func (r *BaseResource) ID() string

ID returns a path-safe, unique id for this resource

type ContainerImage added in v0.0.7

type ContainerImage struct {
	// Provide common helper functions
	BaseResource
	// contains filtered or unexported fields
}

ContainerImage provides a pull and hold a container

func NewContainerImage added in v0.0.7

func NewContainerImage(location string, options *ContainerImageOptions) *ContainerImage

NewContainerImage returns a configured ContainerImage resource for the scanner to scan

func (*ContainerImage) Clone added in v0.0.7

func (r *ContainerImage) Clone(path string) error

Clone the resource to the desired clonePath location

func (*ContainerImage) ClonePath added in v0.0.7

func (r *ContainerImage) ClonePath() string

ClonePath returns where this repo has been cloned if cloned else ""

func (*ContainerImage) Contact added in v0.0.7

func (r *ContainerImage) Contact() response.Contact

Contact Attempts to identify author information returing name and email if found The order was selected for most completeness with a preference to maintainer and OCI spec Returns the name and email

func (*ContainerImage) Depth added in v0.0.7

func (r *ContainerImage) Depth() uint16

Depth returns the depth for things that have version control

func (*ContainerImage) EnrichResult added in v0.0.7

func (r *ContainerImage) EnrichResult(result *response.Result) *response.Result

EnrichResult adds contextual information to each result

func (*ContainerImage) Kind added in v0.0.7

func (r *ContainerImage) Kind() string

Kind of resource (always returns ContainerImage here)

func (*ContainerImage) Priority added in v0.0.7

func (r *ContainerImage) Priority() int

Priority returns the scan priority

func (*ContainerImage) ReadFile added in v0.0.7

func (r *ContainerImage) ReadFile(path string) ([]byte, error)

ReadFile provides a way to access values in the resource

func (*ContainerImage) SetCloneTimeout added in v0.0.7

func (r *ContainerImage) SetCloneTimeout(timeout time.Duration)

SetCloneTimeout lets you adjust the timeout before the clone aborts

func (*ContainerImage) SetDepth added in v0.0.7

func (r *ContainerImage) SetDepth(depth uint16)

SetDepth allows you to adjust the depth for the resource

func (*ContainerImage) Since added in v0.0.7

func (r *ContainerImage) Since() string

Since returns the date after which things should be scanned for containers that have history

func (*ContainerImage) String added in v0.0.7

func (r *ContainerImage) String() string

String representation of the resource

func (*ContainerImage) Walk added in v0.0.7

func (r *ContainerImage) Walk(fn WalkFunc) error

Walk traverses the resource like a directory tree

type ContainerImageOptions added in v0.0.7

type ContainerImageOptions struct {
	// A preferred arch, if it exists - defaults to first
	Arch string `json:"arch"`
	// Set the number of layers to download, counting from the top down.
	Depth uint16 `json:"depth"`
	// A list of layer hashes to exclude from clone and scan
	Exclusions []string `json:"exclusions"`
	// The scan priority
	Priority int `json:"priority"`
	// Only scan since this date
	Since string `json:"since"`
}

ContainerImageOptions are options for the ContainerImage resource

type Files

type Files struct {
	// Provide common helper functions
	BaseResource
	// contains filtered or unexported fields
}

Files provides a way to scan file systems

func NewFiles

func NewFiles(path string, options *FilesOptions) *Files

NewFiles returns a configured Files resource for the scanner to scan

func (*Files) Clone

func (r *Files) Clone(path string) error

Clone the resource to the desired local location and store the path

func (*Files) ClonePath

func (r *Files) ClonePath() string

ClonePath returns where this repo has been cloned if cloned else ""

func (*Files) Depth

func (r *Files) Depth() uint16

Depth returns the depth for things that have version control

func (*Files) EnrichResult added in v0.0.7

func (r *Files) EnrichResult(result *response.Result) *response.Result

EnrichResult enriches the result with contextual information

func (*Files) Kind

func (r *Files) Kind() string

Kind of resource (always returns Files here)

func (*Files) Priority added in v0.0.6

func (r *Files) Priority() int

Priority returns the scan priority

func (*Files) ReadFile

func (r *Files) ReadFile(path string) ([]byte, error)

ReadFile provides a way to access values in the JSON data

func (*Files) SetCloneTimeout

func (r *Files) SetCloneTimeout(timeout time.Duration)

SetCloneTimeout lets you adjust the timeout before the clone aborts

func (*Files) SetDepth

func (r *Files) SetDepth(depth uint16)

SetDepth allows you to adjust the depth for the resource

func (*Files) Since

func (r *Files) Since() string

Since returns the date after which things should be scanned for things that have versions

func (*Files) String

func (r *Files) String() string

String representation of the resource

func (*Files) Walk

func (r *Files) Walk(fn WalkFunc) error

Walk traverses the JSON data structure like it's a directory tree

type FilesOptions

type FilesOptions struct {
	// The scan priority
	Priority int `json:"priority"`
}

FilesOptions are options for the Files resource

type GitRepo

type GitRepo struct {
	// Provide common helper functions
	BaseResource
	// contains filtered or unexported fields
}

GitRepo provides a way to interact with a git repo

func NewGitRepo

func NewGitRepo(cloneURL string, options *GitRepoOptions) *GitRepo

NewGitRepo returns a configured git repo resource for the scanner to scan

func (*GitRepo) Clone

func (r *GitRepo) Clone(path string) error

Clone the resource to the desired local location and store the path

func (*GitRepo) ClonePath

func (r *GitRepo) ClonePath() string

ClonePath returns where this repo has been cloned if cloned else ""

func (*GitRepo) Depth

func (r *GitRepo) Depth() uint16

Depth returns the depth for things that have version control

func (*GitRepo) EnrichResult added in v0.0.7

func (r *GitRepo) EnrichResult(result *response.Result) *response.Result

EnrichResult enriches the result with contextual information

func (*GitRepo) GitDirPath

func (r *GitRepo) GitDirPath() string

GitDirPath returns the path to the git dir so that other things don't need to know how the repo was cloned

func (*GitRepo) Kind

func (r *GitRepo) Kind() string

Kind of resource (always returns GitRepo here

func (*GitRepo) Priority added in v0.0.6

func (r *GitRepo) Priority() int

Priority returns the scan priority

func (*GitRepo) ReadFile

func (r *GitRepo) ReadFile(path string) ([]byte, error)

ReadFile provides a way to get files out of the repo

func (*GitRepo) Refs

func (r *GitRepo) Refs() []string

Refs returns the unique OIDs in a repo

func (*GitRepo) RemoteRefExists

func (r *GitRepo) RemoteRefExists(ref string) bool

RemoteRefExists checks the remote repository to see if the ref exists

func (*GitRepo) SetCloneTimeout

func (r *GitRepo) SetCloneTimeout(timeout time.Duration)

SetCloneTimeout lets you adjust the timeout before the clone aborts

func (*GitRepo) SetDepth

func (r *GitRepo) SetDepth(depth uint16)

SetDepth allows you to adjust the depth for the resource

func (*GitRepo) ShallowCommits

func (r *GitRepo) ShallowCommits() []string

ShallowCommits returns a list of shallow commits in a git repo

func (*GitRepo) Since

func (r *GitRepo) Since() string

Since returns the date after which things should be scanned for things that have versions

func (*GitRepo) String

func (r *GitRepo) String() string

String representation of the resource

func (*GitRepo) Walk

func (r *GitRepo) Walk(fn WalkFunc) error

Walk traverses the HEAD of a git repo like it's a directory tree. This exists this way so even a bare repo can be crawled if needed. To crawl different branches, change HEAD.

type GitRepoOptions

type GitRepoOptions struct {
	// Only scan this branch
	Branch string `json:"branch"`
	// Only scan this many commits (reduced if larger than the max scan depth)
	Depth uint16 `json:"depth"`
	// Only scan since this date
	Since string `json:"since"`
	// Work through a proxy for this request
	Proxy string `json:"proxy"`
	// The scan priority
	Priority int `json:"priority"`
}

GitRepoOptions stores options specific to GitRepo scan requests

type JSONData

type JSONData struct {
	// Provide common helper functions
	BaseResource
	// contains filtered or unexported fields
}

JSONData provides a way to interact with a json data as a resource

func NewJSONData

func NewJSONData(raw string, options *JSONDataOptions) *JSONData

NewJSONData returns a configured JSONData resource for the scanner to scan

func (*JSONData) Clone

func (r *JSONData) Clone(path string) error

Clone the resource to the desired local location and store the path

func (*JSONData) ClonePath

func (r *JSONData) ClonePath() string

ClonePath returns where this repo has been cloned if cloned else ""

func (*JSONData) Depth

func (r *JSONData) Depth() uint16

Depth returns the depth for things that have version control

func (*JSONData) EnrichResult added in v0.0.7

func (r *JSONData) EnrichResult(result *response.Result) *response.Result

EnrichResult enriches the result with contextual information

func (*JSONData) Kind

func (r *JSONData) Kind() string

Kind of resource (always returns JSONData here)

func (*JSONData) Priority added in v0.0.6

func (r *JSONData) Priority() int

Priority returns the scan priority

func (*JSONData) ReadFile

func (r *JSONData) ReadFile(path string) ([]byte, error)

ReadFile provides a way to access values in the JSON data

func (*JSONData) SetCloneTimeout

func (r *JSONData) SetCloneTimeout(timeout time.Duration)

SetCloneTimeout lets you adjust the timeout before the clone aborts

func (*JSONData) SetDepth

func (r *JSONData) SetDepth(depth uint16)

SetDepth allows you to adjust the depth for the resource

func (*JSONData) Since

func (r *JSONData) Since() string

Since returns the date after which things should be scanned for things that have versions

func (*JSONData) String

func (r *JSONData) String() string

String representation of the resource

func (*JSONData) Walk

func (r *JSONData) Walk(fn WalkFunc) error

Walk traverses the JSON data structure like it's a directory tree

type JSONDataOptions

type JSONDataOptions struct {
	FetchURLs bool `json:"fetch_urls"`
	// The scan priority
	Priority int `json:"priority"`
}

JSONDataOptions are options for the JSONData resource

type Resource

type Resource interface {
	Clone(path string) error
	ClonePath() string
	Depth() uint16
	EnrichResult(result *response.Result) *response.Result
	ID() string
	Kind() string
	Priority() int
	ReadFile(path string) ([]byte, error)
	SetCloneTimeout(timeout time.Duration)
	SetDepth(depth uint16)
	Since() string
	String() string
	// Walk is the main way to pick through resource data (except for GitRepo)
	Walk(WalkFunc) error
}

Resource provides a standard interface for acting with resources in the scanner

func NewResource

func NewResource(kind, resource string, options json.RawMessage) (Resource, error)

NewResource handles building out the resource from kind, the resource string and the options as a raw json message

type URL

type URL struct {
	// Provide common helper functions
	BaseResource
	// contains filtered or unexported fields
}

URL provides a to pull remote content by a URL

func NewURL

func NewURL(url string, options *URLOptions) *URL

NewURL returns a configured URL resource for the scanner to scan

func (*URL) Clone

func (r *URL) Clone(path string) error

Clone the resource to the desired local location and store the path

func (*URL) ClonePath

func (r *URL) ClonePath() string

ClonePath returns where this repo has been cloned if cloned else ""

func (*URL) Depth

func (r *URL) Depth() uint16

Depth returns the depth for things that have version control

func (*URL) EnrichResult added in v0.0.7

func (r *URL) EnrichResult(result *response.Result) *response.Result

EnrichResult enriches the result with contextual information

func (*URL) Kind

func (r *URL) Kind() string

Kind of resource (always returns URL here)

func (*URL) Priority added in v0.0.6

func (r *URL) Priority() int

Priority returns the scan priority

func (*URL) ReadFile

func (r *URL) ReadFile(path string) ([]byte, error)

ReadFile provides a way to access values in the resource

func (*URL) SetCloneTimeout

func (r *URL) SetCloneTimeout(timeout time.Duration)

SetCloneTimeout lets you adjust the timeout before the clone aborts

func (*URL) SetDepth

func (r *URL) SetDepth(depth uint16)

SetDepth allows you to adjust the depth for the resource

func (*URL) Since

func (r *URL) Since() string

Since returns the date after which things should be scanned for things that have versions

func (*URL) String

func (r *URL) String() string

String representation of the resource

func (*URL) Walk

func (r *URL) Walk(fn WalkFunc) error

Walk traverses the resource like a directory tree

type URLOptions

type URLOptions struct {
	// The scan priority
	Priority int `json:"priority"`
}

URLOptions are options for the URL resource

type WalkFunc

type WalkFunc func(path string, reader io.Reader) error

WalkFunc is the func signature for functions passed into the various resource Walk methods.

Jump to

Keyboard shortcuts

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