return e;
}
+METHOD(pts_database_t, create_comp_evid_enumerator, enumerator_t*,
+ private_pts_database_t *this, char *product)
+{
+ enumerator_t *e;
+
+ /* look for all entries belonging to a product in the files table */
+ e = this->db->query(this->db,
+ "SELECT f.type, f.path FROM files AS f "
+ "JOIN product_file AS pf ON f.id = pf.file "
+ "JOIN products AS p ON p.id = pf.product "
+ "WHERE p.name = ? AND f.component = 1",
+ DB_TEXT, product, DB_INT, DB_TEXT);
+ return e;
+}
+
+
METHOD(pts_database_t, create_hash_enumerator, enumerator_t*,
private_pts_database_t *this, char *product, pts_meas_algorithms_t algo,
int id, bool is_dir)
return e;
}
+METHOD(pts_database_t, create_comp_hash_enumerator, enumerator_t*,
+ private_pts_database_t *this, char *product,
+ pts_meas_algorithms_t algo, char *comp_name)
+{
+ enumerator_t *e;
+
+ e = this->db->query(this->db,
+ "SELECT fh.hash FROM file_hashes AS fh "
+ "JOIN files AS f ON fh.file = f.id "
+ "JOIN products AS p ON fh.product = p.id "
+ "WHERE p.name = ? AND f.path = ? AND fh.algo = ? ",
+ DB_TEXT, product, DB_TEXT, comp_name, DB_INT, algo, DB_BLOB);
+
+ return e;
+}
+
METHOD(pts_database_t, destroy, void,
private_pts_database_t *this)
{
.public = {
.create_file_meas_enumerator = _create_file_meas_enumerator,
.create_file_meta_enumerator = _create_file_meta_enumerator,
+ .create_comp_evid_enumerator = _create_comp_evid_enumerator,
.create_hash_enumerator = _create_hash_enumerator,
+ .create_comp_hash_enumerator = _create_comp_hash_enumerator,
.destroy = _destroy,
},
.db = lib->db->create(lib->db, uri),
if (!this->db)
{
- DBG1(DBG_PTS, "failed to connect to PTS file measurement database '%s'",
- uri);
+ DBG1(DBG_PTS,
+ "failed to connect to PTS file measurement database '%s'", uri);
free(this);
return NULL;
}
enumerator_t* (*create_file_meta_enumerator)(pts_database_t *this,
char *product);
+ /**
+ * Get functional components to request evidence of
+ *
+ * @param product software product (os, vpn client, etc.)
+ * @return enumerator over all matching components
+ */
+ enumerator_t* (*create_comp_evid_enumerator)(pts_database_t *this,
+ char *product);
+
/**
* Get stored measurement hash for single file or directory entries
*
pts_meas_algorithms_t algo,
int id, bool is_dir);
+ /**
+ * Get stored measurement hash for functional component entries
+ *
+ * @param product software product (os, vpn client, etc.)
+ * @param algo hash algorithm used for measurement
+ * @param comp_name value of path column in files table
+ * @return enumerator over all matching measurement hashes
+ */
+ enumerator_t* (*create_comp_hash_enumerator)(pts_database_t *this, char *product,
+ pts_meas_algorithms_t algo, char *comp_name);
+
/**
* Destroys a pts_database_t object.
*/