Documentation
¶
Overview ¶
Package check implements binary analysis similar to bazel's nogo, or the unitchecker package. It exists in order to provide additional facilities for analysis, namely plumbing through the output from dumping the generated binary (to analyze actual produced code).
Index ¶
- func FilterStdPackages(srcPkgs map[string][]string) (map[string][]string, error)
- func FindRoots(srcs []string, srcRootRegex string) ([]string, error)
- func SplitStdPackages(srcs []string, srcRootPrefix string) (map[string][]string, error)
- func TemplateFuncs(path string, srcs []string) (map[string]any, any, error)
- func WriteFindingsTo(w io.Writer, findings FindingSet, asJSON bool) error
- type Finding
- type FindingSet
- func Bundle(sources map[string][]string, roots []string) (FindingSet, facts.Serializer, error)
- func ExtractFindingsFrom(r io.Reader, asJSON bool) (findings FindingSet, err error)
- func ExtractFindingsFromFile(filename string, asJSON bool) (FindingSet, error)
- func Package(path string, srcs []string) (FindingSet, facts.Serializer, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterStdPackages ¶
FilterStdPackages returns a package source map including only packages that are also present in GOROOT.
The bazel GOROOT contains only exported packages and their dependencies.
On the other hand, srcPkgs comes from rudimentary processing of the full std sources and thus includes things like test only and experimental packages. These packages will fail to analyze without an archive in GOROOT, but we won't need those anyway, so filter them out.
func SplitStdPackages ¶
SplitStdPackages splits a std GOROOT package structure into packages.
func TemplateFuncs ¶
TemplateFuncs runs all analyzers necessary for template generation, and returns a funcmap for template rendering.
Look at facts.ResolveFuncs for a list of supported functions.
func WriteFindingsTo ¶
func WriteFindingsTo(w io.Writer, findings FindingSet, asJSON bool) error
WriteFindingsTo serializes findings.
Types ¶
type Finding ¶
type Finding struct {
Category string
Position token.Position
Message string
GOARCH string
GOOS string
}
Finding is a single finding.
type FindingSet ¶
type FindingSet []Finding
FindingSet is a collection of findings.
func Bundle ¶
func Bundle(sources map[string][]string, roots []string) (FindingSet, facts.Serializer, error)
Bundle checks a bundle of files (typically the standard library).
roots is the set of potential GOROOT prefixes on the file paths in sources. GOROOT is effectively a merged version of these roots.
func ExtractFindingsFrom ¶
func ExtractFindingsFrom(r io.Reader, asJSON bool) (findings FindingSet, err error)
ExtractFindingsFrom loads findings from an io.Reader.
func ExtractFindingsFromFile ¶
func ExtractFindingsFromFile(filename string, asJSON bool) (FindingSet, error)
ExtractFindingsFromFile loads findings from a file.
func Package ¶
func Package(path string, srcs []string) (FindingSet, facts.Serializer, error)
Package runs all analyzer on a single package.