FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Go to the source code of this file.
Functions | |
CompatibilityState | getState (DbManager &dbManager, CompatibilityCliOptions &&cliOptions) |
Create a new state for the current agent based on CliOptions. More... | |
CompatibilityState | getState (CompatibilityCliOptions &&cliOptions) |
Create a new state for the agent without DB manager. More... | |
int | queryAgentId (DbManager &dbManager) |
int | writeARS (const CompatibilityState &state, int arsId, int uploadId, int success, DbManager &dbManager) |
void | bail (int exitval) |
bool | processUploadId (const CompatibilityState &state, int uploadId, CompatibilityDatabaseHandler &databaseHandler, int groupId) |
bool | parseCliOptions (int argc, char **argv, CompatibilityCliOptions &dest, std::string &types, std::string &rules, string &jFile, string &mainLicense) |
Parse the options sent by CLI to CliOptions object. More... | |
void | appendToJson (const std::vector< tuple< string, string, bool >> &resultPair, const std::string &fileName, bool &printComma) |
void | printResultToStdout (const std::vector< tuple< string, string, bool >> &resultPair, const std::string &fileName) |
std::set< std::string > | mainLicenseToSet (const string &mainLicense) |
bool | are_licenses_compatible (const string &first_name, const string &first_type, const string &second_name, const string &second_type, const map< tuple< string, string, string, string >, bool > &rule_list) |
Check the licenses against rules and get the compatibility result. More... | |
int | get_column_ids (const string &header, int &name_col, int &type_col) |
Get the column index for shortname and licensetype columns from CSV header. More... | |
unordered_map< string, string > | initialize_license_map (const string &file_location) |
Parse license type CSV and create a map. More... | |
map< tuple< string, string, string, string >, bool > | initialize_rule_list (const string &file_location) |
Read YAML file of rules and parse it as map. More... | |
The utility functions for OJO agent
Definition in file CompatibilityUtils.cc.
void appendToJson | ( | const std::vector< tuple< string, string, bool >> & | resultPair, |
const std::string & | fileName, | ||
bool & | printComma | ||
) |
Append a new result from scanner to STDOUT
fileName | File which was scanned |
resultPair | Contains the first license name, second license name and their compatibility result |
printComma | Set true to print comma. Will be set true after first data is printed |
Definition at line 289 of file CompatibilityUtils.cc.
bool are_licenses_compatible | ( | const string & | first_name, |
const string & | first_type, | ||
const string & | second_name, | ||
const string & | second_type, | ||
const map< tuple< string, string, string, string >, bool > & | rule_list | ||
) |
Check the licenses against rules and get the compatibility result.
first_name | Name of the license 1 |
first_type | Type of the license 1 |
second_name | Name of the license 2 |
second_type | Type of the license 2 |
rule_list | Map of the compatibility rules |
Definition at line 421 of file CompatibilityUtils.cc.
void bail | ( | int | exitval | ) |
Disconnect scheduler and exit in case of failure.
exitval | Exit code to be sent to scheduler and returned by program |
Definition at line 90 of file CompatibilityUtils.cc.
int get_column_ids | ( | const string & | header, |
int & | name_col, | ||
int & | type_col | ||
) |
Get the column index for shortname and licensetype columns from CSV header.
header | String containing CSV header | |
[out] | name_col | Index of shortname column |
[out] | type_col | Index of licensetype column |
Definition at line 482 of file CompatibilityUtils.cc.
CompatibilityState getState | ( | CompatibilityCliOptions && | cliOptions | ) |
Create a new state for the agent without DB manager.
cliOptions | CLI options passed |
Definition at line 38 of file CompatibilityUtils.cc.
CompatibilityState getState | ( | DbManager & | dbManager, |
CompatibilityCliOptions && | cliOptions | ||
) |
Create a new state for the current agent based on CliOptions.
Called during instantiation of agent.
cliOptions | CLI options passed to the agent |
Definition at line 26 of file CompatibilityUtils.cc.
unordered_map<string, string> initialize_license_map | ( | const string & | file_location | ) |
Parse license type CSV and create a map.
file_location | Location of the CSV file |
invalid_argument | If CSV is missing required headers |
Definition at line 521 of file CompatibilityUtils.cc.
map<tuple<string, string, string, string>, bool> initialize_rule_list | ( | const string & | file_location | ) |
Read YAML file of rules and parse it as map.
The map has key of tuple (first name, first type, second name, second type) and value as boolean of compatibility result.
A special key with tuple (~, ~, ~, ~) holds the default value.
file_location | Location to rule YAML |
Definition at line 567 of file CompatibilityUtils.cc.
std::set<std::string> mainLicenseToSet | ( | const string & | mainLicense | ) |
Converts a main license string (which may contain AND) to a set of licenses.
mainLicense | Main license string from CLI |
Definition at line 390 of file CompatibilityUtils.cc.
bool parseCliOptions | ( | int | argc, |
char ** | argv, | ||
CompatibilityCliOptions & | dest, | ||
std::string & | types, | ||
std::string & | rules, | ||
string & | jFile, | ||
string & | mainLicense | ||
) |
Parse the options sent by CLI to CliOptions object.
[in] | argc | |
[in] | argv | |
[out] | dest | The parsed OjoCliOptions object |
[out] | types | Path of the csv file to be scanned |
[out] | rules | Path of the yaml file to be scanned |
[out] | jFile | Path of the json file to be scanned |
[out] | mainLicense | Main license for the package |
Definition at line 191 of file CompatibilityUtils.cc.
void printResultToStdout | ( | const std::vector< tuple< string, string, bool >> & | resultPair, |
const std::string & | fileName | ||
) |
Print the result of current scan to stdout
fileName | File which was scanned |
resultPair | Contains the first license name, second license name and their compatibility result |
Definition at line 360 of file CompatibilityUtils.cc.
bool processUploadId | ( | const CompatibilityState & | state, |
int | uploadId, | ||
CompatibilityDatabaseHandler & | databaseHandler, | ||
int | groupId | ||
) |
Process a given upload id
state | State of the agent |
uploadId | Upload ID to be scanned |
databaseHandler | Database handler to be used |
groupId | Group who scheduled the agent |
Definition at line 104 of file CompatibilityUtils.cc.
int queryAgentId | ( | DbManager & | dbManager | ) |
Query the agent ID from the DB.
dbManager | DbManager to be used |
Definition at line 48 of file CompatibilityUtils.cc.
int writeARS | ( | const CompatibilityState & | state, |
int | arsId, | ||
int | uploadId, | ||
int | success, | ||
DbManager & | dbManager | ||
) |
Write ARS to the agent's ars table
state | State of the agent |
arsId | ARS id (0 for new entry) |
uploadId | Upload ID |
success | Success status |
dbManager | DbManager to use |
Definition at line 76 of file CompatibilityUtils.cc.