implemented policy rules for OS IMV
This commit is contained in:
@@ -0,0 +1,459 @@
|
||||
/* Products */
|
||||
|
||||
INSERT INTO products ( /* 1 */
|
||||
name
|
||||
) VALUES (
|
||||
'Debian 7.0'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 2 */
|
||||
name
|
||||
) VALUES (
|
||||
'Debian 7.0 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 3 */
|
||||
name
|
||||
) VALUES (
|
||||
'Debian 7.0 x86_64'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 4 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 10.04'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 5 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 10.04 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 6 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 10.04 x86_64'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 7 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 10.10'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 8 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 10.10 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 9 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 10.10 x86_64'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 10 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 11.04'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 11 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 11.04 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 12 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 11.04 x86_64'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 13 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 11.10'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 14 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 11.10 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 15 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 11.10 x86_64'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 16 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 12.04'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 17 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 12.04 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 18 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 12.04 x86_64'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 19 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 12.10'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 20 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 12.10 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 21 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 12.10 x86_64'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 22 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 13.04'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 23 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 13.04 i686'
|
||||
);
|
||||
|
||||
INSERT INTO products ( /* 24 */
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 13.04 x86_64'
|
||||
);
|
||||
|
||||
/* Directories */
|
||||
|
||||
INSERT INTO directories ( /* 1 */
|
||||
path
|
||||
) VALUES (
|
||||
'/bin'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 2 */
|
||||
path
|
||||
) VALUES (
|
||||
'/etc'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 3 */
|
||||
path
|
||||
) VALUES (
|
||||
'/lib'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 4 */
|
||||
path
|
||||
) VALUES (
|
||||
'/lib/i386-linux-gnu'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 5 */
|
||||
path
|
||||
) VALUES (
|
||||
'/lib/x86_64-linux-gnu'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 6 */
|
||||
path
|
||||
) VALUES (
|
||||
'/lib/xtables'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 7 */
|
||||
path
|
||||
) VALUES (
|
||||
'/sbin'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 8 */
|
||||
path
|
||||
) VALUES (
|
||||
'/usr/bin'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 9 */
|
||||
path
|
||||
) VALUES (
|
||||
'/usr/lib'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 10 */
|
||||
path
|
||||
) VALUES (
|
||||
'/usr/lib/i386-linux-gnu'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 11 */
|
||||
path
|
||||
) VALUES (
|
||||
'/usr/lib/x86_64-linux-gnu'
|
||||
);
|
||||
|
||||
INSERT INTO directories ( /* 12 */
|
||||
path
|
||||
) VALUES (
|
||||
'/usr/sbin'
|
||||
);
|
||||
|
||||
/* Files */
|
||||
|
||||
INSERT INTO files ( /* 1 */
|
||||
name, dir
|
||||
) VALUES (
|
||||
'libcrypto.so.1.0.0', 5
|
||||
);
|
||||
|
||||
INSERT INTO files ( /* 2 */
|
||||
name, dir
|
||||
) VALUES (
|
||||
'libcrypto.so.1.0.0', 11
|
||||
);
|
||||
|
||||
INSERT INTO files ( /* 3 */
|
||||
name, dir
|
||||
) VALUES (
|
||||
'libssl.so.1.0.0', 5
|
||||
);
|
||||
|
||||
INSERT INTO files ( /* 4 */
|
||||
name, dir
|
||||
) VALUES (
|
||||
'libssl.so.1.0.0', 11
|
||||
);
|
||||
|
||||
INSERT INTO files ( /* 5 */
|
||||
name, dir
|
||||
) VALUES (
|
||||
'openssl', 8
|
||||
);
|
||||
|
||||
/* Product-File */
|
||||
|
||||
INSERT INTO product_file (
|
||||
product, file, measurement
|
||||
) VALUES (
|
||||
3, 1, 1
|
||||
);
|
||||
|
||||
INSERT INTO product_file (
|
||||
product, file, measurement
|
||||
) VALUES (
|
||||
3, 3, 1
|
||||
);
|
||||
|
||||
INSERT INTO product_file (
|
||||
product, file, measurement
|
||||
) VALUES (
|
||||
3, 5, 1
|
||||
);
|
||||
|
||||
/* Algorithms */
|
||||
|
||||
INSERT INTO algorithms (
|
||||
id, name
|
||||
) VALUES (
|
||||
65536, 'SHA1-IMA'
|
||||
);
|
||||
|
||||
INSERT INTO algorithms (
|
||||
id, name
|
||||
) VALUES (
|
||||
32768, 'SHA1'
|
||||
);
|
||||
|
||||
INSERT INTO algorithms (
|
||||
id, name
|
||||
) VALUES (
|
||||
16384, 'SHA256'
|
||||
);
|
||||
|
||||
INSERT INTO algorithms (
|
||||
id, name
|
||||
) VALUES (
|
||||
8192, 'SHA384'
|
||||
);
|
||||
|
||||
/* File Hashes */
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 2, 32768, X'6c6f8e12f6cbfba612e780374c4cdcd40f20968a'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 2, 16384, X'dbcecd19d59310183cf5c31ddee29e8d7bec64d3f9583aad074330a1b3024b07'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 2, 8192, X'197c5385e5853003188833d4f991136c1b0875fa416a60b1159f64e57e457b3184762c884a802a2bda194c058e3bd953'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 4, 32768, X'3ad204f99eb7262efab79cfca02628870ea76361'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 4, 16384, X'3a2170aad92fdd58b55e0e199822bc873cf587b2d1eb1ed7ed8dcea97ae86376'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 4, 8192, X'f778076baa876b5e4b502494a3db081fb09dd870dee6991d54104a74b7e009c58fe261db5ffd13c11e08ef0cefcfa59f'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 5, 32768, X'ecd9c7076cc0572724c7a67db7f19c2831e0445f'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 5, 16384, X'28f3ea5afd34444c8232ea75003131e294a0c9b847de300e4b205d38c1a41305'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
3, 5, 8192, X'51921a8b9322f2d3f06d55002ff40a79da67e70cb563b2a50977642d603dfac2ccbb68b3d32a8bb350769b75d6254208'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 1, 32768, X'd9309b9e45928239d7a7b18711e690792632cce4'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 1, 16384, X'dbfa1856d278d8707c4989b30dd065b4bcd309908f0f2e6e66ff2aa83ff93f59'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 1, 8192, X'fb8d027f03bb5ebb47741ed247eb9e174127b714d20229885feb37e0979aeb14a1b74020cded891d680441093625729c'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 3, 32768, X'3715f2f94016a91fab5bbc503f0f1d43c5a9fc2b'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 3, 16384, X'c03a5296b5decb87b01517f9927a8b2349dfb29ff9f5ba084f994c155ca5d4be'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 3, 8192, X'b8bc345f56115235cc6091f61e312ce43ea54a5b99e7295002ae7b415fd35e06ec4c731ab70ad00d784bb53a318a2fa0'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 5, 32768, X'e59602f4edf24c1b36199588886d06665d4adcd7'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 5, 16384, X'090e1b77bda7fe665e498c6b5e09dbb7ddc5cfe57f213de48f4fb6736484f500'
|
||||
);
|
||||
|
||||
INSERT INTO file_hashes (
|
||||
product, file, algo, hash
|
||||
) VALUES (
|
||||
21, 5, 8192, X'7cbdb4612a13443dba910ecdef5161f2213e52c9b4a2eef14bcee5d287e9df931cd022e9e9715518ad9c9b6e3384a668'
|
||||
);
|
||||
|
||||
/* Packages */
|
||||
|
||||
INSERT INTO packages ( /* 1 */
|
||||
name
|
||||
) VALUES (
|
||||
'libssl-dev'
|
||||
);
|
||||
|
||||
INSERT INTO packages ( /* 2 */
|
||||
name
|
||||
) VALUES (
|
||||
'libssl1.0.0'
|
||||
);
|
||||
|
||||
INSERT INTO packages ( /* 3 */
|
||||
name
|
||||
) VALUES (
|
||||
'libssl1.0.0-dbg'
|
||||
);
|
||||
|
||||
INSERT INTO packages ( /* 4 */
|
||||
name
|
||||
) VALUES (
|
||||
'openssl'
|
||||
);
|
||||
|
||||
/* Versions */
|
||||
|
||||
INSERT INTO versions (
|
||||
package, product, release, time
|
||||
) values (
|
||||
1, 1, '1.0.1e-2', 1366531494
|
||||
);
|
||||
|
||||
INSERT INTO versions (
|
||||
package, product, release, time
|
||||
) values (
|
||||
2, 1, '1.0.1e-2', 1366531494
|
||||
);
|
||||
|
||||
INSERT INTO versions (
|
||||
package, product, release, time
|
||||
) values (
|
||||
3, 1, '1.0.1e-2', 1366531494
|
||||
);
|
||||
|
||||
INSERT INTO versions (
|
||||
package, product, release, time
|
||||
) values (
|
||||
4, 1, '1.0.1e-2', 1366531494
|
||||
);
|
||||
@@ -16,10 +16,12 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "imv_database.h"
|
||||
#include "imv_workitem.h"
|
||||
|
||||
#include <utils/debug.h>
|
||||
|
||||
@@ -218,6 +220,74 @@ METHOD(imv_database_t, policy_script, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
/** implements enumerator_t */
|
||||
enumerator_t public;
|
||||
/** session ID */
|
||||
int session_id;
|
||||
/** database enumerator */
|
||||
enumerator_t *e;
|
||||
} workitem_enumerator_t;
|
||||
|
||||
/**
|
||||
* Implementation of enumerator.enumerate
|
||||
*/
|
||||
static bool workitem_enumerator_enumerate(workitem_enumerator_t *this, ...)
|
||||
{
|
||||
imv_workitem_t **workitem;
|
||||
imv_workitem_type_t type;
|
||||
int rec_fail, rec_noresult;
|
||||
char *argument;
|
||||
va_list args;
|
||||
|
||||
va_start(args, this);
|
||||
workitem = va_arg(args, imv_workitem_t**);
|
||||
va_end(args);
|
||||
|
||||
if (this->e->enumerate(this->e, &type, &argument, &rec_fail, &rec_noresult))
|
||||
{
|
||||
*workitem = imv_workitem_create(this->session_id, type, argument,
|
||||
rec_fail, rec_noresult);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of enumerator.destroy
|
||||
*/
|
||||
static void workitem_enumerator_destroy(workitem_enumerator_t *this)
|
||||
{
|
||||
this->e->destroy(this->e);
|
||||
free(this);
|
||||
}
|
||||
|
||||
METHOD(imv_database_t, create_workitem_enumerator, enumerator_t*,
|
||||
private_imv_database_t *this, int session_id)
|
||||
{
|
||||
workitem_enumerator_t *enumerator;
|
||||
enumerator_t *e;
|
||||
|
||||
e = this->db->query(this->db,
|
||||
"SELECT type, argument, rec_fail, rec_noresult "
|
||||
"FROM workitems WHERE session = ?",
|
||||
DB_INT, session_id, DB_INT, DB_TEXT, DB_INT, DB_INT);
|
||||
if (!e)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)workitem_enumerator_enumerate,
|
||||
.destroy = (void*)workitem_enumerator_destroy,
|
||||
},
|
||||
.e = e,
|
||||
);
|
||||
|
||||
return (enumerator_t*)enumerator;
|
||||
}
|
||||
|
||||
METHOD(imv_database_t, get_database, database_t*,
|
||||
private_imv_database_t *this)
|
||||
{
|
||||
@@ -244,6 +314,7 @@ imv_database_t *imv_database_create(char *uri)
|
||||
.add_product = _add_product,
|
||||
.add_device = _add_device,
|
||||
.policy_script = _policy_script,
|
||||
.create_workitem_enumerator = _create_workitem_enumerator,
|
||||
.get_database = _get_database,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
|
||||
@@ -71,6 +71,15 @@ struct imv_database_t {
|
||||
*/
|
||||
bool (*policy_script)(imv_database_t *this, int session_id, bool start);
|
||||
|
||||
/**
|
||||
* Create enumerator for workitems assigned to a session ID
|
||||
*
|
||||
* @param session_id Session ID
|
||||
* @return Enumerator of workitems assigned to session ID
|
||||
*/
|
||||
enumerator_t* (*create_workitem_enumerator)(imv_database_t *this,
|
||||
int session_id);
|
||||
|
||||
/**
|
||||
* Get database handle
|
||||
*
|
||||
|
||||
@@ -318,6 +318,12 @@ METHOD(imv_msg_t, receive, TNC_Result,
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
METHOD(imv_msg_t, get_attribute_count, int,
|
||||
private_imv_msg_t *this)
|
||||
{
|
||||
return this->attr_list->get_count(this->attr_list);
|
||||
}
|
||||
|
||||
METHOD(imv_msg_t, create_attribute_enumerator, enumerator_t*,
|
||||
private_imv_msg_t *this)
|
||||
{
|
||||
@@ -363,6 +369,7 @@ imv_msg_t *imv_msg_create(imv_agent_t *agent, imv_state_t *state,
|
||||
.send_assessment = _send_assessment,
|
||||
.receive = _receive,
|
||||
.add_attribute = _add_attribute,
|
||||
.get_attribute_count = _get_attribute_count,
|
||||
.create_attribute_enumerator = _create_attribute_enumerator,
|
||||
.get_encoding = _get_encoding,
|
||||
.destroy = _destroy,
|
||||
|
||||
@@ -91,6 +91,13 @@ struct imv_msg_t {
|
||||
*/
|
||||
void (*add_attribute)(imv_msg_t *this, pa_tnc_attr_t *attr);
|
||||
|
||||
/**
|
||||
* Get the number of PA-TNC attributes in the send queue
|
||||
*
|
||||
* @return number of PA-TNC attribute in send queue
|
||||
*/
|
||||
int (*get_attribute_count)(imv_msg_t *this);
|
||||
|
||||
/**
|
||||
* Enumerator over PA-TNC attributes contained in the PA-TNC message
|
||||
*
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef IMV_STATE_H_
|
||||
#define IMV_STATE_H_
|
||||
|
||||
#include "imv_workitem.h"
|
||||
|
||||
#include <tncifimv.h>
|
||||
|
||||
#include <library.h>
|
||||
@@ -108,6 +110,39 @@ struct imv_state_t {
|
||||
*/
|
||||
int (*get_session_id)(imv_state_t *this);
|
||||
|
||||
/**
|
||||
* Add workitem to list
|
||||
*
|
||||
* @param workitem Workitem to be added
|
||||
*/
|
||||
void (*add_workitem)(imv_state_t *this, imv_workitem_t *workitem);
|
||||
|
||||
/**
|
||||
* Return number of pending workitems
|
||||
*
|
||||
* @return Number of pending workitems
|
||||
*/
|
||||
int (*get_workitem_count)(imv_state_t *this);
|
||||
|
||||
/**
|
||||
* Create an enumerator over the pending workitems
|
||||
*
|
||||
* @return Workitem enumerator
|
||||
*/
|
||||
enumerator_t* (*create_workitem_enumerator)(imv_state_t *this);
|
||||
|
||||
/**
|
||||
* Finalize a workitem
|
||||
*
|
||||
* @param enumerator Current enumerator position pointing to workitem
|
||||
* @param workitem Workitem to be finalized
|
||||
* @param result Result description as a text
|
||||
* @param eval Evaluation Result
|
||||
*/
|
||||
void (*finalize_workitem)(imv_state_t *this, enumerator_t *enumerator,
|
||||
imv_workitem_t *workitem, char *result,
|
||||
TNC_IMV_Evaluation_Result eval);
|
||||
|
||||
/**
|
||||
* Change the connection state
|
||||
*
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "imv_workitem.h"
|
||||
|
||||
#include <utils/debug.h>
|
||||
#include <tncif_names.h>
|
||||
|
||||
typedef struct private_imv_workitem_t private_imv_workitem_t;
|
||||
|
||||
ENUM(imv_workitem_type_names, IMV_WORKITEM_START, IMV_WORKITEM_UDP_SCAN,
|
||||
"START",
|
||||
"PCKGS",
|
||||
"UNSRC",
|
||||
"FWDEN",
|
||||
"PWDEN",
|
||||
"FMEAS",
|
||||
"DMEAS",
|
||||
"TCPSC",
|
||||
"UDPSC"
|
||||
);
|
||||
|
||||
/**
|
||||
* Private data of a imv_workitem_t object.
|
||||
*
|
||||
*/
|
||||
struct private_imv_workitem_t {
|
||||
|
||||
/**
|
||||
* Public imv_workitem_t interface.
|
||||
*/
|
||||
imv_workitem_t public;
|
||||
|
||||
/**
|
||||
* Session ID
|
||||
*/
|
||||
int session_id;
|
||||
|
||||
/**
|
||||
* Workitem type
|
||||
*/
|
||||
imv_workitem_type_t type;
|
||||
|
||||
/**
|
||||
* Argument string
|
||||
*/
|
||||
char *argument;
|
||||
|
||||
/**
|
||||
* Result string
|
||||
*/
|
||||
char *result;
|
||||
|
||||
/**
|
||||
* IMV action recommendation
|
||||
*/
|
||||
TNC_IMV_Action_Recommendation rec_fail;
|
||||
|
||||
/**
|
||||
* IMV action recommendation
|
||||
*/
|
||||
TNC_IMV_Action_Recommendation rec_noresult;
|
||||
|
||||
/**
|
||||
* IMV action recommendation
|
||||
*/
|
||||
TNC_IMV_Action_Recommendation rec_final;
|
||||
|
||||
};
|
||||
|
||||
METHOD(imv_workitem_t, get_session_id, int,
|
||||
private_imv_workitem_t *this)
|
||||
{
|
||||
return this->session_id;
|
||||
}
|
||||
|
||||
METHOD(imv_workitem_t, get_type, imv_workitem_type_t,
|
||||
private_imv_workitem_t *this)
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
|
||||
METHOD(imv_workitem_t, get_argument, char*,
|
||||
private_imv_workitem_t *this)
|
||||
{
|
||||
return this->argument;
|
||||
}
|
||||
|
||||
METHOD(imv_workitem_t, set_result, TNC_IMV_Action_Recommendation,
|
||||
private_imv_workitem_t *this, char *result, TNC_IMV_Evaluation_Result eval)
|
||||
{
|
||||
this->result = strdup(result);
|
||||
switch (eval)
|
||||
{
|
||||
case TNC_IMV_EVALUATION_RESULT_COMPLIANT:
|
||||
this->rec_final = TNC_IMV_ACTION_RECOMMENDATION_ALLOW;
|
||||
break;
|
||||
case TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MINOR:
|
||||
case TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR:
|
||||
this->rec_final = this->rec_fail;
|
||||
break;
|
||||
case TNC_IMV_EVALUATION_RESULT_ERROR:
|
||||
case TNC_IMV_EVALUATION_RESULT_DONT_KNOW:
|
||||
default:
|
||||
this->rec_final = this->rec_noresult;
|
||||
break;
|
||||
}
|
||||
DBG2(DBG_IMV, "workitem %N: %N%s%s", imv_workitem_type_names, this->type,
|
||||
TNC_IMV_Action_Recommendation_names, this->rec_final,
|
||||
strlen(result) ? " - " : "", result);
|
||||
|
||||
return this->rec_final;
|
||||
}
|
||||
|
||||
METHOD(imv_workitem_t, destroy, void,
|
||||
private_imv_workitem_t *this)
|
||||
{
|
||||
free(this->argument);
|
||||
free(this->result);
|
||||
free(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
imv_workitem_t *imv_workitem_create(int session_id, imv_workitem_type_t type,
|
||||
char *argument,
|
||||
TNC_IMV_Action_Recommendation rec_fail,
|
||||
TNC_IMV_Action_Recommendation rec_noresult)
|
||||
{
|
||||
private_imv_workitem_t *this;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.get_session_id = _get_session_id,
|
||||
.get_type = _get_type,
|
||||
.get_argument = _get_argument,
|
||||
.set_result = _set_result,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.session_id = session_id,
|
||||
.type = type,
|
||||
.argument = strdup(argument),
|
||||
.rec_fail = rec_fail,
|
||||
.rec_noresult = rec_noresult,
|
||||
.rec_final = TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||
);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @defgroup imv_workitem_t imv_workitem
|
||||
* @{ @ingroup libimcv_imv
|
||||
*/
|
||||
|
||||
#ifndef IMV_WORKITEM_H_
|
||||
#define IMV_WORKITEM_H_
|
||||
|
||||
#include <tncifimv.h>
|
||||
|
||||
#include <library.h>
|
||||
|
||||
typedef struct imv_workitem_t imv_workitem_t;
|
||||
typedef enum imv_workitem_type_t imv_workitem_type_t;
|
||||
|
||||
enum imv_workitem_type_t {
|
||||
IMV_WORKITEM_START = 0,
|
||||
IMV_WORKITEM_PACKAGES = 1,
|
||||
IMV_WORKITEM_UNKNOWN_SOURCE = 2,
|
||||
IMV_WORKITEM_FORWARDING = 3,
|
||||
IMV_WORKITEM_DEFAULT_PWD = 4,
|
||||
IMV_WORKITEM_FILE_MEAS = 5,
|
||||
IMV_WORKITEM_DIR_MEAS = 6,
|
||||
IMV_WORKITEM_TCP_SCAN = 7,
|
||||
IMV_WORKITEM_UDP_SCAN = 8
|
||||
};
|
||||
|
||||
extern enum_name_t *imv_workitem_type_names;
|
||||
|
||||
/**
|
||||
* IMV database interface
|
||||
*/
|
||||
struct imv_workitem_t {
|
||||
|
||||
/**
|
||||
* Get workitem type
|
||||
*
|
||||
* @return Session ID
|
||||
*/
|
||||
int (*get_session_id)(imv_workitem_t *this);
|
||||
|
||||
/**
|
||||
* Get workitem type
|
||||
*
|
||||
* @return Workitem type
|
||||
*/
|
||||
imv_workitem_type_t (*get_type)(imv_workitem_t *this);
|
||||
|
||||
/**
|
||||
* Get argument string
|
||||
*
|
||||
* @return Argument string
|
||||
*/
|
||||
char* (*get_argument)(imv_workitem_t *this);
|
||||
|
||||
/**
|
||||
* Set result string
|
||||
*
|
||||
* @param result Result string
|
||||
* @param eval Evaluation Result
|
||||
*/
|
||||
TNC_IMV_Action_Recommendation(*set_result)(imv_workitem_t *this,
|
||||
char *result, TNC_IMV_Evaluation_Result eval);
|
||||
|
||||
/**
|
||||
* Destroys an imv_workitem_t object
|
||||
*/
|
||||
void (*destroy)(imv_workitem_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an imv_workitem_t instance
|
||||
*
|
||||
* @param session_id Session ID to which workitem is assigned
|
||||
* @param type Workitem type
|
||||
* @param argument Argument string
|
||||
* @param rec_fail Recommendation with minor/major non-compliance case
|
||||
* @param rec_noresult Recommendation in don't know/error case
|
||||
*/
|
||||
imv_workitem_t *imv_workitem_create(int session_id, imv_workitem_type_t type,
|
||||
char *argument,
|
||||
TNC_IMV_Action_Recommendation rec_fail,
|
||||
TNC_IMV_Action_Recommendation rec_noresult);
|
||||
|
||||
#endif /** IMV_WORKITEM_H_ @}*/
|
||||
@@ -0,0 +1,169 @@
|
||||
/* IMV PTS SQLite database */
|
||||
|
||||
DROP TABLE IF EXISTS directories;
|
||||
CREATE TABLE directories (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
path TEXT NOT NULL
|
||||
);
|
||||
DROP INDEX IF EXISTS directories_path;
|
||||
CREATE INDEX directories_path ON directories (
|
||||
path
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS files;
|
||||
CREATE TABLE files (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
dir INTEGER DEFAULT 0 REFERENCES directories(id),
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
DROP INDEX IF EXISTS files_name;
|
||||
CREATE INDEX files_name ON files (
|
||||
name
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS products;
|
||||
CREATE TABLE products (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
DROP INDEX IF EXISTS products_name;
|
||||
CREATE INDEX products_name ON products (
|
||||
name
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS product_file;
|
||||
CREATE TABLE product_file (
|
||||
product INTEGER NOT NULL REFERENCES products(id),
|
||||
file INTEGER NOT NULL REFERENCES files(id),
|
||||
measurement INTEGER DEFAULT 0,
|
||||
metadata INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (product, file)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS algorithms;
|
||||
CREATE TABLE algorithms (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name VARCHAR(20) not NULL
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS file_hashes;
|
||||
CREATE TABLE file_hashes (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
file INTEGER NOT NULL REFERENCES files(id),
|
||||
product INTEGER NOT NULL REFERENCES products(id),
|
||||
device INTEGER DEFAULT 0,
|
||||
algo INTEGER NOT NULL REFERENCES algorithms(id),
|
||||
hash BLOB NOT NULL
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS sessions;
|
||||
CREATE TABLE sessions (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
time INTEGER NOT NULL,
|
||||
connection INTEGER NOT NULL,
|
||||
identity INTEGER DEFAULT 0 REFERENCES identities(id),
|
||||
device INTEGER DEFAULT 0 REFERENCES devices(id),
|
||||
product INTEGER DEFAULT 0 REFERENCES products(id)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS workitems;
|
||||
CREATE TABLE workitems (
|
||||
id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
session integer NOT NULL REFERENCES sessions(id),
|
||||
type integer DEFAULT 0,
|
||||
argument text NOT NULL,
|
||||
rec_fail integer DEFAULT 1,
|
||||
rec_noresult integer DEFAULT 1,
|
||||
rec_final integer DEFAULT 3,
|
||||
result text
|
||||
);
|
||||
DROP INDEX IF EXISTS workitems_session;
|
||||
CREATE INDEX workitems_sessions ON workitems (
|
||||
session
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS components;
|
||||
CREATE TABLE components (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
vendor_id INTEGER NOT NULL,
|
||||
name INTEGER NOT NULL,
|
||||
qualifier INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS key_component;
|
||||
CREATE TABLE key_component (
|
||||
key INTEGER NOT NULL,
|
||||
component INTEGER NOT NULL,
|
||||
depth INTEGER DEFAULT 0,
|
||||
seq_no INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (key, component)
|
||||
);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS component_hashes;
|
||||
CREATE TABLE component_hashes (
|
||||
component INTEGER NOT NULL,
|
||||
key INTEGER NOT NULL,
|
||||
seq_no INTEGER NOT NULL,
|
||||
pcr INTEGER NOT NULL,
|
||||
algo INTEGER NOT NULL,
|
||||
hash BLOB NOT NULL,
|
||||
PRIMARY KEY(component, key, seq_no, algo)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS packages;
|
||||
CREATE TABLE packages (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
DROP INDEX IF EXISTS packages_name;
|
||||
CREATE INDEX packages_name ON packages (
|
||||
name
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS versions;
|
||||
CREATE TABLE versions (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
package INTEGER NOT NULL,
|
||||
product INTEGER NOT NULL,
|
||||
release TEXT NOT NULL,
|
||||
security INTEGER DEFAULT 0,
|
||||
time INTEGER DEFAULT 0
|
||||
);
|
||||
DROP INDEX IF EXISTS versions_release;
|
||||
CREATE INDEX versions_release ON versions (
|
||||
release
|
||||
);
|
||||
DROP INDEX IF EXISTS versions_package_product;
|
||||
CREATE INDEX versions_package_product ON versions (
|
||||
package, product
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS devices;
|
||||
CREATE TABLE devices (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
value BLOB NOT NULL
|
||||
);
|
||||
DROP INDEX IF EXISTS devices_id;
|
||||
CREATE INDEX devices_value ON devices (
|
||||
value
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS device_infos;
|
||||
CREATE TABLE device_infos (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
session INTEGER NOT NULL REFERENCES sessions(id),
|
||||
count INTEGER DEFAULT 0,
|
||||
count_update INTEGER DEFAULT 0,
|
||||
count_blacklist INTEGER DEFAULT 0,
|
||||
flags INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS identities;
|
||||
CREATE TABLE identities (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
type INTEGER NOT NULL,
|
||||
value BLOB NOT NULL,
|
||||
UNIQUE (type, value)
|
||||
);
|
||||
Reference in New Issue
Block a user