Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ec85e1a
feat(scanoss-agent): Initial version of scanoss agent for Fossology. …
scanoss-qg Mar 14, 2022
6cfcb88
Adding File match info and renamed agent to "scanoss"
scanoss-qg Mar 25, 2022
bcdbb2e
Adding File match info and renamed agent to "scanoss"
scanoss-qg Mar 28, 2022
56ace8a
Merge branch 'scanoss-qg/2166/scanoss-agent' of https://github.com/sc…
scanoss-qg Mar 28, 2022
8d5a651
Merge branch 'scanoss-qg/2166/scanoss-agent' of https://github.com/sc…
scanoss-qg Mar 28, 2022
1b7d480
Merge branch 'scanoss-qg/2166/scanoss-agent' of https://github.com/sc…
scanoss-qg Mar 28, 2022
0ca008b
Fixing php style checks
scanoss-qg Mar 29, 2022
9e17a53
fixing PCBF errors
scanoss-qg Mar 29, 2022
e71768c
Removing dependencies for json.h and other scanner features not neede…
scanoss-qg Mar 30, 2022
4fbc47b
Update src/scanoss/agent/main.c
scanoss-qg May 23, 2022
55992e3
Applying changes suggested by reviewer
scanoss-qg May 23, 2022
c95545c
Merge branch 'scanoss-qg/2166/scanoss-agent' of https://github.com/sc…
scanoss-qg May 23, 2022
eba37ee
Update Makefile
scanoss-qg May 23, 2022
b547100
Update scanoss.html.twig
scanoss-qg May 23, 2022
9785ac5
Update scanoss.html.twig
scanoss-qg May 23, 2022
cf164a2
Removing openssl dependency. Using Crypt instead.
scanoss-qg May 23, 2022
66279c1
Update mod_deps
scanoss-qg May 23, 2022
a755cd2
Create README.MD
scanoss-qg May 23, 2022
a8abe02
Update README.MD
scanoss-qg May 23, 2022
03d4f3d
Update blacklist_ext.h
scanoss-qg May 23, 2022
d5a39af
Update README.MD
scanoss-qg May 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removing openssl dependency. Using Crypt instead.
  • Loading branch information
scanoss-qg committed May 23, 2022
commit cf164a2a70540cc662ceda01c19b8eb6c54bdd8c
2 changes: 1 addition & 1 deletion src/scanoss/agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include $(VARS)

CFLAGS_LOCAL = $(FO_CFLAGS)
LDFLAGS_LOCAL = $(FO_LDFLAGS) -lpq
LDFLAGS+=-lpthread -lcrypto -lssl -lcurl -lm
LDFLAGS+=-lpthread -lcurl -lm -lgcrypt
CCFLAGS+= -fPIC -g -Wall -std=gnu99 -I./inc -I./external/inc

SOURCES_SCANNER=$(wildcard src/*.c) $(wildcard src/**/*.c) $(wildcard external/*.c) $(wildcard external/**/*.c)
Expand Down
23 changes: 8 additions & 15 deletions src/scanoss/agent/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ void logme(char *msg)
}
void loadAgentConfiguration(PGconn *pg_conn)
{

char sqlbuf[200];
PGresult *result;
char sqlA[] = "select conf_value from sysconfig where variablename='ScAPIURL';";

Expand Down Expand Up @@ -84,11 +82,6 @@ void loadAgentConfiguration(PGconn *pg_conn)
}
sprintf(ApiPort, "%s", PQgetvalue(result, 0, 0));






}


Expand All @@ -113,24 +106,24 @@ int createTables(PGconn* pgConn)

result = PQexec(pgConn, sql);
if (fo_checkPQcommand(pgConn, result, sql, __FILE__, __LINE__)) {

// Can 't create table scanoss_fileinfo
}
}
char sqlPort[]="INSERT INTO sysconfig (variablename, conf_value, ui_label, vartype, group_name, group_order, description, validation_function, option_value)\
char sqlPort[]="INSERT INTO sysconfig (variablename, conf_value, ui_label, vartype, group_name, group_order, description, validation_function, option_value)\
VALUES('ScPort', '443', 'SCANOSS port', 2, 'SCANOSS', 3, 'Host port for the API (defult 443)', NULL, NULL);";

