Skip to content

Commit

Permalink
Only pass client config in the client VQL scope. (Velocidex#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
scudette authored Dec 17, 2021
1 parent 9957f69 commit e97c7ea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion actions/vql.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func (self VQLClientAction) StartQuery(
}

builder := services.ScopeBuilder{
Config: config_obj,
// Only provide the client config since we are running in
// client context.
ClientConfig: config_obj.Client,
// Disable ACLs on the client.
ACLManager: vql_subsystem.NullACLManager{},
Env: ordereddict.NewDict(),
Expand Down
17 changes: 11 additions & 6 deletions services/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ func RegisterRepositoryManager(repository RepositoryManager) {
// Make it easier to build a query scope using the aritfact
// repository.
type ScopeBuilder struct {
Config *config_proto.Config
ACLManager vql_subsystem.ACLManager
Uploader api.Uploader
Logger *log.Logger
Env *ordereddict.Dict
Repository Repository
// In server context this contains the full server config required
// for server plugins.
Config *config_proto.Config

// If running in client context we only present the client config.
ClientConfig *config_proto.ClientConfig
ACLManager vql_subsystem.ACLManager
Uploader api.Uploader
Logger *log.Logger
Env *ordereddict.Dict
Repository Repository
}

// An artifact repository holds definitions for artifacts.
Expand Down
4 changes: 2 additions & 2 deletions services/repository/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
actions_proto "www.velocidex.com/golang/velociraptor/actions/proto"
"www.velocidex.com/golang/velociraptor/artifacts"
artifacts_proto "www.velocidex.com/golang/velociraptor/artifacts/proto"
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
"www.velocidex.com/golang/velociraptor/constants"
flows_proto "www.velocidex.com/golang/velociraptor/flows/proto"
"www.velocidex.com/golang/velociraptor/services"
Expand Down Expand Up @@ -87,8 +88,7 @@ func (self *ArtifactRepositoryPlugin) Call(

config_obj, ok := vql_subsystem.GetServerConfig(scope)
if !ok {
scope.Log("Failed to get config_obj")
return
config_obj = &config_proto.Config{}
}

// If the ctx is done do nothing.
Expand Down
6 changes: 6 additions & 0 deletions services/repository/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ func _build(wg *sync.WaitGroup, self services.ScopeBuilder, from_scratch bool) v
}
}

// Builder can contain only the client config if it is running on
// the client.
if self.ClientConfig != nil {
env.Set(constants.SCOPE_CONFIG, self.ClientConfig)
}

if self.ACLManager != nil {
env.Set(vql_subsystem.ACL_MANAGER_VAR, self.ACLManager)
}
Expand Down

0 comments on commit e97c7ea

Please sign in to comment.