mirror of
https://github.com/safedep/vet.git
synced 2025-12-10 00:22:08 -06:00
Merge pull request #321 from safedep/feat/revamp-code-analysis-system
feat/revamp code analysis system
This commit is contained in:
commit
45915b806a
4
Makefile
4
Makefile
@ -4,6 +4,10 @@ VERSION := "$(shell git describe --tags --abbrev=0)-$(shell git rev-parse --shor
|
||||
|
||||
all: quick-vet
|
||||
|
||||
.PHONY: ent
|
||||
ent:
|
||||
go generate ./ent
|
||||
|
||||
linter-install:
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0
|
||||
|
||||
|
||||
199
code.go
199
code.go
@ -1,199 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/safedep/dry/utils"
|
||||
"github.com/safedep/vet/internal/ui"
|
||||
"github.com/safedep/vet/pkg/code"
|
||||
"github.com/safedep/vet/pkg/code/languages"
|
||||
"github.com/safedep/vet/pkg/common/logger"
|
||||
"github.com/safedep/vet/pkg/storage/graph"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
codeAppDirectories = []string{}
|
||||
codeImportDirectories = []string{}
|
||||
codeGraphDatabase string
|
||||
codeLanguage string
|
||||
)
|
||||
|
||||
func newCodeCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "code",
|
||||
Short: "[EXPERIMENTAL] Perform code analysis with insights data",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringArrayVarP(&codeAppDirectories, "src", "", []string{}, "Source code root directory to analyze")
|
||||
cmd.Flags().StringArrayVarP(&codeImportDirectories, "imports", "", []string{}, "Language specific directory to find imported source")
|
||||
cmd.Flags().StringVarP(&codeGraphDatabase, "db", "", "", "Path to the database")
|
||||
cmd.Flags().StringVarP(&codeLanguage, "lang", "", "python", "Language of the source code")
|
||||
|
||||
err := cmd.MarkFlagRequired("db")
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to mark flag as required: %v", err)
|
||||
}
|
||||
|
||||
cmd.AddCommand(newCodeCreateDatabaseCommand())
|
||||
cmd.AddCommand(newCodeImportReachabilityCommand())
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func newCodeCreateDatabaseCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "create-db",
|
||||
Short: "Analyse code and create a database for further analysis",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
startCreateDatabase()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func newCodeImportReachabilityCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "import-reachability",
|
||||
Short: "Analyse import reachability",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
startImportReachability()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func startCreateDatabase() {
|
||||
failOnError("code-create-db", internalStartCreateDatabase())
|
||||
}
|
||||
|
||||
func startImportReachability() {
|
||||
failOnError("code-import-reachability-analysis", internalStartImportReachability())
|
||||
}
|
||||
|
||||
func internalStartImportReachability() error {
|
||||
codePrintExperimentalWarning()
|
||||
|
||||
if utils.IsEmptyString(codeGraphDatabase) {
|
||||
return fmt.Errorf("no database path provided")
|
||||
}
|
||||
|
||||
// TODO: We need a code graph loader to load the code graph from the database
|
||||
// before invoking analysis modules
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func internalStartCreateDatabase() error {
|
||||
codePrintExperimentalWarning()
|
||||
logger.Debugf("Starting code analysis")
|
||||
|
||||
if len(codeAppDirectories) == 0 {
|
||||
return fmt.Errorf("no source code directory provided")
|
||||
}
|
||||
|
||||
if len(codeImportDirectories) == 0 {
|
||||
return fmt.Errorf("no import directory provided")
|
||||
}
|
||||
|
||||
if utils.IsEmptyString(codeGraphDatabase) {
|
||||
return fmt.Errorf("no database path provided")
|
||||
}
|
||||
|
||||
codeRepoCfg := code.FileSystemSourceRepositoryConfig{
|
||||
SourcePaths: codeAppDirectories,
|
||||
ImportPaths: codeImportDirectories,
|
||||
}
|
||||
|
||||
codeRepo, err := code.NewFileSystemSourceRepository(codeRepoCfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create source repository: %w", err)
|
||||
}
|
||||
|
||||
codeLang, err := codeGetLanguage()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create source language: %w", err)
|
||||
}
|
||||
|
||||
codeRepo.ConfigureForLanguage(codeLang)
|
||||
|
||||
graph, err := graph.NewPropertyGraph(&graph.LocalPropertyGraphConfig{
|
||||
Name: "code-analysis",
|
||||
DatabasePath: codeGraphDatabase,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create graph database: %w", err)
|
||||
}
|
||||
|
||||
builderConfig := code.CodeGraphBuilderConfig{
|
||||
RecursiveImport: true,
|
||||
}
|
||||
|
||||
builder, err := code.NewCodeGraphBuilder(builderConfig, codeRepo, codeLang, graph)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create code graph builder: %w", err)
|
||||
}
|
||||
|
||||
redirectLogToFile(logFile)
|
||||
|
||||
var fileProcessedTracker any
|
||||
var importsProcessedTracker any
|
||||
var functionsProcessedTracker any
|
||||
|
||||
builder.RegisterEventHandler("ui-callback",
|
||||
func(event code.CodeGraphBuilderEvent, metrics code.CodeGraphBuilderMetrics) error {
|
||||
switch event.Kind {
|
||||
case code.CodeGraphBuilderEventFileQueued:
|
||||
ui.IncrementTrackerTotal(fileProcessedTracker, 1)
|
||||
case code.CodeGraphBuilderEventFileProcessed:
|
||||
ui.IncrementProgress(fileProcessedTracker, 1)
|
||||
}
|
||||
|
||||
ui.UpdateValue(importsProcessedTracker, int64(metrics.ImportsCount))
|
||||
ui.UpdateValue(functionsProcessedTracker, int64(metrics.FunctionsCount))
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
ui.StartProgressWriter()
|
||||
|
||||
fileProcessedTracker = ui.TrackProgress("Processing source files", 0)
|
||||
importsProcessedTracker = ui.TrackProgress("Processing imports", 0)
|
||||
functionsProcessedTracker = ui.TrackProgress("Processing functions", 0)
|
||||
|
||||
err = builder.Build()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to build code graph: %w", err)
|
||||
}
|
||||
|
||||
ui.MarkTrackerAsDone(fileProcessedTracker)
|
||||
ui.MarkTrackerAsDone(importsProcessedTracker)
|
||||
ui.MarkTrackerAsDone(functionsProcessedTracker)
|
||||
ui.StopProgressWriter()
|
||||
|
||||
logger.Debugf("Code analysis completed")
|
||||
return nil
|
||||
}
|
||||
|
||||
func codePrintExperimentalWarning() {
|
||||
ui.PrintWarning("Code analysis is experimental and may have breaking change")
|
||||
}
|
||||
|
||||
func codeGetLanguage() (code.SourceLanguage, error) {
|
||||
lang := strings.ToLower(codeLanguage)
|
||||
switch lang {
|
||||
case "python":
|
||||
return languages.NewPythonSourceLanguage()
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported language: %s", codeLanguage)
|
||||
}
|
||||
}
|
||||
29
docs/storage.md
Normal file
29
docs/storage.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Storage
|
||||
|
||||
`vet` contains a storage engine defined in `pkg/storage`. We use `sqlite3` as
|
||||
the database and [ent](https://entgo.io/) as the ORM.
|
||||
|
||||
## Usage
|
||||
|
||||
- Create new schema using the following command
|
||||
|
||||
```shell
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new CodeSourceFile
|
||||
```
|
||||
|
||||
- Schemas are generated in `./ent/schema` directory
|
||||
- Edit the generated schema file and add the necessary fields and edges
|
||||
- Generate the models from the schema using the following command
|
||||
|
||||
```shell
|
||||
make ent
|
||||
```
|
||||
|
||||
- Make sure to commit any changes to `ent` directory including the generated
|
||||
files
|
||||
|
||||
## Guidance
|
||||
|
||||
All schemas are stored in `./ent/schema` directory. To avoid naming conflicts,
|
||||
prefer prefixing the schema name with the logical module name. Example: `CodeSourceFile` is
|
||||
used as the schema for storing `SourceFile` within `Code` analysis module.
|
||||
340
ent/client.go
Normal file
340
ent/client.go
Normal file
@ -0,0 +1,340 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"github.com/safedep/vet/ent/migrate"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
)
|
||||
|
||||
// Client is the client that holds all ent builders.
|
||||
type Client struct {
|
||||
config
|
||||
// Schema is the client for creating, migrating and dropping schema.
|
||||
Schema *migrate.Schema
|
||||
// CodeSourceFile is the client for interacting with the CodeSourceFile builders.
|
||||
CodeSourceFile *CodeSourceFileClient
|
||||
}
|
||||
|
||||
// NewClient creates a new client configured with the given options.
|
||||
func NewClient(opts ...Option) *Client {
|
||||
client := &Client{config: newConfig(opts...)}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
func (c *Client) init() {
|
||||
c.Schema = migrate.NewSchema(c.driver)
|
||||
c.CodeSourceFile = NewCodeSourceFileClient(c.config)
|
||||
}
|
||||
|
||||
type (
|
||||
// config is the configuration for the client and its builder.
|
||||
config struct {
|
||||
// driver used for executing database requests.
|
||||
driver dialect.Driver
|
||||
// debug enable a debug logging.
|
||||
debug bool
|
||||
// log used for logging on debug mode.
|
||||
log func(...any)
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
// interceptors to execute on queries.
|
||||
inters *inters
|
||||
}
|
||||
// Option function to configure the client.
|
||||
Option func(*config)
|
||||
)
|
||||
|
||||
// newConfig creates a new config for the client.
|
||||
func newConfig(opts ...Option) config {
|
||||
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
||||
cfg.options(opts...)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
if c.debug {
|
||||
c.driver = dialect.Debug(c.driver, c.log)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug enables debug logging on the ent.Driver.
|
||||
func Debug() Option {
|
||||
return func(c *config) {
|
||||
c.debug = true
|
||||
}
|
||||
}
|
||||
|
||||
// Log sets the logging function for debug mode.
|
||||
func Log(fn func(...any)) Option {
|
||||
return func(c *config) {
|
||||
c.log = fn
|
||||
}
|
||||
}
|
||||
|
||||
// Driver configures the client driver.
|
||||
func Driver(driver dialect.Driver) Option {
|
||||
return func(c *config) {
|
||||
c.driver = driver
|
||||
}
|
||||
}
|
||||
|
||||
// Open opens a database/sql.DB specified by the driver name and
|
||||
// the data source name, and returns a new client attached to it.
|
||||
// Optional parameters can be added for configuring the client.
|
||||
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
|
||||
switch driverName {
|
||||
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
|
||||
drv, err := sql.Open(driverName, dataSourceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewClient(append(options, Driver(drv))...), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported driver: %q", driverName)
|
||||
}
|
||||
}
|
||||
|
||||
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
|
||||
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
|
||||
|
||||
// Tx returns a new transactional client. The provided context
|
||||
// is used until the transaction is committed or rolled back.
|
||||
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, ErrTxStarted
|
||||
}
|
||||
tx, err := newTx(ctx, c.driver)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
|
||||
}
|
||||
cfg := c.config
|
||||
cfg.driver = tx
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
CodeSourceFile: NewCodeSourceFileClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// BeginTx returns a transactional client with specified options.
|
||||
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
||||
}
|
||||
tx, err := c.driver.(interface {
|
||||
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
|
||||
}).BeginTx(ctx, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
|
||||
}
|
||||
cfg := c.config
|
||||
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
CodeSourceFile: NewCodeSourceFileClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
||||
//
|
||||
// client.Debug().
|
||||
// CodeSourceFile.
|
||||
// Query().
|
||||
// Count(ctx)
|
||||
func (c *Client) Debug() *Client {
|
||||
if c.debug {
|
||||
return c
|
||||
}
|
||||
cfg := c.config
|
||||
cfg.driver = dialect.Debug(c.driver, c.log)
|
||||
client := &Client{config: cfg}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
// Close closes the database connection and prevents new queries from starting.
|
||||
func (c *Client) Close() error {
|
||||
return c.driver.Close()
|
||||
}
|
||||
|
||||
// Use adds the mutation hooks to all the entity clients.
|
||||
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
c.CodeSourceFile.Use(hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds the query interceptors to all the entity clients.
|
||||
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
c.CodeSourceFile.Intercept(interceptors...)
|
||||
}
|
||||
|
||||
// Mutate implements the ent.Mutator interface.
|
||||
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
switch m := m.(type) {
|
||||
case *CodeSourceFileMutation:
|
||||
return c.CodeSourceFile.mutate(ctx, m)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
|
||||
}
|
||||
}
|
||||
|
||||
// CodeSourceFileClient is a client for the CodeSourceFile schema.
|
||||
type CodeSourceFileClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewCodeSourceFileClient returns a client for the CodeSourceFile from the given config.
|
||||
func NewCodeSourceFileClient(c config) *CodeSourceFileClient {
|
||||
return &CodeSourceFileClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `codesourcefile.Hooks(f(g(h())))`.
|
||||
func (c *CodeSourceFileClient) Use(hooks ...Hook) {
|
||||
c.hooks.CodeSourceFile = append(c.hooks.CodeSourceFile, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `codesourcefile.Intercept(f(g(h())))`.
|
||||
func (c *CodeSourceFileClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.CodeSourceFile = append(c.inters.CodeSourceFile, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a CodeSourceFile entity.
|
||||
func (c *CodeSourceFileClient) Create() *CodeSourceFileCreate {
|
||||
mutation := newCodeSourceFileMutation(c.config, OpCreate)
|
||||
return &CodeSourceFileCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of CodeSourceFile entities.
|
||||
func (c *CodeSourceFileClient) CreateBulk(builders ...*CodeSourceFileCreate) *CodeSourceFileCreateBulk {
|
||||
return &CodeSourceFileCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *CodeSourceFileClient) MapCreateBulk(slice any, setFunc func(*CodeSourceFileCreate, int)) *CodeSourceFileCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &CodeSourceFileCreateBulk{err: fmt.Errorf("calling to CodeSourceFileClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*CodeSourceFileCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &CodeSourceFileCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for CodeSourceFile.
|
||||
func (c *CodeSourceFileClient) Update() *CodeSourceFileUpdate {
|
||||
mutation := newCodeSourceFileMutation(c.config, OpUpdate)
|
||||
return &CodeSourceFileUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *CodeSourceFileClient) UpdateOne(csf *CodeSourceFile) *CodeSourceFileUpdateOne {
|
||||
mutation := newCodeSourceFileMutation(c.config, OpUpdateOne, withCodeSourceFile(csf))
|
||||
return &CodeSourceFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *CodeSourceFileClient) UpdateOneID(id int) *CodeSourceFileUpdateOne {
|
||||
mutation := newCodeSourceFileMutation(c.config, OpUpdateOne, withCodeSourceFileID(id))
|
||||
return &CodeSourceFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for CodeSourceFile.
|
||||
func (c *CodeSourceFileClient) Delete() *CodeSourceFileDelete {
|
||||
mutation := newCodeSourceFileMutation(c.config, OpDelete)
|
||||
return &CodeSourceFileDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *CodeSourceFileClient) DeleteOne(csf *CodeSourceFile) *CodeSourceFileDeleteOne {
|
||||
return c.DeleteOneID(csf.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *CodeSourceFileClient) DeleteOneID(id int) *CodeSourceFileDeleteOne {
|
||||
builder := c.Delete().Where(codesourcefile.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &CodeSourceFileDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for CodeSourceFile.
|
||||
func (c *CodeSourceFileClient) Query() *CodeSourceFileQuery {
|
||||
return &CodeSourceFileQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeCodeSourceFile},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a CodeSourceFile entity by its id.
|
||||
func (c *CodeSourceFileClient) Get(ctx context.Context, id int) (*CodeSourceFile, error) {
|
||||
return c.Query().Where(codesourcefile.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *CodeSourceFileClient) GetX(ctx context.Context, id int) *CodeSourceFile {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *CodeSourceFileClient) Hooks() []Hook {
|
||||
return c.hooks.CodeSourceFile
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *CodeSourceFileClient) Interceptors() []Interceptor {
|
||||
return c.inters.CodeSourceFile
|
||||
}
|
||||
|
||||
func (c *CodeSourceFileClient) mutate(ctx context.Context, m *CodeSourceFileMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&CodeSourceFileCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&CodeSourceFileUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&CodeSourceFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&CodeSourceFileDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown CodeSourceFile mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
CodeSourceFile []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
CodeSourceFile []ent.Interceptor
|
||||
}
|
||||
)
|
||||
103
ent/codesourcefile.go
Normal file
103
ent/codesourcefile.go
Normal file
@ -0,0 +1,103 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
)
|
||||
|
||||
// CodeSourceFile is the model entity for the CodeSourceFile schema.
|
||||
type CodeSourceFile struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Path holds the value of the "path" field.
|
||||
Path string `json:"path,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*CodeSourceFile) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case codesourcefile.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case codesourcefile.FieldPath:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the CodeSourceFile fields.
|
||||
func (csf *CodeSourceFile) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case codesourcefile.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
csf.ID = int(value.Int64)
|
||||
case codesourcefile.FieldPath:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field path", values[i])
|
||||
} else if value.Valid {
|
||||
csf.Path = value.String
|
||||
}
|
||||
default:
|
||||
csf.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the CodeSourceFile.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (csf *CodeSourceFile) Value(name string) (ent.Value, error) {
|
||||
return csf.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this CodeSourceFile.
|
||||
// Note that you need to call CodeSourceFile.Unwrap() before calling this method if this CodeSourceFile
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (csf *CodeSourceFile) Update() *CodeSourceFileUpdateOne {
|
||||
return NewCodeSourceFileClient(csf.config).UpdateOne(csf)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the CodeSourceFile entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (csf *CodeSourceFile) Unwrap() *CodeSourceFile {
|
||||
_tx, ok := csf.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: CodeSourceFile is not a transactional entity")
|
||||
}
|
||||
csf.config.driver = _tx.drv
|
||||
return csf
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (csf *CodeSourceFile) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("CodeSourceFile(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", csf.ID))
|
||||
builder.WriteString("path=")
|
||||
builder.WriteString(csf.Path)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// CodeSourceFiles is a parsable slice of CodeSourceFile.
|
||||
type CodeSourceFiles []*CodeSourceFile
|
||||
52
ent/codesourcefile/codesourcefile.go
Normal file
52
ent/codesourcefile/codesourcefile.go
Normal file
@ -0,0 +1,52 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package codesourcefile
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the codesourcefile type in the database.
|
||||
Label = "code_source_file"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldPath holds the string denoting the path field in the database.
|
||||
FieldPath = "path"
|
||||
// Table holds the table name of the codesourcefile in the database.
|
||||
Table = "code_source_files"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for codesourcefile fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldPath,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// PathValidator is a validator for the "path" field. It is called by the builders before save.
|
||||
PathValidator func(string) error
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the CodeSourceFile queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPath orders the results by the path field.
|
||||
func ByPath(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPath, opts...).ToFunc()
|
||||
}
|
||||
138
ent/codesourcefile/where.go
Normal file
138
ent/codesourcefile/where.go
Normal file
@ -0,0 +1,138 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package codesourcefile
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/safedep/vet/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Path applies equality check predicate on the "path" field. It's identical to PathEQ.
|
||||
func Path(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldEQ(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathEQ applies the EQ predicate on the "path" field.
|
||||
func PathEQ(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldEQ(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathNEQ applies the NEQ predicate on the "path" field.
|
||||
func PathNEQ(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldNEQ(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathIn applies the In predicate on the "path" field.
|
||||
func PathIn(vs ...string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldIn(FieldPath, vs...))
|
||||
}
|
||||
|
||||
// PathNotIn applies the NotIn predicate on the "path" field.
|
||||
func PathNotIn(vs ...string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldNotIn(FieldPath, vs...))
|
||||
}
|
||||
|
||||
// PathGT applies the GT predicate on the "path" field.
|
||||
func PathGT(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldGT(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathGTE applies the GTE predicate on the "path" field.
|
||||
func PathGTE(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldGTE(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathLT applies the LT predicate on the "path" field.
|
||||
func PathLT(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldLT(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathLTE applies the LTE predicate on the "path" field.
|
||||
func PathLTE(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldLTE(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathContains applies the Contains predicate on the "path" field.
|
||||
func PathContains(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldContains(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathHasPrefix applies the HasPrefix predicate on the "path" field.
|
||||
func PathHasPrefix(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldHasPrefix(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathHasSuffix applies the HasSuffix predicate on the "path" field.
|
||||
func PathHasSuffix(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldHasSuffix(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathEqualFold applies the EqualFold predicate on the "path" field.
|
||||
func PathEqualFold(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldEqualFold(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathContainsFold applies the ContainsFold predicate on the "path" field.
|
||||
func PathContainsFold(v string) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.FieldContainsFold(FieldPath, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.CodeSourceFile) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.CodeSourceFile) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.CodeSourceFile) predicate.CodeSourceFile {
|
||||
return predicate.CodeSourceFile(sql.NotPredicates(p))
|
||||
}
|
||||
188
ent/codesourcefile_create.go
Normal file
188
ent/codesourcefile_create.go
Normal file
@ -0,0 +1,188 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
)
|
||||
|
||||
// CodeSourceFileCreate is the builder for creating a CodeSourceFile entity.
|
||||
type CodeSourceFileCreate struct {
|
||||
config
|
||||
mutation *CodeSourceFileMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (csfc *CodeSourceFileCreate) SetPath(s string) *CodeSourceFileCreate {
|
||||
csfc.mutation.SetPath(s)
|
||||
return csfc
|
||||
}
|
||||
|
||||
// Mutation returns the CodeSourceFileMutation object of the builder.
|
||||
func (csfc *CodeSourceFileCreate) Mutation() *CodeSourceFileMutation {
|
||||
return csfc.mutation
|
||||
}
|
||||
|
||||
// Save creates the CodeSourceFile in the database.
|
||||
func (csfc *CodeSourceFileCreate) Save(ctx context.Context) (*CodeSourceFile, error) {
|
||||
return withHooks(ctx, csfc.sqlSave, csfc.mutation, csfc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (csfc *CodeSourceFileCreate) SaveX(ctx context.Context) *CodeSourceFile {
|
||||
v, err := csfc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (csfc *CodeSourceFileCreate) Exec(ctx context.Context) error {
|
||||
_, err := csfc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (csfc *CodeSourceFileCreate) ExecX(ctx context.Context) {
|
||||
if err := csfc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (csfc *CodeSourceFileCreate) check() error {
|
||||
if _, ok := csfc.mutation.Path(); !ok {
|
||||
return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "CodeSourceFile.path"`)}
|
||||
}
|
||||
if v, ok := csfc.mutation.Path(); ok {
|
||||
if err := codesourcefile.PathValidator(v); err != nil {
|
||||
return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "CodeSourceFile.path": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (csfc *CodeSourceFileCreate) sqlSave(ctx context.Context) (*CodeSourceFile, error) {
|
||||
if err := csfc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := csfc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, csfc.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
csfc.mutation.id = &_node.ID
|
||||
csfc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (csfc *CodeSourceFileCreate) createSpec() (*CodeSourceFile, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &CodeSourceFile{config: csfc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(codesourcefile.Table, sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := csfc.mutation.Path(); ok {
|
||||
_spec.SetField(codesourcefile.FieldPath, field.TypeString, value)
|
||||
_node.Path = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// CodeSourceFileCreateBulk is the builder for creating many CodeSourceFile entities in bulk.
|
||||
type CodeSourceFileCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*CodeSourceFileCreate
|
||||
}
|
||||
|
||||
// Save creates the CodeSourceFile entities in the database.
|
||||
func (csfcb *CodeSourceFileCreateBulk) Save(ctx context.Context) ([]*CodeSourceFile, error) {
|
||||
if csfcb.err != nil {
|
||||
return nil, csfcb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(csfcb.builders))
|
||||
nodes := make([]*CodeSourceFile, len(csfcb.builders))
|
||||
mutators := make([]Mutator, len(csfcb.builders))
|
||||
for i := range csfcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := csfcb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*CodeSourceFileMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, csfcb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, csfcb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, csfcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (csfcb *CodeSourceFileCreateBulk) SaveX(ctx context.Context) []*CodeSourceFile {
|
||||
v, err := csfcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (csfcb *CodeSourceFileCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := csfcb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (csfcb *CodeSourceFileCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := csfcb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/codesourcefile_delete.go
Normal file
88
ent/codesourcefile_delete.go
Normal file
@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
"github.com/safedep/vet/ent/predicate"
|
||||
)
|
||||
|
||||
// CodeSourceFileDelete is the builder for deleting a CodeSourceFile entity.
|
||||
type CodeSourceFileDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CodeSourceFileMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CodeSourceFileDelete builder.
|
||||
func (csfd *CodeSourceFileDelete) Where(ps ...predicate.CodeSourceFile) *CodeSourceFileDelete {
|
||||
csfd.mutation.Where(ps...)
|
||||
return csfd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (csfd *CodeSourceFileDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, csfd.sqlExec, csfd.mutation, csfd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (csfd *CodeSourceFileDelete) ExecX(ctx context.Context) int {
|
||||
n, err := csfd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (csfd *CodeSourceFileDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(codesourcefile.Table, sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt))
|
||||
if ps := csfd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, csfd.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
csfd.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// CodeSourceFileDeleteOne is the builder for deleting a single CodeSourceFile entity.
|
||||
type CodeSourceFileDeleteOne struct {
|
||||
csfd *CodeSourceFileDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CodeSourceFileDelete builder.
|
||||
func (csfdo *CodeSourceFileDeleteOne) Where(ps ...predicate.CodeSourceFile) *CodeSourceFileDeleteOne {
|
||||
csfdo.csfd.mutation.Where(ps...)
|
||||
return csfdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (csfdo *CodeSourceFileDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := csfdo.csfd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{codesourcefile.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (csfdo *CodeSourceFileDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := csfdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
527
ent/codesourcefile_query.go
Normal file
527
ent/codesourcefile_query.go
Normal file
@ -0,0 +1,527 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
"github.com/safedep/vet/ent/predicate"
|
||||
)
|
||||
|
||||
// CodeSourceFileQuery is the builder for querying CodeSourceFile entities.
|
||||
type CodeSourceFileQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []codesourcefile.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.CodeSourceFile
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the CodeSourceFileQuery builder.
|
||||
func (csfq *CodeSourceFileQuery) Where(ps ...predicate.CodeSourceFile) *CodeSourceFileQuery {
|
||||
csfq.predicates = append(csfq.predicates, ps...)
|
||||
return csfq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (csfq *CodeSourceFileQuery) Limit(limit int) *CodeSourceFileQuery {
|
||||
csfq.ctx.Limit = &limit
|
||||
return csfq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (csfq *CodeSourceFileQuery) Offset(offset int) *CodeSourceFileQuery {
|
||||
csfq.ctx.Offset = &offset
|
||||
return csfq
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (csfq *CodeSourceFileQuery) Unique(unique bool) *CodeSourceFileQuery {
|
||||
csfq.ctx.Unique = &unique
|
||||
return csfq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (csfq *CodeSourceFileQuery) Order(o ...codesourcefile.OrderOption) *CodeSourceFileQuery {
|
||||
csfq.order = append(csfq.order, o...)
|
||||
return csfq
|
||||
}
|
||||
|
||||
// First returns the first CodeSourceFile entity from the query.
|
||||
// Returns a *NotFoundError when no CodeSourceFile was found.
|
||||
func (csfq *CodeSourceFileQuery) First(ctx context.Context) (*CodeSourceFile, error) {
|
||||
nodes, err := csfq.Limit(1).All(setContextOp(ctx, csfq.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{codesourcefile.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) FirstX(ctx context.Context) *CodeSourceFile {
|
||||
node, err := csfq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first CodeSourceFile ID from the query.
|
||||
// Returns a *NotFoundError when no CodeSourceFile ID was found.
|
||||
func (csfq *CodeSourceFileQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = csfq.Limit(1).IDs(setContextOp(ctx, csfq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{codesourcefile.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := csfq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single CodeSourceFile entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one CodeSourceFile entity is found.
|
||||
// Returns a *NotFoundError when no CodeSourceFile entities are found.
|
||||
func (csfq *CodeSourceFileQuery) Only(ctx context.Context) (*CodeSourceFile, error) {
|
||||
nodes, err := csfq.Limit(2).All(setContextOp(ctx, csfq.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{codesourcefile.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{codesourcefile.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) OnlyX(ctx context.Context) *CodeSourceFile {
|
||||
node, err := csfq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only CodeSourceFile ID in the query.
|
||||
// Returns a *NotSingularError when more than one CodeSourceFile ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (csfq *CodeSourceFileQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = csfq.Limit(2).IDs(setContextOp(ctx, csfq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{codesourcefile.Label}
|
||||
default:
|
||||
err = &NotSingularError{codesourcefile.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := csfq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of CodeSourceFiles.
|
||||
func (csfq *CodeSourceFileQuery) All(ctx context.Context) ([]*CodeSourceFile, error) {
|
||||
ctx = setContextOp(ctx, csfq.ctx, ent.OpQueryAll)
|
||||
if err := csfq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*CodeSourceFile, *CodeSourceFileQuery]()
|
||||
return withInterceptors[[]*CodeSourceFile](ctx, csfq, qr, csfq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) AllX(ctx context.Context) []*CodeSourceFile {
|
||||
nodes, err := csfq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of CodeSourceFile IDs.
|
||||
func (csfq *CodeSourceFileQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if csfq.ctx.Unique == nil && csfq.path != nil {
|
||||
csfq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, csfq.ctx, ent.OpQueryIDs)
|
||||
if err = csfq.Select(codesourcefile.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := csfq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (csfq *CodeSourceFileQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, csfq.ctx, ent.OpQueryCount)
|
||||
if err := csfq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, csfq, querierCount[*CodeSourceFileQuery](), csfq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) CountX(ctx context.Context) int {
|
||||
count, err := csfq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (csfq *CodeSourceFileQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, csfq.ctx, ent.OpQueryExist)
|
||||
switch _, err := csfq.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (csfq *CodeSourceFileQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := csfq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the CodeSourceFileQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (csfq *CodeSourceFileQuery) Clone() *CodeSourceFileQuery {
|
||||
if csfq == nil {
|
||||
return nil
|
||||
}
|
||||
return &CodeSourceFileQuery{
|
||||
config: csfq.config,
|
||||
ctx: csfq.ctx.Clone(),
|
||||
order: append([]codesourcefile.OrderOption{}, csfq.order...),
|
||||
inters: append([]Interceptor{}, csfq.inters...),
|
||||
predicates: append([]predicate.CodeSourceFile{}, csfq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: csfq.sql.Clone(),
|
||||
path: csfq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Path string `json:"path,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CodeSourceFile.Query().
|
||||
// GroupBy(codesourcefile.FieldPath).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (csfq *CodeSourceFileQuery) GroupBy(field string, fields ...string) *CodeSourceFileGroupBy {
|
||||
csfq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &CodeSourceFileGroupBy{build: csfq}
|
||||
grbuild.flds = &csfq.ctx.Fields
|
||||
grbuild.label = codesourcefile.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Path string `json:"path,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CodeSourceFile.Query().
|
||||
// Select(codesourcefile.FieldPath).
|
||||
// Scan(ctx, &v)
|
||||
func (csfq *CodeSourceFileQuery) Select(fields ...string) *CodeSourceFileSelect {
|
||||
csfq.ctx.Fields = append(csfq.ctx.Fields, fields...)
|
||||
sbuild := &CodeSourceFileSelect{CodeSourceFileQuery: csfq}
|
||||
sbuild.label = codesourcefile.Label
|
||||
sbuild.flds, sbuild.scan = &csfq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a CodeSourceFileSelect configured with the given aggregations.
|
||||
func (csfq *CodeSourceFileQuery) Aggregate(fns ...AggregateFunc) *CodeSourceFileSelect {
|
||||
return csfq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (csfq *CodeSourceFileQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range csfq.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, csfq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range csfq.ctx.Fields {
|
||||
if !codesourcefile.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if csfq.path != nil {
|
||||
prev, err := csfq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
csfq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (csfq *CodeSourceFileQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CodeSourceFile, error) {
|
||||
var (
|
||||
nodes = []*CodeSourceFile{}
|
||||
_spec = csfq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*CodeSourceFile).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &CodeSourceFile{config: csfq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, csfq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (csfq *CodeSourceFileQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := csfq.querySpec()
|
||||
_spec.Node.Columns = csfq.ctx.Fields
|
||||
if len(csfq.ctx.Fields) > 0 {
|
||||
_spec.Unique = csfq.ctx.Unique != nil && *csfq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, csfq.driver, _spec)
|
||||
}
|
||||
|
||||
func (csfq *CodeSourceFileQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(codesourcefile.Table, codesourcefile.Columns, sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt))
|
||||
_spec.From = csfq.sql
|
||||
if unique := csfq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if csfq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := csfq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, codesourcefile.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != codesourcefile.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := csfq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := csfq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := csfq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := csfq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (csfq *CodeSourceFileQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(csfq.driver.Dialect())
|
||||
t1 := builder.Table(codesourcefile.Table)
|
||||
columns := csfq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = codesourcefile.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if csfq.sql != nil {
|
||||
selector = csfq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if csfq.ctx.Unique != nil && *csfq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range csfq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range csfq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := csfq.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := csfq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// CodeSourceFileGroupBy is the group-by builder for CodeSourceFile entities.
|
||||
type CodeSourceFileGroupBy struct {
|
||||
selector
|
||||
build *CodeSourceFileQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (csfgb *CodeSourceFileGroupBy) Aggregate(fns ...AggregateFunc) *CodeSourceFileGroupBy {
|
||||
csfgb.fns = append(csfgb.fns, fns...)
|
||||
return csfgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (csfgb *CodeSourceFileGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, csfgb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := csfgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CodeSourceFileQuery, *CodeSourceFileGroupBy](ctx, csfgb.build, csfgb, csfgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (csfgb *CodeSourceFileGroupBy) sqlScan(ctx context.Context, root *CodeSourceFileQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(csfgb.fns))
|
||||
for _, fn := range csfgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*csfgb.flds)+len(csfgb.fns))
|
||||
for _, f := range *csfgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*csfgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := csfgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// CodeSourceFileSelect is the builder for selecting fields of CodeSourceFile entities.
|
||||
type CodeSourceFileSelect struct {
|
||||
*CodeSourceFileQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (csfs *CodeSourceFileSelect) Aggregate(fns ...AggregateFunc) *CodeSourceFileSelect {
|
||||
csfs.fns = append(csfs.fns, fns...)
|
||||
return csfs
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (csfs *CodeSourceFileSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, csfs.ctx, ent.OpQuerySelect)
|
||||
if err := csfs.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CodeSourceFileQuery, *CodeSourceFileSelect](ctx, csfs.CodeSourceFileQuery, csfs, csfs.inters, v)
|
||||
}
|
||||
|
||||
func (csfs *CodeSourceFileSelect) sqlScan(ctx context.Context, root *CodeSourceFileQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(csfs.fns))
|
||||
for _, fn := range csfs.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*csfs.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := csfs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
235
ent/codesourcefile_update.go
Normal file
235
ent/codesourcefile_update.go
Normal file
@ -0,0 +1,235 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
"github.com/safedep/vet/ent/predicate"
|
||||
)
|
||||
|
||||
// CodeSourceFileUpdate is the builder for updating CodeSourceFile entities.
|
||||
type CodeSourceFileUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CodeSourceFileMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CodeSourceFileUpdate builder.
|
||||
func (csfu *CodeSourceFileUpdate) Where(ps ...predicate.CodeSourceFile) *CodeSourceFileUpdate {
|
||||
csfu.mutation.Where(ps...)
|
||||
return csfu
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (csfu *CodeSourceFileUpdate) SetPath(s string) *CodeSourceFileUpdate {
|
||||
csfu.mutation.SetPath(s)
|
||||
return csfu
|
||||
}
|
||||
|
||||
// SetNillablePath sets the "path" field if the given value is not nil.
|
||||
func (csfu *CodeSourceFileUpdate) SetNillablePath(s *string) *CodeSourceFileUpdate {
|
||||
if s != nil {
|
||||
csfu.SetPath(*s)
|
||||
}
|
||||
return csfu
|
||||
}
|
||||
|
||||
// Mutation returns the CodeSourceFileMutation object of the builder.
|
||||
func (csfu *CodeSourceFileUpdate) Mutation() *CodeSourceFileMutation {
|
||||
return csfu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (csfu *CodeSourceFileUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, csfu.sqlSave, csfu.mutation, csfu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (csfu *CodeSourceFileUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := csfu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (csfu *CodeSourceFileUpdate) Exec(ctx context.Context) error {
|
||||
_, err := csfu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (csfu *CodeSourceFileUpdate) ExecX(ctx context.Context) {
|
||||
if err := csfu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (csfu *CodeSourceFileUpdate) check() error {
|
||||
if v, ok := csfu.mutation.Path(); ok {
|
||||
if err := codesourcefile.PathValidator(v); err != nil {
|
||||
return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "CodeSourceFile.path": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (csfu *CodeSourceFileUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := csfu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(codesourcefile.Table, codesourcefile.Columns, sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt))
|
||||
if ps := csfu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := csfu.mutation.Path(); ok {
|
||||
_spec.SetField(codesourcefile.FieldPath, field.TypeString, value)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, csfu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{codesourcefile.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
csfu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// CodeSourceFileUpdateOne is the builder for updating a single CodeSourceFile entity.
|
||||
type CodeSourceFileUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *CodeSourceFileMutation
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (csfuo *CodeSourceFileUpdateOne) SetPath(s string) *CodeSourceFileUpdateOne {
|
||||
csfuo.mutation.SetPath(s)
|
||||
return csfuo
|
||||
}
|
||||
|
||||
// SetNillablePath sets the "path" field if the given value is not nil.
|
||||
func (csfuo *CodeSourceFileUpdateOne) SetNillablePath(s *string) *CodeSourceFileUpdateOne {
|
||||
if s != nil {
|
||||
csfuo.SetPath(*s)
|
||||
}
|
||||
return csfuo
|
||||
}
|
||||
|
||||
// Mutation returns the CodeSourceFileMutation object of the builder.
|
||||
func (csfuo *CodeSourceFileUpdateOne) Mutation() *CodeSourceFileMutation {
|
||||
return csfuo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CodeSourceFileUpdate builder.
|
||||
func (csfuo *CodeSourceFileUpdateOne) Where(ps ...predicate.CodeSourceFile) *CodeSourceFileUpdateOne {
|
||||
csfuo.mutation.Where(ps...)
|
||||
return csfuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (csfuo *CodeSourceFileUpdateOne) Select(field string, fields ...string) *CodeSourceFileUpdateOne {
|
||||
csfuo.fields = append([]string{field}, fields...)
|
||||
return csfuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated CodeSourceFile entity.
|
||||
func (csfuo *CodeSourceFileUpdateOne) Save(ctx context.Context) (*CodeSourceFile, error) {
|
||||
return withHooks(ctx, csfuo.sqlSave, csfuo.mutation, csfuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (csfuo *CodeSourceFileUpdateOne) SaveX(ctx context.Context) *CodeSourceFile {
|
||||
node, err := csfuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (csfuo *CodeSourceFileUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := csfuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (csfuo *CodeSourceFileUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := csfuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (csfuo *CodeSourceFileUpdateOne) check() error {
|
||||
if v, ok := csfuo.mutation.Path(); ok {
|
||||
if err := codesourcefile.PathValidator(v); err != nil {
|
||||
return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "CodeSourceFile.path": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (csfuo *CodeSourceFileUpdateOne) sqlSave(ctx context.Context) (_node *CodeSourceFile, err error) {
|
||||
if err := csfuo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(codesourcefile.Table, codesourcefile.Columns, sqlgraph.NewFieldSpec(codesourcefile.FieldID, field.TypeInt))
|
||||
id, ok := csfuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CodeSourceFile.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := csfuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, codesourcefile.FieldID)
|
||||
for _, f := range fields {
|
||||
if !codesourcefile.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != codesourcefile.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := csfuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := csfuo.mutation.Path(); ok {
|
||||
_spec.SetField(codesourcefile.FieldPath, field.TypeString, value)
|
||||
}
|
||||
_node = &CodeSourceFile{config: csfuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, csfuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{codesourcefile.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
csfuo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
608
ent/ent.go
Normal file
608
ent/ent.go
Normal file
@ -0,0 +1,608 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
)
|
||||
|
||||
// ent aliases to avoid import conflicts in user's code.
|
||||
type (
|
||||
Op = ent.Op
|
||||
Hook = ent.Hook
|
||||
Value = ent.Value
|
||||
Query = ent.Query
|
||||
QueryContext = ent.QueryContext
|
||||
Querier = ent.Querier
|
||||
QuerierFunc = ent.QuerierFunc
|
||||
Interceptor = ent.Interceptor
|
||||
InterceptFunc = ent.InterceptFunc
|
||||
Traverser = ent.Traverser
|
||||
TraverseFunc = ent.TraverseFunc
|
||||
Policy = ent.Policy
|
||||
Mutator = ent.Mutator
|
||||
Mutation = ent.Mutation
|
||||
MutateFunc = ent.MutateFunc
|
||||
)
|
||||
|
||||
type clientCtxKey struct{}
|
||||
|
||||
// FromContext returns a Client stored inside a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *Client {
|
||||
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the given Client attached.
|
||||
func NewContext(parent context.Context, c *Client) context.Context {
|
||||
return context.WithValue(parent, clientCtxKey{}, c)
|
||||
}
|
||||
|
||||
type txCtxKey struct{}
|
||||
|
||||
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
|
||||
func TxFromContext(ctx context.Context) *Tx {
|
||||
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||
return tx
|
||||
}
|
||||
|
||||
// NewTxContext returns a new context with the given Tx attached.
|
||||
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
return context.WithValue(parent, txCtxKey{}, tx)
|
||||
}
|
||||
|
||||
// OrderFunc applies an ordering on the sql selector.
|
||||
// Deprecated: Use Asc/Desc functions or the package builders instead.
|
||||
type OrderFunc func(*sql.Selector)
|
||||
|
||||
var (
|
||||
initCheck sync.Once
|
||||
columnCheck sql.ColumnCheck
|
||||
)
|
||||
|
||||
// checkColumn checks if the column exists in the given table.
|
||||
func checkColumn(table, column string) error {
|
||||
initCheck.Do(func() {
|
||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||
codesourcefile.Table: codesourcefile.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(table, column)
|
||||
}
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Asc(s.C(f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Desc(s.C(f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
|
||||
type AggregateFunc func(*sql.Selector) string
|
||||
|
||||
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
|
||||
//
|
||||
// GroupBy(field1, field2).
|
||||
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
||||
// Scan(ctx, &v)
|
||||
func As(fn AggregateFunc, end string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.As(fn(s), end)
|
||||
}
|
||||
}
|
||||
|
||||
// Count applies the "count" aggregation function on each group.
|
||||
func Count() AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Count("*")
|
||||
}
|
||||
}
|
||||
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Max(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Avg(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Min(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Sum(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// ValidationError returns when validating a field or edge fails.
|
||||
type ValidationError struct {
|
||||
Name string // Field or edge name.
|
||||
err error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *ValidationError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ValidationError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// IsValidationError returns a boolean indicating whether the error is a validation error.
|
||||
func IsValidationError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ValidationError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
|
||||
type NotFoundError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotFoundError) Error() string {
|
||||
return "ent: " + e.label + " not found"
|
||||
}
|
||||
|
||||
// IsNotFound returns a boolean indicating whether the error is a not found error.
|
||||
func IsNotFound(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotFoundError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// MaskNotFound masks not found error.
|
||||
func MaskNotFound(err error) error {
|
||||
if IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
|
||||
type NotSingularError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotSingularError) Error() string {
|
||||
return "ent: " + e.label + " not singular"
|
||||
}
|
||||
|
||||
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
|
||||
func IsNotSingular(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotSingularError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotLoadedError returns when trying to get a node that was not loaded by the query.
|
||||
type NotLoadedError struct {
|
||||
edge string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotLoadedError) Error() string {
|
||||
return "ent: " + e.edge + " edge was not loaded"
|
||||
}
|
||||
|
||||
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
|
||||
func IsNotLoaded(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotLoadedError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// ConstraintError returns when trying to create/update one or more entities and
|
||||
// one or more of their constraints failed. For example, violation of edge or
|
||||
// field uniqueness.
|
||||
type ConstraintError struct {
|
||||
msg string
|
||||
wrap error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e ConstraintError) Error() string {
|
||||
return "ent: constraint failed: " + e.msg
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ConstraintError) Unwrap() error {
|
||||
return e.wrap
|
||||
}
|
||||
|
||||
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
|
||||
func IsConstraintError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ConstraintError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// selector embedded by the different Select/GroupBy builders.
|
||||
type selector struct {
|
||||
label string
|
||||
flds *[]string
|
||||
fns []AggregateFunc
|
||||
scan func(context.Context, any) error
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (s *selector) ScanX(ctx context.Context, v any) {
|
||||
if err := s.scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (s *selector) StringsX(ctx context.Context) []string {
|
||||
v, err := s.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = s.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (s *selector) StringX(ctx context.Context) string {
|
||||
v, err := s.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (s *selector) IntsX(ctx context.Context) []int {
|
||||
v, err := s.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = s.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (s *selector) IntX(ctx context.Context) int {
|
||||
v, err := s.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (s *selector) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := s.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = s.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (s *selector) Float64X(ctx context.Context) float64 {
|
||||
v, err := s.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (s *selector) BoolsX(ctx context.Context) []bool {
|
||||
v, err := s.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = s.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (s *selector) BoolX(ctx context.Context) bool {
|
||||
v, err := s.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// withHooks invokes the builder operation with the given hooks, if any.
|
||||
func withHooks[V Value, M any, PM interface {
|
||||
*M
|
||||
Mutation
|
||||
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
|
||||
if len(hooks) == 0 {
|
||||
return exec(ctx)
|
||||
}
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutationT, ok := any(m).(PM)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
// Set the mutation to the builder.
|
||||
*mutation = *mutationT
|
||||
return exec(ctx)
|
||||
})
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
if hooks[i] == nil {
|
||||
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = hooks[i](mut)
|
||||
}
|
||||
v, err := mut.Mutate(ctx, mutation)
|
||||
if err != nil {
|
||||
return value, err
|
||||
}
|
||||
nv, ok := v.(V)
|
||||
if !ok {
|
||||
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
|
||||
}
|
||||
return nv, nil
|
||||
}
|
||||
|
||||
// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
|
||||
func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
|
||||
if ent.QueryFromContext(ctx) == nil {
|
||||
qc.Op = op
|
||||
ctx = ent.NewQueryContext(ctx, qc)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func querierAll[V Value, Q interface {
|
||||
sqlAll(context.Context, ...queryHook) (V, error)
|
||||
}]() Querier {
|
||||
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
return query.sqlAll(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func querierCount[Q interface {
|
||||
sqlCount(context.Context) (int, error)
|
||||
}]() Querier {
|
||||
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
return query.sqlCount(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
|
||||
for i := len(inters) - 1; i >= 0; i-- {
|
||||
qr = inters[i].Intercept(qr)
|
||||
}
|
||||
rv, err := qr.Query(ctx, q)
|
||||
if err != nil {
|
||||
return v, err
|
||||
}
|
||||
vt, ok := rv.(V)
|
||||
if !ok {
|
||||
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
|
||||
}
|
||||
return vt, nil
|
||||
}
|
||||
|
||||
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
|
||||
sqlScan(context.Context, Q1, any) error
|
||||
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
|
||||
rv := reflect.ValueOf(v)
|
||||
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q1)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
|
||||
return rv.Elem().Interface(), nil
|
||||
}
|
||||
return v, nil
|
||||
})
|
||||
for i := len(inters) - 1; i >= 0; i-- {
|
||||
qr = inters[i].Intercept(qr)
|
||||
}
|
||||
vv, err := qr.Query(ctx, rootQuery)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch rv2 := reflect.ValueOf(vv); {
|
||||
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
|
||||
case rv.Type() == rv2.Type():
|
||||
rv.Elem().Set(rv2.Elem())
|
||||
case rv.Elem().Type() == rv2.Type():
|
||||
rv.Elem().Set(rv2)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// queryHook describes an internal hook for the different sqlAll methods.
|
||||
type queryHook func(context.Context, *sqlgraph.QuerySpec)
|
||||
84
ent/enttest/enttest.go
Normal file
84
ent/enttest/enttest.go
Normal file
@ -0,0 +1,84 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package enttest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/safedep/vet/ent"
|
||||
// required by schema hooks.
|
||||
_ "github.com/safedep/vet/ent/runtime"
|
||||
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"github.com/safedep/vet/ent/migrate"
|
||||
)
|
||||
|
||||
type (
|
||||
// TestingT is the interface that is shared between
|
||||
// testing.T and testing.B and used by enttest.
|
||||
TestingT interface {
|
||||
FailNow()
|
||||
Error(...any)
|
||||
}
|
||||
|
||||
// Option configures client creation.
|
||||
Option func(*options)
|
||||
|
||||
options struct {
|
||||
opts []ent.Option
|
||||
migrateOpts []schema.MigrateOption
|
||||
}
|
||||
)
|
||||
|
||||
// WithOptions forwards options to client creation.
|
||||
func WithOptions(opts ...ent.Option) Option {
|
||||
return func(o *options) {
|
||||
o.opts = append(o.opts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithMigrateOptions forwards options to auto migration.
|
||||
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
||||
return func(o *options) {
|
||||
o.migrateOpts = append(o.migrateOpts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
func newOptions(opts []Option) *options {
|
||||
o := &options{}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// Open calls ent.Open and auto-run migration.
|
||||
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
migrateSchema(t, c, o)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewClient calls ent.NewClient and auto-run migration.
|
||||
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c := ent.NewClient(o.opts...)
|
||||
migrateSchema(t, c, o)
|
||||
return c
|
||||
}
|
||||
func migrateSchema(t TestingT, c *ent.Client, o *options) {
|
||||
tables, err := schema.CopyTables(migrate.Tables)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
3
ent/generate.go
Normal file
3
ent/generate.go
Normal file
@ -0,0 +1,3 @@
|
||||
package ent
|
||||
|
||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema
|
||||
199
ent/hook/hook.go
Normal file
199
ent/hook/hook.go
Normal file
@ -0,0 +1,199 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/safedep/vet/ent"
|
||||
)
|
||||
|
||||
// The CodeSourceFileFunc type is an adapter to allow the use of ordinary
|
||||
// function as CodeSourceFile mutator.
|
||||
type CodeSourceFileFunc func(context.Context, *ent.CodeSourceFileMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f CodeSourceFileFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.CodeSourceFileMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CodeSourceFileMutation", m)
|
||||
}
|
||||
|
||||
// Condition is a hook condition function.
|
||||
type Condition func(context.Context, ent.Mutation) bool
|
||||
|
||||
// And groups conditions with the AND operator.
|
||||
func And(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if !first(ctx, m) || !second(ctx, m) {
|
||||
return false
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if !cond(ctx, m) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Or groups conditions with the OR operator.
|
||||
func Or(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if first(ctx, m) || second(ctx, m) {
|
||||
return true
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if cond(ctx, m) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Not negates a given condition.
|
||||
func Not(cond Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
return !cond(ctx, m)
|
||||
}
|
||||
}
|
||||
|
||||
// HasOp is a condition testing mutation operation.
|
||||
func HasOp(op ent.Op) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
return m.Op().Is(op)
|
||||
}
|
||||
}
|
||||
|
||||
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||
func HasAddedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||
func HasClearedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasFields is a condition validating `.Field` on fields.
|
||||
func HasFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// If executes the given hook under condition.
|
||||
//
|
||||
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||
return func(next ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if cond(ctx, m) {
|
||||
return hk(next).Mutate(ctx, m)
|
||||
}
|
||||
return next.Mutate(ctx, m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// On executes the given hook only for the given operation.
|
||||
//
|
||||
// hook.On(Log, ent.Delete|ent.Create)
|
||||
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, HasOp(op))
|
||||
}
|
||||
|
||||
// Unless skips the given hook only for the given operation.
|
||||
//
|
||||
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, Not(HasOp(op)))
|
||||
}
|
||||
|
||||
// FixedError is a hook returning a fixed error.
|
||||
func FixedError(err error) ent.Hook {
|
||||
return func(ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
|
||||
return nil, err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Reject returns a hook that rejects all operations that match op.
|
||||
//
|
||||
// func (T) Hooks() []ent.Hook {
|
||||
// return []ent.Hook{
|
||||
// Reject(ent.Delete|ent.Update),
|
||||
// }
|
||||
// }
|
||||
func Reject(op ent.Op) ent.Hook {
|
||||
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||
return On(hk, op)
|
||||
}
|
||||
|
||||
// Chain acts as a list of hooks and is effectively immutable.
|
||||
// Once created, it will always hold the same set of hooks in the same order.
|
||||
type Chain struct {
|
||||
hooks []ent.Hook
|
||||
}
|
||||
|
||||
// NewChain creates a new chain of hooks.
|
||||
func NewChain(hooks ...ent.Hook) Chain {
|
||||
return Chain{append([]ent.Hook(nil), hooks...)}
|
||||
}
|
||||
|
||||
// Hook chains the list of hooks and returns the final hook.
|
||||
func (c Chain) Hook() ent.Hook {
|
||||
return func(mutator ent.Mutator) ent.Mutator {
|
||||
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||
mutator = c.hooks[i](mutator)
|
||||
}
|
||||
return mutator
|
||||
}
|
||||
}
|
||||
|
||||
// Append extends a chain, adding the specified hook
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Append(hooks ...ent.Hook) Chain {
|
||||
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
|
||||
newHooks = append(newHooks, c.hooks...)
|
||||
newHooks = append(newHooks, hooks...)
|
||||
return Chain{newHooks}
|
||||
}
|
||||
|
||||
// Extend extends a chain, adding the specified chain
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Extend(chain Chain) Chain {
|
||||
return c.Append(chain.hooks...)
|
||||
}
|
||||
64
ent/migrate/migrate.go
Normal file
64
ent/migrate/migrate.go
Normal file
@ -0,0 +1,64 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
// WithGlobalUniqueID sets the universal ids options to the migration.
|
||||
// If this option is enabled, ent migration will allocate a 1<<32 range
|
||||
// for the ids of each entity (table).
|
||||
// Note that this option cannot be applied on tables that already exist.
|
||||
WithGlobalUniqueID = schema.WithGlobalUniqueID
|
||||
// WithDropColumn sets the drop column option to the migration.
|
||||
// If this option is enabled, ent migration will drop old columns
|
||||
// that were used for both fields and edges. This defaults to false.
|
||||
WithDropColumn = schema.WithDropColumn
|
||||
// WithDropIndex sets the drop index option to the migration.
|
||||
// If this option is enabled, ent migration will drop old indexes
|
||||
// that were defined in the schema. This defaults to false.
|
||||
// Note that unique constraints are defined using `UNIQUE INDEX`,
|
||||
// and therefore, it's recommended to enable this option to get more
|
||||
// flexibility in the schema changes.
|
||||
WithDropIndex = schema.WithDropIndex
|
||||
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
||||
WithForeignKeys = schema.WithForeignKeys
|
||||
)
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||
|
||||
// Create creates all schema resources.
|
||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, s, Tables, opts...)
|
||||
}
|
||||
|
||||
// Create creates all table resources using the given schema driver.
|
||||
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %w", err)
|
||||
}
|
||||
return migrate.Create(ctx, tables...)
|
||||
}
|
||||
|
||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||
//
|
||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
|
||||
}
|
||||
29
ent/migrate/schema.go
Normal file
29
ent/migrate/schema.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// CodeSourceFilesColumns holds the columns for the "code_source_files" table.
|
||||
CodeSourceFilesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "path", Type: field.TypeString, Unique: true},
|
||||
}
|
||||
// CodeSourceFilesTable holds the schema information for the "code_source_files" table.
|
||||
CodeSourceFilesTable = &schema.Table{
|
||||
Name: "code_source_files",
|
||||
Columns: CodeSourceFilesColumns,
|
||||
PrimaryKey: []*schema.Column{CodeSourceFilesColumns[0]},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
CodeSourceFilesTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
353
ent/mutation.go
Normal file
353
ent/mutation.go
Normal file
@ -0,0 +1,353 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
"github.com/safedep/vet/ent/predicate"
|
||||
)
|
||||
|
||||
const (
|
||||
// Operation types.
|
||||
OpCreate = ent.OpCreate
|
||||
OpDelete = ent.OpDelete
|
||||
OpDeleteOne = ent.OpDeleteOne
|
||||
OpUpdate = ent.OpUpdate
|
||||
OpUpdateOne = ent.OpUpdateOne
|
||||
|
||||
// Node types.
|
||||
TypeCodeSourceFile = "CodeSourceFile"
|
||||
)
|
||||
|
||||
// CodeSourceFileMutation represents an operation that mutates the CodeSourceFile nodes in the graph.
|
||||
type CodeSourceFileMutation struct {
|
||||
config
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
_path *string
|
||||
clearedFields map[string]struct{}
|
||||
done bool
|
||||
oldValue func(context.Context) (*CodeSourceFile, error)
|
||||
predicates []predicate.CodeSourceFile
|
||||
}
|
||||
|
||||
var _ ent.Mutation = (*CodeSourceFileMutation)(nil)
|
||||
|
||||
// codesourcefileOption allows management of the mutation configuration using functional options.
|
||||
type codesourcefileOption func(*CodeSourceFileMutation)
|
||||
|
||||
// newCodeSourceFileMutation creates new mutation for the CodeSourceFile entity.
|
||||
func newCodeSourceFileMutation(c config, op Op, opts ...codesourcefileOption) *CodeSourceFileMutation {
|
||||
m := &CodeSourceFileMutation{
|
||||
config: c,
|
||||
op: op,
|
||||
typ: TypeCodeSourceFile,
|
||||
clearedFields: make(map[string]struct{}),
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(m)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// withCodeSourceFileID sets the ID field of the mutation.
|
||||
func withCodeSourceFileID(id int) codesourcefileOption {
|
||||
return func(m *CodeSourceFileMutation) {
|
||||
var (
|
||||
err error
|
||||
once sync.Once
|
||||
value *CodeSourceFile
|
||||
)
|
||||
m.oldValue = func(ctx context.Context) (*CodeSourceFile, error) {
|
||||
once.Do(func() {
|
||||
if m.done {
|
||||
err = errors.New("querying old values post mutation is not allowed")
|
||||
} else {
|
||||
value, err = m.Client().CodeSourceFile.Get(ctx, id)
|
||||
}
|
||||
})
|
||||
return value, err
|
||||
}
|
||||
m.id = &id
|
||||
}
|
||||
}
|
||||
|
||||
// withCodeSourceFile sets the old CodeSourceFile of the mutation.
|
||||
func withCodeSourceFile(node *CodeSourceFile) codesourcefileOption {
|
||||
return func(m *CodeSourceFileMutation) {
|
||||
m.oldValue = func(context.Context) (*CodeSourceFile, error) {
|
||||
return node, nil
|
||||
}
|
||||
m.id = &node.ID
|
||||
}
|
||||
}
|
||||
|
||||
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
||||
// executed in a transaction (ent.Tx), a transactional client is returned.
|
||||
func (m CodeSourceFileMutation) Client() *Client {
|
||||
client := &Client{config: m.config}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
||||
// it returns an error otherwise.
|
||||
func (m CodeSourceFileMutation) Tx() (*Tx, error) {
|
||||
if _, ok := m.driver.(*txDriver); !ok {
|
||||
return nil, errors.New("ent: mutation is not running in a transaction")
|
||||
}
|
||||
tx := &Tx{config: m.config}
|
||||
tx.init()
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
// ID returns the ID value in the mutation. Note that the ID is only available
|
||||
// if it was provided to the builder or after it was returned from the database.
|
||||
func (m *CodeSourceFileMutation) ID() (id int, exists bool) {
|
||||
if m.id == nil {
|
||||
return
|
||||
}
|
||||
return *m.id, true
|
||||
}
|
||||
|
||||
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
||||
// That means, if the mutation is applied within a transaction with an isolation level such
|
||||
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
||||
// or updated by the mutation.
|
||||
func (m *CodeSourceFileMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
switch {
|
||||
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
||||
id, exists := m.ID()
|
||||
if exists {
|
||||
return []int{id}, nil
|
||||
}
|
||||
fallthrough
|
||||
case m.op.Is(OpUpdate | OpDelete):
|
||||
return m.Client().CodeSourceFile.Query().Where(m.predicates...).IDs(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
||||
}
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (m *CodeSourceFileMutation) SetPath(s string) {
|
||||
m._path = &s
|
||||
}
|
||||
|
||||
// Path returns the value of the "path" field in the mutation.
|
||||
func (m *CodeSourceFileMutation) Path() (r string, exists bool) {
|
||||
v := m._path
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldPath returns the old "path" field's value of the CodeSourceFile entity.
|
||||
// If the CodeSourceFile object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CodeSourceFileMutation) OldPath(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldPath is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldPath requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldPath: %w", err)
|
||||
}
|
||||
return oldValue.Path, nil
|
||||
}
|
||||
|
||||
// ResetPath resets all changes to the "path" field.
|
||||
func (m *CodeSourceFileMutation) ResetPath() {
|
||||
m._path = nil
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CodeSourceFileMutation builder.
|
||||
func (m *CodeSourceFileMutation) Where(ps ...predicate.CodeSourceFile) {
|
||||
m.predicates = append(m.predicates, ps...)
|
||||
}
|
||||
|
||||
// WhereP appends storage-level predicates to the CodeSourceFileMutation builder. Using this method,
|
||||
// users can use type-assertion to append predicates that do not depend on any generated package.
|
||||
func (m *CodeSourceFileMutation) WhereP(ps ...func(*sql.Selector)) {
|
||||
p := make([]predicate.CodeSourceFile, len(ps))
|
||||
for i := range ps {
|
||||
p[i] = ps[i]
|
||||
}
|
||||
m.Where(p...)
|
||||
}
|
||||
|
||||
// Op returns the operation name.
|
||||
func (m *CodeSourceFileMutation) Op() Op {
|
||||
return m.op
|
||||
}
|
||||
|
||||
// SetOp allows setting the mutation operation.
|
||||
func (m *CodeSourceFileMutation) SetOp(op Op) {
|
||||
m.op = op
|
||||
}
|
||||
|
||||
// Type returns the node type of this mutation (CodeSourceFile).
|
||||
func (m *CodeSourceFileMutation) Type() string {
|
||||
return m.typ
|
||||
}
|
||||
|
||||
// Fields returns all fields that were changed during this mutation. Note that in
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *CodeSourceFileMutation) Fields() []string {
|
||||
fields := make([]string, 0, 1)
|
||||
if m._path != nil {
|
||||
fields = append(fields, codesourcefile.FieldPath)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// Field returns the value of a field with the given name. The second boolean
|
||||
// return value indicates that this field was not set, or was not defined in the
|
||||
// schema.
|
||||
func (m *CodeSourceFileMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case codesourcefile.FieldPath:
|
||||
return m.Path()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// OldField returns the old value of the field from the database. An error is
|
||||
// returned if the mutation operation is not UpdateOne, or the query to the
|
||||
// database failed.
|
||||
func (m *CodeSourceFileMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case codesourcefile.FieldPath:
|
||||
return m.OldPath(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown CodeSourceFile field %s", name)
|
||||
}
|
||||
|
||||
// SetField sets the value of a field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *CodeSourceFileMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case codesourcefile.FieldPath:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetPath(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown CodeSourceFile field %s", name)
|
||||
}
|
||||
|
||||
// AddedFields returns all numeric fields that were incremented/decremented during
|
||||
// this mutation.
|
||||
func (m *CodeSourceFileMutation) AddedFields() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddedField returns the numeric value that was incremented/decremented on a field
|
||||
// with the given name. The second boolean return value indicates that this field
|
||||
// was not set, or was not defined in the schema.
|
||||
func (m *CodeSourceFileMutation) AddedField(name string) (ent.Value, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// AddField adds the value to the field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *CodeSourceFileMutation) AddField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
}
|
||||
return fmt.Errorf("unknown CodeSourceFile numeric field %s", name)
|
||||
}
|
||||
|
||||
// ClearedFields returns all nullable fields that were cleared during this
|
||||
// mutation.
|
||||
func (m *CodeSourceFileMutation) ClearedFields() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||
// cleared in this mutation.
|
||||
func (m *CodeSourceFileMutation) FieldCleared(name string) bool {
|
||||
_, ok := m.clearedFields[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ClearField clears the value of the field with the given name. It returns an
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *CodeSourceFileMutation) ClearField(name string) error {
|
||||
return fmt.Errorf("unknown CodeSourceFile nullable field %s", name)
|
||||
}
|
||||
|
||||
// ResetField resets all changes in the mutation for the field with the given name.
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *CodeSourceFileMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case codesourcefile.FieldPath:
|
||||
m.ResetPath()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown CodeSourceFile field %s", name)
|
||||
}
|
||||
|
||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||
func (m *CodeSourceFileMutation) AddedEdges() []string {
|
||||
edges := make([]string, 0, 0)
|
||||
return edges
|
||||
}
|
||||
|
||||
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
||||
// name in this mutation.
|
||||
func (m *CodeSourceFileMutation) AddedIDs(name string) []ent.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||
func (m *CodeSourceFileMutation) RemovedEdges() []string {
|
||||
edges := make([]string, 0, 0)
|
||||
return edges
|
||||
}
|
||||
|
||||
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||
// the given name in this mutation.
|
||||
func (m *CodeSourceFileMutation) RemovedIDs(name string) []ent.Value {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||
func (m *CodeSourceFileMutation) ClearedEdges() []string {
|
||||
edges := make([]string, 0, 0)
|
||||
return edges
|
||||
}
|
||||
|
||||
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
||||
// was cleared in this mutation.
|
||||
func (m *CodeSourceFileMutation) EdgeCleared(name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ClearEdge clears the value of the edge with the given name. It returns an error
|
||||
// if that edge is not defined in the schema.
|
||||
func (m *CodeSourceFileMutation) ClearEdge(name string) error {
|
||||
return fmt.Errorf("unknown CodeSourceFile unique edge %s", name)
|
||||
}
|
||||
|
||||
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
||||
// It returns an error if the edge is not defined in the schema.
|
||||
func (m *CodeSourceFileMutation) ResetEdge(name string) error {
|
||||
return fmt.Errorf("unknown CodeSourceFile edge %s", name)
|
||||
}
|
||||
10
ent/predicate/predicate.go
Normal file
10
ent/predicate/predicate.go
Normal file
@ -0,0 +1,10 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package predicate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// CodeSourceFile is the predicate function for codesourcefile builders.
|
||||
type CodeSourceFile func(*sql.Selector)
|
||||
20
ent/runtime.go
Normal file
20
ent/runtime.go
Normal file
@ -0,0 +1,20 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"github.com/safedep/vet/ent/codesourcefile"
|
||||
"github.com/safedep/vet/ent/schema"
|
||||
)
|
||||
|
||||
// The init function reads all schema descriptors with runtime code
|
||||
// (default values, validators, hooks and policies) and stitches it
|
||||
// to their package variables.
|
||||
func init() {
|
||||
codesourcefileFields := schema.CodeSourceFile{}.Fields()
|
||||
_ = codesourcefileFields
|
||||
// codesourcefileDescPath is the schema descriptor for path field.
|
||||
codesourcefileDescPath := codesourcefileFields[0].Descriptor()
|
||||
// codesourcefile.PathValidator is a validator for the "path" field. It is called by the builders before save.
|
||||
codesourcefile.PathValidator = codesourcefileDescPath.Validators[0].(func(string) error)
|
||||
}
|
||||
10
ent/runtime/runtime.go
Normal file
10
ent/runtime/runtime.go
Normal file
@ -0,0 +1,10 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package runtime
|
||||
|
||||
// The schema-stitching logic is generated in github.com/safedep/vet/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.14.1" // Version of ent codegen.
|
||||
Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen.
|
||||
)
|
||||
23
ent/schema/codesourcefile.go
Normal file
23
ent/schema/codesourcefile.go
Normal file
@ -0,0 +1,23 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CodeSourceFile holds the schema definition for the CodeSourceFile entity.
|
||||
type CodeSourceFile struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the CodeSourceFile.
|
||||
func (CodeSourceFile) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("path").NotEmpty().Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the CodeSourceFile.
|
||||
func (CodeSourceFile) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
210
ent/tx.go
Normal file
210
ent/tx.go
Normal file
@ -0,0 +1,210 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
)
|
||||
|
||||
// Tx is a transactional client that is created by calling Client.Tx().
|
||||
type Tx struct {
|
||||
config
|
||||
// CodeSourceFile is the client for interacting with the CodeSourceFile builders.
|
||||
CodeSourceFile *CodeSourceFileClient
|
||||
|
||||
// lazily loaded.
|
||||
client *Client
|
||||
clientOnce sync.Once
|
||||
// ctx lives for the life of the transaction. It is
|
||||
// the same context used by the underlying connection.
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
type (
|
||||
// Committer is the interface that wraps the Commit method.
|
||||
Committer interface {
|
||||
Commit(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The CommitFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Committer. If f is a function with the appropriate
|
||||
// signature, CommitFunc(f) is a Committer that calls f.
|
||||
CommitFunc func(context.Context, *Tx) error
|
||||
|
||||
// CommitHook defines the "commit middleware". A function that gets a Committer
|
||||
// and returns a Committer. For example:
|
||||
//
|
||||
// hook := func(next ent.Committer) ent.Committer {
|
||||
// return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Commit(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
CommitHook func(Committer) Committer
|
||||
)
|
||||
|
||||
// Commit calls f(ctx, m).
|
||||
func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Commit commits the transaction.
|
||||
func (tx *Tx) Commit() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Commit()
|
||||
})
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]CommitHook(nil), txDriver.onCommit...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Commit(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnCommit adds a hook to call on commit.
|
||||
func (tx *Tx) OnCommit(f CommitHook) {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onCommit = append(txDriver.onCommit, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
type (
|
||||
// Rollbacker is the interface that wraps the Rollback method.
|
||||
Rollbacker interface {
|
||||
Rollback(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The RollbackFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Rollbacker. If f is a function with the appropriate
|
||||
// signature, RollbackFunc(f) is a Rollbacker that calls f.
|
||||
RollbackFunc func(context.Context, *Tx) error
|
||||
|
||||
// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker
|
||||
// and returns a Rollbacker. For example:
|
||||
//
|
||||
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||
// return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Rollback(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
RollbackHook func(Rollbacker) Rollbacker
|
||||
)
|
||||
|
||||
// Rollback calls f(ctx, m).
|
||||
func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Rollback rollbacks the transaction.
|
||||
func (tx *Tx) Rollback() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Rollback()
|
||||
})
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]RollbackHook(nil), txDriver.onRollback...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Rollback(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnRollback adds a hook to call on rollback.
|
||||
func (tx *Tx) OnRollback(f RollbackHook) {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onRollback = append(txDriver.onRollback, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
// Client returns a Client that binds to current transaction.
|
||||
func (tx *Tx) Client() *Client {
|
||||
tx.clientOnce.Do(func() {
|
||||
tx.client = &Client{config: tx.config}
|
||||
tx.client.init()
|
||||
})
|
||||
return tx.client
|
||||
}
|
||||
|
||||
func (tx *Tx) init() {
|
||||
tx.CodeSourceFile = NewCodeSourceFileClient(tx.config)
|
||||
}
|
||||
|
||||
// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.
|
||||
// The idea is to support transactions without adding any extra code to the builders.
|
||||
// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance.
|
||||
// Commit and Rollback are nop for the internal builders and the user must call one
|
||||
// of them in order to commit or rollback the transaction.
|
||||
//
|
||||
// If a closed transaction is embedded in one of the generated entities, and the entity
|
||||
// applies a query, for example: CodeSourceFile.QueryXXX(), the query will be executed
|
||||
// through the driver which created this transaction.
|
||||
//
|
||||
// Note that txDriver is not goroutine safe.
|
||||
type txDriver struct {
|
||||
// the driver we started the transaction from.
|
||||
drv dialect.Driver
|
||||
// tx is the underlying transaction.
|
||||
tx dialect.Tx
|
||||
// completion hooks.
|
||||
mu sync.Mutex
|
||||
onCommit []CommitHook
|
||||
onRollback []RollbackHook
|
||||
}
|
||||
|
||||
// newTx creates a new transactional driver.
|
||||
func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) {
|
||||
tx, err := drv.Tx(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &txDriver{tx: tx, drv: drv}, nil
|
||||
}
|
||||
|
||||
// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls
|
||||
// from the internal builders. Should be called only by the internal builders.
|
||||
func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil }
|
||||
|
||||
// Dialect returns the dialect of the driver we started the transaction from.
|
||||
func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }
|
||||
|
||||
// Close is a nop close.
|
||||
func (*txDriver) Close() error { return nil }
|
||||
|
||||
// Commit is a nop commit for the internal builders.
|
||||
// User must call `Tx.Commit` in order to commit the transaction.
|
||||
func (*txDriver) Commit() error { return nil }
|
||||
|
||||
// Rollback is a nop rollback for the internal builders.
|
||||
// User must call `Tx.Rollback` in order to rollback the transaction.
|
||||
func (*txDriver) Rollback() error { return nil }
|
||||
|
||||
// Exec calls tx.Exec.
|
||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// Query calls tx.Query.
|
||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
var _ dialect.Driver = (*txDriver)(nil)
|
||||
7
go.mod
7
go.mod
@ -5,6 +5,7 @@ go 1.23.2
|
||||
require (
|
||||
buf.build/gen/go/safedep/api/grpc/go v1.5.1-20250120081932-370c5c54f7c9.2
|
||||
buf.build/gen/go/safedep/api/protocolbuffers/go v1.36.3-20250120081932-370c5c54f7c9.1
|
||||
entgo.io/ent v0.14.1
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7
|
||||
github.com/CycloneDX/cyclonedx-go v0.9.2
|
||||
github.com/anchore/syft v1.18.1
|
||||
@ -23,9 +24,11 @@ require (
|
||||
github.com/hashicorp/hcl/v2 v2.23.0
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.5
|
||||
github.com/kubescape/go-git-url v0.0.30
|
||||
github.com/mattn/go-sqlite3 v1.14.22
|
||||
github.com/oklog/ulid/v2 v2.1.0
|
||||
github.com/owenrumney/go-sarif/v2 v2.3.3
|
||||
github.com/package-url/packageurl-go v0.1.3
|
||||
github.com/safedep/code v0.0.0-20250129053905-bde6512236a6
|
||||
github.com/safedep/dry v0.0.0-20250106055453-e0772cda4a25
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
|
||||
@ -44,6 +47,7 @@ replace github.com/owenrumney/go-sarif/v2 v2.3.1 => github.com/safedep/go-sarif/
|
||||
replace github.com/cli/oauth v1.0.1 => github.com/abhisek/oauth v1.0.1-audience
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.3-20241127180247-a33202765966.1 // indirect
|
||||
cel.dev/expr v0.19.1 // indirect
|
||||
dario.cat/mergo v1.0.1 // indirect
|
||||
@ -84,7 +88,6 @@ require (
|
||||
github.com/chainguard-dev/git-urls v1.0.2 // indirect
|
||||
github.com/cloudflare/circl v1.5.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/containerd/errdefs v1.0.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||
@ -103,6 +106,7 @@ require (
|
||||
github.com/gin-gonic/gin v1.10.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.24.0 // indirect
|
||||
@ -151,7 +155,6 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/mholt/archiver/v3 v3.5.1 // indirect
|
||||
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||
|
||||
190
go.sum
190
go.sum
@ -1,17 +1,11 @@
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.2-20240508200655-46a4cf4ba109.1 h1:IQ7h10cY5brtPWVllkhiEd2wa6S6vmbQMbmY717Ptv0=
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.2-20240508200655-46a4cf4ba109.1/go.mod h1:JnMVLi3qrNYPODVpEKG7UjHLl/d2zR221e66YCSmP2Q=
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14=
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.3-20241127180247-a33202765966.1 h1:cQZXKoQ+eB0kykzfJe80RP3nc+3PWbbBrUBm8XNYAQY=
|
||||
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.3-20241127180247-a33202765966.1/go.mod h1:6VPKM8zbmgf9qsmkmKeH49a36Vtmidw3rG53B5mTenc=
|
||||
buf.build/gen/go/safedep/api/grpc/go v1.5.1-20250113125913-f90710bfd672.2 h1:pGKPh/jHOBc2kDbYDitNoY2mr4cI1LgrIy0pNKtWNbU=
|
||||
buf.build/gen/go/safedep/api/grpc/go v1.5.1-20250113125913-f90710bfd672.2/go.mod h1:7DC6BumVy4Tsw0rnJrOBL1JcpQr0/6Y0pL9KsEb3Xmg=
|
||||
buf.build/gen/go/safedep/api/grpc/go v1.5.1-20250120081932-370c5c54f7c9.2 h1:8GnhglDlnetv0W40JaRxUloAALoDUNYjgUy9ZsKFGrQ=
|
||||
buf.build/gen/go/safedep/api/grpc/go v1.5.1-20250120081932-370c5c54f7c9.2/go.mod h1:tJ3olHksW0Top5Uq4gagVEoEwzA3KQrBeSbKdmK/iOo=
|
||||
buf.build/gen/go/safedep/api/protocolbuffers/go v1.36.2-20250113125913-f90710bfd672.1 h1:0LzooeICg9EC7ycCJGmltiWBu/lor1RsH3i8pZWO4s8=
|
||||
buf.build/gen/go/safedep/api/protocolbuffers/go v1.36.2-20250113125913-f90710bfd672.1/go.mod h1:0imTeAc72NLqWJl8by9QHVuEEz+6jt18Nr0iINEB5Bc=
|
||||
buf.build/gen/go/safedep/api/protocolbuffers/go v1.36.3-20250120081932-370c5c54f7c9.1 h1:oxEK5wTESsdCmtdcVCI0aoXf5Hflvk7pYlKlTVPXMhM=
|
||||
buf.build/gen/go/safedep/api/protocolbuffers/go v1.36.3-20250120081932-370c5c54f7c9.1/go.mod h1:buFDzX2R5tIKP7wAw/B+iJR0WykeqRTLuNsbJA27hYQ=
|
||||
cel.dev/expr v0.18.0 h1:CJ6drgk+Hf96lkLikr4rFf19WrU0BOWEihyZnI2TAzo=
|
||||
cel.dev/expr v0.18.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
|
||||
cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=
|
||||
cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
@ -64,6 +58,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
||||
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=
|
||||
entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco=
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
||||
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 h1:59MxjQVfjXsBpLy+dbd2/ELV5ofnUkUZBvWSC85sheA=
|
||||
@ -79,10 +75,10 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4s
|
||||
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
|
||||
github.com/CloudyKit/jet/v6 v6.2.0 h1:EpcZ6SR9n28BUGtNJSvlBqf90IpjeFr36Tizxhn/oME=
|
||||
github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
|
||||
github.com/CycloneDX/cyclonedx-go v0.9.1 h1:yffaWOZsv77oTJa/SdVZYdgAgFioCeycBUKkqS2qzQM=
|
||||
github.com/CycloneDX/cyclonedx-go v0.9.1/go.mod h1:NE/EWvzELOFlG6+ljX/QeMlVt9VKcTwu8u0ccsACEsw=
|
||||
github.com/CycloneDX/cyclonedx-go v0.9.2 h1:688QHn2X/5nRezKe2ueIVCt+NRqf7fl3AVQk+vaFcIo=
|
||||
github.com/CycloneDX/cyclonedx-go v0.9.2/go.mod h1:vcK6pKgO1WanCdd61qx4bFnSsDJQ6SbM2ZuMIgq86Jg=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||
github.com/DataDog/datadog-go v3.7.1+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
|
||||
@ -91,9 +87,6 @@ github.com/Joker/hpp v1.0.0 h1:65+iuJYdRXv/XyN62C1uEmmOx3432rNG/rKlX6V7Kkc=
|
||||
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
|
||||
github.com/Joker/jade v1.1.3 h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk=
|
||||
github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM=
|
||||
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
||||
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
|
||||
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
|
||||
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
@ -103,8 +96,6 @@ github.com/Microsoft/hcsshim v0.11.7/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA
|
||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
|
||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/ProtonMail/go-crypto v1.1.2 h1:A7JbD57ThNqh7XjmHE+PXpQ3Dqt3BrSAC0AL0Go3KS0=
|
||||
github.com/ProtonMail/go-crypto v1.1.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
|
||||
github.com/ProtonMail/go-crypto v1.1.5 h1:eoAQfK2dwL+tFSFpr7TbOaPNUbPiJj4fLYwwGE1FQO4=
|
||||
github.com/ProtonMail/go-crypto v1.1.5/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
|
||||
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
|
||||
@ -126,22 +117,14 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/anchore/archiver/v3 v3.5.3-0.20241210171143-5b1d8d1c7c51 h1:yhk+P8lF3ZiROjmaVRao9WGTRo4b/wYjoKEiAHWrKwc=
|
||||
github.com/anchore/archiver/v3 v3.5.3-0.20241210171143-5b1d8d1c7c51/go.mod h1:nwuGSd7aZp0rtYt79YggCGafz1RYsclE7pi3fhLwvuw=
|
||||
github.com/anchore/clio v0.0.0-20241115144204-29e89f9fa837 h1:bIG3WsfosZsJ5LMC7PB9J/ekFM3a0j0ZEDvN3ID6GTI=
|
||||
github.com/anchore/clio v0.0.0-20241115144204-29e89f9fa837/go.mod h1:tRQVKkjYeejrh9AdM0s1esbwtMU7rdHAHSQWkv4qskE=
|
||||
github.com/anchore/clio v0.0.0-20250115173119-036c31e4dfd7 h1:58Jkuok064peUdoOef3wHp0zc9XLcW6kyWjtKqc9K9A=
|
||||
github.com/anchore/clio v0.0.0-20250115173119-036c31e4dfd7/go.mod h1:iHfut2N3hTPFR19HV7PLCkC8y0It++JRZAL/ANtEX+s=
|
||||
github.com/anchore/fangs v0.0.0-20241031222233-81506aed5251 h1:pY93gR/my9xIxIkud/pSeAXGNz8dUp+OQDqECWwKfUs=
|
||||
github.com/anchore/fangs v0.0.0-20241031222233-81506aed5251/go.mod h1:7tbilRyb93SAKRYR4AnOGCCgIn1Fy2KQWQjI42FOwW4=
|
||||
github.com/anchore/fangs v0.0.0-20241125225345-c73f048692d3 h1:GaErkA967XCOkqfOgZ+ijU0rswhIJ3py9kH1LfQKDMs=
|
||||
github.com/anchore/fangs v0.0.0-20241125225345-c73f048692d3/go.mod h1:PWdaRnahkGJ+56c9Q5TMmMeEEKgVT7vZHmL/wg0E8aw=
|
||||
github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537 h1:GjNGuwK5jWjJMyVppBjYS54eOiiSNv4Ba869k4wh72Q=
|
||||
github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537/go.mod h1:1aiktV46ATCkuVg0O573ZrH56BUawTECPETbZyBcqT8=
|
||||
github.com/anchore/go-logger v0.0.0-20241005132348-65b4486fbb28 h1:TKlTOayTJKpoLPJbeMykEwxCn0enACf06u0RSIdFG5w=
|
||||
github.com/anchore/go-logger v0.0.0-20241005132348-65b4486fbb28/go.mod h1:5iJIa34inbIEFRwoWxNBTnjzIcl4G3le1LppPDmpg/4=
|
||||
github.com/anchore/go-logger v0.0.0-20241205183533-4fc29b5832e7 h1:H6XDQQrAT6jMsr4k0uH+bD+zza7N0K21Mfywo1H0uWM=
|
||||
github.com/anchore/go-logger v0.0.0-20241205183533-4fc29b5832e7/go.mod h1:L2TJz+/eN3eOWbHiMXGddj5eRNX48XruxWVgap0bqJ0=
|
||||
github.com/anchore/go-macholibre v0.0.0-20241029130037-f2cd2ff1a192 h1:BSmVIbiUSS9j7YyZKe7095krnhgIpIBcas50Rk1lf5E=
|
||||
github.com/anchore/go-macholibre v0.0.0-20241029130037-f2cd2ff1a192/go.mod h1:Eo8ljGv2RLMmToXXFhfPHX1h8La2hpzHA7fBXAZUfpg=
|
||||
github.com/anchore/go-macholibre v0.0.0-20241219195549-70b0e607b241 h1:MyZM9WIeCynOs1W9DQ7J/KDMoxYlxNwvRVhirkJzULY=
|
||||
github.com/anchore/go-macholibre v0.0.0-20241219195549-70b0e607b241/go.mod h1:Eo8ljGv2RLMmToXXFhfPHX1h8La2hpzHA7fBXAZUfpg=
|
||||
github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092/go.mod h1:rYqSE9HbjzpHTI74vwPvae4ZVYZd1lue2ta6xHPdblA=
|
||||
@ -151,16 +134,11 @@ github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04 h1:VzprUTpc0v
|
||||
github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04/go.mod h1:6dK64g27Qi1qGQZ67gFmBFvEHScy0/C8qhQhNe5B5pQ=
|
||||
github.com/anchore/packageurl-go v0.1.1-0.20241018175412-5c22e6360c4f h1:dAQPIrQ3a5PBqZeZ+B9NGZsGmodk4NO9OjDIsQmQyQM=
|
||||
github.com/anchore/packageurl-go v0.1.1-0.20241018175412-5c22e6360c4f/go.mod h1:KoYIv7tdP5+CC9VGkeZV4/vGCKsY55VvoG+5dadg4YI=
|
||||
github.com/anchore/stereoscope v0.0.8 h1:ma8A7SnM5WWU0HJ2p6YBq7myN7zKa0JnUQOY/4enekk=
|
||||
github.com/anchore/stereoscope v0.0.8/go.mod h1:o1eDg6BZwORU6nh4vRe3C2ZmAmmH+MWRLNl55uAF/v8=
|
||||
github.com/anchore/stereoscope v0.0.12 h1:ovUWeyeZGml6pTGiu/uha/rCbToANFPu+cnhLbeperY=
|
||||
github.com/anchore/stereoscope v0.0.12/go.mod h1:cmb/MGya7ccOd6fZZEREuhdSH2kFALBMrkY/66Sfv1o=
|
||||
github.com/anchore/syft v1.16.0 h1:iHPqE2q7gmvRDdmh5/897ycRbetfmLwor17/YBNVQNw=
|
||||
github.com/anchore/syft v1.16.0/go.mod h1:x8JNItb+Dj3xwG1tRfyCbJj9Xl/vlcBfXz7q3M2GmjA=
|
||||
github.com/anchore/syft v1.18.1 h1:JZ7CLbeWrWolCZa4f6SJBLJ9qGBLFCzHrFd8c4bsm94=
|
||||
github.com/anchore/syft v1.18.1/go.mod h1:ufXPZcjmoTjERaC0HTEW2+chF+fQdryhaQ9arcUO2WQ=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
|
||||
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
@ -187,21 +165,15 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
||||
github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0CXv75Q=
|
||||
github.com/bmatcuk/doublestar/v4 v4.7.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
||||
github.com/bmatcuk/doublestar/v4 v4.8.0 h1:DSXtrypQddoug1459viM9X9D3dp1Z7993fw36I2kNcQ=
|
||||
github.com/bmatcuk/doublestar/v4 v4.8.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
||||
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
|
||||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||
github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M=
|
||||
github.com/bradleyjkemp/cupaloy/v2 v2.8.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0=
|
||||
github.com/bytedance/sonic v1.12.4 h1:9Csb3c9ZJhfUWeMtpCDCq6BUoH5ogfDFLUgQ/jG+R0k=
|
||||
github.com/bytedance/sonic v1.12.4/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
|
||||
github.com/bytedance/sonic v1.12.7 h1:CQU8pxOy9HToxhndH0Kx/S1qU/CuS9GnKYrGioDcU1Q=
|
||||
github.com/bytedance/sonic v1.12.7/go.mod h1:tnbal4mxOMju17EGfknm2XyYcpyCnIROYOEYuemj13I=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E=
|
||||
github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.3 h1:yctD0Q3v2NOGfSWPLPvG2ggA2kV6TS6s4wioyEqssH0=
|
||||
github.com/bytedance/sonic/loader v0.2.3/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c h1:HIGF0r/56+7fuIZw2V4isE22MK6xpxWx7BbV8dJ290w=
|
||||
@ -212,7 +184,6 @@ github.com/cayleygraph/quad v1.3.0 h1:xg7HOLWWPgvZ4CcvzEpfCwq42L8mzYUR+8V0jtYoBz
|
||||
github.com/cayleygraph/quad v1.3.0/go.mod h1:NadtM7uMm78FskmX++XiOOrNvgkq0E1KvvhQdMseMz4=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
@ -238,11 +209,8 @@ github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys=
|
||||
github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
@ -258,9 +226,8 @@ github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 h1:QVw89YDxXxEe+l8gU8E
|
||||
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
|
||||
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
|
||||
github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw=
|
||||
github.com/containerd/containerd v1.7.23 h1:H2CClyUkmpKAGlhQp95g2WXHfLYc7whAuvZGBNYOOwQ=
|
||||
github.com/containerd/containerd v1.7.23/go.mod h1:7QUzfURqZWCZV7RLNEn1XjUCQLEf0bkaK4GjUaZehxw=
|
||||
github.com/containerd/containerd v1.7.24 h1:zxszGrGjrra1yYJW/6rhm9cJ1ZQ8rkKBR48brqsa7nA=
|
||||
github.com/containerd/containerd v1.7.24/go.mod h1:7QUzfURqZWCZV7RLNEn1XjUCQLEf0bkaK4GjUaZehxw=
|
||||
github.com/containerd/containerd/api v1.7.19 h1:VWbJL+8Ap4Ju2mx9c9qS1uFSB1OVYr5JJrW2yT5vFoA=
|
||||
github.com/containerd/containerd/api v1.7.19/go.mod h1:fwGavl3LNwAV5ilJ0sbrABL44AQxmNjDRcwheXDb6Ig=
|
||||
github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8=
|
||||
@ -273,9 +240,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
||||
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
|
||||
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G/ZW/0kEe2oEKCdS/ZxIyoCU=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.16.3 h1:7evrXtoh1mSbGj/pfRccTampEyKpjpOnS3CyiV1Ebr8=
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.16.3/go.mod h1:uyr4BfYfOj3G9WBVE8cOlQmXAbPN9VEQpBBeJIuOipU=
|
||||
github.com/containerd/ttrpc v1.2.5 h1:IFckT1EFQoFBMG4c3sMdT8EP3/aKfumK1msY+Ze4oLU=
|
||||
github.com/containerd/ttrpc v1.2.5/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
|
||||
github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4=
|
||||
@ -301,15 +267,12 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
|
||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
|
||||
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/docker/cli v27.3.1+incompatible h1:qEGdFBF3Xu6SCvCYhc7CzaQTlBmqDuzxPDpigSyeKQQ=
|
||||
github.com/docker/cli v27.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/cli v27.5.0+incompatible h1:aMphQkcGtpHixwwhAXJT1rrK/detk2JIvDaFkLctbGM=
|
||||
github.com/docker/cli v27.5.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI=
|
||||
github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v27.5.0+incompatible h1:um++2NcQtGRTz5eEgO6aJimo6/JxrTXC941hd05JO6U=
|
||||
github.com/docker/docker v27.5.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
|
||||
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
|
||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||
@ -318,8 +281,6 @@ github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ
|
||||
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/dop251/goja v0.0.0-20241024094426-79f3a7efcdbd h1:QMSNEh9uQkDjyPwu/J541GgSH+4hw+0skJDIj9HJ3mE=
|
||||
github.com/dop251/goja v0.0.0-20241024094426-79f3a7efcdbd/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
|
||||
github.com/dop251/goja v0.0.0-20250114131315-46d383d606d3 h1:xPoFl7UDOasFiReIaL75lqkKTgIRMKBvfOyiZfq9s3Q=
|
||||
github.com/dop251/goja v0.0.0-20250114131315-46d383d606d3/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
|
||||
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY=
|
||||
@ -334,8 +295,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ=
|
||||
github.com/envoyproxy/go-control-plane v0.13.0 h1:HzkeUz1Knt+3bK+8LG1bxOO/jzWZmdxpwC51i202les=
|
||||
github.com/envoyproxy/go-control-plane v0.13.0/go.mod h1:GRaKG3dwvFoTg4nj7aXdZnvMg4d7nvT/wl9WgVXn3Q8=
|
||||
github.com/envoyproxy/go-control-plane v0.13.1 h1:vPfJZCkob6yTMEgS+0TwfTUfbHjfy/6vOJ8hUWX/uXE=
|
||||
github.com/envoyproxy/go-control-plane v0.13.1/go.mod h1:X45hY0mufo6Fd0KW3rqsGvQMw58jvjymeCzBU3mWyHw=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM=
|
||||
@ -364,13 +325,9 @@ github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7z
|
||||
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
|
||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
|
||||
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
@ -397,14 +354,14 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o=
|
||||
github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg=
|
||||
github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
|
||||
github.com/go-restruct/restruct v1.2.0-alpha h1:2Lp474S/9660+SJjpVxoKuWX09JsXHSrdV7Nv3/gkvc=
|
||||
@ -420,8 +377,6 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA
|
||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
|
||||
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
|
||||
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
|
||||
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
@ -441,8 +396,9 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
@ -471,18 +427,13 @@ github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomarkdown/markdown v0.0.0-20241105142532-d03b89096d81 h1:5lyLWsV+qCkoYqsKUDuycESh9DEIPVKN6iCFeL7ag50=
|
||||
github.com/gomarkdown/markdown v0.0.0-20241105142532-d03b89096d81/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
|
||||
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62 h1:pbAFUZisjG4s6sxvRJvf2N7vhpCvx2Oxb3PmS6pDO1g=
|
||||
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/cel-go v0.22.0 h1:b3FJZxpiv1vTMo2/5RDUqAHPxkT8mmMfJIrq1llbf7g=
|
||||
github.com/google/cel-go v0.22.0/go.mod h1:BuznPXXfQDpXKWQ9sPW3TzlAJN5zzFe+i9tIs0yC4s8=
|
||||
github.com/google/cel-go v0.22.1 h1:AfVXx3chM2qwoSbM7Da8g8hX8OVSkBFwX+rz2+PcK40=
|
||||
github.com/google/cel-go v0.22.1/go.mod h1:BuznPXXfQDpXKWQ9sPW3TzlAJN5zzFe+i9tIs0yC4s8=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
@ -500,8 +451,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-containerregistry v0.20.2 h1:B1wPJ1SN/S7pB+ZAimcciVD+r+yV/l/DSArMxlbwseo=
|
||||
github.com/google/go-containerregistry v0.20.2/go.mod h1:z38EKdKh4h7IP2gSfUUqEvalZBqs6AoLeWfUy34nQC8=
|
||||
github.com/google/go-containerregistry v0.20.3 h1:oNx7IdTI936V8CQRveCjaxOiegWwvM7kqkbXTpyiovI=
|
||||
github.com/google/go-containerregistry v0.20.3/go.mod h1:w00pIgBRDVUDFM6bq+Qx8lwNWK+cxgCuX1vd3PIBDNI=
|
||||
github.com/google/go-github/v54 v54.0.0 h1:OZdXwow4EAD5jEo5qg+dGFH2DpkyZvVsAehjvJuUL/c=
|
||||
@ -515,8 +464,6 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk=
|
||||
github.com/google/osv-scanner v1.9.1 h1:L/j81YXO+DuhBd+v2eYwpDTfmUpMLryItSv7SXA1Db4=
|
||||
github.com/google/osv-scanner v1.9.1/go.mod h1:VNJG6+N9l6Y1dcaGgK/a7D4g9hnxakn0DBKGH0Aw+mQ=
|
||||
github.com/google/osv-scanner v1.9.2 h1:N5Arl9SA75afbjmX8mKURgOIaKyuK3NUjCaxDlj1KHI=
|
||||
github.com/google/osv-scanner v1.9.2/go.mod h1:ZTL8Dp9z/7Jr9kkQSOGqo8z6Csqt83qMIr58aZVx+pM=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
@ -535,8 +482,6 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
|
||||
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
|
||||
github.com/google/pprof v0.0.0-20241101162523-b92577c0c142 h1:sAGdeJj0bnMgUNVeUpp6AYlVdCt3/GdI3pGRqsNSQLs=
|
||||
github.com/google/pprof v0.0.0-20241101162523-b92577c0c142/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
|
||||
github.com/google/pprof v0.0.0-20250121033306-997b0b79cac0 h1:EinjE47mmVVsxcjIwVKQWNY+3P+5R2BhkbULjhEDThc=
|
||||
github.com/google/pprof v0.0.0-20250121033306-997b0b79cac0/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
@ -617,8 +562,6 @@ github.com/iris-contrib/httpexpect/v2 v2.15.2 h1:T9THsdP1woyAqKHwjkEsbCnMefsAFvk
|
||||
github.com/iris-contrib/httpexpect/v2 v2.15.2/go.mod h1:JLDgIqnFy5loDSUv1OA2j0mb6p/rDhiCqigP22Uq9xE=
|
||||
github.com/iris-contrib/schema v0.0.6 h1:CPSBLyx2e91H2yJzPuhGuifVRnZBBJ3pCOMbOvPZaTw=
|
||||
github.com/iris-contrib/schema v0.0.6/go.mod h1:iYszG0IOsuIsfzjymw1kMzTL8YQcCWlm65f3wX8J5iA=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.1 h1:iJ65Xjb680rHcikRj6DSIbzCex2huitmc7bDtxYVWyc=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.1/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3NgSqAo=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs=
|
||||
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
|
||||
@ -636,8 +579,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kataras/blocks v0.0.8 h1:MrpVhoFTCR2v1iOOfGng5VJSILKeZZI+7NGfxEh3SUM=
|
||||
github.com/kataras/blocks v0.0.8/go.mod h1:9Jm5zx6BB+06NwA+OhTbHW1xkMOYxahnqTN5DveZ2Yg=
|
||||
github.com/kataras/blocks v0.0.11 h1:JJdYW0AUaJKLx5kEWs/oRVCvKVXo+6CAAeaVAiJf7wE=
|
||||
github.com/kataras/blocks v0.0.11/go.mod h1:b4UySrJySEOq6drKH9U3bOpMI+dRH148mayYfS3RFb8=
|
||||
github.com/kataras/golog v0.1.12 h1:Bu7I/G4ilJlbfzjmU39O9N+2uO1pBcMK045fzZ4ytNg=
|
||||
@ -655,14 +596,12 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:C
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
|
||||
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
|
||||
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
@ -679,8 +618,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kubescape/go-git-url v0.0.30 h1:PIbg86ae0ftee/p/Tu/6CA1ju6VoJ51G3sQWNHOm6wg=
|
||||
github.com/kubescape/go-git-url v0.0.30/go.mod h1:3ddc1HEflms1vMhD9owt/3FBES070UaYTUarcjx8jDk=
|
||||
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
|
||||
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
|
||||
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
||||
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
|
||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||
@ -692,13 +629,10 @@ github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczG
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w=
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
|
||||
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mailgun/raymond/v2 v2.0.48 h1:5dmlB680ZkFG2RN/0lvTAghrSxIESeu9/2aeDqACtjw=
|
||||
github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
||||
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||
@ -710,8 +644,6 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
@ -720,17 +652,16 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo=
|
||||
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
|
||||
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
@ -774,7 +705,6 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
||||
github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc=
|
||||
github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
||||
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
|
||||
@ -789,7 +719,6 @@ github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaL
|
||||
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
|
||||
github.com/owenrumney/go-sarif v1.1.1 h1:QNObu6YX1igyFKhdzd7vgzmw7XsWN3/6NMGuDzBgXmE=
|
||||
github.com/owenrumney/go-sarif v1.1.1/go.mod h1:dNDiPlF04ESR/6fHlPyq7gHKmrM0sHUvAGjsoh8ZH0U=
|
||||
github.com/owenrumney/go-sarif/v2 v2.3.3 h1:ubWDJcF5i3L/EIOER+ZyQ03IfplbSU1BLOE26uKQIIU=
|
||||
github.com/owenrumney/go-sarif/v2 v2.3.3/go.mod h1:MSqMMx9WqlBSY7pXoOZWgEsVB4FDNfhcaXDA1j6Sr+w=
|
||||
@ -807,9 +736,6 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v
|
||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||
github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
|
||||
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/piprate/json-gold v0.5.0 h1:RmGh1PYboCFcchVFuh2pbSWAZy4XJaqTMU4KQYsApbM=
|
||||
@ -843,8 +769,6 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
|
||||
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
@ -861,18 +785,16 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/safedep/dry v0.0.0-20241128083908-2f8ecd48dc2c h1:qUSfzPPlEcLKF6cKvkkXU6ddu4NGSz0UdS7Xjcrenvw=
|
||||
github.com/safedep/dry v0.0.0-20241128083908-2f8ecd48dc2c/go.mod h1:dtGFDAnRo+WqwEyqPc2hTwuVGwWLq2jHnP4Q8BO1u7g=
|
||||
github.com/safedep/code v0.0.0-20250129053905-bde6512236a6 h1:BDVlc8NTVurERomvVXl+Uz/9t3epQAO4bnBhz8VggWI=
|
||||
github.com/safedep/code v0.0.0-20250129053905-bde6512236a6/go.mod h1:oZJ1skQ0nAnqneDMbSN08IM1tl8DKRGD57fEaSXpyuQ=
|
||||
github.com/safedep/dry v0.0.0-20250106055453-e0772cda4a25 h1:vkW9YyId5WHPnnGhnrmucKL53xTNUE8mBLBdmTBOGBc=
|
||||
github.com/safedep/dry v0.0.0-20250106055453-e0772cda4a25/go.mod h1:VNiIEzsaDJUncMyS+Aly7Hojf3qYNAz+J6Kmi0DALFw=
|
||||
github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig=
|
||||
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
|
||||
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
|
||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||
@ -909,13 +831,9 @@ github.com/spdx/tools-golang v0.5.5 h1:61c0KLfAcNqAjlg6UNMdkwpMernhw3zVRwDZ2x9XO
|
||||
github.com/spdx/tools-golang v0.5.5/go.mod h1:MVIsXx8ZZzaRWNQpUDhC4Dud34edUYJYecciXgrw5vE=
|
||||
github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
|
||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
|
||||
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
|
||||
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
|
||||
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
||||
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
|
||||
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4=
|
||||
@ -947,22 +865,16 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/sylabs/sif/v2 v2.19.2 h1:KKcUKnbnT69rN1WWHRYoAVKFpqnXpNJ36kmQLpp86Uc=
|
||||
github.com/sylabs/sif/v2 v2.19.2/go.mod h1:nhX6D/CJntHDWspNLXLe+yct0cd5lm8HJ7VIW6hgKrw=
|
||||
github.com/sylabs/sif/v2 v2.20.2 h1:HGEPzauCHhIosw5o6xmT3jczuKEuaFzSfdjAsH33vYw=
|
||||
github.com/sylabs/squashfs v1.0.0 h1:xAyMS21ogglkuR5HaY55PCfqY3H32ma9GkasTYo28Zg=
|
||||
github.com/sylabs/squashfs v1.0.0/go.mod h1:rhWzvgefq1X+R+LZdts10hfMsTg3g74OfGunW8tvg/4=
|
||||
github.com/sylabs/sif/v2 v2.20.2/go.mod h1:WyYryGRaR4Wp21SAymm5pK0p45qzZCSRiZMFvUZiuhc=
|
||||
github.com/sylabs/squashfs v1.0.4 h1:uFSw7WXv7zjutPvU+JzY0nY494Vw8s4FAf4+7DhoMdI=
|
||||
github.com/sylabs/squashfs v1.0.4/go.mod h1:PDgf8YmCntvN4d9Y8hBUBDCZL6qZOzOQwRGxnIdbERk=
|
||||
github.com/tdewolff/minify/v2 v2.21.1 h1:AAf5iltw6+KlUvjRNPAPrANIXl3XEJNBBzuZom5iCAM=
|
||||
github.com/tdewolff/minify/v2 v2.21.1/go.mod h1:PoqFH8ugcuTUvKqVM9vOqXw4msxvuhL/DTmV5ZXhSCI=
|
||||
github.com/tdewolff/minify/v2 v2.21.3 h1:KmhKNGrN/dGcvb2WDdB5yA49bo37s+hcD8RiF+lioV8=
|
||||
github.com/tdewolff/minify/v2 v2.21.3/go.mod h1:iGxHaGiONAnsYuo8CRyf8iPUcqRJVB/RhtEcTpqS7xw=
|
||||
github.com/tdewolff/parse/v2 v2.7.19 h1:7Ljh26yj+gdLFEq/7q9LT4SYyKtwQX4ocNrj45UCePg=
|
||||
@ -970,9 +882,8 @@ github.com/tdewolff/parse/v2 v2.7.19/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W
|
||||
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo=
|
||||
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
|
||||
github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo=
|
||||
github.com/terminalstatic/go-xsd-validate v0.1.5/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw=
|
||||
github.com/terminalstatic/go-xsd-validate v0.1.6 h1:TenYeQ3eY631qNi1/cTmLH/s2slHPRKTTHT+XSHkepo=
|
||||
github.com/terminalstatic/go-xsd-validate v0.1.6/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw=
|
||||
github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw=
|
||||
github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
@ -991,16 +902,14 @@ github.com/tylertreat/BoomFilters v0.0.0-20210315201527-1a82519a3e43/go.mod h1:O
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
|
||||
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
|
||||
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
|
||||
github.com/vbatts/tar-split v0.11.6 h1:4SjTW5+PU11n6fZenf2IPoV8/tz3AaYHMWjf23envGs=
|
||||
github.com/vbatts/tar-split v0.11.6/go.mod h1:dqKNtesIOr2j2Qv3W/cHjnvk9I8+G7oAkFDFN6TCBEI=
|
||||
github.com/vifraa/gopom v1.0.0 h1:L9XlKbyvid8PAIK8nr0lihMApJQg/12OBvMA28BcWh0=
|
||||
github.com/vifraa/gopom v1.0.0/go.mod h1:oPa1dcrGrtlO37WPDBm5SqHAT+wTgF8An1Q71Z6Vv4o=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
||||
@ -1041,8 +950,6 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
||||
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
|
||||
github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||
github.com/zclconf/go-cty v1.16.1 h1:a5TZEPzBFFR53udlIKApXzj8JIF4ZNQ6abH79z5R1S0=
|
||||
github.com/zclconf/go-cty v1.16.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
|
||||
@ -1061,22 +968,18 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0 h1:qtFISDHKolvIxzSs0gIaiPUPR0Cucb0F2coHC7ZLdps=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0/go.mod h1:Y+Pop1Q6hCOnETWTW4NROK/q1hv50hM7yDaUTjG8lp8=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 h1:rgMkmiGfix9vFJDcDi1PK8WEQP4FLQwLDfhp5ZLpFeE=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0/go.mod h1:ijPqXp5P6IRRByFVVg9DY8P5HkxkHE5ARIa+86aXPf4=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
|
||||
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
|
||||
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 h1:yd02MEjBdJkG3uabWP9apV+OuWRIXGDuJEUJbOHmCFU=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0/go.mod h1:umTcuxiv1n/s/S6/c2AT/g2CQ7u5C59sHDNmfSwgz7Q=
|
||||
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
|
||||
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
|
||||
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
|
||||
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
|
||||
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
|
||||
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
|
||||
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
|
||||
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
|
||||
go.opentelemetry.io/otel/sdk v1.33.0 h1:iax7M131HuAm9QkZotNHEfstof92xM+N8sr3uHXc2IM=
|
||||
go.opentelemetry.io/otel/sdk v1.33.0/go.mod h1:A1Q5oi7/9XaMlIWzPSxLRWOI8nG3FnzHJNbiENQuihM=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ=
|
||||
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
|
||||
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
@ -1091,8 +994,6 @@ go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/arch v0.12.0 h1:UsYJhbzPYGsT0HbEdmYcqtCv8UNGvnaL561NnIUvaKg=
|
||||
golang.org/x/arch v0.12.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/arch v0.13.0 h1:KCkqVVV1kGg0X87TFysjCJ8MxtZEIU4Ja/yXGeoECdA=
|
||||
golang.org/x/arch v0.13.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
@ -1106,8 +1007,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@ -1120,8 +1019,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
|
||||
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
|
||||
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
@ -1198,8 +1095,6 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -1219,8 +1114,6 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ
|
||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
|
||||
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
|
||||
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -1308,16 +1201,11 @@ golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -1335,8 +1223,6 @@ golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
|
||||
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
|
||||
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
@ -1397,8 +1283,6 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
|
||||
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
|
||||
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
|
||||
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -1508,14 +1392,10 @@ google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ6
|
||||
google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y=
|
||||
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f h1:M65LEviCfuZTfrfzwwEoxVtgvfkFkBUbFnRbxCXuXhU=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f/go.mod h1:Yo94eF2nj7igQt+TiJ49KxjIH8ndLYPZMIRSiRcEbg0=
|
||||
google.golang.org/genproto v0.0.0-20241202173237-19429a94021a h1:4voejwOVTsjw6IMfnGt8IzTQBIw45hP8S0e77UMounA=
|
||||
google.golang.org/genproto v0.0.0-20241202173237-19429a94021a/go.mod h1:dW27OyXi0Ph+N43jeCWMFC86aTT5VgdeQtOSf0Hehdw=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f h1:gap6+3Gk41EItBuyi4XX/bp4oqJ3UwuIMl25yGinuAA=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:Ic02D47M+zbarjYYUlK57y316f2MoN0gjAwI3f2S95o=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f h1:C1QccEa9kUwvMgEUORqQD9S17QesQijxjZ84sO82mfo=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
@ -1545,8 +1425,6 @@ google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD
|
||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
|
||||
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
|
||||
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
|
||||
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
@ -1563,8 +1441,6 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU=
|
||||
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
|
||||
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
@ -1602,8 +1478,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 h1:jGnCPejIetjiy2gqaJ5V0NLwTpF4wbQ6cZIItJCSHno=
|
||||
k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0=
|
||||
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
moul.io/http2curl/v2 v2.3.0 h1:9r3JfDzWPcbIklMOs2TnIFzDYvfAZvjeavG6EzP7jYs=
|
||||
|
||||
1
main.go
1
main.go
@ -56,7 +56,6 @@ func main() {
|
||||
cmd.AddCommand(newAuthCommand())
|
||||
cmd.AddCommand(newScanCommand())
|
||||
cmd.AddCommand(newQueryCommand())
|
||||
cmd.AddCommand(newCodeCommand())
|
||||
cmd.AddCommand(newVersionCommand())
|
||||
cmd.AddCommand(newConnectCommand())
|
||||
cmd.AddCommand(cloud.NewCloudCommand())
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
package code
|
||||
|
||||
// Things that we can do
|
||||
// 1. Prune unused direct dependencies based on code usage
|
||||
// 2. Find places in 1P code where a vulnerable library is imported
|
||||
// 3. Find places in 1P code where a call to a vulnerable function is made
|
||||
// 4. Find path from 1P code to a vulnerable function in direct or transitive dependencies
|
||||
// 5. Find path from 1P code to a vulnerable library in direct or transitive dependencies
|
||||
|
||||
// Primitives that we need
|
||||
// 1. Source code parsing
|
||||
// 2. Import resolution to local 1P code or imported files in 3P code
|
||||
// 3. Graph datastructure to represent a function call graph across 1P and 3P code
|
||||
// 4. Graph datastructure to represent a file import graph across 1P and 3P code
|
||||
//
|
||||
// Source code parsing should provide
|
||||
// 1. Enumerate imported 3P code
|
||||
// 2. Enumerate functions in the source code
|
||||
// 3. Enumerate function calls to 1P or 3P code
|
||||
//
|
||||
// Code Property Graph (CPG), stitching 1P and 3P code
|
||||
// into a queryable graph datastructure for analyzers having
|
||||
//
|
||||
// Future enhancements should include ability to enrich function nodes
|
||||
// with meta information such as contributors, last modified time, use-case tags etc.
|
||||
|
||||
// CONCEPTS used in building the framework
|
||||
// 1. Source: Used to represent a mechanism to find and enumerate source files
|
||||
// 2. Language: Used to represent the domain of programming languages
|
||||
// 3. Node: Used to represent an in-memory representation of a node in an AST / CST
|
||||
// 4. Entity: Used to represent a node that can be persisted in a property graph (analysis and query domain)
|
||||
@ -1,364 +0,0 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/safedep/vet/pkg/code/entities"
|
||||
"github.com/safedep/vet/pkg/code/nodes"
|
||||
"github.com/safedep/vet/pkg/common/logger"
|
||||
"github.com/safedep/vet/pkg/storage/graph"
|
||||
)
|
||||
|
||||
type CodeGraphBuilderConfig struct {
|
||||
// Resolve imports to file and load them
|
||||
RecursiveImport bool
|
||||
|
||||
// Code analyser concurrency
|
||||
Concurrency int
|
||||
}
|
||||
|
||||
type CodeGraphBuilderMetrics struct {
|
||||
GoRoutineCount int
|
||||
ErrorCount int
|
||||
FilesProcessed int
|
||||
FilesInQueue int
|
||||
ImportsCount int
|
||||
FunctionsCount int
|
||||
}
|
||||
|
||||
type CodeGraphBuilderEvent struct {
|
||||
Kind string
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
const (
|
||||
CodeGraphBuilderEventFileQueued = "file_queued"
|
||||
CodeGraphBuilderEventFileProcessed = "file_processed"
|
||||
CodeGraphBuilderEventImportProcessed = "import_processed"
|
||||
CodeGraphBuilderEventFunctionProcessed = "function_processed"
|
||||
)
|
||||
|
||||
// The event handler is invoked from its own go routine. Handler functions
|
||||
// must be thread safe.
|
||||
type CodeGraphBuilderEventHandler func(CodeGraphBuilderEvent, CodeGraphBuilderMetrics) error
|
||||
|
||||
type codeGraphBuilder struct {
|
||||
config CodeGraphBuilderConfig
|
||||
eventHandlers map[string]CodeGraphBuilderEventHandler
|
||||
metrics CodeGraphBuilderMetrics
|
||||
|
||||
repository SourceRepository
|
||||
lang SourceLanguage
|
||||
storage graph.Graph
|
||||
|
||||
// Queue for processing files
|
||||
fileQueue chan SourceFile
|
||||
fileQueueWg *sync.WaitGroup
|
||||
fileQueueLock *sync.Mutex
|
||||
|
||||
fileCache map[string]bool
|
||||
functionDeclCache map[string]string
|
||||
functionCallCache map[string]string
|
||||
}
|
||||
|
||||
func NewCodeGraphBuilder(config CodeGraphBuilderConfig,
|
||||
repository SourceRepository,
|
||||
lang SourceLanguage,
|
||||
storage graph.Graph) (*codeGraphBuilder, error) {
|
||||
// Concurrency will cause issues with the the common cache
|
||||
if config.Concurrency <= 0 {
|
||||
config.Concurrency = 1
|
||||
}
|
||||
|
||||
return &codeGraphBuilder{
|
||||
config: config,
|
||||
repository: repository,
|
||||
lang: lang,
|
||||
storage: storage,
|
||||
eventHandlers: make(map[string]CodeGraphBuilderEventHandler, 0),
|
||||
metrics: CodeGraphBuilderMetrics{GoRoutineCount: config.Concurrency},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) RegisterEventHandler(name string, handler CodeGraphBuilderEventHandler) {
|
||||
if _, ok := b.eventHandlers[name]; ok {
|
||||
logger.Warnf("Event handler already registered: %s", name)
|
||||
return
|
||||
}
|
||||
|
||||
b.eventHandlers[name] = handler
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) Build() error {
|
||||
// Reinitialize the file queue if needed
|
||||
if b.fileQueue != nil {
|
||||
close(b.fileQueue)
|
||||
}
|
||||
|
||||
b.fileQueue = make(chan SourceFile, 10000)
|
||||
b.fileQueueWg = &sync.WaitGroup{}
|
||||
b.fileQueueLock = &sync.Mutex{}
|
||||
|
||||
b.fileCache = make(map[string]bool)
|
||||
b.functionDeclCache = make(map[string]string)
|
||||
b.functionCallCache = make(map[string]string)
|
||||
|
||||
logger.Debugf("Building code graph using repository: %s", b.repository.Name())
|
||||
|
||||
for i := 0; i < b.config.Concurrency; i++ {
|
||||
go b.fileProcessor(b.fileQueueWg)
|
||||
}
|
||||
|
||||
err := b.repository.EnumerateSourceFiles(func(file SourceFile) error {
|
||||
b.enqueueSourceFile(file)
|
||||
return nil
|
||||
})
|
||||
|
||||
b.fileQueueWg.Wait()
|
||||
|
||||
close(b.fileQueue)
|
||||
b.fileQueue = nil
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) enqueueSourceFile(file SourceFile) {
|
||||
b.synchronized(func() {
|
||||
b.metrics.FilesInQueue++
|
||||
|
||||
if _, ok := b.fileCache[file.Path]; ok {
|
||||
logger.Debugf("Skipping already processed file: %s", file.Path)
|
||||
return
|
||||
}
|
||||
|
||||
b.fileQueueWg.Add(1)
|
||||
b.fileQueue <- file
|
||||
|
||||
// TODO: Optimize this. Storing entire file path is not needed
|
||||
b.fileCache[file.Path] = true
|
||||
})
|
||||
|
||||
b.notifyEventHandlers(CodeGraphBuilderEvent{
|
||||
Kind: CodeGraphBuilderEventFileQueued,
|
||||
Data: file,
|
||||
}, b.metrics)
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) fileProcessor(wg *sync.WaitGroup) {
|
||||
for file := range b.fileQueue {
|
||||
err := b.buildForFile(file)
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to process code graph for: %s: %v", file.Path, err)
|
||||
|
||||
b.synchronized(func() {
|
||||
b.metrics.ErrorCount++
|
||||
})
|
||||
}
|
||||
|
||||
wg.Done()
|
||||
|
||||
b.synchronized(func() {
|
||||
b.metrics.FilesProcessed++
|
||||
})
|
||||
|
||||
b.notifyEventHandlers(CodeGraphBuilderEvent{
|
||||
Kind: CodeGraphBuilderEventFileProcessed,
|
||||
Data: file,
|
||||
}, b.metrics)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) buildForFile(file SourceFile) error {
|
||||
logger.Debugf("Parsing source file: %s", file.Path)
|
||||
|
||||
cst, err := b.lang.ParseSource(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer cst.Close()
|
||||
|
||||
b.processSourceFileNode(file)
|
||||
b.processImportNodes(cst, file)
|
||||
b.processFunctionDeclarations(cst, file)
|
||||
b.processFunctionCalls(cst, file)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) processSourceFileNode(file SourceFile) {
|
||||
// What?
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) processImportNodes(cst *nodes.CST, currentFile SourceFile) {
|
||||
// Get the module name for the source file we are processing
|
||||
// This serves as the current node in the graph
|
||||
currentModuleName, err := LangMapFileToModule(currentFile, b.repository, b.lang, b.useImports())
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to map file to module: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
thisNode := b.buildPackageNode(currentModuleName,
|
||||
currentModuleName, currentFile.Path, b.importSourceName(currentFile))
|
||||
|
||||
importNodes, err := b.lang.GetImportNodes(cst)
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to get import nodes: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, importNode := range importNodes {
|
||||
logger.Debugf("Processing import node: %s", importNode.ImportName())
|
||||
|
||||
// Try to resolve the imported package to file for further processing
|
||||
sourceFile, err := LangMapModuleToFile(importNode.ImportName(), currentFile,
|
||||
b.repository, b.lang, b.useImports())
|
||||
if err != nil {
|
||||
logger.Warnf("Failed to map import node: '%s' to file: %v", importNode.ImportName(), err)
|
||||
} else {
|
||||
logger.Debugf("Import node: %s resolved to path: %s",
|
||||
importNode.ImportName(), sourceFile.Path)
|
||||
|
||||
if b.useImports() {
|
||||
b.enqueueSourceFile(sourceFile)
|
||||
}
|
||||
}
|
||||
|
||||
// Import name may be current file relative in which case we fix it up
|
||||
// to appropriate module name to avoid duplicate nodes in the graph
|
||||
importNodeName := importNode.ImportName()
|
||||
if len(sourceFile.Path) > 0 {
|
||||
fixedImportName, err := LangMapFileToModule(sourceFile, b.repository, b.lang, b.useImports())
|
||||
if err != nil {
|
||||
logger.Errorf("[Import Fixing]: Failed to map file to module: %v", err)
|
||||
return
|
||||
} else {
|
||||
importNodeName = fixedImportName
|
||||
}
|
||||
}
|
||||
|
||||
// Finally add the imported package node to the graph
|
||||
importedPkgNode := b.buildPackageNode(importNodeName, importNodeName,
|
||||
sourceFile.Path, b.importSourceName(sourceFile))
|
||||
|
||||
err = b.storage.Link(thisNode.Imports(&importedPkgNode))
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to link import node: %v", err)
|
||||
}
|
||||
|
||||
b.synchronized(func() {
|
||||
b.metrics.ImportsCount++
|
||||
})
|
||||
|
||||
b.notifyEventHandlers(CodeGraphBuilderEvent{
|
||||
Kind: CodeGraphBuilderEventImportProcessed,
|
||||
Data: importNode.ImportName(),
|
||||
}, b.metrics)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) processFunctionDeclarations(cst *nodes.CST, currentFile SourceFile) {
|
||||
moduleName, err := LangMapFileToModule(currentFile, b.repository, b.lang, b.useImports())
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to map file to module: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
functionDecls, err := b.lang.GetFunctionDeclarationNodes(cst)
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to get function declaration nodes: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
thisNode := b.buildPackageNode(moduleName, moduleName,
|
||||
currentFile.Path, b.importSourceName(currentFile))
|
||||
|
||||
for _, functionDecl := range functionDecls {
|
||||
if fid, ok := b.functionDeclCache[moduleName]; ok {
|
||||
if fid == functionDecl.Id() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debugf("Processing function declaration: %s/%s",
|
||||
moduleName,
|
||||
functionDecl.Id())
|
||||
|
||||
fnNode := entities.FunctionDecl{
|
||||
Id: functionDecl.Id(),
|
||||
SourceFilePath: currentFile.Path,
|
||||
SourceFileType: b.importSourceName(currentFile),
|
||||
FunctionName: functionDecl.Name(),
|
||||
ContainerName: functionDecl.Container(),
|
||||
}
|
||||
|
||||
err = b.storage.Link(thisNode.DeclaresFunction(&fnNode))
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to link function declaration: %v", err)
|
||||
}
|
||||
|
||||
b.synchronized(func() {
|
||||
b.metrics.FunctionsCount++
|
||||
})
|
||||
|
||||
b.notifyEventHandlers(CodeGraphBuilderEvent{
|
||||
Kind: CodeGraphBuilderEventFunctionProcessed,
|
||||
Data: functionDecl.Id(),
|
||||
}, b.metrics)
|
||||
|
||||
b.functionDeclCache[moduleName] = functionDecl.Id()
|
||||
}
|
||||
}
|
||||
|
||||
// The function call graph will be built as follows:
|
||||
// [Function] -> [FunctionCall] -> [Function]
|
||||
//
|
||||
// # To build this, we will
|
||||
//
|
||||
// - Enumerate all function declarations
|
||||
// - Assign an unique ID for the function (source)
|
||||
// - Enumerate all function calls within the function body
|
||||
// - Resolve the function call to a function declaration
|
||||
// - Assign an unique ID to the called function (target)
|
||||
// - Store the relationship in the graph
|
||||
func (b *codeGraphBuilder) processFunctionCalls(cst *nodes.CST, currentFile SourceFile) {
|
||||
// Building a function call graph through static analysis is harder than expected
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) useImports() bool {
|
||||
return b.config.RecursiveImport
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) buildPackageNode(id, name, path, src string) entities.Package {
|
||||
return entities.Package{
|
||||
Id: id,
|
||||
Name: name,
|
||||
SourceFilePath: path,
|
||||
SourceFileType: src,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) importSourceName(file SourceFile) string {
|
||||
if file.IsImportedFile() {
|
||||
return entities.PackageEntitySourceTypeImport
|
||||
} else {
|
||||
return entities.PackageEntitySourceTypeApp
|
||||
}
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) notifyEventHandlers(event CodeGraphBuilderEvent, metrics CodeGraphBuilderMetrics) {
|
||||
for name, handler := range b.eventHandlers {
|
||||
err := handler(event, metrics)
|
||||
if err != nil {
|
||||
logger.Warnf("Failed to notify event handler: %s: %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *codeGraphBuilder) synchronized(fn func()) {
|
||||
b.fileQueueLock.Lock()
|
||||
defer b.fileQueueLock.Unlock()
|
||||
|
||||
fn()
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package entities
|
||||
|
||||
const (
|
||||
FunctionDeclEntity = "function_decl"
|
||||
|
||||
FunctionDeclPropertyName = "name"
|
||||
FunctionDeclPropertyContainerName = "containerName"
|
||||
FunctionDeclPropertySourceFilePath = "sourceFilePath"
|
||||
FunctionDeclPropertySourceFileType = "sourceFileType"
|
||||
)
|
||||
|
||||
type FunctionDecl struct {
|
||||
Id string
|
||||
|
||||
ContainerName string
|
||||
FunctionName string
|
||||
SourceFilePath string
|
||||
SourceFileType string
|
||||
}
|
||||
|
||||
func (f *FunctionDecl) Properties() map[string]string {
|
||||
return map[string]string{
|
||||
FunctionDeclPropertyName: f.FunctionName,
|
||||
FunctionDeclPropertyContainerName: f.ContainerName,
|
||||
FunctionDeclPropertySourceFilePath: f.SourceFilePath,
|
||||
FunctionDeclPropertySourceFileType: f.SourceFileType,
|
||||
}
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package entities
|
||||
|
||||
import "github.com/safedep/vet/pkg/storage/graph"
|
||||
|
||||
const (
|
||||
// The entity type
|
||||
PackageEntity = "package"
|
||||
|
||||
// Entity specific constants
|
||||
PackageEntitySourceTypeApp = "app"
|
||||
PackageEntitySourceTypeImport = "import"
|
||||
|
||||
// Property names
|
||||
PackagePropertyName = "name"
|
||||
PackagePropertySourceFilePath = "sourceFilePath"
|
||||
PackagePropertySourceFileType = "sourceFileType"
|
||||
|
||||
// Relationship names
|
||||
PackageRelationshipImports = "imports"
|
||||
PackageRelationshipDeclaresFunction = "declares_function"
|
||||
)
|
||||
|
||||
type Package struct {
|
||||
Id string
|
||||
Name string
|
||||
SourceFilePath string
|
||||
SourceFileType string
|
||||
}
|
||||
|
||||
func (p *Package) Properties() map[string]string {
|
||||
return map[string]string{
|
||||
PackagePropertyName: p.Name,
|
||||
PackagePropertySourceFilePath: p.SourceFilePath,
|
||||
PackagePropertySourceFileType: p.SourceFileType,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Package) Imports(anotherPackage *Package) *graph.Edge {
|
||||
return &graph.Edge{
|
||||
Name: PackageRelationshipImports,
|
||||
From: &graph.Node{
|
||||
ID: p.Id,
|
||||
Label: PackageEntity,
|
||||
Properties: p.Properties(),
|
||||
},
|
||||
To: &graph.Node{
|
||||
ID: anotherPackage.Id,
|
||||
Label: PackageEntity,
|
||||
Properties: anotherPackage.Properties(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Package) DeclaresFunction(fn *FunctionDecl) *graph.Edge {
|
||||
return &graph.Edge{
|
||||
Name: PackageRelationshipDeclaresFunction,
|
||||
From: &graph.Node{
|
||||
ID: p.Id,
|
||||
Label: PackageEntity,
|
||||
Properties: p.Properties(),
|
||||
},
|
||||
To: &graph.Node{
|
||||
ID: fn.Id,
|
||||
Label: FunctionDeclEntity,
|
||||
Properties: fn.Properties(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
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)
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
package languages
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/safedep/vet/pkg/code"
|
||||
"github.com/safedep/vet/pkg/code/nodes"
|
||||
sitter "github.com/smacker/go-tree-sitter"
|
||||
)
|
||||
|
||||
// Base implementation of a common source language
|
||||
type commonSourceLanguage struct {
|
||||
parser *sitter.Parser
|
||||
lang *sitter.Language
|
||||
}
|
||||
|
||||
func (l *commonSourceLanguage) ParseSource(file code.SourceFile) (*nodes.CST, error) {
|
||||
fileReader, err := file.Open()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open source file: %w", err)
|
||||
}
|
||||
|
||||
defer fileReader.Close()
|
||||
|
||||
data, err := io.ReadAll(fileReader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read source: %w", err)
|
||||
}
|
||||
|
||||
tree, err := l.parser.ParseCtx(context.Background(), nil, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nodes.NewCST(tree, l.lang, data), nil
|
||||
}
|
||||
|
||||
func (l *commonSourceLanguage) GetImportNodes(cst *nodes.CST) ([]nodes.CSTImportNode, error) {
|
||||
return nil, fmt.Errorf("language does not support import nodes")
|
||||
}
|
||||
|
||||
func (l *commonSourceLanguage) GetFunctionDeclarationNodes(cst *nodes.CST) ([]nodes.CSTFunctionNode, error) {
|
||||
return nil, fmt.Errorf("language does not support function declaration nodes")
|
||||
}
|
||||
|
||||
func (l *commonSourceLanguage) GetFunctionCallNodes(cst *nodes.CST) ([]nodes.CSTFunctionCallNode, error) {
|
||||
return nil, fmt.Errorf("language does not support function call nodes")
|
||||
}
|
||||
|
||||
func (l *commonSourceLanguage) ResolveImportNameFromPath(relPath string) (string, error) {
|
||||
return "", fmt.Errorf("language does not support import name resolution")
|
||||
}
|
||||
|
||||
func (l *commonSourceLanguage) ResolveImportPathsFromName(importName string) ([]string, error) {
|
||||
return nil, fmt.Errorf("language does not support import path resolution")
|
||||
}
|
||||
|
||||
func (l *commonSourceLanguage) GetMeta() code.SourceLanguageMeta {
|
||||
return code.SourceLanguageMeta{}
|
||||
}
|
||||
@ -1,233 +0,0 @@
|
||||
package languages
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/safedep/vet/pkg/code"
|
||||
"github.com/safedep/vet/pkg/code/nodes"
|
||||
"github.com/safedep/vet/pkg/common/logger"
|
||||
sitter "github.com/smacker/go-tree-sitter"
|
||||
"github.com/smacker/go-tree-sitter/python"
|
||||
)
|
||||
|
||||
type pythonSourceLanguage struct {
|
||||
commonSourceLanguage
|
||||
}
|
||||
|
||||
func NewPythonSourceLanguage() (code.SourceLanguage, error) {
|
||||
parser := sitter.NewParser()
|
||||
parser.SetLanguage(python.GetLanguage())
|
||||
|
||||
return &pythonSourceLanguage{
|
||||
commonSourceLanguage: commonSourceLanguage{
|
||||
parser: parser,
|
||||
lang: python.GetLanguage(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (l *pythonSourceLanguage) GetMeta() code.SourceLanguageMeta {
|
||||
return code.SourceLanguageMeta{
|
||||
SourceFileGlobs: []string{"*.py"},
|
||||
}
|
||||
}
|
||||
|
||||
func (l *pythonSourceLanguage) GetImportNodes(cst *nodes.CST) ([]nodes.CSTImportNode, error) {
|
||||
// Tree Sitter query to get import nodes in Python
|
||||
// The order of capture names are important because the extraction
|
||||
// uses capture index
|
||||
query := `
|
||||
(import_statement
|
||||
name: ((dotted_name) @module_name))
|
||||
|
||||
(import_from_statement
|
||||
module_name: (dotted_name) @module_name
|
||||
name: (dotted_name
|
||||
(identifier) @submodule_name @submodule_alias))
|
||||
|
||||
(import_from_statement
|
||||
module_name: (relative_import) @module_name
|
||||
name: (dotted_name
|
||||
(identifier) @submodule_name @submodule_alias))
|
||||
|
||||
(import_statement
|
||||
name: (aliased_import
|
||||
name: ((dotted_name) @module_name @submodule_name)
|
||||
alias: (identifier) @submodule_alias))
|
||||
|
||||
(import_from_statement
|
||||
module_name: (dotted_name) @module_name
|
||||
name: (aliased_import
|
||||
name: (dotted_name
|
||||
(identifier) @submodule_name)
|
||||
alias: (identifier) @submodule_alias))
|
||||
|
||||
(import_from_statement
|
||||
module_name: (relative_import) @module_name
|
||||
name: (aliased_import
|
||||
name: ((dotted_name) @submodule_name)
|
||||
alias: (identifier) @submodule_alias))
|
||||
`
|
||||
|
||||
importNodes := []nodes.CSTImportNode{}
|
||||
err := code.TSExecQuery(query, python.GetLanguage(),
|
||||
cst.Code(),
|
||||
cst.Root(),
|
||||
func(m *sitter.QueryMatch, _ *sitter.Query, ok bool) error {
|
||||
importNode := nodes.NewCSTImportNode(cst).
|
||||
WithModuleName(m.Captures[0].Node)
|
||||
|
||||
if len(m.Captures) > 1 {
|
||||
importNode = importNode.WithModuleItem(m.Captures[1].Node)
|
||||
}
|
||||
|
||||
if len(m.Captures) > 2 {
|
||||
importNode = importNode.WithModuleAlias(m.Captures[2].Node)
|
||||
}
|
||||
|
||||
logger.Debugf("Found imported module: %s (%s) as (%s)",
|
||||
importNode.ImportName(),
|
||||
importNode.ImportItem(),
|
||||
importNode.ImportAlias())
|
||||
|
||||
importNodes = append(importNodes, *importNode)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return importNodes, err
|
||||
}
|
||||
|
||||
func (l *pythonSourceLanguage) GetFunctionDeclarationNodes(cst *nodes.CST) ([]nodes.CSTFunctionNode, error) {
|
||||
query := `
|
||||
(function_definition
|
||||
name: (identifier) @function_name
|
||||
parameters: (parameters) @function_args
|
||||
body: (block) @function_body) @function_declaration
|
||||
`
|
||||
functionNodes := []nodes.CSTFunctionNode{}
|
||||
err := code.TSExecQuery(query, python.GetLanguage(),
|
||||
cst.Code(),
|
||||
cst.Root(),
|
||||
func(m *sitter.QueryMatch, _ *sitter.Query, ok bool) error {
|
||||
if len(m.Captures) != 4 {
|
||||
return fmt.Errorf("expected 4 captures, got %d", len(m.Captures))
|
||||
}
|
||||
|
||||
functionNode := nodes.NewCSTFunctionNode(cst).
|
||||
WithDeclaration(m.Captures[0].Node).
|
||||
WithName(m.Captures[1].Node).
|
||||
WithArgs(m.Captures[2].Node).
|
||||
WithBody(m.Captures[3].Node)
|
||||
|
||||
// Find the containing class if any by walking up the tree
|
||||
parent := functionNode.Declaration().Parent()
|
||||
for parent != nil {
|
||||
if parent.Type() == "class_definition" {
|
||||
functionNode = functionNode.WithContainer(parent.ChildByFieldName("name"))
|
||||
break
|
||||
}
|
||||
|
||||
parent = parent.Parent()
|
||||
}
|
||||
|
||||
logger.Debugf("Found function declaration: %s/%s",
|
||||
functionNode.Container(),
|
||||
functionNode.Name())
|
||||
|
||||
functionNodes = append(functionNodes, *functionNode)
|
||||
return nil
|
||||
})
|
||||
|
||||
return functionNodes, err
|
||||
}
|
||||
|
||||
func (l *pythonSourceLanguage) GetFunctionCallNodes(cst *nodes.CST) ([]nodes.CSTFunctionCallNode, error) {
|
||||
query := `
|
||||
(call
|
||||
function: (identifier) @function_name
|
||||
arguments: (argument_list) @arguments) @function_call
|
||||
|
||||
(call
|
||||
function: (attribute
|
||||
object: (identifier) @object
|
||||
attribute: (identifier) @function_name)
|
||||
arguments: (argument_list) @arguments) @function_call
|
||||
`
|
||||
callNodes := []nodes.CSTFunctionCallNode{}
|
||||
err := code.TSExecQuery(query, python.GetLanguage(),
|
||||
cst.Code(),
|
||||
cst.Root(),
|
||||
func(m *sitter.QueryMatch, q *sitter.Query, ok bool) error {
|
||||
if len(m.Captures) < 3 {
|
||||
return fmt.Errorf("expected at least 3 captures, got %d", len(m.Captures))
|
||||
}
|
||||
|
||||
functionCallNode := nodes.NewCSTFunctionCallNode(cst).WithCall(m.Captures[0].Node)
|
||||
|
||||
n := len(m.Captures)
|
||||
switch n {
|
||||
case 3:
|
||||
functionCallNode = functionCallNode.WithCallee(m.Captures[1].Node)
|
||||
functionCallNode = functionCallNode.WithArgs(m.Captures[2].Node)
|
||||
case 4:
|
||||
functionCallNode = functionCallNode.WithReceiver(m.Captures[1].Node)
|
||||
functionCallNode = functionCallNode.WithCallee(m.Captures[2].Node)
|
||||
functionCallNode = functionCallNode.WithArgs(m.Captures[3].Node)
|
||||
}
|
||||
|
||||
logger.Debugf("Found function call: (%s).%s",
|
||||
functionCallNode.Receiver(),
|
||||
functionCallNode.Callee())
|
||||
|
||||
callNodes = append(callNodes, *functionCallNode)
|
||||
return nil
|
||||
})
|
||||
|
||||
return callNodes, err
|
||||
}
|
||||
|
||||
func (l *pythonSourceLanguage) ResolveImportNameFromPath(relPath string) (string, error) {
|
||||
if relPath[0] == '/' {
|
||||
return "", fmt.Errorf("path is not relative: %s", relPath)
|
||||
}
|
||||
|
||||
relPath = strings.TrimSuffix(relPath, "__init__.py")
|
||||
relPath = strings.TrimSuffix(relPath, "/")
|
||||
relPath = strings.TrimSuffix(relPath, ".py")
|
||||
|
||||
relPath = strings.ReplaceAll(relPath, "/", ".")
|
||||
|
||||
return relPath, nil
|
||||
}
|
||||
|
||||
func (l *pythonSourceLanguage) ResolveImportPathsFromName(currentFile code.SourceFile,
|
||||
importName string, includeImports bool) ([]string, error) {
|
||||
paths := []string{}
|
||||
|
||||
if len(importName) == 0 {
|
||||
return paths, fmt.Errorf("import name is empty")
|
||||
}
|
||||
|
||||
// If its a relative import, resolve it to the root
|
||||
if importName[0] == '.' {
|
||||
currDir := filepath.Dir(currentFile.Path)
|
||||
relativeImportName := filepath.Join(currDir, importName[1:])
|
||||
|
||||
rootRelativePath, err := currentFile.Repository().GetRelativePath(relativeImportName, includeImports)
|
||||
if err != nil {
|
||||
return paths, fmt.Errorf("failed to get relative path: %w", err)
|
||||
}
|
||||
|
||||
importName = rootRelativePath
|
||||
}
|
||||
|
||||
importName = strings.ReplaceAll(importName, ".", "/")
|
||||
|
||||
paths = append(paths, importName+".py")
|
||||
paths = append(paths, importName+"/__init__.py")
|
||||
|
||||
return paths, nil
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package languages
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestResolveImportNameFromPath(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
path string
|
||||
expected string
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "Path is module",
|
||||
path: "module.py",
|
||||
expected: "module",
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "Path is module with subdirectory",
|
||||
path: "subdir/module.py",
|
||||
expected: "subdir.module",
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "Path is module with subdirectory and init",
|
||||
path: "subdir/__init__.py",
|
||||
expected: "subdir",
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "Absolute path",
|
||||
path: "/subdir/module.py",
|
||||
expected: "",
|
||||
err: fmt.Errorf("path is not relative: /subdir/module.py"),
|
||||
},
|
||||
}
|
||||
|
||||
l := &pythonSourceLanguage{}
|
||||
for _, test := range cases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
res, err := l.ResolveImportNameFromPath(test.path)
|
||||
|
||||
if test.err != nil {
|
||||
assert.ErrorContains(t, err, test.err.Error())
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, test.expected, res)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
package nodes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sitter "github.com/smacker/go-tree-sitter"
|
||||
)
|
||||
|
||||
// Represents a Concreate Syntax Tree (CST) of a *single* source file
|
||||
// We will use TreeSitter as the only supported parser.
|
||||
// However, we can have language specific wrappers over TreeSitter CST
|
||||
// to make it easy for high level modules to operate
|
||||
type CST struct {
|
||||
tree *sitter.Tree
|
||||
lang *sitter.Language
|
||||
code []byte
|
||||
}
|
||||
|
||||
func NewCST(tree *sitter.Tree, lang *sitter.Language, code []byte) *CST {
|
||||
return &CST{tree: tree, lang: lang, code: code}
|
||||
}
|
||||
|
||||
func (n *CST) Close() {
|
||||
n.tree.Close()
|
||||
}
|
||||
|
||||
func (n *CST) Root() *sitter.Node {
|
||||
return n.tree.RootNode()
|
||||
}
|
||||
|
||||
func (n *CST) Code() []byte {
|
||||
return n.code
|
||||
}
|
||||
|
||||
func (n *CST) SubTree(node *sitter.Node) (*CST, error) {
|
||||
p := sitter.NewParser()
|
||||
p.SetLanguage(n.lang)
|
||||
|
||||
data := []byte(node.Content(n.code))
|
||||
|
||||
t, err := p.ParseCtx(context.Background(), nil, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewCST(t, n.lang, data), nil
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
package nodes
|
||||
|
||||
import sitter "github.com/smacker/go-tree-sitter"
|
||||
|
||||
type CSTFunctionCallNode struct {
|
||||
cst *CST
|
||||
caller *CSTFunctionNode
|
||||
|
||||
call *sitter.Node
|
||||
receiver *sitter.Node
|
||||
callee *sitter.Node
|
||||
args *sitter.Node
|
||||
}
|
||||
|
||||
func NewCSTFunctionCallNode(cst *CST) *CSTFunctionCallNode {
|
||||
return &CSTFunctionCallNode{cst: cst}
|
||||
}
|
||||
|
||||
// Should we mutate the receiver or make a copy?
|
||||
func (n *CSTFunctionCallNode) WithCaller(caller *CSTFunctionNode) *CSTFunctionCallNode {
|
||||
n.caller = caller
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionCallNode) WithCall(call *sitter.Node) *CSTFunctionCallNode {
|
||||
n.call = call
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionCallNode) WithReceiver(receiver *sitter.Node) *CSTFunctionCallNode {
|
||||
n.receiver = receiver
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionCallNode) WithCallee(callee *sitter.Node) *CSTFunctionCallNode {
|
||||
n.callee = callee
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionCallNode) WithArgs(args *sitter.Node) *CSTFunctionCallNode {
|
||||
n.args = args
|
||||
return n
|
||||
}
|
||||
|
||||
func (n CSTFunctionCallNode) CallNode() *sitter.Node {
|
||||
return n.call
|
||||
}
|
||||
|
||||
func (n CSTFunctionCallNode) ReceiverNode() *sitter.Node {
|
||||
return n.receiver
|
||||
}
|
||||
|
||||
func (n CSTFunctionCallNode) Receiver() string {
|
||||
if n.receiver != nil {
|
||||
return n.receiver.Content(n.cst.code)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n CSTFunctionCallNode) Callee() string {
|
||||
if n.callee != nil {
|
||||
return n.callee.Content(n.cst.code)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
package nodes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sitter "github.com/smacker/go-tree-sitter"
|
||||
)
|
||||
|
||||
type CSTFunctionNode struct {
|
||||
cst *CST
|
||||
|
||||
// The function declaration
|
||||
declaration *sitter.Node
|
||||
|
||||
// Container node, such as a class or a module
|
||||
container *sitter.Node
|
||||
|
||||
// Name of the function
|
||||
name *sitter.Node
|
||||
|
||||
// Arguments of the function
|
||||
args *sitter.Node
|
||||
|
||||
// Body of the function
|
||||
body *sitter.Node
|
||||
}
|
||||
|
||||
func NewCSTFunctionNode(cst *CST) *CSTFunctionNode {
|
||||
return &CSTFunctionNode{cst: cst}
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) WithDeclaration(declaration *sitter.Node) *CSTFunctionNode {
|
||||
n.declaration = declaration
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) WithContainer(container *sitter.Node) *CSTFunctionNode {
|
||||
n.container = container
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) WithName(name *sitter.Node) *CSTFunctionNode {
|
||||
n.name = name
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) WithArgs(args *sitter.Node) *CSTFunctionNode {
|
||||
n.args = args
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) WithBody(body *sitter.Node) *CSTFunctionNode {
|
||||
n.body = body
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) Declaration() *sitter.Node {
|
||||
return n.declaration
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) ContainerNode() *sitter.Node {
|
||||
return n.container
|
||||
}
|
||||
|
||||
func (n *CSTFunctionNode) NameNode() *sitter.Node {
|
||||
return n.name
|
||||
}
|
||||
|
||||
// Human readable Id for use in graph query
|
||||
func (n CSTFunctionNode) Id() string {
|
||||
return fmt.Sprintf("%s/%s", n.Container(), n.Name())
|
||||
}
|
||||
|
||||
func (n CSTFunctionNode) Name() string {
|
||||
if n.name != nil {
|
||||
return n.name.Content(n.cst.code)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n CSTFunctionNode) Container() string {
|
||||
if n.container != nil {
|
||||
return n.container.Content(n.cst.code)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
package nodes
|
||||
|
||||
import sitter "github.com/smacker/go-tree-sitter"
|
||||
|
||||
type CSTImportNode struct {
|
||||
cst *CST
|
||||
moduleNameNode *sitter.Node
|
||||
moduleItemNode *sitter.Node
|
||||
moduleAliasNode *sitter.Node
|
||||
}
|
||||
|
||||
func NewCSTImportNode(cst *CST) *CSTImportNode {
|
||||
return &CSTImportNode{cst: cst}
|
||||
}
|
||||
|
||||
func (n *CSTImportNode) WithModuleName(moduleName *sitter.Node) *CSTImportNode {
|
||||
n.moduleNameNode = moduleName
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTImportNode) WithModuleItem(moduleItem *sitter.Node) *CSTImportNode {
|
||||
n.moduleItemNode = moduleItem
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CSTImportNode) WithModuleAlias(moduleAlias *sitter.Node) *CSTImportNode {
|
||||
n.moduleAliasNode = moduleAlias
|
||||
return n
|
||||
}
|
||||
|
||||
func (n CSTImportNode) ImportName() string {
|
||||
if n.moduleNameNode != nil {
|
||||
return n.moduleNameNode.Content(n.cst.code)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n CSTImportNode) ImportItem() string {
|
||||
if n.moduleItemNode != nil {
|
||||
return n.moduleItemNode.Content(n.cst.code)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (n CSTImportNode) ImportAlias() string {
|
||||
if n.moduleAliasNode != nil {
|
||||
return n.moduleAliasNode.Content(n.cst.code)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
package nodes
|
||||
|
||||
// The nodes package represent the concept of in-memory
|
||||
// CST / AST nodes, ideally as language agnostic as possible.
|
||||
// These are essentially wrappers over Tree Sitter nodes with
|
||||
// some helpful methods to extract information from them.
|
||||
33
pkg/code/repository.go
Normal file
33
pkg/code/repository.go
Normal file
@ -0,0 +1,33 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/safedep/code/plugin/depsusage"
|
||||
"github.com/safedep/vet/ent"
|
||||
)
|
||||
|
||||
// Currently we only need this in CodeScanner
|
||||
type writerRepository interface {
|
||||
SaveDependencyUsage(context.Context, *depsusage.UsageEvidence) error
|
||||
}
|
||||
|
||||
// Repository exposed to rest of the vet to query code analysis data
|
||||
// persisted in the storage. This is a contract to the rest of the system
|
||||
type ReaderRepository interface {
|
||||
// Stuff like GetEvidenceByPackageName(...)
|
||||
}
|
||||
|
||||
type writerRepositoryImpl struct {
|
||||
client *ent.Client
|
||||
}
|
||||
|
||||
func newWriterRepository(client *ent.Client) (writerRepository, error) {
|
||||
return &writerRepositoryImpl{
|
||||
client: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *writerRepositoryImpl) SaveDependencyUsage(ctx context.Context, evidence *depsusage.UsageEvidence) error {
|
||||
return nil
|
||||
}
|
||||
83
pkg/code/scanner.go
Normal file
83
pkg/code/scanner.go
Normal file
@ -0,0 +1,83 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/safedep/code/core"
|
||||
"github.com/safedep/vet/ent"
|
||||
"github.com/safedep/vet/pkg/storage"
|
||||
)
|
||||
|
||||
// User define configuration for the scanner
|
||||
type ScannerConfig struct {
|
||||
// First party application code directories
|
||||
AppDirectories []string
|
||||
|
||||
// 3rd party imported code directories (e.g. Python virtual env, `node_modules` etc.)
|
||||
ImportDirectories []string
|
||||
|
||||
// Languages to scan
|
||||
Languages []core.Language
|
||||
|
||||
// Define callbacks if required
|
||||
Callbacks *ScannerCallbackRegistry
|
||||
|
||||
// Plugin specific configuration
|
||||
SkipDependencyUsagePlugin bool
|
||||
}
|
||||
|
||||
type ScannerCallbackRegistry struct {
|
||||
// On start of scan
|
||||
OnScanStart func() error
|
||||
|
||||
// On end of scan
|
||||
OnScanEnd func() error
|
||||
}
|
||||
|
||||
// Scanner defines the contract for implementing a code scanner. The purpose
|
||||
// of code scanner is to scan configured directories for code files,
|
||||
// parse them, process them with plugins, persist the plugin results. It
|
||||
// should also expose the necessary callbacks for interactive applications
|
||||
// to show progress to user.
|
||||
type Scanner interface {
|
||||
Scan(context.Context) error
|
||||
}
|
||||
|
||||
type scanner struct {
|
||||
config ScannerConfig
|
||||
storage storage.Storage[*ent.Client]
|
||||
writer writerRepository
|
||||
}
|
||||
|
||||
func NewScanner(config ScannerConfig, storage storage.Storage[*ent.Client]) (Scanner, error) {
|
||||
client, err := storage.Client()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get ent client: %w", err)
|
||||
}
|
||||
|
||||
writer, err := newWriterRepository(client)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create writer repository: %w", err)
|
||||
}
|
||||
|
||||
return &scanner{
|
||||
config: config,
|
||||
storage: storage,
|
||||
writer: writer,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *scanner) Scan(ctx context.Context) error {
|
||||
// Create the file system walker with config
|
||||
|
||||
// Initialize the plugins
|
||||
|
||||
// Start the tree walker with plugins
|
||||
|
||||
// Handle results from plugins
|
||||
|
||||
// Use repository to persist the results
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package code
|
||||
|
||||
import "io"
|
||||
|
||||
// Represents a source file. This is required because import resolution
|
||||
// algorithm may need to know the path of the current file
|
||||
type SourceFile struct {
|
||||
// Identifier for the source file. This is dependent on the
|
||||
// language on how to uniquely identify a source file
|
||||
Id string
|
||||
|
||||
// Repository specific path to the file
|
||||
Path string
|
||||
|
||||
// The repository from where the source file is retrieved
|
||||
repository SourceRepository
|
||||
}
|
||||
|
||||
func (f SourceFile) Open() (io.ReadCloser, error) {
|
||||
return f.repository.OpenSourceFile(f)
|
||||
}
|
||||
|
||||
func (f SourceFile) Repository() SourceRepository {
|
||||
return f.repository
|
||||
}
|
||||
|
||||
// Check if the source file is imported. Returns true
|
||||
// if the source file is relative to the source directories
|
||||
// without considering any import directories
|
||||
func (f SourceFile) IsImportedFile() bool {
|
||||
// When we don't have a repository, we assume that the file
|
||||
// is not valid. Let us consider it to be an unresolved import
|
||||
if f.repository == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
_, err := f.repository.GetRelativePath(f.Path, false)
|
||||
return (err != nil)
|
||||
}
|
||||
|
||||
type sourceFileHandlerFn func(file SourceFile) error
|
||||
|
||||
// SourceRepository is a repository of source files. It can be a local
|
||||
// repository such as a directory or a remote repository such as a git repository.
|
||||
// The concept of repository is just to find 1P and 3P code while abstracting the
|
||||
// underlying storage mechanism (e.g. local file system or remote git repository)
|
||||
type SourceRepository interface {
|
||||
// Name of the repository
|
||||
Name() string
|
||||
|
||||
// Enumerate all source files in the repository. This can be multiple
|
||||
// directories for a local source repository
|
||||
EnumerateSourceFiles(handler sourceFileHandlerFn) error
|
||||
|
||||
// Get a source file by path. This function enumerates all directories
|
||||
// available in the repository to check for existence of the source file by path
|
||||
GetSourceFileByPath(path string, includeImports bool) (SourceFile, error)
|
||||
|
||||
// Open a source file for reading
|
||||
OpenSourceFile(file SourceFile) (io.ReadCloser, error)
|
||||
|
||||
// Configure the repository for a source language
|
||||
ConfigureForLanguage(language SourceLanguage)
|
||||
|
||||
// Get relative path of the source file from the repository root
|
||||
// This is useful for constructing the import path. The first match is returned
|
||||
GetRelativePath(path string, includeImport bool) (string, error)
|
||||
}
|
||||
@ -1,180 +0,0 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/safedep/vet/pkg/common/logger"
|
||||
)
|
||||
|
||||
type FileSystemSourceRepositoryConfig struct {
|
||||
// List of paths to search for source code
|
||||
SourcePaths []string
|
||||
|
||||
// Glob patterns to exclude from source code search
|
||||
ExcludedGlobs []string
|
||||
|
||||
// Glob patterns to include in source code search
|
||||
IncludedGlobs []string
|
||||
|
||||
// List of paths to search for imported source code
|
||||
ImportPaths []string
|
||||
}
|
||||
|
||||
type fileSystemSourceRepository struct {
|
||||
config FileSystemSourceRepositoryConfig
|
||||
}
|
||||
|
||||
func NewFileSystemSourceRepository(config FileSystemSourceRepositoryConfig) (SourceRepository, error) {
|
||||
return &fileSystemSourceRepository{config: config}, nil
|
||||
}
|
||||
|
||||
func (r *fileSystemSourceRepository) Name() string {
|
||||
return "FileSystemSourceRepository"
|
||||
}
|
||||
|
||||
func (r *fileSystemSourceRepository) GetRelativePath(path string, includeImportPaths bool) (string, error) {
|
||||
lookupPaths := []string{}
|
||||
|
||||
lookupPaths = append(lookupPaths, r.config.SourcePaths...)
|
||||
if includeImportPaths {
|
||||
lookupPaths = append(lookupPaths, r.config.ImportPaths...)
|
||||
}
|
||||
|
||||
for _, rootPath := range lookupPaths {
|
||||
if relPath, err := filepath.Rel(rootPath, path); err == nil {
|
||||
if strings.HasPrefix(relPath, "..") {
|
||||
continue
|
||||
}
|
||||
|
||||
return relPath, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("path not found in source or import paths: %s", path)
|
||||
}
|
||||
|
||||
func (r *fileSystemSourceRepository) ConfigureForLanguage(language SourceLanguage) {
|
||||
langMeta := language.GetMeta()
|
||||
|
||||
r.config.IncludedGlobs = append(r.config.IncludedGlobs, langMeta.SourceFileGlobs...)
|
||||
}
|
||||
|
||||
func (r *fileSystemSourceRepository) EnumerateSourceFiles(handler sourceFileHandlerFn) error {
|
||||
logger.Debugf("Enumerating source files with config: %v", r.config)
|
||||
|
||||
for _, sourcePath := range r.config.SourcePaths {
|
||||
if err := r.enumSourceDir(sourcePath, handler); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSourceFileByPath searches for a source file by path in the repository.
|
||||
// It starts by searching the source paths and then the import paths.
|
||||
//
|
||||
// TODO: This is a problem. Source file lookup is ecosystem specific. For example
|
||||
// Python and Ruby may have different rules to lookup a source file by path during
|
||||
// import operation. May be we need to make the operations explicit at repository level.
|
||||
func (r *fileSystemSourceRepository) GetSourceFileByPath(path string, includeImports bool) (SourceFile, error) {
|
||||
lookupPaths := []string{}
|
||||
|
||||
// Import paths are generally are higher precedence than source paths
|
||||
if includeImports {
|
||||
lookupPaths = append(lookupPaths, r.config.ImportPaths...)
|
||||
}
|
||||
|
||||
lookupPaths = append(lookupPaths, r.config.SourcePaths...)
|
||||
|
||||
for _, sourcePath := range lookupPaths {
|
||||
st, err := os.Stat(sourcePath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if !st.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
sourceFilePath := filepath.Join(sourcePath, path)
|
||||
if _, err := os.Stat(sourceFilePath); err == nil {
|
||||
return SourceFile{
|
||||
Path: sourceFilePath,
|
||||
repository: r,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return SourceFile{}, fmt.Errorf("source file not found: %s", path)
|
||||
}
|
||||
|
||||
func (r *fileSystemSourceRepository) OpenSourceFile(file SourceFile) (io.ReadCloser, error) {
|
||||
return os.OpenFile(file.Path, os.O_RDONLY, 0)
|
||||
}
|
||||
|
||||
func (r *fileSystemSourceRepository) enumSourceDir(path string, handler sourceFileHandlerFn) error {
|
||||
return filepath.WalkDir(path, func(path string, info os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !r.isAcceptableSourceFile(path) {
|
||||
logger.Debugf("Ignoring file: %s", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
return handler(SourceFile{
|
||||
Path: path,
|
||||
repository: r,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// A source file is acceptable if the base file name meets the following conditions:
|
||||
//
|
||||
// 1. It does not match any of the excluded globs
|
||||
// 2. It matches any of the included globs
|
||||
//
|
||||
// If there are no included globs, then all files are acceptable.
|
||||
func (r *fileSystemSourceRepository) isAcceptableSourceFile(path string) bool {
|
||||
baseFileName := filepath.Base(path)
|
||||
|
||||
for _, excludedGlob := range r.config.ExcludedGlobs {
|
||||
matched, err := filepath.Match(excludedGlob, baseFileName)
|
||||
if err != nil {
|
||||
logger.Errorf("Invalid exclude glob pattern: %s: %v", excludedGlob, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if matched {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if len(r.config.IncludedGlobs) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, includedGlob := range r.config.IncludedGlobs {
|
||||
matched, err := filepath.Match(includedGlob, baseFileName)
|
||||
if err != nil {
|
||||
logger.Errorf("Invalid include glob pattern: %s: %v", includedGlob, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if matched {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
@ -1,146 +0,0 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsAcceptableSourceFile(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
path string
|
||||
excludedGlobs []string
|
||||
includedGlobs []string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
"No globs",
|
||||
"/a/b/foo.go",
|
||||
[]string{},
|
||||
[]string{},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"Excluded glob",
|
||||
"/a/b/foo.go",
|
||||
[]string{"*.go"},
|
||||
[]string{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Included glob",
|
||||
"/a/b/foo.go",
|
||||
[]string{},
|
||||
[]string{"*.go"},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"Excluded and included globs",
|
||||
"/a/b/foo.go",
|
||||
[]string{"*.go"},
|
||||
[]string{"*.go"},
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range cases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
repo := fileSystemSourceRepository{
|
||||
config: FileSystemSourceRepositoryConfig{
|
||||
ExcludedGlobs: test.excludedGlobs,
|
||||
IncludedGlobs: test.includedGlobs,
|
||||
},
|
||||
}
|
||||
|
||||
ret := repo.isAcceptableSourceFile(test.path)
|
||||
assert.Equal(t, test.want, ret)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetRelativePath(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
path string
|
||||
sourcePaths []string
|
||||
importPaths []string
|
||||
includeImports bool
|
||||
want string
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"Relative in source path with no imports",
|
||||
"/a/b/c/foo.go",
|
||||
[]string{"/a/b"},
|
||||
[]string{},
|
||||
false,
|
||||
"c/foo.go",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Relative in source path with imports",
|
||||
"/a/b/c/foo.go",
|
||||
[]string{"/a/b"},
|
||||
[]string{"/a/b/c"},
|
||||
true,
|
||||
"c/foo.go",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Relative in import path with imports",
|
||||
"/a/b/c/foo.go",
|
||||
[]string{"/x/y"},
|
||||
[]string{"/a/b"},
|
||||
true,
|
||||
"c/foo.go",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"First match in import path",
|
||||
"/a/b/c/foo.go",
|
||||
[]string{"/x/y"},
|
||||
[]string{"/a/b", "/a/b/c"},
|
||||
true,
|
||||
"c/foo.go",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Relative in source path",
|
||||
"./a/b/c/foo.go",
|
||||
[]string{"./a/b"},
|
||||
[]string{"/a/b/c"},
|
||||
true,
|
||||
"c/foo.go",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"No match",
|
||||
"/a/b/c/foo.go",
|
||||
[]string{"/x/y"},
|
||||
[]string{"/z"},
|
||||
true,
|
||||
"",
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range cases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
repo := fileSystemSourceRepository{
|
||||
config: FileSystemSourceRepositoryConfig{
|
||||
SourcePaths: test.sourcePaths,
|
||||
ImportPaths: test.importPaths,
|
||||
},
|
||||
}
|
||||
|
||||
ret, err := repo.GetRelativePath(test.path, test.includeImports)
|
||||
if test.err {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, test.want, ret)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,80 +0,0 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sitter "github.com/smacker/go-tree-sitter"
|
||||
)
|
||||
|
||||
type tsQueryMatchHandler func(*sitter.QueryMatch, *sitter.Query, bool) error
|
||||
|
||||
func TSExecQuery(query string, lang *sitter.Language, source []byte,
|
||||
node *sitter.Node, handler tsQueryMatchHandler) error {
|
||||
tsQuery, err := sitter.NewQuery([]byte(query), lang)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tsQueryCursor := sitter.NewQueryCursor()
|
||||
tsQueryCursor.Exec(tsQuery, node)
|
||||
|
||||
for {
|
||||
match, ok := tsQueryCursor.NextMatch()
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
|
||||
match = tsQueryCursor.FilterPredicates(match, source)
|
||||
|
||||
if len(match.Captures) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := handler(match, tsQuery, ok); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Maps a file path to a module name. This is an important operation
|
||||
// because it serves as the bridge between FS and Language domain
|
||||
func LangMapFileToModule(file SourceFile, repo SourceRepository, lang SourceLanguage, includeImports bool) (string, error) {
|
||||
// Get the relative path of the file in the repository because most language
|
||||
// runtimes (module loaders) identify modules by relative paths
|
||||
relSourceFilePath, err := repo.GetRelativePath(file.Path, includeImports)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get relative path: %w", err)
|
||||
}
|
||||
|
||||
// Use the language adapter to translate the relative path to a module name
|
||||
// which is language specific
|
||||
moduleName, err := lang.ResolveImportNameFromPath(relSourceFilePath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to resolve import name from path: %w", err)
|
||||
}
|
||||
|
||||
return moduleName, nil
|
||||
}
|
||||
|
||||
// Maps a module name back to a file path that must exist in the repository
|
||||
func LangMapModuleToFile(moduleName string, currentFile SourceFile,
|
||||
repo SourceRepository, lang SourceLanguage, includeImports bool) (SourceFile, error) {
|
||||
// Use the language adapter to get possible relative paths for the module name
|
||||
relPaths, err := lang.ResolveImportPathsFromName(currentFile, moduleName, includeImports)
|
||||
if err != nil {
|
||||
return SourceFile{}, fmt.Errorf("failed to resolve import paths from name: %w", err)
|
||||
}
|
||||
|
||||
for _, relPath := range relPaths {
|
||||
sf, err := repo.GetSourceFileByPath(relPath, includeImports)
|
||||
if err != nil {
|
||||
continue
|
||||
} else {
|
||||
return sf, nil
|
||||
}
|
||||
}
|
||||
|
||||
return SourceFile{}, fmt.Errorf("no source file found for module: %s", moduleName)
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package code
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestLangMapFileToModule(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
path string
|
||||
mod string
|
||||
err error
|
||||
}{
|
||||
{},
|
||||
}
|
||||
|
||||
for _, test := range cases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
// TODO: Implement test
|
||||
})
|
||||
}
|
||||
}
|
||||
55
pkg/storage/ent_sqlite.go
Normal file
55
pkg/storage/ent_sqlite.go
Normal file
@ -0,0 +1,55 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/safedep/vet/ent"
|
||||
)
|
||||
|
||||
type EntSqliteClientConfig struct {
|
||||
// Path to the sqlite database file
|
||||
Path string
|
||||
|
||||
// Read Only mode
|
||||
ReadOnly bool
|
||||
|
||||
// Skip schema creation
|
||||
SkipSchemaCreation bool
|
||||
}
|
||||
|
||||
type entSqliteClient struct {
|
||||
client *ent.Client
|
||||
}
|
||||
|
||||
func NewEntSqliteClient(config EntSqliteClientConfig) (Storage[*ent.Client], error) {
|
||||
mode := "rwc"
|
||||
if config.ReadOnly {
|
||||
mode = "ro"
|
||||
}
|
||||
|
||||
dbConn := fmt.Sprintf("file:%s?mode=%s&cache=private&_fk=1", config.Path, mode)
|
||||
client, err := ent.Open("sqlite3", dbConn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open sqlite3 connection: %w", err)
|
||||
}
|
||||
|
||||
if !config.SkipSchemaCreation {
|
||||
if err := client.Schema.Create(context.Background()); err != nil {
|
||||
return nil, fmt.Errorf("failed to create schema resources: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &entSqliteClient{
|
||||
client: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *entSqliteClient) Client() (*ent.Client, error) {
|
||||
return c.client, nil
|
||||
}
|
||||
|
||||
func (c *entSqliteClient) Close() error {
|
||||
return c.client.Close()
|
||||
}
|
||||
32
pkg/storage/ent_sqlite_test.go
Normal file
32
pkg/storage/ent_sqlite_test.go
Normal file
@ -0,0 +1,32 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewSqliteClient(t *testing.T) {
|
||||
t.Run("NewEntSqliteClient", func(t *testing.T) {
|
||||
t.Run("should return storage client when path is given", func(t *testing.T) {
|
||||
tmpPath := filepath.Join(t.TempDir(), "test.db")
|
||||
client, err := NewEntSqliteClient(EntSqliteClientConfig{
|
||||
Path: tmpPath,
|
||||
})
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, client)
|
||||
assert.FileExists(t, tmpPath)
|
||||
})
|
||||
|
||||
t.Run("should return an error when an invalid path is given", func(t *testing.T) {
|
||||
client, err := NewEntSqliteClient(EntSqliteClientConfig{
|
||||
Path: "/invalid/path/1/2",
|
||||
})
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, client)
|
||||
})
|
||||
})
|
||||
}
|
||||
16
pkg/storage/storage.go
Normal file
16
pkg/storage/storage.go
Normal file
@ -0,0 +1,16 @@
|
||||
package storage
|
||||
|
||||
// Storage interface defines a generic contract for implementing
|
||||
// a storage driver in the system. This usually means wrapping
|
||||
// a DB client with our defined interface.
|
||||
type Storage[T any] interface {
|
||||
// Returns a client to the underlying storage driver.
|
||||
// We will NOT hide the underlying storage driver because for an ORM
|
||||
// which already abstracts DB connection, its unnecessary work to abstract
|
||||
// an ORM and then implement function wrappers for all ORM operations.
|
||||
Client() (T, error)
|
||||
|
||||
// Close any open connections, file descriptors and free
|
||||
// any resources used by the storage driver
|
||||
Close() error
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user