Skip to content

Commit

Permalink
SNOW-152050 SNOW-133396 fix OOB telemetryServerDeployment is dev for …
Browse files Browse the repository at this point in the history
…production OOB events. Bump up version to 0.4.10
  • Loading branch information
sfc-gh-stakeda authored Apr 13, 2020
1 parent 518f67a commit 994a2b2
Show file tree
Hide file tree
Showing 17 changed files with 471 additions and 769 deletions.
19 changes: 0 additions & 19 deletions deps/oob-1.0.1/Makefile

This file was deleted.

187 changes: 0 additions & 187 deletions deps/oob-1.0.1/oobtelemetry.c

This file was deleted.

1 change: 1 addition & 0 deletions deps/oob-1.0.1/.gitignore → deps/oob-1.0.2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.obj
*.lib
*.pdb
sampleoobevent
31 changes: 31 additions & 0 deletions deps/oob-1.0.2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

#make LIB=libtelemetry.a

$(LIB): oobtelemetry.c jsonutil.c oobtelemetry.h jsonutil.h
@ $(CC) -g $(CFLAGS) -fPIC -c oobtelemetry.c -I$(OOB_SOURCE_DIR)/../$(CURL_DIR)/include -I$(OOB_SOURCE_DIR)/../$(CURL_DIR)/lib/vtls -I$(OOB_SOURCE_DIR)/../../include -I$(OOB_SOURCE_DIR)/../util-linux/libuuid/src
@ $(CC) -g $(CFLAGS) -fPIC -c jsonutil.c -I$(OOB_SOURCE_DIR)/../$(CURL_DIR)/lib/vtls -I$(OOB_SOURCE_DIR)/../ -I$(OOB_SOURCE_DIR)/../../include -I$(OOB_SOURCE_DIR)/../util-linux/libuuid/src
@ $(INFO Building OOB telemetry lib)
$(AR) $(AROPTIONS) $@ oobtelemetry.o jsonutil.o

distclean: clean
@ rm -f *.a

clean:
@ rm -f *.o sampleoobevent

sample:
$(CC) $(CFLAGS) -g sample.c $(OOB_SOURCE_DIR)/../../lib/cJSON.c \
-I$(OOB_SOURCE_DIR)/../../lib/ \
-I$(OOB_SOURCE_DIR)/../$(CURL_DIR)/lib/vtls \
-I$(OOB_SOURCE_DIR)/../../include \
-I$(OOB_SOURCE_DIR)/../$(CURL_DIR)/include \
libtelemetry.a \
-o sampleoobevent \
$(LDFLAGS) $(OOB_SOURCE_DIR)/../../deps-build/linux/Debug/curl/lib/libcurl.a \
$(OOB_SOURCE_DIR)/../../deps-build/linux/Debug/openssl/lib/libssl.a \
$(OOB_SOURCE_DIR)/../../deps-build/linux/Debug/openssl/lib/libcrypto.a \
-lpthread \
$(OOB_SOURCE_DIR)/../../deps-build/linux/Debug/zlib/lib/libz.a \
$(OOB_SOURCE_DIR)/../../deps-build/linux/Debug/uuid/lib/libuuid.a \
-ldl -lrt

