mirror of
https://github.com/safedep/vet.git
synced 2025-12-10 13:43:01 -06:00
feat: Building code graph Refactor to support import processing Handle relative import name fixup Add docs for code analysis framework Update docs to include additional examples feat: Function call graph Update code graph to link function decl and calls Include call node in function calls feat: Flatten vulnerabilities in CSV reporter refactor: Maintain separation of concerns for code analysis framework refactor: Separate storage entities in its own package feat: Add callback support in code graph builder docs: Fix code analysis framework docs Signed-off-by: abhisek <abhisek.datta@gmail.com>
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package code
|
|
|
|
import (
|
|
"github.com/safedep/vet/pkg/code/nodes"
|
|
)
|
|
|
|
// Declarative metadata for the source language
|
|
type SourceLanguageMeta struct {
|
|
SourceFileGlobs []string
|
|
}
|
|
|
|
// Any source language implementation must support these
|
|
// primitives for integration with the code analysis system
|
|
type SourceLanguage interface {
|
|
// Get metadata for the source language
|
|
GetMeta() SourceLanguageMeta
|
|
|
|
// Parse a source file and return the CST (tree-sitter concrete syntax tree)
|
|
ParseSource(file SourceFile) (*nodes.CST, error)
|
|
|
|
// Get import nodes from the CST
|
|
GetImportNodes(cst *nodes.CST) ([]nodes.CSTImportNode, error)
|
|
|
|
// Get function declaration nodes from the CST
|
|
GetFunctionDeclarationNodes(cst *nodes.CST) ([]nodes.CSTFunctionNode, error)
|
|
|
|
// Get function call nodes from the CST
|
|
GetFunctionCallNodes(cst *nodes.CST) ([]nodes.CSTFunctionCallNode, error)
|
|
|
|
// Resolve the import module / package name from relative path
|
|
ResolveImportNameFromPath(relPath string) (string, error)
|
|
|
|
// Resolve import name to possible relative file names
|
|
// Multiple paths are possible because an import such
|
|
// as a.b can resolve to a/b.py or a/b/__init__.py depending
|
|
// on language and file system
|
|
ResolveImportPathsFromName(currentFile SourceFile, importName string, includeImports bool) ([]string, error)
|
|
}
|