Skip to content
Draft
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
20 changes: 20 additions & 0 deletions cf-agent/cf-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,8 @@ static void KeepPromises(EvalContext *ctx, const Policy *policy, GenericAgentCon

static void KeepControlPromises(EvalContext *ctx, const Policy *policy, GenericAgentConfig *config)
{
assert(config != NULL);

Seq *constraints = ControlBodyConstraints(policy, AGENT_TYPE_AGENT);
if (constraints)
{
Expand Down Expand Up @@ -1302,6 +1304,24 @@ static void KeepControlPromises(EvalContext *ctx, const Policy *policy, GenericA
continue;
}

if (StringEqual(cp->lval, CFA_CONTROLBODY[AGENT_CONTROL_REPORT_METATAGS_INCLUDE].lval))
{
assert(value_type == CF_DATA_TYPE_STRING_LIST);
RlistDestroy(config->agent_specific.agent.report_metatags_include);
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
config->agent_specific.agent.report_metatags_include = RlistCopy(value);
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Log(LOG_LEVEL_VERBOSE, "Setting report_metatags_include");
continue;
}

if (StringEqual(cp->lval, CFA_CONTROLBODY[AGENT_CONTROL_REPORT_METATAGS_EXCLUDE].lval))
{
assert(value_type == CF_DATA_TYPE_STRING_LIST);
RlistDestroy(config->agent_specific.agent.report_metatags_exclude);
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
config->agent_specific.agent.report_metatags_exclude = RlistCopy(value);
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Log(LOG_LEVEL_VERBOSE, "Setting report_metatags_exclude");
continue;
}

if (StringEqual(cp->lval, CFA_CONTROLBODY[AGENT_CONTROL_EVALUATION_ORDER].lval))
{
assert(value_type == CF_DATA_TYPE_STRING);
Expand Down
2 changes: 1 addition & 1 deletion cf-net/cf-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static const char *const HINTS[] =
"Enable basic information output",
"Minimum TLS version to use",
"TLS ciphers to use (comma-separated list)",
"Specify CFEngine protocol to use. Possible values: 'classic', 'tls', 'cookie', 'filestream', 'leech2', 'latest' (default)",
"Specify CFEngine protocol to use. Possible values: 'classic', 'tls', 'cookie', 'filestream', 'leech2', 'transfusion', 'latest' (default)",
"Print rsync performance statistics to stderr",
NULL
};
Expand Down
4 changes: 4 additions & 0 deletions libcfnet/protocol_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ ProtocolVersion ParseProtocolVersionPolicy(const char *const s)
{
return CF_PROTOCOL_LEECH2;
}
else if (StringEqual(s, "6") || StringEqual(s, "transfusion"))
{
return CF_PROTOCOL_TRANSFUSION;
}
else if (StringEqual(s, "latest"))
{
return CF_PROTOCOL_LATEST;
Expand Down
10 changes: 9 additions & 1 deletion libcfnet/protocol_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ typedef enum
CF_PROTOCOL_COOKIE = 3,
CF_PROTOCOL_FILESTREAM = 4,
CF_PROTOCOL_LEECH2 = 5,
CF_PROTOCOL_TRANSFUSION = 6,
} ProtocolVersion;

/* We use CF_PROTOCOL_LATEST as the default for new connections. */
#define CF_PROTOCOL_LATEST CF_PROTOCOL_LEECH2
#define CF_PROTOCOL_LATEST CF_PROTOCOL_TRANSFUSION

static inline const char *ProtocolVersionString(const ProtocolVersion p)
{
Expand All @@ -60,6 +61,8 @@ static inline const char *ProtocolVersionString(const ProtocolVersion p)
return "filestream";
case CF_PROTOCOL_LEECH2:
return "leech2";
case CF_PROTOCOL_TRANSFUSION:
return "transfusion";
default:
return "undefined";
}
Expand Down Expand Up @@ -100,6 +103,11 @@ static inline bool ProtocolSupportsLeech2(const ProtocolVersion p)
return (p >= CF_PROTOCOL_LEECH2);
}

static inline bool ProtocolSupportsTransfusion(const ProtocolVersion p)
{
return (p >= CF_PROTOCOL_TRANSFUSION);
}

static inline bool ProtocolTerminateCSV(const ProtocolVersion p)
{
return (p < CF_PROTOCOL_COOKIE);
Expand Down
2 changes: 2 additions & 0 deletions libpromises/cf3.defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ typedef enum
AGENT_CONTROL_COPYFROM_RESTRICT_KEYS,
AGENT_CONTROL_EVALUATION_ORDER,
AGENT_CONTROL_DEFAULT_DIRECTORY_CREATE_MODE,
AGENT_CONTROL_REPORT_METATAGS_INCLUDE,
AGENT_CONTROL_REPORT_METATAGS_EXCLUDE,
AGENT_CONTROL_NONE
} AgentControl;

Expand Down
6 changes: 6 additions & 0 deletions libpromises/generic_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -2620,6 +2620,10 @@ GenericAgentConfig *GenericAgentConfigNewDefault(AgentType agent_type, bool tty_
/* Log classes */
config->agent_specific.agent.report_class_log = false;

/* Report class metatags filter (NULL means no filter) */
config->agent_specific.agent.report_metatags_include = NULL;
config->agent_specific.agent.report_metatags_exclude = NULL;

config->agent_specific.common.no_augments = false;
config->agent_specific.common.no_host_specific = false;

Expand Down Expand Up @@ -2664,6 +2668,8 @@ void GenericAgentConfigDestroy(GenericAgentConfig *config)
free(config->agent_specific.agent.bootstrap_host);
free(config->agent_specific.agent.bootstrap_ip);
free(config->agent_specific.agent.bootstrap_port);
RlistDestroy(config->agent_specific.agent.report_metatags_include);
RlistDestroy(config->agent_specific.agent.report_metatags_exclude);
free(config);
}
}
Expand Down
2 changes: 2 additions & 0 deletions libpromises/generic_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ typedef struct

// BODY AGENT CONTROL
bool report_class_log;
Rlist *report_metatags_include;
Rlist *report_metatags_exclude;
} agent;
struct
{
Expand Down
4 changes: 3 additions & 1 deletion libpromises/mod_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const ConstraintSyntax CFG_CONTROLBODY[COMMON_CONTROL_MAX + 1] =
ConstraintSyntaxNewBool("fips_mode", "Activate full FIPS mode restrictions. Default value: false", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewReal("bwlimit", CF_VALRANGE, "Limit outgoing protocol bandwidth in Bytes per second", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewBool("cache_system_functions", "Cache the result of system functions. Default value: true", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewOption("protocol_version", "1,classic,2,tls,3,cookie,4,filestream,5,leech2,latest", "CFEngine protocol version to use when connecting to the server. Default: \"latest\"", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewOption("protocol_version", "1,classic,2,tls,3,cookie,4,filestream,5,leech2,6,transfusion,latest", "CFEngine protocol version to use when connecting to the server. Default: \"latest\"", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewString("tls_ciphers", "", "List of acceptable ciphers in outgoing TLS connections, defaults to OpenSSL's default. For syntax help see man page for \"openssl ciphers\"", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewString("tls_min_version", "", "Minimum acceptable TLS version for outgoing connections, defaults to OpenSSL's default", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewStringList("package_inventory", ".*", "Name of the package manager used for software inventory management", SYNTAX_STATUS_NORMAL),
Expand Down Expand Up @@ -325,6 +325,8 @@ const ConstraintSyntax CFA_CONTROLBODY[] =
ConstraintSyntaxNewStringList("copyfrom_restrict_keys", ".*", "A list of key hashes to restrict copy_from to", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewString("evaluation_order", "(classic|top_down)", "Order of evaluation of promises of agent", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewString("default_directory_create_mode", ".*", "Default directory create mode (defaults to 0700 if not specified)", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewStringList("report_metatags_include", CF_ANYSTRING, "List of regex filters for metatags of classes to be included into reports", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewStringList("report_metatags_exclude", CF_ANYSTRING, "List of regex filters for metatags of classes to be excluded from reports", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewNull()
};

Expand Down
2 changes: 1 addition & 1 deletion libpromises/mod_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static const ConstraintSyntax copy_from_constraints[] =
ConstraintSyntaxNewBool("trustkey", "true/false trust public keys from remote server if previously unknown. Default value: false", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewBool("type_check", "true/false compare file types before copying and require match", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewBool("verify", "true/false verify transferred file by hashing after copy (resource penalty). Default value: false", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewOption("protocol_version", "1,classic,2,tls,3,cookie,4,filestream,5,leech2,latest", "CFEngine protocol version to use when connecting to the server. Default: undefined", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewOption("protocol_version", "1,classic,2,tls,3,cookie,4,filestream,5,leech2,6,transfusion,latest", "CFEngine protocol version to use when connecting to the server. Default: undefined", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewBool("missing_ok", "true/false Do not treat missing file as an error. Default value: false", SYNTAX_STATUS_NORMAL),
ConstraintSyntaxNewNull()
};
Expand Down
14 changes: 14 additions & 0 deletions libpromises/rlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <eval_context.h>
#include <json.h>
#include <vars.h> /* IsCf3VarString */
#include <sequence.h>
#include <alloc.h>


static Rlist *RlistPrependRval(Rlist **start, Rval rval);
Expand Down Expand Up @@ -1776,3 +1778,15 @@ Rlist *RlistFromContainer(const JsonElement *container)

return list;
}

Seq *RlistToStringSeq(const Rlist *list)
{
Seq *seq = SeqNew(RlistLen(list), free);

for (const Rlist *rp = list; rp != NULL; rp = rp->next)
{
SeqAppend(seq, xstrdup(RlistScalarValue(rp)));
}

return seq;
}
8 changes: 8 additions & 0 deletions libpromises/rlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <writer.h>
#include <json.h>
#include <fncall.h>
#include <sequence.h>

/* NOTE: an empty Rlist is simply NULL. */
struct Rlist_
Expand Down Expand Up @@ -107,6 +108,13 @@ Rlist *RlistFromSplitRegex(const char *string, const char *regex, size_t max_ent
Rlist *RlistFromRegexSplitNoOverflow(const char *string, const char *regex, int max);
Rlist *RlistFromContainer(const JsonElement *container);

/**
* @brief Copy the scalar strings of a list into a sequence
* @param list List of scalar strings (NULL is the empty list)
* @return Sequence of copied strings. Destroy with SeqDestroy().
*/
Seq *RlistToStringSeq(const Rlist *list);

void RlistWrite(Writer *writer, const Rlist *list);
Rlist *RlistLast(Rlist *start);
void RlistFilter(Rlist **list, bool (*KeepPredicate)(void *item, void *predicate_data), void *predicate_user_data, void (*DestroyItem)(void *item));
Expand Down
Loading