diff options
Diffstat (limited to 'src/libpts/plugins')
-rw-r--r-- | src/libpts/plugins/imv_attestation/attest.c | 8 | ||||
-rw-r--r-- | src/libpts/plugins/imv_attestation/attest_db.c | 22 | ||||
-rw-r--r-- | src/libpts/plugins/imv_attestation/attest_db.h | 5 | ||||
-rw-r--r-- | src/libpts/plugins/imv_attestation/attest_usage.c | 8 | ||||
-rw-r--r-- | src/libpts/plugins/imv_attestation/tables.sql | 23 |
5 files changed, 66 insertions, 0 deletions
diff --git a/src/libpts/plugins/imv_attestation/attest.c b/src/libpts/plugins/imv_attestation/attest.c index 281078aaf..5cfc07316 100644 --- a/src/libpts/plugins/imv_attestation/attest.c +++ b/src/libpts/plugins/imv_attestation/attest.c @@ -99,6 +99,7 @@ static void do_args(int argc, char *argv[]) OP_USAGE, OP_KEYS, OP_COMPONENTS, + OP_DEVICES, OP_FILES, OP_HASHES, OP_MEASUREMENTS, @@ -118,6 +119,7 @@ static void do_args(int argc, char *argv[]) struct option long_opts[] = { { "help", no_argument, NULL, 'h' }, { "components", no_argument, NULL, 'c' }, + { "devices", no_argument, NULL, 'e' }, { "files", no_argument, NULL, 'f' }, { "keys", no_argument, NULL, 'k' }, { "packages", no_argument, NULL, 'g' }, @@ -168,6 +170,9 @@ static void do_args(int argc, char *argv[]) case 'c': op = OP_COMPONENTS; continue; + case 'e': + op = OP_DEVICES; + continue; case 'f': op = OP_FILES; continue; @@ -360,6 +365,9 @@ static void do_args(int argc, char *argv[]) case OP_COMPONENTS: attest->list_components(attest); break; + case OP_DEVICES: + attest->list_devices(attest); + break; case OP_FILES: attest->list_files(attest); break; diff --git a/src/libpts/plugins/imv_attestation/attest_db.c b/src/libpts/plugins/imv_attestation/attest_db.c index 8e64d0a28..d01c182d6 100644 --- a/src/libpts/plugins/imv_attestation/attest_db.c +++ b/src/libpts/plugins/imv_attestation/attest_db.c @@ -790,6 +790,27 @@ METHOD(attest_db_t, list_components, void, } } +METHOD(attest_db_t, list_devices, void, + private_attest_db_t *this) +{ + enumerator_t *e; + chunk_t value; + int id, count = 0; + + e = this->db->query(this->db, + "SELECT id, value FROM devices", DB_INT, DB_BLOB); + if (e) + { + while (e->enumerate(e, &id, &value)) + { + printf("%4d: %.*s\n", id, value.len, value.ptr); + count++; + } + e->destroy(e); + printf("%d device%s found\n", count, (count == 1) ? "" : "s"); + } +} + METHOD(attest_db_t, list_keys, void, private_attest_db_t *this) { @@ -1660,6 +1681,7 @@ attest_db_t *attest_db_create(char *uri) .list_products = _list_products, .list_files = _list_files, .list_components = _list_components, + .list_devices = _list_devices, .list_keys = _list_keys, .list_hashes = _list_hashes, .list_measurements = _list_measurements, diff --git a/src/libpts/plugins/imv_attestation/attest_db.h b/src/libpts/plugins/imv_attestation/attest_db.h index 81dd0ad84..471b0a28d 100644 --- a/src/libpts/plugins/imv_attestation/attest_db.h +++ b/src/libpts/plugins/imv_attestation/attest_db.h @@ -199,6 +199,11 @@ struct attest_db_t { void (*list_components)(attest_db_t *this); /** + * List all devices stored in the database + */ + void (*list_devices)(attest_db_t *this); + + /** * List all AIKs stored in the database */ void (*list_keys)(attest_db_t *this); diff --git a/src/libpts/plugins/imv_attestation/attest_usage.c b/src/libpts/plugins/imv_attestation/attest_usage.c index f7040f7ad..c7bf97631 100644 --- a/src/libpts/plugins/imv_attestation/attest_usage.c +++ b/src/libpts/plugins/imv_attestation/attest_usage.c @@ -60,6 +60,10 @@ Usage:\n\ Show a list of component measurements for a given AIK or\n\ its primary key as an optional selector.\n\ \n\ + ipsec attest --packages [--product <name>|--pid <id>]\n\ + Show a list of software packages for a given product or\n\ + its primary key as an optional selector.\n\ + \n\ ipsec attest --add --file <path>|--dir <path>|--product <name>|--component <cfn>\n\ Add a file, directory, product or component entry\n\ Component <cfn> entries must be of the form <vendor_id>/<name>-<qualifier>\n\ @@ -74,6 +78,10 @@ Usage:\n\ ipsec attest --add --key <digest|--kid <id> --component <cfn>|--cid <id> --sequence <no>|--seq <no>\n\ Add an ordered key/component entry\n\ \n\ + ipsec attest --add --package <name> --version <string> [--security|--blacklist]\n\ + [--product <name>|--pid <id>]\n\ + Add a package version for a given product optionally with security or blacklist flag\n\ + \n\ ipsec attest --del --file <path>|--fid <id>|--dir <path>|--did <id>\n\ Delete a file or directory entry referenced either by value or primary key\n\ \n\ diff --git a/src/libpts/plugins/imv_attestation/tables.sql b/src/libpts/plugins/imv_attestation/tables.sql index 51d6cfa1b..e17318b22 100644 --- a/src/libpts/plugins/imv_attestation/tables.sql +++ b/src/libpts/plugins/imv_attestation/tables.sql @@ -113,3 +113,26 @@ 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 ( + device INTEGER NOT NULL, + time INTEGER NOT NULL, + product INTEGER DEFAULT 0, + count INTEGER DEFAULT 0, + count_update INTEGER DEFAULT 0, + count_remove INTEGER DEFAULT 0, + flags INTEGER DEFAULT 0, + PRIMARY KEY (device, time) +); + |