implemented policy rules for OS IMV
This commit is contained in:
@@ -24,8 +24,7 @@ imv_attestation_la_LDFLAGS = -module -avoid-version
|
||||
ipsec_PROGRAMS = attest
|
||||
attest_SOURCES = attest.c \
|
||||
attest_usage.h attest_usage.c \
|
||||
attest_db.h attest_db.c \
|
||||
tables.sql data.sql
|
||||
attest_db.h attest_db.c
|
||||
attest_LDADD = \
|
||||
$(top_builddir)/src/libimcv/libimcv.la \
|
||||
$(top_builddir)/src/libpts/libpts.la \
|
||||
|
||||
@@ -78,6 +78,11 @@ struct private_imv_attestation_state_t {
|
||||
*/
|
||||
int session_id;
|
||||
|
||||
/**
|
||||
* List of workitems
|
||||
*/
|
||||
linked_list_t *workitems;
|
||||
|
||||
/**
|
||||
* IMV Attestation handshake state
|
||||
*/
|
||||
@@ -260,6 +265,36 @@ METHOD(imv_state_t, get_session_id, int,
|
||||
return this->session_id;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, add_workitem, void,
|
||||
private_imv_attestation_state_t *this, imv_workitem_t *workitem)
|
||||
{
|
||||
this->workitems->insert_last(this->workitems, workitem);
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_workitem_count, int,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
return this->workitems->get_count(this->workitems);
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, create_workitem_enumerator, enumerator_t*,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
return this->workitems->create_enumerator(this->workitems);
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, finalize_workitem, void,
|
||||
private_imv_attestation_state_t *this, enumerator_t *enumerator,
|
||||
imv_workitem_t *workitem, char *result, TNC_IMV_Evaluation_Result eval)
|
||||
{
|
||||
TNC_IMV_Action_Recommendation rec;
|
||||
|
||||
this->workitems->remove_at(this->workitems, enumerator);
|
||||
rec = workitem->set_result(workitem, result, eval);
|
||||
/* TODO update workitem in IMV database */
|
||||
workitem->destroy(workitem);
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, change_state, void,
|
||||
private_imv_attestation_state_t *this, TNC_ConnectionState new_state)
|
||||
{
|
||||
@@ -334,6 +369,8 @@ METHOD(imv_state_t, destroy, void,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
DESTROY_IF(this->reason_string);
|
||||
this->workitems->destroy_offset(this->workitems,
|
||||
offsetof(imv_workitem_t, destroy));
|
||||
this->file_meas_requests->destroy_function(this->file_meas_requests, free);
|
||||
this->components->destroy_function(this->components, (void *)free_func_comp);
|
||||
this->pts->destroy(this->pts);
|
||||
@@ -529,6 +566,10 @@ imv_state_t *imv_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
.get_ar_id = _get_ar_id,
|
||||
.set_session_id = _set_session_id,
|
||||
.get_session_id = _get_session_id,
|
||||
.add_workitem = _add_workitem,
|
||||
.get_workitem_count = _get_workitem_count,
|
||||
.create_workitem_enumerator = _create_workitem_enumerator,
|
||||
.finalize_workitem = _finalize_workitem,
|
||||
.change_state = _change_state,
|
||||
.get_recommendation = _get_recommendation,
|
||||
.set_recommendation = _set_recommendation,
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
/* 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 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