func (e *SqliteEndorsementStore) GetSoftwareComponents(args common.QueryArgs) (common.QueryResult, error) {
	platformID, err := args.GetString("platform_id")
	if err != nil {
		return nil, fmt.Errorf("error getting mandatory argument \"platform_id\": %s", err.Error())
	}
	measurements, err := args.GetStringSlice("measurements")
	if err != nil {
		return nil, fmt.Errorf("error getting mandatory argument \"measurements\": %s", err.Error())
	}
	if len(measurements) == 0 {
		return common.QueryResult{[]interface{}{}}, nil
	}
	schemeMeasMap, err := e.processSchemeMeasurements(measurements, platformID)
	if err != nil {
		return nil, err
	}
	return e.getSoftwareEndorsements(schemeMeasMap, len(measurements))
}
GetSoftwareComponents returns the matching measurements
package main
import (
	"context"
	"database/sql"
	"fmt"
	"github.com/hashicorp/go-plugin"
	_ "github.com/mattn/go-sqlite3"
	"github.com/veraison/common"
)
type SqliteEndorsementStore struct {
	common.BaseEndorsementStore
	db   *sql.DB
	path string
}
func (e *SqliteEndorsementStore) GetName() string {
	return "sqlite"
}
func retrieveDbPath(args common.EndorsementStoreParams) string {
	i, found := args["dbpath"]
	if !found {
		return ""
	}
	switch v := i.(type) {
	case string:
		return v
	case []byte:
		return string(v)
	default:
		return ""
	}
}
func (e *SqliteEndorsementStore) Init(args common.EndorsementStoreParams) error {
	dbPath := retrieveDbPath(args)
	if dbPath == "" {
		return fmt.Errorf("dbPath not specified inside FetcherParams")
	}
	dbConfig := fmt.Sprintf("file:%s?cache=shared", dbPath)
	db, err := sql.Open("sqlite3", dbConfig)
	if err != nil {
		return err
	}
	e.db = db
	e.path = dbPath
	e.Queries = map[string]common.Query{
		"hardware_id":         e.GetHardwareID,
		"software_components": e.GetSoftwareComponents,
	}
	e.Adders = map[string]common.QueryAdder{
		"hardware_id":         e.AddHardwareID,
		"software_components": e.AddSoftwareComponents,
	}
	return nil
}
func (e *SqliteEndorsementStore) Close() error {
	return e.db.Close()
}
func (e *SqliteEndorsementStore) GetHardwareID(args common.QueryArgs) (common.QueryResult, error) {
	var result []interface{}
	platformID, err := args.GetString("platform_id")
	if err != nil {
		return nil, fmt.Errorf("error getting mandatory argument \"platform_id\": %s", err.Error())
	}
	rows, err := e.db.Query("select hw_id from hardware where platform_id = ?", platformID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	for rows.Next() {
		var hwID string
		if err := rows.Scan(&hwID); err != nil {
			return nil, err
		}
		result = append(result, hwID)
	}
	return result, nil
}
func (e *SqliteEndorsementStore) AddHardwareID(args common.QueryArgs, update bool) error {
	platformID, err := args.GetString("platform_id")
	if err != nil {
		return fmt.Errorf("error getting mandatory argument \"platform_id\": %s", err.Error())
	}
	hardwareID, err := args.GetString("hardware_id")
	if err != nil {
		return fmt.Errorf("error getting mandatory argument \"hardware_id\": %s", err.Error())
	}
	if update {
		_, err = e.db.Exec(
			"update hardware set hw_id = ? where platform_id = ?",
			hardwareID,
			platformID,
		)
	} else {
		_, err = e.db.Exec(
			"insert into hardware(platform_id, hw_id) values (?, ?)",
			platformID,
			hardwareID,
		)
	}
	return err
}