mirror of
https://github.com/safedep/vet.git
synced 2025-12-10 13:43:01 -06:00
* Add initial UI for agent mode * fix: Cleanup and define agent contract * Add react agent * Add interactions memory * Add support for stdio based MCP integration * Add basic sqlite3 report generator * fix: Persist vulnerabilities with package relation * fix: Persist license information * refactor: Agents into its own command package * feat: Add support for tool calling introspection * refactor: UI to hide implementation detail * sqlite3 reporter persist dependency graph * fix: Support multiple LLM provider for agent * docs: Update agents doc * docs: Remove deprecated query docs * fix: UI tests * fix: Linter issue * Add support for prompt mode * Improve UI with animation * Fix UI tests after update * Add OpenSSF scorecard persistence * Add slsa provenances in sqlite3 reporter * Add test cases for sqlite3 reporter * Fix agent doc * fix: Sqlite3 reporter use safe accessors * feat: Add support for fast model * feat: Simplify and streamline agent UI for better user experience - Remove decorative borders and excessive styling to maximize output area - Implement clean minimal design similar to modern TUI interfaces - Add bordered input area for clear visual separation - Move thinking indicator above input area for better visibility - Enhance input field reset logic for proper line alignment - Remove verbose help text and status messages - Optimize layout calculations for full width utilization - Add smooth animations for agent thinking state with spinner - Clean up code structure and remove unused progress bar functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Improve agent status line * test: Update UI tests * fix: Use terminal safe rendering * fix: Fix nil deref without storing empty strings in DB * fix: Support overwriting sqlite3 database * fix: Data model to use m2m between manifest and package * style: Fix linter issue with unused variables * Misc fixes * Add test for agent memory --------- Co-authored-by: Claude <noreply@anthropic.com>
366 lines
12 KiB
Go
366 lines
12 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/safedep/vet/ent/reportdependency"
|
|
"github.com/safedep/vet/ent/reportpackage"
|
|
)
|
|
|
|
// ReportDependencyCreate is the builder for creating a ReportDependency entity.
|
|
type ReportDependencyCreate struct {
|
|
config
|
|
mutation *ReportDependencyMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetDependencyPackageID sets the "dependency_package_id" field.
|
|
func (rdc *ReportDependencyCreate) SetDependencyPackageID(s string) *ReportDependencyCreate {
|
|
rdc.mutation.SetDependencyPackageID(s)
|
|
return rdc
|
|
}
|
|
|
|
// SetDependencyName sets the "dependency_name" field.
|
|
func (rdc *ReportDependencyCreate) SetDependencyName(s string) *ReportDependencyCreate {
|
|
rdc.mutation.SetDependencyName(s)
|
|
return rdc
|
|
}
|
|
|
|
// SetDependencyVersion sets the "dependency_version" field.
|
|
func (rdc *ReportDependencyCreate) SetDependencyVersion(s string) *ReportDependencyCreate {
|
|
rdc.mutation.SetDependencyVersion(s)
|
|
return rdc
|
|
}
|
|
|
|
// SetDependencyEcosystem sets the "dependency_ecosystem" field.
|
|
func (rdc *ReportDependencyCreate) SetDependencyEcosystem(s string) *ReportDependencyCreate {
|
|
rdc.mutation.SetDependencyEcosystem(s)
|
|
return rdc
|
|
}
|
|
|
|
// SetDependencyType sets the "dependency_type" field.
|
|
func (rdc *ReportDependencyCreate) SetDependencyType(s string) *ReportDependencyCreate {
|
|
rdc.mutation.SetDependencyType(s)
|
|
return rdc
|
|
}
|
|
|
|
// SetNillableDependencyType sets the "dependency_type" field if the given value is not nil.
|
|
func (rdc *ReportDependencyCreate) SetNillableDependencyType(s *string) *ReportDependencyCreate {
|
|
if s != nil {
|
|
rdc.SetDependencyType(*s)
|
|
}
|
|
return rdc
|
|
}
|
|
|
|
// SetDepth sets the "depth" field.
|
|
func (rdc *ReportDependencyCreate) SetDepth(i int) *ReportDependencyCreate {
|
|
rdc.mutation.SetDepth(i)
|
|
return rdc
|
|
}
|
|
|
|
// SetNillableDepth sets the "depth" field if the given value is not nil.
|
|
func (rdc *ReportDependencyCreate) SetNillableDepth(i *int) *ReportDependencyCreate {
|
|
if i != nil {
|
|
rdc.SetDepth(*i)
|
|
}
|
|
return rdc
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (rdc *ReportDependencyCreate) SetCreatedAt(t time.Time) *ReportDependencyCreate {
|
|
rdc.mutation.SetCreatedAt(t)
|
|
return rdc
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (rdc *ReportDependencyCreate) SetNillableCreatedAt(t *time.Time) *ReportDependencyCreate {
|
|
if t != nil {
|
|
rdc.SetCreatedAt(*t)
|
|
}
|
|
return rdc
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (rdc *ReportDependencyCreate) SetUpdatedAt(t time.Time) *ReportDependencyCreate {
|
|
rdc.mutation.SetUpdatedAt(t)
|
|
return rdc
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (rdc *ReportDependencyCreate) SetNillableUpdatedAt(t *time.Time) *ReportDependencyCreate {
|
|
if t != nil {
|
|
rdc.SetUpdatedAt(*t)
|
|
}
|
|
return rdc
|
|
}
|
|
|
|
// SetPackageID sets the "package" edge to the ReportPackage entity by ID.
|
|
func (rdc *ReportDependencyCreate) SetPackageID(id int) *ReportDependencyCreate {
|
|
rdc.mutation.SetPackageID(id)
|
|
return rdc
|
|
}
|
|
|
|
// SetNillablePackageID sets the "package" edge to the ReportPackage entity by ID if the given value is not nil.
|
|
func (rdc *ReportDependencyCreate) SetNillablePackageID(id *int) *ReportDependencyCreate {
|
|
if id != nil {
|
|
rdc = rdc.SetPackageID(*id)
|
|
}
|
|
return rdc
|
|
}
|
|
|
|
// SetPackage sets the "package" edge to the ReportPackage entity.
|
|
func (rdc *ReportDependencyCreate) SetPackage(r *ReportPackage) *ReportDependencyCreate {
|
|
return rdc.SetPackageID(r.ID)
|
|
}
|
|
|
|
// Mutation returns the ReportDependencyMutation object of the builder.
|
|
func (rdc *ReportDependencyCreate) Mutation() *ReportDependencyMutation {
|
|
return rdc.mutation
|
|
}
|
|
|
|
// Save creates the ReportDependency in the database.
|
|
func (rdc *ReportDependencyCreate) Save(ctx context.Context) (*ReportDependency, error) {
|
|
rdc.defaults()
|
|
return withHooks(ctx, rdc.sqlSave, rdc.mutation, rdc.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (rdc *ReportDependencyCreate) SaveX(ctx context.Context) *ReportDependency {
|
|
v, err := rdc.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (rdc *ReportDependencyCreate) Exec(ctx context.Context) error {
|
|
_, err := rdc.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (rdc *ReportDependencyCreate) ExecX(ctx context.Context) {
|
|
if err := rdc.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (rdc *ReportDependencyCreate) defaults() {
|
|
if _, ok := rdc.mutation.Depth(); !ok {
|
|
v := reportdependency.DefaultDepth
|
|
rdc.mutation.SetDepth(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (rdc *ReportDependencyCreate) check() error {
|
|
if _, ok := rdc.mutation.DependencyPackageID(); !ok {
|
|
return &ValidationError{Name: "dependency_package_id", err: errors.New(`ent: missing required field "ReportDependency.dependency_package_id"`)}
|
|
}
|
|
if v, ok := rdc.mutation.DependencyPackageID(); ok {
|
|
if err := reportdependency.DependencyPackageIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "dependency_package_id", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_package_id": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := rdc.mutation.DependencyName(); !ok {
|
|
return &ValidationError{Name: "dependency_name", err: errors.New(`ent: missing required field "ReportDependency.dependency_name"`)}
|
|
}
|
|
if v, ok := rdc.mutation.DependencyName(); ok {
|
|
if err := reportdependency.DependencyNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "dependency_name", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := rdc.mutation.DependencyVersion(); !ok {
|
|
return &ValidationError{Name: "dependency_version", err: errors.New(`ent: missing required field "ReportDependency.dependency_version"`)}
|
|
}
|
|
if v, ok := rdc.mutation.DependencyVersion(); ok {
|
|
if err := reportdependency.DependencyVersionValidator(v); err != nil {
|
|
return &ValidationError{Name: "dependency_version", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_version": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := rdc.mutation.DependencyEcosystem(); !ok {
|
|
return &ValidationError{Name: "dependency_ecosystem", err: errors.New(`ent: missing required field "ReportDependency.dependency_ecosystem"`)}
|
|
}
|
|
if v, ok := rdc.mutation.DependencyEcosystem(); ok {
|
|
if err := reportdependency.DependencyEcosystemValidator(v); err != nil {
|
|
return &ValidationError{Name: "dependency_ecosystem", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_ecosystem": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := rdc.mutation.Depth(); !ok {
|
|
return &ValidationError{Name: "depth", err: errors.New(`ent: missing required field "ReportDependency.depth"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (rdc *ReportDependencyCreate) sqlSave(ctx context.Context) (*ReportDependency, error) {
|
|
if err := rdc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := rdc.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, rdc.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)
|
|
rdc.mutation.id = &_node.ID
|
|
rdc.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (rdc *ReportDependencyCreate) createSpec() (*ReportDependency, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &ReportDependency{config: rdc.config}
|
|
_spec = sqlgraph.NewCreateSpec(reportdependency.Table, sqlgraph.NewFieldSpec(reportdependency.FieldID, field.TypeInt))
|
|
)
|
|
if value, ok := rdc.mutation.DependencyPackageID(); ok {
|
|
_spec.SetField(reportdependency.FieldDependencyPackageID, field.TypeString, value)
|
|
_node.DependencyPackageID = value
|
|
}
|
|
if value, ok := rdc.mutation.DependencyName(); ok {
|
|
_spec.SetField(reportdependency.FieldDependencyName, field.TypeString, value)
|
|
_node.DependencyName = value
|
|
}
|
|
if value, ok := rdc.mutation.DependencyVersion(); ok {
|
|
_spec.SetField(reportdependency.FieldDependencyVersion, field.TypeString, value)
|
|
_node.DependencyVersion = value
|
|
}
|
|
if value, ok := rdc.mutation.DependencyEcosystem(); ok {
|
|
_spec.SetField(reportdependency.FieldDependencyEcosystem, field.TypeString, value)
|
|
_node.DependencyEcosystem = value
|
|
}
|
|
if value, ok := rdc.mutation.DependencyType(); ok {
|
|
_spec.SetField(reportdependency.FieldDependencyType, field.TypeString, value)
|
|
_node.DependencyType = value
|
|
}
|
|
if value, ok := rdc.mutation.Depth(); ok {
|
|
_spec.SetField(reportdependency.FieldDepth, field.TypeInt, value)
|
|
_node.Depth = value
|
|
}
|
|
if value, ok := rdc.mutation.CreatedAt(); ok {
|
|
_spec.SetField(reportdependency.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := rdc.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(reportdependency.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := rdc.mutation.PackageIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: reportdependency.PackageTable,
|
|
Columns: []string{reportdependency.PackageColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.report_package_dependencies = &nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// ReportDependencyCreateBulk is the builder for creating many ReportDependency entities in bulk.
|
|
type ReportDependencyCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*ReportDependencyCreate
|
|
}
|
|
|
|
// Save creates the ReportDependency entities in the database.
|
|
func (rdcb *ReportDependencyCreateBulk) Save(ctx context.Context) ([]*ReportDependency, error) {
|
|
if rdcb.err != nil {
|
|
return nil, rdcb.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(rdcb.builders))
|
|
nodes := make([]*ReportDependency, len(rdcb.builders))
|
|
mutators := make([]Mutator, len(rdcb.builders))
|
|
for i := range rdcb.builders {
|
|
func(i int, root context.Context) {
|
|
builder := rdcb.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*ReportDependencyMutation)
|
|
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, rdcb.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, rdcb.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, rdcb.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (rdcb *ReportDependencyCreateBulk) SaveX(ctx context.Context) []*ReportDependency {
|
|
v, err := rdcb.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (rdcb *ReportDependencyCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := rdcb.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (rdcb *ReportDependencyCreateBulk) ExecX(ctx context.Context) {
|
|
if err := rdcb.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|