| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
#include <config.h> |
| 25 |
#endif |
| 26 |
|
| 27 |
#include <xccdf_benchmark.h> |
| 28 |
#include <stdio.h> |
| 29 |
#include <string.h> |
| 30 |
#include <stdlib.h> |
| 31 |
#include <oscap_source.h> |
| 32 |
#include "common/public/oscap_error.h" |
| 33 |
|
| 34 |
|
| 35 |
int main(int argc, char **argv) |
| 36 |
{ |
| 37 |
if (argc < 2) return 1; |
| 38 |
|
| 39 |
if (strcmp(argv[1], "--export") == 0) { |
| 40 |
if (argc != 4) return 1; |
| 41 |
struct oscap_source *source = oscap_source_new_from_file(argv[2]); |
| 42 |
struct xccdf_benchmark *bench = xccdf_benchmark_import_source(source); |
| 43 |
oscap_source_free(source); |
| 44 |
if (bench == NULL) return 1; |
| 45 |
xccdf_benchmark_export(bench, argv[3]); |
| 46 |
xccdf_benchmark_free(bench); |
| 47 |
oscap_cleanup(); |
| 48 |
return 0; |
| 49 |
} |
| 50 |
else if (strcmp(argv[1], "--validate") == 0) { |
| 51 |
if (argc != 4) { |
| 52 |
fprintf(stderr, "Usage: %s --validate ver xccdf\n", argv[0]); |
| 53 |
return 1; |
| 54 |
} |
| 55 |
|
| 56 |
struct oscap_source *source = oscap_source_new_from_file(argv[3]); |
| 57 |
if (oscap_source_validate(source, NULL, stdout)) { |
| 58 |
fprintf(stderr, "ERROR: %s\n", oscap_err_desc()); |
| 59 |
oscap_source_free(source); |
| 60 |
return 1; |
| 61 |
} |
| 62 |
oscap_source_free(source); |
| 63 |
return 0; |
| 64 |
|
| 65 |
} |
| 66 |
else { |
| 67 |
fprintf(stderr, "Unknown mode: %s\n", argv[1]); |
| 68 |
} |
| 69 |
|
| 70 |
return 1; |
| 71 |
} |
| 72 |
|