implemented IETF Remediation Instructions attribute
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <ietf/ietf_attr_installed_packages.h>
|
||||
#include <ietf/ietf_attr_op_status.h>
|
||||
#include <ietf/ietf_attr_product_info.h>
|
||||
#include <ietf/ietf_attr_remediation_instr.h>
|
||||
#include <ietf/ietf_attr_string_version.h>
|
||||
#include <os_info/os_info.h>
|
||||
|
||||
@@ -309,6 +310,39 @@ static TNC_Result receive_message(imc_msg_t *in_msg)
|
||||
}
|
||||
e->destroy(e);
|
||||
}
|
||||
else if (attr_type.type == IETF_ATTR_REMEDIATION_INSTRUCTIONS)
|
||||
{
|
||||
ietf_attr_remediation_instr_t *attr_cast;
|
||||
pen_type_t parameters_type;
|
||||
chunk_t parameters, string, lang_code;
|
||||
|
||||
attr_cast = (ietf_attr_remediation_instr_t*)attr;
|
||||
parameters_type = attr_cast->get_parameters_type(attr_cast);
|
||||
parameters = attr_cast->get_parameters(attr_cast);
|
||||
|
||||
if (parameters_type.vendor_id == PEN_IETF)
|
||||
{
|
||||
switch (parameters_type.type)
|
||||
{
|
||||
case IETF_REMEDIATION_PARAMETERS_URI:
|
||||
DBG1(DBG_IMC, "remediation uri: '%.*s'",
|
||||
parameters.len, parameters.ptr);
|
||||
break;
|
||||
case IETF_REMEDIATION_PARAMETERS_STRING:
|
||||
string = attr_cast->get_string(attr_cast, &lang_code);
|
||||
DBG1(DBG_IMC, "remediation string: '%.*s' [%.*s]",
|
||||
string.len, string.ptr,
|
||||
lang_code.len, lang_code.ptr);
|
||||
break;
|
||||
default:
|
||||
DBG1(DBG_IMC, "remediation parameters %B", ¶meters);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG1(DBG_IMC, "remediation parameters %B", ¶meters);
|
||||
}
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <ietf/ietf_attr_op_status.h>
|
||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||
#include <ietf/ietf_attr_product_info.h>
|
||||
#include <ietf/ietf_attr_remediation_instr.h>
|
||||
#include <ietf/ietf_attr_string_version.h>
|
||||
#include <os_info/os_info.h>
|
||||
|
||||
@@ -224,6 +225,9 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
|
||||
if (os_name.len && os_version.len)
|
||||
{
|
||||
char *product_info;
|
||||
char *uri = "http://remediation.strongswan.org/fix-it/";
|
||||
char *string = "use a Linux operating system instead of Windows 1.2.3";
|
||||
char *lang_code = "en";
|
||||
|
||||
os_state = (imv_os_state_t*)state;
|
||||
os_state->set_info(os_state, os_name, os_version);
|
||||
@@ -233,6 +237,14 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
|
||||
{
|
||||
DBG1(DBG_IMV, "OS '%s' is not supported", product_info);
|
||||
|
||||
attr = ietf_attr_remediation_instr_create_from_string(
|
||||
chunk_create(string, strlen(string)),
|
||||
chunk_create(lang_code, strlen(lang_code)));
|
||||
out_msg->add_attribute(out_msg, attr);
|
||||
attr = ietf_attr_remediation_instr_create_from_uri(
|
||||
chunk_create(uri, strlen(uri)));
|
||||
out_msg->add_attribute(out_msg, attr);
|
||||
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_ISOLATE,
|
||||
TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MINOR);
|
||||
|
||||
Reference in New Issue
Block a user