char sqlHost[]="INSERT INTO sysconfig (variablename, conf_value, ui_label, vartype, group_name, group_order, description, validation_function, option_value) \
char sqlHost[]="INSERT INTO sysconfig (variablename, conf_value, ui_label, vartype, group_name, group_order, description, validation_function, option_value) \
VALUES('ScAPIURL', 'https://scanoss.com/api', 'SCANOSS API URL', 2, 'SCANOSS', 1, '(leave blank for default https://osskb.org/scan/direct)', NULL, NULL);";
char sqlToken[]="INSERT INTO sysconfig (sysconfig_pk, variablename, conf_value, ui_label, vartype, group_name, group_order, description, validation_function, option_value) \
VALUES(73, 'ScToken', 'fD4P8wbfWS9XHvsrzcDrB0zu', 'SCANOSS access token', 2, 'SCANOSS', 2, 'Set token to access full scanning service.', NULL, NULL);";
result = PQexec(pgConn, sqlPort);
if (fo_checkPQcommand(pgConn, result, sqlPort, __FILE__, __LINE__)) {
char sqlToken[]="INSERT INTO sysconfig ( variablename, conf_value, ui_label, vartype, group_name, group_order, description, validation_function, option_value) \
VALUES( 'ScToken', 'fD4P8wbfWS9XHvsrzcDrB0zu', 'SCANOSS access token', 2, 'SCANOSS', 2, 'Set token to access full scanning service.', NULL, NULL);";
result = PQexec(pgConn, sqlPort);
if (fo_checkPQcommand(pgConn, result, sqlPort, __FILE__, __LINE__)) {

// Can 't create table scanoss_fileinfo
}
result = PQexec(pgConn, sqlHost);
if (fo_checkPQcommand(pgConn, result, sqlHost, __FILE__, __LINE__)) {
if (fo_checkPQcommand(pgConn, result, sqlHost, __FILE__, __LINE__)) {

// Can 't create table scanoss_fileinfo
}
Expand Down
2 changes: 0 additions & 2 deletions src/scanoss/agent/snippet_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ void scanTempFile(long key)
char auxSql[5000];




int licCount = runScan(aux, detectedLicenses,purl,url,matchType,oss_lines,filePath); /* Scan for licenses on the temp file */
if(strcmp(matchType,"none") && (!(strcmp(matchType,"file"))||!(strcmp(matchType,"snippet")) )){
sprintf(auxSql,"INSERT INTO scanoss_fileinfo (pfile_fk, matchtype, lineranges, purl, url, filepath) VALUES(%d, '%s', '%s', '%s', '%s', '%s');", key,matchType,oss_lines,purl,url,filePath);
Expand Down
13 changes: 11 additions & 2 deletions src/scanoss/agent/src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

#define _GNU_SOURCE
#include <ctype.h>
#include <openssl/md5.h>
#include <openssl/ssl.h>
#include <gcrypt.h>
#include <dirent.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -64,6 +63,16 @@ const char EXCLUDED_EXTENSIONS[] = " .1, .2, .3, .4, .5, .6, .7, .8, .9, .ac, .a


static int curl_request(int api_req, char* endpoint, char* data,scanner_object_t *s);
/* Adapter function for compatibility with openssl*/
void MD5(unsigned char *fileContent,int len,unsigned char output[16] ){
unsigned int l = gcry_md_get_algo_dlen(GCRY_MD_MD5); /* get digest length (used later to print the result) */
unsigned char *x;
gcry_md_hd_t h;
gcry_md_open(&h, GCRY_MD_MD5, GCRY_MD_FLAG_SECURE); /* initialise the hash context */
gcry_md_write(h, fileContent,len); /* hash some text */
x = gcry_md_read(h, GCRY_MD_MD5); /* get the result */
memcpy(output,x,16);
}

/* Returns a hexadecimal representation of the first "len" bytes in "bin" */
static char *bin_to_hex(uint8_t *bin, uint32_t len)
Expand Down