MCPcopy
hub / github.com/Velocidex/velociraptor / newBaseTemplateEngine

Function newBaseTemplateEngine

reporting/report.go:343–387  ·  view source on GitHub ↗
(
	ctx context.Context,
	config_obj *config_proto.Config,
	scope vfilter.Scope,
	acl_manager vql_subsystem.ACLManager,
	uploader uploads.Uploader,
	repository services.Repository,
	artifact_name string)

Source from the content-addressed store, hash-verified

341}
342
343func newBaseTemplateEngine(
344 ctx context.Context,
345 config_obj *config_proto.Config,
346 scope vfilter.Scope,
347 acl_manager vql_subsystem.ACLManager,
348 uploader uploads.Uploader,
349 repository services.Repository,
350 artifact_name string) (
351 *BaseTemplateEngine, error) {
352
353 artifact, pres := repository.Get(ctx, config_obj, artifact_name)
354 if !pres {
355 return nil, fmt.Errorf(
356 "Artifact %v not known.", artifact_name)
357 }
358
359 // The template shares the same scope environment for the
360 // whole processing. Keep a reference to the environment so
361 // SetEnv() can update it later.
362 env := ordereddict.NewDict()
363 if scope == nil {
364 manager, err := services.GetRepositoryManager(config_obj)
365 if err != nil {
366 return nil, err
367 }
368
369 scope = manager.BuildScope(
370 services.ScopeBuilder{
371 Config: config_obj,
372 Uploader: uploader,
373 ACLManager: acl_manager,
374 })
375 }
376 scope.AppendVars(env)
377
378 // Closing the scope is deferred to closing the template.
379 return &BaseTemplateEngine{
380 Artifact: artifact,
381 Repository: repository,
382 Scope: scope,
383 Env: env,
384 logger: logging.GetLogger(config_obj, &logging.FrontendComponent),
385 config_obj: config_obj,
386 }, nil
387}
388
389// Go templates require template escape sequences to be all on one
390// line. This makes it very hard to work with due to wrapping and does

Callers 1

NewGuiTemplateEngineFunction · 0.85

Calls 5

GetRepositoryManagerFunction · 0.92
GetLoggerFunction · 0.92
GetMethod · 0.65
BuildScopeMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected