ghsarepo

package
v0.0.0-...-854d032 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause, CC-BY-4.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2023 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Package ghsarepo provides a client and utilities for reading GitHub security advisories directly from the Git repo https://github.com/github/advisory-database.

This allows us to read GHSAs in OSV format instead of the SecurityAdvisory format output by the GraphQL API.

Index

Constants

View Source
const DirectURLPrefix = "https://raw.githubusercontent.com/github/advisory-database/main/advisories/github-reviewed"
View Source
const URL = "https://github.com/github/advisory-database"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(repo *git.Repository) (*Client, error)

NewClient returns a client that reads from the GHSA database in the given repo, which must follow the structure of https://github.com/github/advisory-database.

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient returns a client to read from the GHSA database. It clones the Git repo at https://github.com/github/advisory-database, which can take around ~20 seconds.

func NewLocalClient

func NewLocalClient(ctx context.Context, path string) (*Client, error)

func (*Client) ByCVE

func (c *Client) ByCVE(cve string) []*genericosv.Entry

ByCVE returns the genericosv.Entry entries for the given CVE, or nil if none exist.

func (*Client) ByGHSA

func (c *Client) ByGHSA(ghsa string) *genericosv.Entry

ByGHSA returns the genericosv.Entry entry for the given GHSA, or nil if none exists.

func (*Client) IDs

func (c *Client) IDs() []string

IDs returns all the GHSA IDs in the GHSA database that affect Go and are not withdrawn.

func (*Client) List

func (c *Client) List() []*genericosv.Entry

List returns all the genericosv.Entry entries in the GHSA database that affect Go and are not withdrawn.

type File

type File struct {
	Path     string
	BlobHash plumbing.Hash
}

func Files

func Files(repo *git.Repository, commit *object.Commit) (files []*File, _ error)

func (*File) ID

func (f *File) ID() string

func (*File) Name

func (f *File) Name() string

func (*File) ReadAll

func (f *File) ReadAll(repo *git.Repository) ([]byte, error)

Jump to

Keyboard shortcuts

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