diff --git a/inc/component.h b/inc/component.h index 1f9f086..6fd15a8 100644 --- a/inc/component.h +++ b/inc/component.h @@ -43,6 +43,7 @@ typedef struct component_data_t int hits; /*used in binary analysis*/ char * file_path_ref; int path_rank; + int url_stats[5]; } component_data_t; component_data_t * component_init(void); diff --git a/inc/scanoss.h b/inc/scanoss.h index 7caeced..77333a9 100644 --- a/inc/scanoss.h +++ b/inc/scanoss.h @@ -40,7 +40,7 @@ #define WFP_REC_LN 18 /* Log files */ -#define SCANOSS_VERSION "5.4.6" +#define SCANOSS_VERSION "5.4.7" #define SCAN_LOG "/tmp/scanoss_scan.log" #define MAP_DUMP "/tmp/scanoss_map.dump" #define SLOW_QUERY_LOG "/tmp/scanoss_slow_query.log" diff --git a/src/component.c b/src/component.c index d15ff30..e5a133a 100644 --- a/src/component.c +++ b/src/component.c @@ -243,6 +243,14 @@ bool fill_component(component_data_t *component, uint8_t *url_key, char *file_pa extract_csv(license, (char *)url_record, 5, sizeof(license)); extract_csv(purl, (char *)url_record, 6, sizeof(purl)); extract_csv(url, (char *)url_record, 7, sizeof(url)); + /* Fill url stats if these are available*/ + for (int i = 0; i < 5; i++) { + char stat[16] = "\0"; + extract_csv(stat, (char *)url_record, 8+i, sizeof(url)); + if (!*stat) + break; + component->url_stats[i] = atoi(stat); + } strcpy(latest_version, version); flip_slashes(vendor); diff --git a/src/health.c b/src/health.c index 2d53296..d4ec099 100644 --- a/src/health.c +++ b/src/health.c @@ -84,7 +84,7 @@ bool print_health_item(uint8_t *key, uint8_t *subkey, int subkey_ln, uint8_t *da int len = 0; - len += sprintf(&result[len]," \"health\":{\"creation_date\":\"%s\", ", isalnum(*creation_date) ? creation_date : "n"); + len += sprintf(&result[len]," \"health\":{\"creation_date\":\"%s\", ", isalnum(*creation_date) ? creation_date : " "); len += sprintf(&result[len],"\"last_update\":\"%s\", ", isalnum(*last_update) ? last_update : " "); len += sprintf(&result[len],"\"last_push\":\"%s\", ", isalnum(*last_push) ? last_push : " "); len += sprintf(&result[len],"\"stars\":%s, ", isdigit(*watchers_count) ? watchers_count : "null"); diff --git a/src/license.c b/src/license.c index 6e56cea..93c5e5a 100644 --- a/src/license.c +++ b/src/license.c @@ -50,7 +50,7 @@ 3 = Declared in LICENSE file 4 = Scancode detection 5 = Scancode detection at mining time*/ -const char *license_sources[] = {"component_declared", "file_spdx_tag", "file_header", "license_file", "scancode", "scancode"}; +const char *license_sources[] = {"component_declared", "file_spdx_tag", "file_header", "license_file", "scancode", "scancode", "osselot"}; /** * @brief Remove invalid characters from a license name diff --git a/src/report.c b/src/report.c index 0f3edcb..e4b9064 100644 --- a/src/report.c +++ b/src/report.c @@ -248,6 +248,19 @@ bool print_json_component(component_data_t * component) char *url_id = md5_hex(component->url_md5); printf("\"url_hash\": \"%s\"", url_id); free(url_id); + //report url stats. An empty object is reported if there are not availables + printf(",\"url_stats\":{"); + if (component->url_stats[0] > 0) + { + printf("\"total_files\":%d,"\ + "\"indexed_files\":%d,"\ + "\"source_files\":%d,"\ + "\"ignored_files\":%d,"\ + "\"package_size\":%d", + component->url_stats[0], component->url_stats[1], component->url_stats[2], + component->url_stats[3], component->url_stats[4]); + } + printf("}"); if (!(engine_flags & DISABLE_LICENSES)) {