mod

package
v0.0.0-...-1de9a37 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 10 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// By convention, modules with a major version equal to or above v2
	// have it as suffix in their module path.
	VCSUrlMajorVersionSuffixRegex = regexp.MustCompile(`(/v[\d]+)$`)

	// gopkg.in/user/pkg.v -> github.com/user/pkg
	VCSUrlGoPkgInRegexWithUser = regexp.MustCompile(`^gopkg\.in/([^/]+)/([^.]+)\..*$`)

	// gopkg.in without user segment
	// Example: gopkg.in/pkg.v3 -> github.com/go-pkg/pkg
	VCSUrlGoPkgInRegexWithoutUser = regexp.MustCompile(`^gopkg\.in/([^.]+)\..*$`)
)
View Source
var (
	// execute go mod tidy in normal folder
	GoModNormal = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211224170007-df43bca6b6ff",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211224170007-df43bca6b6ff",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1",
			Name:     "golang.org/x/xerrors",
			Version:  "0.0.0-20200804184101-5ec99f83aff1",
			Indirect: true,
		},
		{
			ID:       "gopkg.in/yaml.v3@v3.0.0-20210107192922-496545a6307b",
			Name:     "gopkg.in/yaml.v3",
			Version:  "3.0.0-20210107192922-496545a6307b",
			Indirect: true,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/go-yaml/yaml",
				},
			},
		},
	}

	// execute go mod tidy in replaced folder
	GoModReplaced = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20220406074731-71021a481237",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20220406074731-71021a481237",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1",
			Name:     "golang.org/x/xerrors",
			Version:  "0.0.0-20200804184101-5ec99f83aff1",
			Indirect: true,
		},
	}

	// execute go mod tidy in replaced folder
	GoModUnreplaced = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211110174639-8257534ffed3",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211110174639-8257534ffed3",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1",
			Name:     "golang.org/x/xerrors",
			Version:  "0.0.0-20200804184101-5ec99f83aff1",
			Indirect: true,
		},
	}

	// execute go mod tidy in replaced-with-version folder
	GoModReplacedWithVersion = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20220406074731-71021a481237",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20220406074731-71021a481237",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1",
			Name:     "golang.org/x/xerrors",
			Version:  "0.0.0-20200804184101-5ec99f83aff1",
			Indirect: true,
		},
	}

	// execute go mod tidy in replaced-with-version-mismatch folder
	GoModReplacedWithVersionMismatch = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211224170007-df43bca6b6ff",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211224170007-df43bca6b6ff",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1",
			Name:     "golang.org/x/xerrors",
			Version:  "0.0.0-20200804184101-5ec99f83aff1",
			Indirect: true,
		},
		{
			ID:       "gopkg.in/yaml.v3@v3.0.0-20210107192922-496545a6307b",
			Name:     "gopkg.in/yaml.v3",
			Version:  "3.0.0-20210107192922-496545a6307b",
			Indirect: true,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/go-yaml/yaml",
				},
			},
		},
	}

	// execute go mod tidy in replaced-with-local-path folder
	GoModReplacedWithLocalPath = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211224170007-df43bca6b6ff",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211224170007-df43bca6b6ff",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "gopkg.in/yaml.v3@v3.0.0-20210107192922-496545a6307b",
			Name:     "gopkg.in/yaml.v3",
			Version:  "3.0.0-20210107192922-496545a6307b",
			Indirect: true,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/go-yaml/yaml",
				},
			},
		},
	}

	// execute go mod tidy in replaced-with-local-path-and-version folder
	GoModReplacedWithLocalPathAndVersion = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211224170007-df43bca6b6ff",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211224170007-df43bca6b6ff",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "gopkg.in/yaml.v3@v3.0.0-20210107192922-496545a6307b",
			Name:     "gopkg.in/yaml.v3",
			Version:  "3.0.0-20210107192922-496545a6307b",
			Indirect: true,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/go-yaml/yaml",
				},
			},
		},
	}

	// execute go mod tidy in replaced-with-local-path-and-version-mismatch folder
	GoModReplacedWithLocalPathAndVersionMismatch = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211224170007-df43bca6b6ff",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211224170007-df43bca6b6ff",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
		{
			ID:       "golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1",
			Name:     "golang.org/x/xerrors",
			Version:  "0.0.0-20200804184101-5ec99f83aff1",
			Indirect: true,
		},
		{
			ID:       "gopkg.in/yaml.v3@v3.0.0-20210107192922-496545a6307b",
			Name:     "gopkg.in/yaml.v3",
			Version:  "3.0.0-20210107192922-496545a6307b",
			Indirect: true,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/go-yaml/yaml",
				},
			},
		},
	}

	// execute go mod tidy in go116 folder
	GoMod116 = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211224170007-df43bca6b6ff",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211224170007-df43bca6b6ff",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
	}

	// execute go mod tidy in no-go-version folder
	GoModNoGoVersion = []types.Library{
		{
			ID:       "github.com/aquasecurity/go-dep-parser@v0.0.0-20211224170007-df43bca6b6ff",
			Name:     "github.com/aquasecurity/go-dep-parser",
			Version:  "0.0.0-20211224170007-df43bca6b6ff",
			Indirect: false,
			ExternalReferences: []types.ExternalRef{
				{
					Type: types.RefVCS,
					URL:  "https://github.com/aquasecurity/go-dep-parser",
				},
			},
		},
	}
)

Functions

func ModuleID

func ModuleID(name, version string) string

ModuleID returns a module ID according the Go way. Format: <module_name>@v<module_version> e.g. github.com/aquasecurity/go-dep-parser@v0.0.0-20230130190635-5e31092b0621

func NewParser

func NewParser(replace bool) types.Parser

Types

type Parser

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

func (*Parser) GetExternalRefs

func (p *Parser) GetExternalRefs(path string) []types.ExternalRef

func (*Parser) Parse

func (p *Parser) Parse(r dio.ReadSeekerAt) ([]types.Library, []types.Dependency, error)

Parse parses a go.mod file

Jump to

Keyboard shortcuts

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