4278fadf7c9169a6dddf4a4bd4113bf9d04ae3c5
[strongswan.git] / src / libpts / plugins / imv_swid / imv_swid_agent.c
1 /*
2 * Copyright (C) 2013-2014 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #define _GNU_SOURCE
17 #include <stdio.h>
18
19 #include "imv_swid_agent.h"
20 #include "imv_swid_state.h"
21 #include "imv_swid_rest.h"
22
23 #include "libpts.h"
24 #include "swid/swid_error.h"
25 #include "swid/swid_inventory.h"
26 #include "tcg/swid/tcg_swid_attr_req.h"
27 #include "tcg/swid/tcg_swid_attr_tag_inv.h"
28 #include "tcg/swid/tcg_swid_attr_tag_id_inv.h"
29
30 #include <imcv.h>
31 #include <ietf/ietf_attr_pa_tnc_error.h>
32 #include <imv/imv_agent.h>
33 #include <imv/imv_msg.h>
34 #include <ita/ita_attr.h>
35 #include <ita/ita_attr_angel.h>
36
37 #include <tncif_names.h>
38 #include <tncif_pa_subtypes.h>
39
40 #include <pen/pen.h>
41 #include <utils/debug.h>
42 #include <bio/bio_reader.h>
43
44 typedef struct private_imv_swid_agent_t private_imv_swid_agent_t;
45
46 /* Subscribed PA-TNC message subtypes */
47 static pen_type_t msg_types[] = {
48 { PEN_TCG, PA_SUBTYPE_TCG_SWID }
49 };
50
51 /**
52 * Flag set when corresponding attribute has been received
53 */
54 enum imv_swid_attr_t {
55 IMV_SWID_ATTR_TAG_INV = (1<<0),
56 IMV_SWID_ATTR_TAG_ID_INV = (1<<1)
57 };
58
59 /**
60 * Private data of an imv_swid_agent_t object.
61 */
62 struct private_imv_swid_agent_t {
63
64 /**
65 * Public members of imv_swid_agent_t
66 */
67 imv_agent_if_t public;
68
69 /**
70 * IMV agent responsible for generic functions
71 */
72 imv_agent_t *agent;
73
74 /**
75 * REST API to strongTNC manager
76 */
77 imv_swid_rest_t *rest_api;
78
79 };
80
81 METHOD(imv_agent_if_t, bind_functions, TNC_Result,
82 private_imv_swid_agent_t *this, TNC_TNCS_BindFunctionPointer bind_function)
83 {
84 return this->agent->bind_functions(this->agent, bind_function);
85 }
86
87 METHOD(imv_agent_if_t, notify_connection_change, TNC_Result,
88 private_imv_swid_agent_t *this, TNC_ConnectionID id,
89 TNC_ConnectionState new_state)
90 {
91 imv_state_t *state;
92
93 switch (new_state)
94 {
95 case TNC_CONNECTION_STATE_CREATE:
96 state = imv_swid_state_create(id);
97 return this->agent->create_state(this->agent, state);
98 case TNC_CONNECTION_STATE_DELETE:
99 return this->agent->delete_state(this->agent, id);
100 default:
101 return this->agent->change_state(this->agent, id, new_state, NULL);
102 }
103 }
104
105 /**
106 * Process a received message
107 */
108 static TNC_Result receive_msg(private_imv_swid_agent_t *this,
109 imv_state_t *state, imv_msg_t *in_msg)
110 {
111 imv_swid_state_t *swid_state;
112 imv_msg_t *out_msg;
113 enumerator_t *enumerator;
114 pa_tnc_attr_t *attr;
115 TNC_Result result;
116 bool fatal_error = FALSE;
117
118 /* parse received PA-TNC message and handle local and remote errors */
119 result = in_msg->receive(in_msg, &fatal_error);
120 if (result != TNC_RESULT_SUCCESS)
121 {
122 return result;
123 }
124
125 swid_state = (imv_swid_state_t*)state;
126
127 /* analyze PA-TNC attributes */
128 enumerator = in_msg->create_attribute_enumerator(in_msg);
129 while (enumerator->enumerate(enumerator, &attr))
130 {
131 uint32_t request_id = 0, last_eid, eid_epoch;
132 swid_inventory_t *inventory;
133 pen_type_t type;
134
135 type = attr->get_type(attr);
136
137 if (type.vendor_id == PEN_IETF && type.type == IETF_ATTR_PA_TNC_ERROR)
138 {
139 ietf_attr_pa_tnc_error_t *error_attr;
140 pen_type_t error_code;
141 chunk_t msg_info, description;
142 bio_reader_t *reader;
143 uint32_t max_attr_size;
144 bool success;
145
146 error_attr = (ietf_attr_pa_tnc_error_t*)attr;
147 error_code = error_attr->get_error_code(error_attr);
148
149 if (error_code.vendor_id == PEN_TCG)
150 {
151 fatal_error = TRUE;
152 msg_info = error_attr->get_msg_info(error_attr);
153 reader = bio_reader_create(msg_info);
154 success = reader->read_uint32(reader, &request_id);
155
156 DBG1(DBG_IMV, "received TCG error '%N' for request %d",
157 swid_error_code_names, error_code.type, request_id);
158 if (!success)
159 {
160 reader->destroy(reader);
161 continue;
162 }
163 if (error_code.type == TCG_SWID_RESPONSE_TOO_LARGE)
164 {
165 if (!reader->read_uint32(reader, &max_attr_size))
166 {
167 reader->destroy(reader);
168 continue;
169 }
170 DBG1(DBG_IMV, " maximum PA-TNC attribute size is %u bytes",
171 max_attr_size);
172 }
173 description = reader->peek(reader);
174 if (description.len)
175 {
176 DBG1(DBG_IMV, " description: %.*s", description.len,
177 description.ptr);
178 }
179 reader->destroy(reader);
180 }
181 }
182 else if (type.vendor_id == PEN_ITA)
183 {
184 switch (type.type)
185 {
186 case ITA_ATTR_START_ANGEL:
187 swid_state->set_angel_count(swid_state, TRUE);
188 continue;
189 case ITA_ATTR_STOP_ANGEL:
190 swid_state->set_angel_count(swid_state, FALSE);
191 continue;
192 default:
193 continue;
194 }
195 }
196 else if (type.vendor_id != PEN_TCG)
197 {
198 continue;
199 }
200
201 switch (type.type)
202 {
203 case TCG_SWID_TAG_ID_INVENTORY:
204 {
205 tcg_swid_attr_tag_id_inv_t *attr_cast;
206 int tag_id_count;
207
208 state->set_action_flags(state, IMV_SWID_ATTR_TAG_ID_INV);
209
210 attr_cast = (tcg_swid_attr_tag_id_inv_t*)attr;
211 request_id = attr_cast->get_request_id(attr_cast);
212 last_eid = attr_cast->get_last_eid(attr_cast, &eid_epoch);
213 inventory = attr_cast->get_inventory(attr_cast);
214 tag_id_count = inventory->get_count(inventory);
215
216 DBG2(DBG_IMV, "received SWID tag ID inventory with %d item%s "
217 "for request %d at eid %d of epoch 0x%08x",
218 tag_id_count, (tag_id_count == 1) ? "" : "s",
219 request_id, last_eid, eid_epoch);
220
221 if (request_id == swid_state->get_request_id(swid_state))
222 {
223 swid_state->set_swid_inventory(swid_state, inventory);
224 swid_state->set_count(swid_state, tag_id_count, 0);
225 }
226 else
227 {
228 DBG1(DBG_IMV, "no workitem found for SWID tag ID inventory "
229 "with request ID %d", request_id);
230 }
231 break;
232 }
233 case TCG_SWID_TAG_INVENTORY:
234 {
235 tcg_swid_attr_tag_inv_t *attr_cast;
236 swid_tag_t *tag;
237 chunk_t tag_encoding;
238 json_object *jarray, *jstring;
239 char *tag_str;
240 int tag_count;
241 enumerator_t *e;
242
243 state->set_action_flags(state, IMV_SWID_ATTR_TAG_INV);
244
245 attr_cast = (tcg_swid_attr_tag_inv_t*)attr;
246 request_id = attr_cast->get_request_id(attr_cast);
247 last_eid = attr_cast->get_last_eid(attr_cast, &eid_epoch);
248 inventory = attr_cast->get_inventory(attr_cast);
249 tag_count = inventory->get_count(inventory);
250
251 DBG2(DBG_IMV, "received SWID tag inventory with %d item%s for "
252 "request %d at eid %d of epoch 0x%08x",
253 tag_count, (tag_count == 1) ? "" : "s",
254 request_id, last_eid, eid_epoch);
255
256
257 if (request_id == swid_state->get_request_id(swid_state))
258 {
259 swid_state->set_count(swid_state, 0, tag_count);
260
261 if (this->rest_api)
262 {
263 jarray = json_object_new_array();
264
265 e = inventory->create_enumerator(inventory);
266 while (e->enumerate(e, &tag))
267 {
268 tag_encoding = tag->get_encoding(tag);
269 tag_str = strndup(tag_encoding.ptr, tag_encoding.len);
270 DBG3(DBG_IMV, "%s", tag_str);
271 jstring = json_object_new_string(tag_str);
272 json_object_array_add(jarray, jstring);
273 free(tag_str);
274 }
275 e->destroy(e);
276
277 if (this->rest_api->post(this->rest_api,
278 "swid/add-tags/", jarray, NULL) != SUCCESS)
279 {
280 DBG1(DBG_IMV, "error in REST API add-tags request");
281 }
282 json_object_put(jarray);
283 }
284 }
285 else
286 {
287 DBG1(DBG_IMV, "no workitem found for SWID tag inventory "
288 "with request ID %d", request_id);
289 }
290 }
291 default:
292 continue;
293 }
294 }
295 enumerator->destroy(enumerator);
296
297 if (fatal_error)
298 {
299 state->set_recommendation(state,
300 TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
301 TNC_IMV_EVALUATION_RESULT_ERROR);
302 out_msg = imv_msg_create_as_reply(in_msg);
303 result = out_msg->send_assessment(out_msg);
304 out_msg->destroy(out_msg);
305 if (result != TNC_RESULT_SUCCESS)
306 {
307 return result;
308 }
309 return this->agent->provide_recommendation(this->agent, state);
310 }
311
312 return TNC_RESULT_SUCCESS;
313 }
314
315 METHOD(imv_agent_if_t, receive_message, TNC_Result,
316 private_imv_swid_agent_t *this, TNC_ConnectionID id,
317 TNC_MessageType msg_type, chunk_t msg)
318 {
319 imv_state_t *state;
320 imv_msg_t *in_msg;
321 TNC_Result result;
322
323 if (!this->agent->get_state(this->agent, id, &state))
324 {
325 return TNC_RESULT_FATAL;
326 }
327 in_msg = imv_msg_create_from_data(this->agent, state, id, msg_type, msg);
328 result = receive_msg(this, state, in_msg);
329 in_msg->destroy(in_msg);
330
331 return result;
332 }
333
334 METHOD(imv_agent_if_t, receive_message_long, TNC_Result,
335 private_imv_swid_agent_t *this, TNC_ConnectionID id,
336 TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
337 TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype, chunk_t msg)
338 {
339 imv_state_t *state;
340 imv_msg_t *in_msg;
341 TNC_Result result;
342
343 if (!this->agent->get_state(this->agent, id, &state))
344 {
345 return TNC_RESULT_FATAL;
346 }
347 in_msg = imv_msg_create_from_long_data(this->agent, state, id,
348 src_imc_id, dst_imv_id, msg_vid, msg_subtype, msg);
349 result = receive_msg(this, state, in_msg);
350 in_msg->destroy(in_msg);
351
352 return result;
353
354 }
355
356 METHOD(imv_agent_if_t, batch_ending, TNC_Result,
357 private_imv_swid_agent_t *this, TNC_ConnectionID id)
358 {
359 imv_msg_t *out_msg;
360 imv_state_t *state;
361 imv_session_t *session;
362 imv_workitem_t *workitem;
363 imv_swid_state_t *swid_state;
364 imv_swid_handshake_state_t handshake_state;
365 pa_tnc_attr_t *attr;
366 TNC_IMVID imv_id;
367 TNC_Result result = TNC_RESULT_SUCCESS;
368 bool no_workitems = TRUE;
369 uint32_t request_id, received;
370 uint8_t flags;
371 enumerator_t *enumerator;
372
373 if (!this->agent->get_state(this->agent, id, &state))
374 {
375 return TNC_RESULT_FATAL;
376 }
377 swid_state = (imv_swid_state_t*)state;
378 handshake_state = swid_state->get_handshake_state(swid_state);
379 session = state->get_session(state);
380 imv_id = this->agent->get_id(this->agent);
381
382 if (handshake_state == IMV_SWID_STATE_END)
383 {
384 return TNC_RESULT_SUCCESS;
385 }
386
387 /* Create an empty out message - we might need it */
388 out_msg = imv_msg_create(this->agent, state, id, imv_id, TNC_IMCID_ANY,
389 msg_types[0]);
390
391 if (!imcv_db)
392 {
393 DBG2(DBG_IMV, "no workitems available - no evaluation possible");
394 state->set_recommendation(state,
395 TNC_IMV_ACTION_RECOMMENDATION_ALLOW,
396 TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
397 result = out_msg->send_assessment(out_msg);
398 out_msg->destroy(out_msg);
399 swid_state->set_handshake_state(swid_state, IMV_SWID_STATE_END);
400
401 if (result != TNC_RESULT_SUCCESS)
402 {
403 return result;
404 }
405 return this->agent->provide_recommendation(this->agent, state);
406 }
407
408 /* Look for SWID tag workitem and create SWID tag request */
409 if (handshake_state == IMV_SWID_STATE_INIT &&
410 session->get_policy_started(session))
411 {
412 enumerator = session->create_workitem_enumerator(session);
413 if (enumerator)
414 {
415 while (enumerator->enumerate(enumerator, &workitem))
416 {
417 if (workitem->get_imv_id(workitem) != TNC_IMVID_ANY ||
418 workitem->get_type(workitem) != IMV_WORKITEM_SWID_TAGS)
419 {
420 continue;
421 }
422
423 flags = TCG_SWID_ATTR_REQ_FLAG_NONE;
424 if (strchr(workitem->get_arg_str(workitem), 'R'))
425 {
426 flags |= TCG_SWID_ATTR_REQ_FLAG_R;
427 }
428 if (strchr(workitem->get_arg_str(workitem), 'S'))
429 {
430 flags |= TCG_SWID_ATTR_REQ_FLAG_S;
431 }
432 if (strchr(workitem->get_arg_str(workitem), 'C'))
433 {
434 flags |= TCG_SWID_ATTR_REQ_FLAG_C;
435 }
436 request_id = workitem->get_id(workitem);
437 swid_state->set_request_id(swid_state, request_id);
438 attr = tcg_swid_attr_req_create(flags, request_id, 0);
439 out_msg->add_attribute(out_msg, attr);
440 workitem->set_imv_id(workitem, imv_id);
441 no_workitems = FALSE;
442 DBG2(DBG_IMV, "IMV %d issues SWID request %d",
443 imv_id, request_id);
444 break;
445 }
446 enumerator->destroy(enumerator);
447
448 if (no_workitems)
449 {
450 DBG2(DBG_IMV, "IMV %d has no workitems - "
451 "no evaluation requested", imv_id);
452 state->set_recommendation(state,
453 TNC_IMV_ACTION_RECOMMENDATION_ALLOW,
454 TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
455 }
456 handshake_state = IMV_SWID_STATE_WORKITEMS;
457 swid_state->set_handshake_state(swid_state, handshake_state);
458 }
459 }
460
461 received = state->get_action_flags(state);
462
463 if (handshake_state == IMV_SWID_STATE_WORKITEMS &&
464 (received & (IMV_SWID_ATTR_TAG_INV|IMV_SWID_ATTR_TAG_ID_INV)) &&
465 swid_state->get_angel_count(swid_state) <= 0)
466 {
467 TNC_IMV_Evaluation_Result eval;
468 TNC_IMV_Action_Recommendation rec;
469 char result_str[BUF_LEN], *error_str = "", *command;
470 char *target, *separator;
471 int tag_id_count, tag_count, i;
472 size_t max_attr_size, attr_size, entry_size;
473 chunk_t tag_creator, unique_sw_id;
474 json_object *jrequest, *jresponse, *jvalue;
475 tcg_swid_attr_req_t *cast_attr;
476 swid_tag_id_t *tag_id;
477 status_t status = SUCCESS;
478
479 if (this->rest_api && (received & IMV_SWID_ATTR_TAG_ID_INV))
480 {
481 if (asprintf(&command, "sessions/%d/swid_measurement/",
482 session->get_session_id(session, NULL, NULL)) < 0)
483 {
484 error_str = "allocation of command string failed";
485 status = FAILED;
486 }
487 else
488 {
489 jrequest = swid_state->get_swid_inventory(swid_state);
490 status = this->rest_api->post(this->rest_api, command,
491 jrequest, &jresponse);
492 if (status == FAILED)
493 {
494 error_str = "error in REST API swid_measurement request";
495 }
496 free(command);
497 }
498 }
499
500 switch (status)
501 {
502 case SUCCESS:
503 enumerator = session->create_workitem_enumerator(session);
504 while (enumerator->enumerate(enumerator, &workitem))
505 {
506 if (workitem->get_type(workitem) == IMV_WORKITEM_SWID_TAGS)
507 {
508 swid_state->get_count(swid_state, &tag_id_count,
509 &tag_count);
510 snprintf(result_str, BUF_LEN, "received inventory of "
511 "%d SWID tag ID%s and %d SWID tag%s",
512 tag_id_count, (tag_id_count == 1) ? "" : "s",
513 tag_count, (tag_count == 1) ? "" : "s");
514 session->remove_workitem(session, enumerator);
515
516 eval = TNC_IMV_EVALUATION_RESULT_COMPLIANT;
517 rec = workitem->set_result(workitem, result_str, eval);
518 state->update_recommendation(state, rec, eval);
519 imcv_db->finalize_workitem(imcv_db, workitem);
520 workitem->destroy(workitem);
521 break;
522 }
523 }
524 enumerator->destroy(enumerator);
525 break;
526 case NEED_MORE:
527 if (received & IMV_SWID_ATTR_TAG_INV)
528 {
529 error_str = "not all requested SWID tags were received";
530 status = FAILED;
531 json_object_put(jresponse);
532 break;
533 }
534 if (json_object_get_type(jresponse) != json_type_array)
535 {
536 error_str = "response was not a json_array";
537 status = FAILED;
538 json_object_put(jresponse);
539 break;
540 }
541
542 /* Compute the maximum TCG SWID Request attribute size */
543 max_attr_size = state->get_max_msg_len(state) -
544 PA_TNC_HEADER_SIZE;
545
546 /* Create the [first] TCG SWID Request attribute */
547 attr_size = PA_TNC_ATTR_HEADER_SIZE + TCG_SWID_REQ_MIN_SIZE;
548 attr = tcg_swid_attr_req_create(TCG_SWID_ATTR_REQ_FLAG_NONE,
549 swid_state->get_request_id(swid_state), 0);
550
551 tag_id_count = json_object_array_length(jresponse);
552 DBG1(DBG_IMV, "%d SWID tag target%s", tag_id_count,
553 (tag_id_count == 1) ? "" : "s");
554
555 for (i = 0; i < tag_id_count; i++)
556 {
557 jvalue = json_object_array_get_idx(jresponse, i);
558 if (json_object_get_type(jvalue) != json_type_string)
559 {
560 error_str = "json_string element expected in json_array";
561 status = FAILED;
562 json_object_put(jresponse);
563 break;
564 }
565 target = (char*)json_object_get_string(jvalue);
566 DBG1(DBG_IMV, " %s", target);
567
568 /* Separate target into tag_creator and unique_sw_id */
569 separator = strchr(target, '_');
570 if (!separator)
571 {
572 error_str = "separation of regid from "
573 "unique software ID failed";
574 break;
575 }
576 tag_creator = chunk_create(target, separator - target);
577 separator++;
578 unique_sw_id = chunk_create(separator, strlen(target) -
579 tag_creator.len - 1);
580 tag_id = swid_tag_id_create(tag_creator, unique_sw_id,
581 chunk_empty);
582 entry_size = 2 + tag_creator.len + 2 + unique_sw_id.len;
583
584 /* Have we reached the maximum attribute size? */
585 if (attr_size + entry_size > max_attr_size)
586 {
587 out_msg->add_attribute(out_msg, attr);
588 attr_size = PA_TNC_ATTR_HEADER_SIZE +
589 TCG_SWID_REQ_MIN_SIZE;
590 attr = tcg_swid_attr_req_create(
591 TCG_SWID_ATTR_REQ_FLAG_NONE,
592 swid_state->get_request_id(swid_state), 0);
593 }
594 cast_attr = (tcg_swid_attr_req_t*)attr;
595 cast_attr->add_target(cast_attr, tag_id);
596 }
597 json_object_put(jresponse);
598
599 out_msg->add_attribute(out_msg, attr);
600 break;
601 case FAILED:
602 default:
603 break;
604 }
605
606 if (status == FAILED)
607 {
608 enumerator = session->create_workitem_enumerator(session);
609 while (enumerator->enumerate(enumerator, &workitem))
610 {
611 if (workitem->get_type(workitem) == IMV_WORKITEM_SWID_TAGS)
612 {
613 session->remove_workitem(session, enumerator);
614 eval = TNC_IMV_EVALUATION_RESULT_ERROR;
615 rec = workitem->set_result(workitem, error_str, eval);
616 state->update_recommendation(state, rec, eval);
617 imcv_db->finalize_workitem(imcv_db, workitem);
618 workitem->destroy(workitem);
619 break;
620 }
621 }
622 enumerator->destroy(enumerator);
623 }
624 }
625
626 /* finalized all workitems ? */
627 if (handshake_state == IMV_SWID_STATE_WORKITEMS &&
628 session->get_workitem_count(session, imv_id) == 0)
629 {
630 result = out_msg->send_assessment(out_msg);
631 out_msg->destroy(out_msg);
632 swid_state->set_handshake_state(swid_state, IMV_SWID_STATE_END);
633
634 if (result != TNC_RESULT_SUCCESS)
635 {
636 return result;
637 }
638 return this->agent->provide_recommendation(this->agent, state);
639 }
640
641 /* send non-empty PA-TNC message with excl flag not set */
642 if (out_msg->get_attribute_count(out_msg))
643 {
644 result = out_msg->send(out_msg, FALSE);
645 }
646 out_msg->destroy(out_msg);
647
648 return result;
649 }
650
651 METHOD(imv_agent_if_t, solicit_recommendation, TNC_Result,
652 private_imv_swid_agent_t *this, TNC_ConnectionID id)
653 {
654 imv_state_t *state;
655
656 if (!this->agent->get_state(this->agent, id, &state))
657 {
658 return TNC_RESULT_FATAL;
659 }
660 return this->agent->provide_recommendation(this->agent, state);
661 }
662
663 METHOD(imv_agent_if_t, destroy, void,
664 private_imv_swid_agent_t *this)
665 {
666 DESTROY_IF(this->rest_api);
667 this->agent->destroy(this->agent);
668 free(this);
669 libpts_deinit();
670 }
671
672 /**
673 * Described in header.
674 */
675 imv_agent_if_t *imv_swid_agent_create(const char *name, TNC_IMVID id,
676 TNC_Version *actual_version)
677 {
678 private_imv_swid_agent_t *this;
679 imv_agent_t *agent;
680 char *rest_api_uri;
681 u_int rest_api_timeout;
682
683 agent = imv_agent_create(name, msg_types, countof(msg_types), id,
684 actual_version);
685 if (!agent)
686 {
687 return NULL;
688 }
689
690 INIT(this,
691 .public = {
692 .bind_functions = _bind_functions,
693 .notify_connection_change = _notify_connection_change,
694 .receive_message = _receive_message,
695 .receive_message_long = _receive_message_long,
696 .batch_ending = _batch_ending,
697 .solicit_recommendation = _solicit_recommendation,
698 .destroy = _destroy,
699 },
700 .agent = agent,
701 );
702
703 rest_api_uri = lib->settings->get_str(lib->settings,
704 "%s.plugins.imv-swid.rest_api_uri", NULL, lib->ns);
705 rest_api_timeout = lib->settings->get_int(lib->settings,
706 "%s.plugins.imv-swid.rest_api_timeout", 120, lib->ns);
707 if (rest_api_uri)
708 {
709 this->rest_api = imv_swid_rest_create(rest_api_uri, rest_api_timeout);
710 }
711 libpts_init();
712
713 return &this->public;
714 }
715