RDKB-62878:Enhance Sample App Automation and Remote Log Access#801
RDKB-62878:Enhance Sample App Automation and Remote Log Access#801Aniket0606 wants to merge 1 commit intordkcentral:developfrom
Conversation
aa52390 to
85de41b
Compare
|
b'## WARNING: A Blackduck scan failure has been waived A prior failure has been upvoted
|
| if (execute_system_command_with_status( | ||
| "/usr/bin/rdkssacli \"{STOR=GET,SRC=kquhqtoczcbx,DST=/dev/stdout}\"", | ||
| output_key, | ||
| output_len, | ||
| NULL) != 0) |
There was a problem hiding this comment.
What's the point of filling this buffer at this place if it might fail or will be overwritten later with another command output at lines https://github.com/rdkcentral/OneWifi/pull/801/files#diff-1d7faf20d911b0287acf3399680c51aa629b17b99f49a25cbb6ca2c9286ccc0eR235-R239
There was a problem hiding this comment.
I didn't get you.
There was a problem hiding this comment.
You supply output_key and output_len here to fill that buffer and later you fill it again overwriting whatever it was filled in here.
| size_t len = 0; | ||
|
|
||
| if (!cmd || !cmd_output || output_size == 0) { | ||
| errno = EINVAL; |
There was a problem hiding this comment.
You set errno in here and print error here: https://github.com/rdkcentral/OneWifi/pull/801/files#diff-1d7faf20d911b0287acf3399680c51aa629b17b99f49a25cbb6ca2c9286ccc0eR181
Please choose single approach.
| int get_server_password(char *output_key, size_t output_len) | ||
| { | ||
| if (!output_key || output_len == 0) { | ||
| errno = EINVAL; |
There was a problem hiding this comment.
You set errno in here and print error in other cases.
Please choose single approach.
| if (len + buf_len < output_size - 1) { | ||
| memcpy(cmd_output + len, buffer, buf_len); | ||
| len += buf_len; | ||
| cmd_output[len] = '\0'; |
There was a problem hiding this comment.
I think this can be moved outside the while loop.
| char curl_output[1024]; | ||
| int curl_exit_code; | ||
|
|
||
| #if defined (_XB7_PRODUCT_REQ_) |
There was a problem hiding this comment.
| #if defined (_XB7_PRODUCT_REQ_) | |
| #ifdef _XB7_PRODUCT_REQ_ |
|
|
||
| int upload_file_to_cloud(const char *file_name) | ||
| { | ||
| static char password[256] = { 0 }; |
There was a problem hiding this comment.
I am getting password onetime and then using the same password later.
| if (strlen(password) == 0) { | ||
| if (get_server_password(password, sizeof(password)) != 0) { | ||
| fprintf(stderr, "Failed to get server password\n"); | ||
| return -1; | ||
| } | ||
| } | ||
|
|
||
| for (int attempt = 0; attempt < 2; attempt++) { | ||
| snprintf(curl_cmd, sizeof(curl_cmd), | ||
| "curl -s " | ||
| "--cert-type P12 " | ||
| "--cert %s:%s " | ||
| "-F \"data=@%s\" " | ||
| "https://devprimary.vbautobot.comcast.com:6002/post_csi_file", | ||
| cert_file_name, | ||
| password, | ||
| file_name); | ||
|
|
||
| if (execute_system_command_with_status( | ||
| curl_cmd, | ||
| curl_output, | ||
| sizeof(curl_output), | ||
| &curl_exit_code) != 0) | ||
| { | ||
| fprintf(stderr, "Failed to execute curl\n"); | ||
| return -1; | ||
| } | ||
|
|
||
| printf("Curl Output:\n%s\n", curl_output); | ||
|
|
||
| if (curl_exit_code == 0) { | ||
| printf("Upload successful\n"); | ||
| return 0; | ||
| } | ||
|
|
||
| if (curl_exit_code == 58 && attempt == 0) { | ||
| printf("PKCS12 password invalid, regenerating and retrying once...\n"); | ||
|
|
||
| memset(password, 0, sizeof(password)); | ||
| if (get_server_password(password, sizeof(password)) != 0) { | ||
| fprintf(stderr, "Failed to regenerate password\n"); | ||
| return -1; | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| fprintf(stderr, "Upload failed (curl exit code %d)\n", curl_exit_code); | ||
| } |
There was a problem hiding this comment.
| if (strlen(password) == 0) { | |
| if (get_server_password(password, sizeof(password)) != 0) { | |
| fprintf(stderr, "Failed to get server password\n"); | |
| return -1; | |
| } | |
| } | |
| for (int attempt = 0; attempt < 2; attempt++) { | |
| snprintf(curl_cmd, sizeof(curl_cmd), | |
| "curl -s " | |
| "--cert-type P12 " | |
| "--cert %s:%s " | |
| "-F \"data=@%s\" " | |
| "https://devprimary.vbautobot.comcast.com:6002/post_csi_file", | |
| cert_file_name, | |
| password, | |
| file_name); | |
| if (execute_system_command_with_status( | |
| curl_cmd, | |
| curl_output, | |
| sizeof(curl_output), | |
| &curl_exit_code) != 0) | |
| { | |
| fprintf(stderr, "Failed to execute curl\n"); | |
| return -1; | |
| } | |
| printf("Curl Output:\n%s\n", curl_output); | |
| if (curl_exit_code == 0) { | |
| printf("Upload successful\n"); | |
| return 0; | |
| } | |
| if (curl_exit_code == 58 && attempt == 0) { | |
| printf("PKCS12 password invalid, regenerating and retrying once...\n"); | |
| memset(password, 0, sizeof(password)); | |
| if (get_server_password(password, sizeof(password)) != 0) { | |
| fprintf(stderr, "Failed to regenerate password\n"); | |
| return -1; | |
| } | |
| continue; | |
| } | |
| fprintf(stderr, "Upload failed (curl exit code %d)\n", curl_exit_code); | |
| } | |
| for (int attempt = 0; attempt < 2; attempt++) { | |
| if (get_server_password(password, sizeof(password)) != 0) { | |
| fprintf(stderr, "Failed to get server password\n"); | |
| return -1; | |
| } | |
| snprintf(curl_cmd, sizeof(curl_cmd), | |
| "curl -s " | |
| "--cert-type P12 " | |
| "--cert %s:%s " | |
| "-F \"data=@%s\" " | |
| "https://devprimary.vbautobot.comcast.com:6002/post_csi_file", | |
| cert_file_name, | |
| password, | |
| file_name); | |
| if (execute_system_command_with_status( | |
| curl_cmd, | |
| curl_output, | |
| sizeof(curl_output), | |
| &curl_exit_code) != 0) | |
| { | |
| fprintf(stderr, "Failed to execute curl\n"); | |
| return -1; | |
| } | |
| printf("Curl Output:\n%s\n", curl_output); | |
| if (curl_exit_code == 0) { | |
| printf("Upload successful\n"); | |
| return 0; | |
| } | |
| if ((curl_exit_code != 58) || (attempt != 0)) { | |
| fprintf(stderr, "Upload failed (curl exit code %d)\n", curl_exit_code); | |
| break; | |
| } | |
| printf("Retrying\n"); | |
| } |
| if ((i + 1) % 3 == 0) { | ||
| if (mac[i] != ':') { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
| if ((i + 1) % 3 == 0) { | |
| if (mac[i] != ':') { | |
| return false; | |
| } | |
| } | |
| if (((i + 1) % 3 == 0) && (mac[i] != ':')) { | |
| return false; | |
| } |
| printf(" number of samples to be collected : %d\n", g_num_of_samples); | ||
| break; | ||
| case 'm': | ||
| if (!optarg || (validate_mac_list(optarg) == false)) { |
There was a problem hiding this comment.
| if (!optarg || (validate_mac_list(optarg) == false)) { | |
| if (!optarg || !validate_mac_list(optarg)) { |
Reason for change: Added support for providing the client MAC address
as an input to the sample app, enabling automation
of sample app execution. Also implemented a log upload
feature to the server to allow remote access to CSI
JSON files.
Test Procedure: 1) Load OneWifi Image.
2) Execute CSI sample APP.
wifi_events_consumer -e 7 -i 300 -n 20 -m C0:8D:51:A5:FA:74
3) Once log upload done then you will see below log.
Upload successful
Risks: Low
Priority: P1
Signed-off-by: apatel599@cable.comcast.com
85de41b to
5088620
Compare
Reason for change: Added support for providing the client MAC address
as an input to the sample app, enabling automation
of sample app execution. Also implemented a log upload
feature to the server to allow remote access to CSI
JSON files.
Test Procedure: 1) Load OneWifi Image.
2) Execute CSI sample APP.
wifi_events_consumer -e 7 -i 300 -n 20 -m C0:8D:51:A5:FA:74
3) Once log upload done then you will see below log.
Upload successful
Risks: Low
Priority: P1
Signed-off-by: apatel599@cable.comcast.com