<commit_before>/*
 *
 * Example program that read OVAL content (argv[1]) and
 * evaluate all objects in it. The output oval results xml file.
 *
 * author: <NAME> <<EMAIL>>
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oval_agent_api.h>
#include <assume.h>

int main(int argc, char **argv) {

  /* definition model populate */
  struct oval_definition_model *def_model=NULL;
  def_model = oval_definition_model_import(argv[1]);
  assume(def_model != NULL);

  assume(oval_definition_model_is_valid(def_model));

  /* create syschar model */
  struct oval_syschar_model *sys_model = oval_syschar_model_new(def_model);
  assume(sys_model != NULL);

  /* create probe session */
  oval_probe_session_t *sess = oval_probe_session_new(sys_model);

  /* probe sysinfo */
  assume(oval_probe_session_query_sysinfo(sess) == 0);

  /* call probes */
  assume(oval_probe_session_query_objects(sess) == 0);

  /* create result model */
  struct oval_syschar_model *sys_models[] = {sys_model, NULL};
  struct oval_results_model* res_model = oval_results_model_new( def_model, sys_models );
  assume(res_model != NULL);

  /* evaluate gathered system characteristics */
  oval_results_model_eval(res_model);

  /* set up directives */
  struct oval_result_directives * res_direct = oval_result_directives_new(res_model);
  assume(res_direct != NULL);

  oval_result_directives_set_reported(res_direct, OVAL_RESULT_INVALID, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_TRUE, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_FALSE, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_UNKNOWN, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_ERROR, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_NOT_EVALUATED, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_NOT_APPLICABLE , true);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_FALSE, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_TRUE, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_INVALID, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_UNKNOWN, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_ERROR, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_NOT_EVALUATED, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_NOT_APPLICABLE, OVAL_DIRECTIVE_CONTENT_FULL);

  /* report results */
  oval_results_model_export(res_model, res_direct, argv[2]);

  /* free */
  oval_probe_session_destroy(sess);
  oval_definition_model_free(def_model);
  oval_syschar_model_free(sys_model);
  oval_results_model_free(res_model);

  return 0;
}

/* /\* */
/*  * test_probes.c */
/*  * */
/*  *  Created on: Aug 4, 2009 */
/*  *      Author: <NAME> */
/*  *\/ */

/* #include <stdio.h> */
/* #include <string.h> */
/* #include <stdlib.h> */
/* #include "oval_agent_api.h" */
/* #include "oval_definitions_impl.h" */
/* #include "oval_system_characteristics_impl.h" */<commit_msg>[tests] test_probes: use oscap_cleanup()<commit_after>/*
 *
 * Example program that read OVAL content (argv[1]) and
 * evaluate all objects in it. The output oval results xml file.
 *
 * author: <NAME> <<EMAIL>>
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oval_agent_api.h>
#include <assume.h>

int main(int argc, char **argv) {

  /* definition model populate */
  struct oval_definition_model *def_model=NULL;
  def_model = oval_definition_model_import(argv[1]);
  assume(def_model != NULL);

  assume(oval_definition_model_is_valid(def_model));

  /* create syschar model */
  struct oval_syschar_model *sys_model = oval_syschar_model_new(def_model);
  assume(sys_model != NULL);

  /* create probe session */
  oval_probe_session_t *sess = oval_probe_session_new(sys_model);

  /* probe sysinfo */
  assume(oval_probe_session_query_sysinfo(sess) == 0);

  /* call probes */
  assume(oval_probe_session_query_objects(sess) == 0);

  /* create result model */
  struct oval_syschar_model *sys_models[] = {sys_model, NULL};
  struct oval_results_model* res_model = oval_results_model_new( def_model, sys_models );
  assume(res_model != NULL);

  /* evaluate gathered system characteristics */
  oval_results_model_eval(res_model);

  /* set up directives */
  struct oval_result_directives * res_direct = oval_result_directives_new(res_model);
  assume(res_direct != NULL);

  oval_result_directives_set_reported(res_direct, OVAL_RESULT_INVALID, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_TRUE, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_FALSE, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_UNKNOWN, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_ERROR, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_NOT_EVALUATED, true);
  oval_result_directives_set_reported(res_direct, OVAL_RESULT_NOT_APPLICABLE , true);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_FALSE, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_TRUE, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_INVALID, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_UNKNOWN, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_ERROR, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_NOT_EVALUATED, OVAL_DIRECTIVE_CONTENT_FULL);
  oval_result_directives_set_content(res_direct,OVAL_RESULT_NOT_APPLICABLE, OVAL_DIRECTIVE_CONTENT_FULL);

  /* report results */
  oval_results_model_export(res_model, res_direct, argv[2]);

  /* free */
  oval_probe_session_destroy(sess);
  oval_definition_model_free(def_model);
  oval_syschar_model_free(sys_model);
  oval_results_model_free(res_model);
  oscap_cleanup();

  return 0;
}

/* /\* */
/*  * test_probes.c */
/*  * */
/*  *  Created on: Aug 4, 2009 */
/*  *      Author: <NAME> */
/*  *\/ */

/* #include <stdio.h> */
/* #include <string.h> */
/* #include <stdlib.h> */
/* #include "oval_agent_api.h" */
/* #include "oval_definitions_impl.h" */
/* #include "oval_system_characteristics_impl.h" */
{'fraction_non_alphanumeric': 0.10939907550077041, 'fraction_numerical': 0.003389830508474576, 'mean_word_length': 6.469505178365938, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1187605', 'n_tokens_mistral': 2401, 'n_tokens_neox': 2282, 'n_words': 342}