Blame utils/oscap-tool.h

Packit 517ee8
/*
Packit 517ee8
 * Copyright 2010 Red Hat Inc., Durham, North Carolina.
Packit 517ee8
 * All Rights Reserved.
Packit 517ee8
 *
Packit 517ee8
 * This library is free software; you can redistribute it and/or
Packit 517ee8
 * modify it under the terms of the GNU Lesser General Public
Packit 517ee8
 * License as published by the Free Software Foundation; either
Packit 517ee8
 * version 2.1 of the License, or (at your option) any later version.
Packit 517ee8
 *
Packit 517ee8
 * This library is distributed in the hope that it will be useful, 
Packit 517ee8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 517ee8
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 517ee8
 * Lesser General Public License for more details.
Packit 517ee8
 *
Packit 517ee8
 * You should have received a copy of the GNU Lesser General Public
Packit 517ee8
 * License along with this library; if not, write to the Free Software 
Packit 517ee8
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit 517ee8
 *
Packit 517ee8
 * Authors:
Packit 517ee8
 *      Maros Barabas <mbarabas@redhat.com>
Packit 517ee8
 */
Packit 517ee8
Packit 517ee8
#pragma once
Packit 517ee8
#ifndef OSCAP_TOOL_H_
Packit 517ee8
#define OSCAP_TOOL_H_
Packit 517ee8
Packit 517ee8
/* Standard header files */
Packit 517ee8
#include <stdio.h>
Packit 517ee8
#include <stdlib.h>
Packit 517ee8
#include <string.h>
Packit 517ee8
#ifdef HAVE_GETOPT_H
Packit 517ee8
#include <getopt.h>
Packit 517ee8
#endif
Packit 517ee8
Packit 517ee8
/* openscap common */
Packit 517ee8
#include <oscap.h>
Packit 517ee8
#include <oscap_error.h>
Packit 517ee8
#include <oscap_text.h>
Packit 517ee8
Packit 517ee8
#include <oval_definitions.h>
Packit 517ee8
#if defined(OVAL_PROBES_ENABLED)
Packit 517ee8
# include <oval_probe.h>
Packit 517ee8
#endif
Packit 517ee8
#include <cvss_score.h>
Packit 517ee8
#include <xccdf_benchmark.h>
Packit 517ee8
#include <xccdf_session.h>
Packit 517ee8
#include <cpe_dict.h>
Packit 517ee8
#include <cpe_name.h>
Packit 517ee8
#include <cve_nvd.h>
Packit 517ee8
#include <cvrf.h>
Packit 517ee8
Packit 517ee8
#define OSCAP_PRODUCTNAME "cpe:/a:open-scap:oscap"
Packit 517ee8
#define OSCAP_ERR_MSG "OpenSCAP Error:"
Packit 517ee8
Packit 517ee8
struct oscap_action;
Packit 517ee8
struct oscap_module;
Packit 517ee8
Packit 517ee8
typedef int(*oscap_tool_func)(const struct oscap_action* action);
Packit 517ee8
typedef bool(*oscap_option_func)(int argc, char **argv, struct oscap_action* action);
Packit 517ee8
Packit 517ee8
struct oscap_module {
Packit 517ee8
    const char *name;
Packit 517ee8
    const char *usage;
Packit 517ee8
    const char *usage_extra;
Packit 517ee8
    const char *summary;
Packit 517ee8
    const char *help;
Packit 517ee8
    bool hidden;
Packit 517ee8
    struct oscap_module *parent;
Packit 517ee8
    struct oscap_module **submodules;
Packit 517ee8
    oscap_tool_func func;
Packit 517ee8
    oscap_option_func opt_parser;
Packit 517ee8
    void *user;
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
// standard oscap CLI exit statuses
Packit 517ee8
enum oscap_exitcode {
Packit 517ee8
    OSCAP_OK             =   0, // successful exit
Packit 517ee8
    OSCAP_ERROR          =   1, // an error occured
Packit 517ee8
    OSCAP_FAIL           =   2, // a process (e.g. scan or validation) failed
Packit 517ee8
    OSCAP_ERR_FETCH      =   1, // cold not fetch input file (same as error for now)
Packit 517ee8
    OSCAP_BADARGS        = 100, // bad commandline arguments
Packit 517ee8
    OSCAP_BADMODULE      = 101, // unrecognized module
Packit 517ee8
    OSCAP_UNIMPL_MOD     = 110, // module functionality not implemented
Packit 517ee8
    OSCAP_UNIMPL         = 111, // functionality not implemented
Packit 517ee8
    // end of list
Packit 517ee8
    OSCAP_EXITCODES_END_ = 120  // any code returned shall not be higher than this
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
struct cvss_impact;
Packit 517ee8
Packit 517ee8
struct ds_action {
Packit 517ee8
	char* file;
Packit 517ee8
	char* target;
Packit 517ee8
	char* xccdf_result;
Packit 517ee8
	char** oval_results;
Packit 517ee8
	size_t oval_result_count;
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
struct cpe_action {
Packit 517ee8
	char * name;
Packit 517ee8
	char * dict;
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
struct cve_action {
Packit 517ee8
        char * file;
Packit 517ee8
        char * cve;
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
struct cvrf_action {
Packit 517ee8
	int index;
Packit 517ee8
	char *f_cvrf;
Packit 517ee8
	char *f_results;
Packit 517ee8
	char *f_output;
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
struct oscap_action {
Packit 517ee8
        struct oscap_module *module;
Packit 517ee8
	/* files */
Packit 517ee8
        char *f_xccdf;
Packit 517ee8
	char *f_datastream_id;
Packit 517ee8
	char *f_xccdf_id;
Packit 517ee8
	char *f_oval_id;
Packit 517ee8
	char *f_benchmark_id;
Packit 517ee8
	char *f_report_id;
Packit 517ee8
        char *f_oval;
Packit 517ee8
        char **f_ovals;
Packit 517ee8
	char *f_syschar;
Packit 517ee8
	char *f_directives;
Packit 517ee8
        char *f_results;
Packit 517ee8
	char *f_results_stig;
Packit 517ee8
	char *f_results_arf;
Packit 517ee8
        char *f_report;
Packit 517ee8
	char *f_variables;
Packit 517ee8
	char *f_verbose_log;
Packit 517ee8
	/* others */
Packit 517ee8
        char *profile;
Packit 517ee8
	const char *rule;
Packit 517ee8
        char *format;
Packit 517ee8
        const char *tmpl;
Packit 517ee8
        char *id;
Packit 517ee8
        char *oval_template;
Packit 517ee8
        char *cvss_vector;
Packit 517ee8
        int hide_profile_info;
Packit 517ee8
        char *stylesheet;
Packit 517ee8
	char *tailoring_file;
Packit 517ee8
	char *tailoring_id;
Packit 517ee8
	char *cpe;
Packit 517ee8
Packit 517ee8
        struct cvss_impact *cvss_impact;
Packit 517ee8
	struct ds_action* ds_action;
Packit 517ee8
	struct cpe_action * cpe_action;
Packit 517ee8
	struct cve_action * cve_action;
Packit 517ee8
	struct cvrf_action * cvrf_action;
Packit 517ee8
	char *file;
Packit 517ee8
Packit 517ee8
	int verbosity;
Packit 517ee8
	int show_profiles_only;
Packit 517ee8
	int provide_machine_readable_output;
Packit 517ee8
	int doctype;
Packit 517ee8
	int force;
Packit 517ee8
	int validate;
Packit Bot 61bab5
	int validate_signature;
Packit Bot 61bab5
	int enforce_signature;
Packit 517ee8
	int schematron;
Packit 517ee8
	int remote_resources;
Packit 517ee8
	int progress;
Packit 517ee8
	int oval_results;
Packit 517ee8
	int without_sys_chars;
Packit 517ee8
	int thin_results;
Packit 517ee8
	int remediate;
Packit 517ee8
	char *sce_template;
Packit 517ee8
	int check_engine_results;
Packit 517ee8
	int export_variables;
Packit 517ee8
        int list_dynamic;
Packit 517ee8
	char *verbosity_level;
Packit 517ee8
	char *fix_type;
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
int app_xslt(const char *infile, const char *xsltfile, const char *outfile, const char **params);
Packit 517ee8
int reporter(const char *file, int line, const char *msg, void *arg);
Packit 517ee8
Packit 517ee8
int oscap_module_process(struct oscap_module *module, int argc, char **argv);
Packit 517ee8
bool oscap_module_usage(struct oscap_module *module, FILE *out, const char *err, ...);
Packit 517ee8
int oscap_module_call(struct oscap_action *action);
Packit 517ee8
Packit 517ee8
void oscap_print_error(void);
Packit 517ee8
bool check_verbose_options(struct oscap_action *action);
Packit 517ee8
void download_reporting_callback(bool warning, const char *format, ...);
Packit 517ee8
Packit 517ee8
void report_missing_profile(const char *profile_suffix, const char *source_file);
Packit 517ee8
void report_multiple_profile_matches(const char *profile_suffix, const char *source_file);
Packit 517ee8
Packit 517ee8
int xccdf_set_profile_or_report_bad_id(struct xccdf_session *session, const char *profile_id, const char *source_file);
Packit 517ee8
int evaluate_suffix_match_result_with_custom_reports(int suffix_match_result, const char *profile_suffix, const char *source_file, void (* report_missing)(const char *, const char *), void (* report_multiple)(const char *, const char *));
Packit 517ee8
int evaluate_suffix_match_result(int suffix_match_result, const char *profile_suffix, const char *source_file);
Packit 517ee8
Packit 517ee8
extern struct oscap_module OSCAP_ROOT_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_DS_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_XCCDF_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_CVSS_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_OVAL_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_CVE_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_CVRF_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_CPE_MODULE;
Packit 517ee8
extern struct oscap_module OSCAP_INFO_MODULE;
Packit 517ee8
Packit 517ee8
#ifndef HAVE_GETOPT_H
Packit 517ee8
Packit 517ee8
#define __getopt_argv_const const
Packit 517ee8
#define no_argument		0
Packit 517ee8
#define required_argument	1
Packit 517ee8
#define optional_argument	2
Packit 517ee8
Packit 517ee8
extern char *optarg;
Packit 517ee8
extern int optind;
Packit 517ee8
extern int opterr;
Packit 517ee8
extern int optopt;
Packit 517ee8
Packit 517ee8
struct option
Packit 517ee8
{
Packit 517ee8
	const char *name;
Packit 517ee8
	int has_arg;
Packit 517ee8
	int *flag;
Packit 517ee8
	int val;
Packit 517ee8
};
Packit 517ee8
Packit 517ee8
getopt_long(int ___argc, char *__getopt_argv_const *___argv,
Packit 517ee8
	const char *__shortopts,
Packit 517ee8
	const struct option *__longopts, int *__longind);
Packit 517ee8
Packit 517ee8
#endif
Packit 517ee8
Packit 517ee8
#endif //OSCAP_TOOL_H_