Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 67 additions & 57 deletions api/proto/notebooks.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/proto/notebooks.proto
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ message NotebookCell {
string notebook_id = 16;
string input = 1;
string output = 2;

// A short summary of the notebook cell.
string summary = 17;
string data = 3;
string cell_id = 4;
repeated string messages = 5;
Expand Down
48 changes: 38 additions & 10 deletions api/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"regexp"
"strings"
"sync"

"google.golang.org/protobuf/types/known/emptypb"
api_proto "www.velocidex.com/golang/velociraptor/api/proto"
Expand All @@ -33,9 +34,40 @@ import (
)

var (
doc_regex = regexp.MustCompile("doc=(.+)")
doc_regex = regexp.MustCompile("doc=(.+)")
mu sync.Mutex
cachedDescriptions []*api_proto.Completion
)

// Get the top level description line.
func elideDescription(in string) string {
parts := strings.SplitN(in, ".", 2)
return utils.Elide(parts[0], 80)
}

func loadApiDescriptions() []*api_proto.Completion {
mu.Lock()
defer mu.Unlock()

if len(cachedDescriptions) > 0 {
return cachedDescriptions
}

descriptions, err := utils.LoadApiDescription()
if err != nil {
descriptions = IntrospectDescription()
}

for _, d := range descriptions {
d.Description = elideDescription(d.Description)
}

// Cache it for next time.
cachedDescriptions = descriptions

return cachedDescriptions
}

func IntrospectDescription() []*api_proto.Completion {
result := []*api_proto.Completion{}

Expand All @@ -55,7 +87,7 @@ func IntrospectDescription() []*api_proto.Completion {
}
result = append(result, &api_proto.Completion{
Name: item.Name,
Description: item.Doc,
Description: elideDescription(item.Doc),
Type: "Function",
Args: getArgDescriptors(item.ArgType, type_map, scope),
Metadata: metadata,
Expand All @@ -72,7 +104,7 @@ func IntrospectDescription() []*api_proto.Completion {
}
result = append(result, &api_proto.Completion{
Name: item.Name,
Description: item.Doc,
Description: elideDescription(item.Doc),
Type: "Plugin",
Args: getArgDescriptors(item.ArgType, type_map, scope),
Metadata: metadata,
Expand Down Expand Up @@ -108,11 +140,7 @@ func (self *ApiServer) GetKeywordCompletions(
},
}

descriptions, err := utils.LoadApiDescription()
if err != nil {
descriptions = IntrospectDescription()
}
result.Items = append(result.Items, descriptions...)
result.Items = append(result.Items, loadApiDescriptions()...)

manager, err := services.GetRepositoryManager(org_config_obj)
if err != nil {
Expand Down Expand Up @@ -171,7 +199,7 @@ func getArgDescriptors(
}
args = append(args, &api_proto.ArgDescriptor{
Name: i.Key,
Description: doc + required,
Description: elideDescription(doc) + required,
Type: target,
})
}
Expand All @@ -185,7 +213,7 @@ func getArtifactParamDescriptors(artifact *artifacts_proto.Artifact) []*api_prot
for _, parameter := range artifact.Parameters {
args = append(args, &api_proto.ArgDescriptor{
Name: parameter.Name,
Description: parameter.Description,
Description: elideDescription(parameter.Description),
Type: "Artifact Parameter",
})
}
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ require (
github.com/xor-gate/ar v0.0.0-20170530204233-5c72ae81e2b7 // indirect
github.com/xor-gate/debpkg v1.0.0
go.starlark.net v0.0.0-20230925163745-10651d5192ab
golang.org/x/crypto v0.39.0
golang.org/x/mod v0.28.0
golang.org/x/net v0.41.0
golang.org/x/sys v0.37.0
golang.org/x/text v0.30.0
golang.org/x/crypto v0.45.0
golang.org/x/mod v0.29.0
golang.org/x/net v0.47.0
golang.org/x/sys v0.38.0
golang.org/x/text v0.31.0
golang.org/x/time v0.5.0
google.golang.org/api v0.169.0
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
Expand Down Expand Up @@ -290,8 +290,8 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/term v0.32.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/term v0.37.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
kernel.org/pub/linux/libs/security/libcap/cap v1.2.71 // indirect
kernel.org/pub/linux/libs/security/libcap/psx v1.2.71 // indirect
Expand Down
Loading
Loading