Documentation ¶
Overview ¶
Package analysistest contains utility functions for testing the analysis tools.
Index ¶
- func AstFiles(pkgs []*packages.Package) []*ast.File
- func LoadTest(fsys ReadFileDirFS, dir string, extraFiles []string, options LoadTestOptions) result.Result[loadprogram.State]
- func MapComments(fs []*ast.File, fmap func(*ast.Comment))
- type AnnotationID
- type LPos
- type LoadTestOptions
- type ReadFileDirFS
- type TargetToSources
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTest ¶
func LoadTest( fsys ReadFileDirFS, dir string, extraFiles []string, options LoadTestOptions) result.Result[loadprogram.State]
LoadTest loads the program in the directory dir, looking for a main.go and a config.yaml. If additional files are specified as extraFiles, the program will be loaded using those files too.
LoadTest is a wrapper over loadprogram.NewState that sets all the config options and config file to load the program.
NOTE If the Analysis function runs without error but no analysis entrypoints are detected, that may mean that the config's code id's package names do not patch the package name of the SSA program. Try changing the package name to the test directory name to fix the issue.
Types ¶
type AnnotationID ¶
type AnnotationID struct { // ID is the value of an annotation id. // e.g. @Source(id) // ^^ ID string // Meta is the identifier of the second portion of an annotation id. // This represents an annotation id metadata, usually for trace information. // e.g. @Source(id call:example1->call:helper) // ^^^^^^^^^^^^^^^^^^^^^^^^^^ // Meta can be empty. // e.g. @Source(id) Meta string // Pos is the position of the annotation. Pos LPos }
AnnotationID represents an identifier in an annotation.
func (AnnotationID) String ¶
func (id AnnotationID) String() string
type LPos ¶
type LPos struct { // Filename is the file name of the position Filename string // Line is the line number in the file Line int }
LPos is a line position
func RemoveColumn ¶
RemoveColumn transforms a token.Position into a LPos by removing the column information
type LoadTestOptions ¶
type LoadTestOptions struct { // Whether to apply the rewriting steps before analyzing the program ApplyRewrite bool // Which platform Platform string }
LoadTestOptions groups the options of the LoadTest function together.
type ReadFileDirFS ¶
type ReadFileDirFS interface { fs.ReadDirFS fs.ReadFileFS }
ReadFileDirFS represents a filesystem that can read both directories and files.
type TargetToSources ¶
type TargetToSources map[AnnotationID]map[AnnotationID]bool
TargetToSources is a mapping from a target annotation (e.g. ex in @Sink(ex, ex2)) to a source annotation (e.g. ex in @Source(ex, ex2)).
func (TargetToSources) HasMetadata ¶
func (t TargetToSources) HasMetadata() bool
HasMetadata returns true if the TargetToSources mapping contains metadata