Esempio n. 1
0
struct oval_test *oval_test_new(struct oval_definition_model *model, const char *id)
{
	__attribute__nonnull__(model);
	oval_test_t *test;

	test = (oval_test_t *) oscap_alloc(sizeof(oval_test_t));
	if (test == NULL)
		return NULL;

	test->deprecated = 0;
	test->version = 0;
	test->check = OVAL_CHECK_UNKNOWN;
	test->existence = OVAL_EXISTENCE_UNKNOWN;
	test->state_operator = OVAL_OPERATOR_AND;
	test->subtype = OVAL_SUBTYPE_UNKNOWN;
	test->comment = NULL;
	test->id = oscap_strdup(id);
	test->object = NULL;
	test->states = oval_collection_new();
	test->notes = oval_collection_new();
	test->model = model;

	oval_definition_model_add_test(model, test);

	return test;
}
Esempio n. 2
0
struct oval_affected *oval_affected_new(struct oval_definition_model *model)
{
	struct oval_affected *affected = (struct oval_affected *)oscap_alloc(sizeof(oval_affected_t));
	if (affected == NULL)
		return NULL;

	affected->model = model;
	affected->family = OVAL_AFCFML_UNKNOWN;
	affected->platforms = oval_collection_new();
	affected->products = oval_collection_new();
	return affected;
}
Esempio n. 3
0
int oval_definition_model_bind_variable_model(struct oval_definition_model *defmodel,
					       struct oval_variable_model *varmodel)
{
	struct oval_string_iterator *evar_id_itr;

	if (!defmodel->bound_variable_models)
		defmodel->bound_variable_models = oval_collection_new();

	oval_collection_add(defmodel->bound_variable_models, varmodel);

	/* todo: keep reference count for each variable model if it can be bound to multiple definition models */

	evar_id_itr = oval_variable_model_get_variable_ids(varmodel);
	while (oval_string_iterator_has_more(evar_id_itr)) {
		char *evar_id;
		struct oval_variable *var;

		evar_id = oval_string_iterator_next(evar_id_itr);
		var = oval_definition_model_get_variable(defmodel, evar_id);
		if (!var)
			continue;

		oval_variable_bind_ext_var(var, varmodel, evar_id);
	}
	oval_string_iterator_free(evar_id_itr);

	return 0;
}
Esempio n. 4
0
struct oval_result_test *oval_result_test_new(struct oval_result_system *sys, char *tstid)
{
	oval_result_test_t *test = (oval_result_test_t *)
	    oscap_alloc(sizeof(oval_result_test_t));
	if (test == NULL)
		return NULL;

	struct oval_syschar_model *syschar_model = oval_result_system_get_syschar_model(sys);
	struct oval_definition_model *definition_model = oval_syschar_model_get_definition_model(syschar_model);
	test->system = sys;
	test->test = oval_definition_model_get_new_test(definition_model, tstid);
	test->messages = oval_collection_new();
	test->result = OVAL_RESULT_NOT_EVALUATED;
	test->instance = 1;
	test->items = oval_collection_new();
	test->bindings = oval_collection_new();
	test->bindings_initialized = false;
	return test;
}
Esempio n. 5
0
struct oval_state_content *oval_state_content_new(struct oval_definition_model *model)
{
	oval_state_content_t *content = (oval_state_content_t *)
	    oscap_alloc(sizeof(oval_state_content_t));
	if (content == NULL)
		return NULL;

	content->entity = NULL;
	content->record_fields = oval_collection_new();
	content->ent_check = OVAL_CHECK_UNKNOWN;
	content->var_check = OVAL_CHECK_UNKNOWN;
	content->check_existence = OVAL_EXISTENCE_UNKNOWN;
	content->model = model;
	return content;
}
struct oval_result_definition *oval_result_definition_new(struct oval_result_system *sys, char *definition_id) {
	oval_result_definition_t *definition = (oval_result_definition_t *)
	    oscap_alloc(sizeof(oval_result_definition_t));
	if (definition == NULL)
		return NULL;

	definition->system = sys;
	struct oval_syschar_model *syschar_model = oval_result_system_get_syschar_model(sys);
	struct oval_definition_model *definition_model = oval_syschar_model_get_definition_model(syschar_model);
	definition->definition = oval_definition_model_get_new_definition(definition_model, definition_id);
	definition->result = OVAL_RESULT_NOT_EVALUATED;
	definition->criteria = NULL;
	definition->messages = oval_collection_new();
	definition->variable_instance_hint = 1;
	definition->instance = 1;
	return definition;
}
Esempio n. 7
0
void oval_sysent_add_record_field(struct oval_sysent *sysent, struct oval_record_field *rf)
{
	if (sysent->record_fields == NULL)
		sysent->record_fields = oval_collection_new();
	oval_collection_add(sysent->record_fields, rf);
}