File renamed without changes.
35 changes: 19 additions & 16 deletions deps/oob-1.0.1/jsonutil.c → deps/oob-1.0.2/jsonutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static struct conStr connectionInfo = {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {

static struct logDetails oobevent = {{0}, {0}, {0}, {0}, 0, 0};

void setdeployment(const char *host);

int sendOOBevent(char *event);

//connStr will be copied into another string
Expand All @@ -34,8 +36,15 @@ void getuuid(char *buffer);

char* getConnectionInfo(enum OOBINFO id);

void getCabundle(char *cabundle, int maxlen);

static void freeAll(void);

char* getOOBDeployment()
{
return connectionInfo.dep;
}

void maskSecrets(char *str)
{
//Look for Azure SAS key.
Expand Down Expand Up @@ -182,11 +191,8 @@ char *prepareOOBevent(oobOcspData *ocspevent)
key = cJSON_CreateString( connectionInfo.dep );
if( ! key ) goto end;
cJSON_AddItemToObject(tags, "telemetryServerDeployment", key);
key = cJSON_CreateString( connectionInfo.dep );
if( ! key ) goto end;
cJSON_AddItemToObject(tags, "snowhouseSchema", key);
}else {
key = cJSON_CreateString( "dev" );
key = cJSON_CreateString( "prod" );
if( ! key ) goto end;
cJSON_AddItemToObject(tags, "telemetryServerDeployment", key);
}
Expand Down Expand Up @@ -297,13 +303,13 @@ char *prepareOOBevent(oobOcspData *ocspevent)
maskSecrets(oobevent.request);
key = cJSON_CreateString( oobevent.request);
if( ! key ) goto end;
cJSON_AddItemToObject(list, "request", key);
cJSON_AddItemToObject(vals, "request", key);
}

if(connectionInfo.sqlstate[0] != 0 ){
key = cJSON_CreateString( connectionInfo.sqlstate);
if( ! key ) goto end;
cJSON_AddItemToObject(list, "sqlState", key);
cJSON_AddItemToObject(vals, "sqlState", key);
}

if (root)
Expand Down Expand Up @@ -360,7 +366,7 @@ void setOOBeventdata(enum OOBINFO id, const char *data, long num)
copyString(data, connectionInfo.sqlstate, 64);
break;
case CTX_STR:
copyString(data, connectionInfo.ctxStr, 1024);
copyString(data, connectionInfo.ctxStr, 4096);
break;
case URGENCY:
oobevent.urgent = num;
Expand All @@ -384,6 +390,7 @@ void setoobConnectioninfo(const char* host,
)
{
copyString(host, connectionInfo.host, 512);
setdeployment(host);
copyString(port, connectionInfo.port, 10);
copyString(account, connectionInfo.account, 256);
copyString(user, connectionInfo.user, 256);
Expand All @@ -403,32 +410,28 @@ void setoobConnectioninfo(const char* host,
void setdeployment(const char *host)
{
const char *tmp=NULL;
if( !host ) {
sb_strcpy(connectionInfo.dep, sizeof(connectionInfo.dep), "dev");
if( !host || host[0] == 0) {
sb_strcpy(connectionInfo.dep, sizeof(connectionInfo.dep), "Ignore");
return;
}

if( (strstr(host, "dev") != NULL) || (strstr(host, "reg") != NULL) ){
if( (strstr(host, "local") != NULL) || (strstr(host, "reg") != NULL) ){
sb_strcpy(connectionInfo.dep, sizeof(connectionInfo.dep), "dev");
}

else if( (strstr(host, "qa1") != NULL) || (strstr(host, "prepod2") != NULL) ){
else if( (strstr(host, "qa1") != NULL) || (strstr(host, "preprod") != NULL)){
sb_strcpy(connectionInfo.dep, sizeof(connectionInfo.dep), "qa1");
}

else if( strstr(host, "Production") != NULL ) {
sb_strcpy(connectionInfo.dep, sizeof(connectionInfo.dep), "Production");
}
else
sb_strcpy(connectionInfo.dep, sizeof(connectionInfo.dep), "dev");
sb_strcpy(connectionInfo.dep, sizeof(connectionInfo.dep), "prod");
}

void setConnectionString(char const *connStr)
{
if(connStr && connStr[0] != 0 )
{
sb_strcpy(connectionInfo.ctxStr, sizeof(connectionInfo.ctxStr), connStr);
setdeployment(connStr); //Extract deployment type from connectionString
}
}

Expand Down
13 changes: 12 additions & 1 deletion deps/oob-1.0.1/jsonutil.h → deps/oob-1.0.2/jsonutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
#define __JSONUTIL_H_
#include "sf_ocsp_telemetry_data.h"

#ifdef __cplusplus
extern "C" {
#endif

enum OOBINFO { CTX_ACCOUNT, CTX_HOST, CTX_PORT, CTX_USER, CTX_STR, CTX_PROTOCOL, CTX_DEPLOYMENT, OOBEVENTNAME, EXCPMSG, EXCPMSGTRC, REQUESTURL, RESPSTATUSCODE, ERRORCODE, OOBSQLSTATE, URGENCY, OOBCABUNDLE };

struct conStr{
char ctxStr[1024];
char ctxStr[4096];
char dep[256];
char host[512];
char port[10];
Expand Down Expand Up @@ -47,4 +51,11 @@ void setoobConnectioninfo(const char* host,
short ssl
);

extern char* getOOBDeployment();

extern void getCabundle(char *cabundle, int maxlen);

#ifdef __cplusplus
}
#endif
#endif
Loading

0 comments on commit 994a2b2

Please sign in to comment.