2016-03-29 06:37:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-07-11 16:45:57 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-03-29 06:37:34 +00:00
|
|
|
#include <map>
|
|
|
|
#include <functional>
|
2016-07-11 16:45:57 +00:00
|
|
|
|
2016-03-29 06:37:34 +00:00
|
|
|
#include <osquery/config.h>
|
|
|
|
#include <osquery/database.h>
|
|
|
|
|
|
|
|
namespace osquery {
|
|
|
|
|
|
|
|
/// Enforce specific types of decoration.
|
|
|
|
enum DecorationPoint {
|
|
|
|
DECORATE_LOAD,
|
|
|
|
DECORATE_ALWAYS,
|
|
|
|
DECORATE_INTERVAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Define a map of decoration points to their expected configuration key.
|
2016-07-11 16:45:57 +00:00
|
|
|
extern const std::map<DecorationPoint, std::string> kDecorationPointKeys;
|
2016-03-29 06:37:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Iterate the discovered decorators for a given point type.
|
|
|
|
*
|
|
|
|
* The configuration maintains various sources, each may contain a set of
|
|
|
|
* decorators. The source tracking is abstracted for the decorator iterator.
|
|
|
|
*
|
|
|
|
* @param point request execution of decorators for this given point.
|
|
|
|
* @param time an optional time for points using intervals.
|
|
|
|
* @param source restrict run to a specific config source.
|
|
|
|
*/
|
|
|
|
void runDecorators(DecorationPoint point,
|
|
|
|
size_t time = 0,
|
|
|
|
const std::string& source = "");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Access the internal storage of the Decorator parser.
|
|
|
|
*
|
|
|
|
* The decoration set is a map of column name to value. It contains the opaque
|
|
|
|
* set of decoration point results.
|
|
|
|
*
|
|
|
|
* Decorations are applied to log items before they are sent to the downstream
|
2016-05-10 15:34:55 +00:00
|
|
|
* logging APIs: logString, logSnapshot, etc.
|
2016-03-29 06:37:34 +00:00
|
|
|
*
|
|
|
|
* @param results the output parameter to write decorations.
|
|
|
|
*/
|
|
|
|
void getDecorations(std::map<std::string, std::string>& results);
|
|
|
|
|
|
|
|
/// Clear decorations for a source when it updates.
|
|
|
|
void clearDecorations(const std::string& source);
|
|
|
|
}
|