From 4d551ef09d728838dc25e7feb6f226e7798c0b41 Mon Sep 17 00:00:00 2001 From: Bill Mahoney Date: Mon, 10 May 2021 11:15:18 -0700 Subject: [PATCH 01/18] ci: remove Jenkins chron --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index af5fae5..d424a21 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,5 @@ pipeline { agent none - triggers {cron '@daily'} options { buildDiscarder(logRotator(numToKeepStr: '5', daysToKeepStr: '30')) timestamps() @@ -169,4 +168,4 @@ pipeline { } } } -} \ No newline at end of file +} From cb24fae43a361b865350c57d33c6ca70a55a676b Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Tue, 1 Jun 2021 15:32:57 -0700 Subject: [PATCH 02/18] fix: update examples text and version --- CMakeLists.txt | 2 +- usage.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05d3981..2a85cb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.1) -project (rpc VERSION 1.2.0) +project (rpc VERSION 1.2.1) set (CMAKE_CXX_STANDARD 11) diff --git a/usage.cpp b/usage.cpp index 9c642a6..eb5934b 100644 --- a/usage.cpp +++ b/usage.cpp @@ -49,15 +49,15 @@ void usage_show_help() std::cout << "Examples:" << std::endl; std::cout << " # Activate platform using profile1" << std::endl; std::cout << " " << PROJECT_NAME << \ - " --url wss://localhost:8080 --cmd \"-t activate --profile profile1\"" << std::endl; + " --url wss://192.168.86.100/activate --cmd \"-t activate --profile profile1\"" << std::endl; std::cout << std::endl; std::cout << " # Activate platform using profile1 and override DNS detection" << std::endl; std::cout << " " << PROJECT_NAME << \ - " --url wss://localhost:8080 --cmd \"-t activate --profile profile1\" --dns corp.com" << std::endl; + " --url wss://mycloud.com/activate --cmd \"-t activate --profile profile1\" --dns corp.com" << std::endl; std::cout << std::endl; std::cout << " # Deactivate platform and connect through a proxy" << std::endl; std::cout << " " << PROJECT_NAME << \ - " -u wss://localhost:8080 -c \"-t deactivate --password P@ssw0rd\" -p http://proxy.com:1000" << std::endl; + " -u wss://mycloud.com/activate -c \"-t deactivate --password P@ssw0rd\" -p http://proxy.com:1000" << std::endl; std::cout << std::endl; std::cout << " # Show all informational items" << std::endl; std::cout << " " << PROJECT_NAME << " --amtinfo all" << std::endl; From 491f5087de641f44744524b10c813cb5e4a15a7f Mon Sep 17 00:00:00 2001 From: bwendlandt-intel Date: Fri, 18 Jun 2021 15:37:41 -0700 Subject: [PATCH 03/18] docs(readme): update readme --- README.md | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1584590..641d522 100644 --- a/README.md +++ b/README.md @@ -4,26 +4,45 @@ The Remote Provisioning Client (RPC) is an application that enables remote capabilities for IntelĀ® AMT, such as as device activation and configuration. To accomplish this, RPC communicates with the Remote Provisioning Server (RPS) to activate and connect the edge device. +

+ **For detailed documentation** about RPC or other features of the Open AMT Cloud Toolkit, see the [docs](https://open-amt-cloud-toolkit.github.io/docs/). +
+ ## Prerequisites We leverage GitHub Actions as a means to build RPC automatically leveraging Github's CI/CD Infrastructure. This avoids having to deal with the challenges of getting your build environment just right on your local machine and allows you to get up and running much faster. Read more about GitHub Actions [here](https://github.blog/2019-08-08-github-actions-now-supports-ci-cd/#:~:text=GitHub%20Actions%20is%20an%20API,every%20step%20along%20the%20way.) -## Build the Remote Provisioning Client (RPC)

-1. Create a fork of the rpc repository [here](https://github.com/open-amt-cloud-toolkit/rpc/fork) or via the Fork button in the top-right corner of the rpc repository. +## Build the Remote Provisioning Client (RPC) -2. Click on "Actions" and Select "Build RPC (Native)" Workflow. +1. Create a fork of rpc on GitHub. -3. Click "Run Workflow", select branch "master", and click "Run Workflow". +2. Click on the **Actions** tab at the top and select **Build RPC (Native) Debug/Release**. -4. Grab a coffee. The build for Windows will take approximately 30 minutes and the build for Linux will take approximately 5 minutes. +3. Click the **Run Workflow** dropdown. -5. Once complete, click the completed job, and download the appropriate RPC for your OS under the "Artifacts" section. +4. Select the **Branch: master**, or a preferred version, from the **Use workflow from** dropdown. -For detailed documentation about RPC and using it to activate a device, see the [docs](https://open-amt-cloud-toolkit.github.io/docs/) +5. By default, the Build Type should be **release**. + +6. Click the **Run Workflow** button. + +7. The build time ranges from 15 to 20 minutes. + +8. Once the download is complete, click the completed job which will feature a green checkmark. + +9. Download the appropriate RPC for your managed device's OS under the **Artifacts** section. + +### To Delete your workflow run + +1. Click the ellipsis ( **...** ) menu for the workflow. + +2. Choose the **Delete workflow run** option. + +For detailed documentation about RPC and using it to activate a device, see the [docs](https://open-amt-cloud-toolkit.github.io/docs/) \ No newline at end of file From f7dc3f4faa4027027a192a3271af9dab81daaa65 Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Tue, 22 Jun 2021 15:37:11 -0700 Subject: [PATCH 04/18] feat: add AMT wireless adapter info to amtinfo LAN settings. --- commands.cpp | 6 ++++-- commands.h | 2 +- info.cpp | 42 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/commands.cpp b/commands.cpp index 1b1f7dc..3bf50ca 100644 --- a/commands.cpp +++ b/commands.cpp @@ -377,14 +377,14 @@ bool cmd_get_remote_access_connection_status(int& network_status, int& remote_st return false; } -bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings) +bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings, bool wired_interface) { // initialize HECI interface if (heci_Init(NULL, PTHI_CLIENT) == 0) return false; // get wired interface LAN_SETTINGS lan_settings; - UINT32 interface_settings = 0; // wired=0, wireless=1 + UINT32 interface_settings = (wired_interface) ? 0 : 1; // wired=0, wireless=1 AMT_STATUS amt_status = pthi_GetLanInterfaceSettings(interface_settings, &lan_settings); if (amt_status == 0) { @@ -393,11 +393,13 @@ bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settin lan_interface_settings.dhcp_enabled = lan_settings.DhcpEnabled; lan_interface_settings.link_status = lan_settings.LinkStatus; + lan_interface_settings.ip_address.clear(); lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address >> 24) & 0xff); lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address >> 16) & 0xff); lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address >> 8) & 0xff); lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address) & 0xff); + lan_interface_settings.mac_address.clear(); lan_interface_settings.mac_address.push_back(lan_settings.MacAddress[0]); lan_interface_settings.mac_address.push_back(lan_settings.MacAddress[1]); lan_interface_settings.mac_address.push_back(lan_settings.MacAddress[2]); diff --git a/commands.h b/commands.h index 851ea6b..b9ad220 100644 --- a/commands.h +++ b/commands.h @@ -49,6 +49,6 @@ bool cmd_get_dns_suffix(std::string& suffix); bool cmd_get_wired_mac_address(std::vector& address); bool cmd_get_certificate_hashes(std::vector& hash_entries); bool cmd_get_remote_access_connection_status(int& network_status, int& remote_status, int& remote_trigger, std::string& mps_hostname); -bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings); +bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings, bool wired_interface = true); #endif \ No newline at end of file diff --git a/info.cpp b/info.cpp index 6973b7c..1b18f57 100644 --- a/info.cpp +++ b/info.cpp @@ -20,7 +20,7 @@ void out_text(const std::string name, const std::vector value, co for (unsigned char tmp : value) { (hex) ? std::cout << std::setfill('0') << std::setw(2) << std::hex << (unsigned int)tmp - : std::cout << (unsigned int)tmp; + : std::cout << std::dec << (unsigned int)tmp; if (char_count++ < value.size()) { @@ -270,15 +270,41 @@ bool info_get_lan_interface_settings() tmp.ip_address.clear(); tmp.mac_address.clear(); - if (!cmd_get_lan_interface_settings(tmp)) return false; + bool hasWired = cmd_get_lan_interface_settings(tmp); + if (hasWired) + { + out_text("LAN Inteface", "wired"); + out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false"); + out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive"); + out_text("Link Status", (tmp.link_status) ? "up" : "down"); + out_text("IP Address", tmp.ip_address, '.', false); + out_text("MAC Address", tmp.mac_address, ':'); + } + + tmp.is_enabled = false; + tmp.link_status = false; + tmp.dhcp_enabled = false; + tmp.dhcp_mode = 0; + tmp.ip_address.clear(); + tmp.mac_address.clear(); - out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false"); - out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive"); - out_text("Link Status", (tmp.link_status) ? "up" : "down"); - out_text("IP Address", tmp.ip_address, '.', false); - out_text("MAC Address", tmp.mac_address, ':'); + bool hasWireless = cmd_get_lan_interface_settings(tmp, false); + if (hasWireless) + { + out_text("LAN Inteface", "wireless"); + out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false"); + out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive"); + out_text("Link Status", (tmp.link_status) ? "up" : "down"); + out_text("IP Address", tmp.ip_address, '.', false); + out_text("MAC Address", tmp.mac_address, ':'); + } - return true; + if (hasWired || hasWireless) + { + return true; + } + + return false; } bool info_get(const std::string info) From ec1374280bf47fd315739d106ef233d9d46e415b Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 22 Jun 2021 16:41:47 -0700 Subject: [PATCH 05/18] ci(changelog): add automation for changelog generation --- .github/workflows/changelog.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/changelog.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..7da1632 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,20 @@ +name: Changelog Generator + +on: + pull_request: + branches: [ master ] + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - run: docker run -v $PWD:/workdir quay.io/git-chglog/git-chglog --next-tag vNext --output CHANGELOG-new.md vNext.. + - name: GitHub Upload Release Artifacts + uses: actions/upload-artifact@v2 + with: + name: CHANGELOG-new.md + path: | + ./CHANGELOG-new.md From b4c12d63b5637ce0ac39be195a483c9084917ec9 Mon Sep 17 00:00:00 2001 From: Matt Primrose <47540908+matt-primrose@users.noreply.github.com> Date: Thu, 24 Jun 2021 14:30:37 -0700 Subject: [PATCH 06/18] docs(security): added security.md file --- security.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 security.md diff --git a/security.md b/security.md new file mode 100644 index 0000000..f14ba1e --- /dev/null +++ b/security.md @@ -0,0 +1,5 @@ +# Security Policy +Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. + +## Reporting a Vulnerability +Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). \ No newline at end of file From c2be90c8a7db8c8d561d5bd5893e9828aae5b1c8 Mon Sep 17 00:00:00 2001 From: Matt Primrose <47540908+matt-primrose@users.noreply.github.com> Date: Thu, 24 Jun 2021 14:44:31 -0700 Subject: [PATCH 07/18] docs(security): added SECURITY.md file --- security.md => SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename security.md => SECURITY.md (84%) diff --git a/security.md b/SECURITY.md similarity index 84% rename from security.md rename to SECURITY.md index f14ba1e..a4b23c3 100644 --- a/security.md +++ b/SECURITY.md @@ -2,4 +2,4 @@ Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. ## Reporting a Vulnerability -Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). \ No newline at end of file +Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). From 34981ad2c73386854e287906169b4b4de20bf9e4 Mon Sep 17 00:00:00 2001 From: bwendlandt-intel Date: Mon, 28 Jun 2021 11:42:37 -0700 Subject: [PATCH 08/18] docs(readme): wording --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 641d522..833848b 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,7 @@ We leverage GitHub Actions as a means to build RPC automatically leveraging Gith 5. By default, the Build Type should be **release**. -6. Click the **Run Workflow** button. - -7. The build time ranges from 15 to 20 minutes. +6. Click the **Run Workflow** button. Grab a coffee and take a break! The build time ranges from 15 to 20 minutes. 8. Once the download is complete, click the completed job which will feature a green checkmark. From 33abb9d2d2a457ba269857b6ced2776eb7bc1ff4 Mon Sep 17 00:00:00 2001 From: Bill Mahoney Date: Wed, 30 Jun 2021 11:18:27 -0700 Subject: [PATCH 09/18] ci: update scanning Signed-off-by: Bill Mahoney --- Jenkinsfile | 195 ++++++++++++++++++++++++---------------------------- 1 file changed, 89 insertions(+), 106 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d424a21..cdfcec2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,61 +1,33 @@ pipeline { - agent none + agent { + label 'docker-amt' + } options { buildDiscarder(logRotator(numToKeepStr: '5', daysToKeepStr: '30')) timestamps() timeout(unit: 'HOURS', time: 2) } + stages { - stage ('Parallel') { - parallel { - stage ('Linux') { - agent { label 'docker-amt' } - stages { - stage ('Cloning Repository') { - steps { - script { - scmCheckout { - clean = true - } - } - } - } - } - } - stage ('Windows') { - agent { label 'openamt-win' } - stages { - stage ('Cloning Repository') { - steps { - script { - scmCheckout { - clean = true - } - } - } - } - } - } - } - } - stage ('Static Code Scan - Protex') { - agent { label 'docker-amt' } + stage ('Cloning Repository') { steps { script { - staticCodeScan { - // generic - scanners = ['protex'] - scannerType = ['c','c++'] - - protexProjectName = 'OpenAMT - RPC' - // internal, do not change - protexBuildName = 'rrs-generic-protex-build' + scmCheckout { + clean = true } } } } - + stage('Static Code Scan - Protex') { + environment{ + PROJECT_NAME = 'OpenAMT - RPC' + SCANNERS = 'protex' + } + steps { + rbheStaticCodeScan() + } + } stage ('Parallel Builds') { parallel { stage ('Linux') { @@ -71,6 +43,7 @@ pipeline { steps { sh './scripts/jenkins-pre-build.sh' sh './scripts/jenkins-build.sh' + stash includes: 'build/rpc', name: 'linux-rpc-app' } } stage ('Archive') { @@ -78,7 +51,6 @@ pipeline { archiveArtifacts allowEmptyArchive: true, artifacts: 'build/rpc', caseSensitive: false, onlyIfSuccessful: true } } - } } stage ('Windows') { @@ -89,7 +61,7 @@ pipeline { bat 'scripts\\jenkins-pre-build.cmd' bat 'scripts\\jenkins-build.cmd' // prepare stash for the binary scan - stash includes: "**/*.exe", name: 'rpc-app' + stash includes: '**/*.exe', name: 'win-rpc-app' } } stage ('Archive') { @@ -101,71 +73,82 @@ pipeline { } } } - stage ('Parallel Scans') { - parallel { - stage ('Static Code Scan Linux') { - agent { label 'docker-amt' } - steps { - script { - staticCodeScan { - // generic - scanners = ['bdba','klocwork'] - scannerType = 'c++' - protecodeGroup = '25' - protecodeScanName = 'rpc-zip' - protecodeDirectory = './build/rpc' - - klockworkPreBuildScript = './scripts/jenkins-pre-build.sh' - klockworkBuildCommand = './scripts/jenkins-build.sh' - klockworkProjectName = 'Panther Point Creek' - klockworkIgnoreCompileErrors = true - } - } - } + stage('Prep Binary') { + steps { + sh 'mkdir -p ./bin' + dir('./bin') { + unstash 'linux-rpc-app' + unstash 'win-rpc-app' } - stage ('Static Code Scan Windows') { - stages { - stage ('Static Code Scan Windows - Klockwork') { - agent { label 'openamt-win' } - steps { - script { - staticCodeScan { - // generic - scanners = ['klocwork'] - scannerType = 'c++' - - klockworkPreBuildScript = 'scripts\\jenkins-pre-build.cmd' - klockworkBuildCommand = 'scripts\\jenkins-build.cmd' - klockworkProjectName = 'Panther Point Creek' - klockworkIgnoreCompileErrors = true - } - } - } - } - stage ('Static Code Scan Windows - BDBA') { - agent { label 'docker-amt' } - steps { - script { - sh "mkdir -p bdbaScanDir" - dir("bdbaScanDir") { - unstash 'rpc-app' - } - staticCodeScan { - // generic - scanners = ['bdba'] - scannerType = 'c++' - - protecodeGroup = '25' - protecodeScanName = 'rpc-zip' - protecodeDirectory = 'bdbaScanDir' - } - } - } + } + } + stage('Linux Scans') { + environment{ + PROJECT_NAME = 'OpenAMT - RPC - Linux' + SCANNERS = 'bdba,klocwork' + + // protecode details + PROTECODE_BIN_DIR = './bin' + PROTECODE_INCLUDE_SUB_DIRS = true + + // klocwork details + KLOCWORK_SCAN_TYPE = 'c++' + KLOCWORK_PRE_BUILD_SCRIPT = './scripts/jenkins-pre-build.sh' + KLOCWORK_BUILD_COMMAND = './scripts/jenkins-build.sh' + KLOCWORK_IGNORE_COMPILE_ERRORS = true + + // publishArtifacts details + PUBLISH_TO_ARTIFACTORY = true + } + steps { + rbheStaticCodeScan() + dir('artifacts/Klockwork'){ + sh 'cp kw_report.html kw_report_linux.html' + sh 'cp kw_report.csv kw_report_linux.csv' + archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_linux.html' + archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_linux.csv' + } + + } + } + stage('Windows Scans'){ + agent { label 'openamt-win' } + stages{ + stage ('Windows Scans - klocwork') { + environment { + PROJECT_NAME = 'OpenAMT - RPC - Windows' + SCANNERS = 'klocwork' + + // klocwork details + KLOCWORK_SCAN_TYPE = 'c++' + KLOCWORK_PRE_BUILD_SCRIPT = 'scripts\\jenkins-pre-build.cmd' + KLOCWORK_BUILD_COMMAND = 'scripts\\jenkins-build.cmd' + KLOCWORK_IGNORE_COMPILE_ERRORS = true + + // publishArtifacts details + PUBLISH_TO_ARTIFACTORY = true + } + steps { + rbheStaticCodeScan() + dir('artifacts\\Klockwork'){ + bat 'copy kw_report.html kw_report_windows.html' + bat 'copy kw_report.csv kw_report_windows.csv' + stash includes: 'kw_report_windows.*', name: 'win-kwreports' + archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_windows.html' + archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_windows.csv' } } } } } + stage('Publish Artifacts'){ + steps{ + dir('artifacts/Klockwork'){ + unstash 'win-kwreports' + } + publishArtifacts() + } + } } -} +} \ No newline at end of file From 913fa41b17736333d734a3e0269109964228061f Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Mon, 19 Jul 2021 13:25:33 -0700 Subject: [PATCH 10/18] fix: klockwork reported success / failure check fix --- commands.cpp | 83 +++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/commands.cpp b/commands.cpp index 3bf50ca..f68b675 100644 --- a/commands.cpp +++ b/commands.cpp @@ -282,51 +282,54 @@ bool cmd_get_certificate_hashes(std::vector& hash_entries) for (int i = 0; i < (int) amt_hash_handles.Length; i++) { // get each entry - AMT_STATUS status = pthi_GetCertificateHashEntry(amt_hash_handles.Handles[i], &certhash_entry); + AMT_STATUS amt_status = pthi_GetCertificateHashEntry(amt_hash_handles.Handles[i], &certhash_entry); - int hashSize; - cert_hash_entry tmp; - switch (certhash_entry.HashAlgorithm) { - case 0: // MD5 - hashSize = 16; - tmp.algorithm = "MD5"; - break; - case 1: // SHA1 - hashSize = 20; - tmp.algorithm = "SHA1"; - break; - case 2: // SHA256 - hashSize = 32; - tmp.algorithm = "SHA256"; - break; - case 3: // SHA512 - hashSize = 64; - tmp.algorithm = "SHA512"; - break; - default: - hashSize = 0; - tmp.algorithm = "UNKNOWN"; - break; - } - - if (certhash_entry.IsActive == 1) + if (amt_status == 0) { - std::string cert_name(certhash_entry.Name.Buffer, certhash_entry.Name.Length); - tmp.name = cert_name; - tmp.is_default = certhash_entry.IsDefault; - tmp.is_active = certhash_entry.IsActive; - - std::string hashString; - for (int i = 0; i < hashSize; i++) - { - char hex[10]; - snprintf(hex, 10, "%02x", certhash_entry.CertificateHash[i]); - hashString += hex; + int hashSize; + cert_hash_entry tmp; + switch (certhash_entry.HashAlgorithm) { + case 0: // MD5 + hashSize = 16; + tmp.algorithm = "MD5"; + break; + case 1: // SHA1 + hashSize = 20; + tmp.algorithm = "SHA1"; + break; + case 2: // SHA256 + hashSize = 32; + tmp.algorithm = "SHA256"; + break; + case 3: // SHA512 + hashSize = 64; + tmp.algorithm = "SHA512"; + break; + default: + hashSize = 0; + tmp.algorithm = "UNKNOWN"; + break; } - tmp.hash = hashString; + if (certhash_entry.IsActive == 1) + { + std::string cert_name(certhash_entry.Name.Buffer, certhash_entry.Name.Length); + tmp.name = cert_name; + tmp.is_default = certhash_entry.IsDefault; + tmp.is_active = certhash_entry.IsActive; - hash_entries.push_back(tmp); + std::string hashString; + for (int i = 0; i < hashSize; i++) + { + char hex[10]; + snprintf(hex, 10, "%02x", certhash_entry.CertificateHash[i]); + hashString += hex; + } + + tmp.hash = hashString; + + hash_entries.push_back(tmp); + } } } From db924a9b2ecbb47eb575eb46ca99fba264beef01 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 2 Aug 2021 10:13:39 -0700 Subject: [PATCH 11/18] build: bump version to v1.3.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a85cb9..a256dad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.1) -project (rpc VERSION 1.2.1) +project (rpc VERSION 1.3.0) set (CMAKE_CXX_STANDARD 11) From 26629a1a6810c370f2e1a9611789f85839d7abb6 Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Tue, 17 Aug 2021 13:41:07 -0700 Subject: [PATCH 12/18] feat: format json status messages --- main.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 3c5497a..1d2f680 100644 --- a/main.cpp +++ b/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "port.h" #include "lms.h" #include "commands.h" @@ -271,7 +272,22 @@ int main(int argc, char* argv[]) g_timeout_val = 0; // exit - std::cout << std::endl << msgMessage << std::endl; + try { + std::cout << std::endl; + utility::string_t tmp = utility::conversions::convertstring(msgMessage); + web::json::value parsed = web::json::value::parse(tmp); + for (const auto& obj : parsed.as_object()) { + std::string key = utility::conversions::to_utf8string(obj.first); + std::string value = utility::conversions::to_utf8string(obj.second.serialize()); + value.erase(std::remove(value.begin(), value.end(), '"'), value.end()); + std::cout << key << ": " << value << std::endl; + } + } + catch (...) + { + std::cout << std::endl << msgMessage << std::endl; + } + return; } else if (msgStatus.compare("failed")==0) @@ -280,7 +296,22 @@ int main(int argc, char* argv[]) g_timeout_val = 0; // exit - std::cout << std::endl << msgMessage << std::endl; + try { + std::cout << std::endl; + utility::string_t tmp = utility::conversions::convertstring(msgMessage); + web::json::value parsed = web::json::value::parse(tmp); + for (const auto& obj : parsed.as_object()) { + std::string key = utility::conversions::to_utf8string(obj.first); + std::string value = utility::conversions::to_utf8string(obj.second.serialize()); + value.erase(std::remove(value.begin(), value.end(), '"'), value.end()); + std::cout << key << ": " << value << std::endl; + } + } + catch (...) + { + std::cout << std::endl << msgMessage << std::endl; + } + return; } From c9a2ab44dd1cfeff3c3f13c7dcab6033ea4ec757 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 24 Aug 2021 16:03:21 -0700 Subject: [PATCH 13/18] fix(spelling): lan inteface -> lan interface in amtinfo --- info.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/info.cpp b/info.cpp index 1b18f57..9ec5fec 100644 --- a/info.cpp +++ b/info.cpp @@ -273,7 +273,7 @@ bool info_get_lan_interface_settings() bool hasWired = cmd_get_lan_interface_settings(tmp); if (hasWired) { - out_text("LAN Inteface", "wired"); + out_text("LAN Interface", "wired"); out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false"); out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive"); out_text("Link Status", (tmp.link_status) ? "up" : "down"); @@ -291,7 +291,7 @@ bool info_get_lan_interface_settings() bool hasWireless = cmd_get_lan_interface_settings(tmp, false); if (hasWireless) { - out_text("LAN Inteface", "wireless"); + out_text("LAN Interface", "wireless"); out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false"); out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive"); out_text("Link Status", (tmp.link_status) ? "up" : "down"); @@ -368,4 +368,4 @@ bool info_get_verify(const std::string info) } return false; -} \ No newline at end of file +} From bb8211ae03221210c97df80461e0807346fe5af9 Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Wed, 25 Aug 2021 08:19:02 -0700 Subject: [PATCH 14/18] feat: Update docs and scripts for Windows and Ubuntu. --- Build.md | 4 ++-- scripts/jenkins-pre-build.cmd | 2 +- scripts/jenkins-pre-build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Build.md b/Build.md index be47cb0..ba41e22 100644 --- a/Build.md +++ b/Build.md @@ -25,7 +25,7 @@ sudo apt install git cmake build-essential curl zip unzip tar pkg-config Open a Terminal window. ``` -git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git +git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg install cpprestsdk[websockets] @@ -68,7 +68,7 @@ Steps below are for Windows 10 and Visual Studio 2019 Professional. Open an x64 Native Tools Command Prompt for Visual Studio 2019. ``` -git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git +git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git cd vcpkg bootstrap-vcpkg.bat vcpkg install cpprestsdk[websockets]:x64-windows-static diff --git a/scripts/jenkins-pre-build.cmd b/scripts/jenkins-pre-build.cmd index 0d48cb5..70e1c1e 100755 --- a/scripts/jenkins-pre-build.cmd +++ b/scripts/jenkins-pre-build.cmd @@ -15,7 +15,7 @@ set VCPKG_DIR=C:\opt\vcpkg-source cd %VCPKG_DIR% REM build vcpkg -git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git +git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git cd vcpkg cmd /c bootstrap-vcpkg.bat diff --git a/scripts/jenkins-pre-build.sh b/scripts/jenkins-pre-build.sh index 3fb1543..7e2c3b1 100755 --- a/scripts/jenkins-pre-build.sh +++ b/scripts/jenkins-pre-build.sh @@ -12,7 +12,7 @@ apt install git cmake build-essential curl zip unzip tar pkg-config -y #cd "$BASE_DIR"/rpc ## build vcpkg -git -C vcpkg pull || git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git vcpkg +git -C vcpkg pull || git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git vcpkg cd vcpkg ./bootstrap-vcpkg.sh From cb9539639ac6d9d38de1c6edac077f45b6ea9ede Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Thu, 26 Aug 2021 12:54:43 -0700 Subject: [PATCH 15/18] feat: Update to latest vcpkg --- CentOS7.md | 2 +- CentOS8.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CentOS7.md b/CentOS7.md index 79b8898..a3e0dc5 100644 --- a/CentOS7.md +++ b/CentOS7.md @@ -50,7 +50,7 @@ export PATH=/home/user/Downloads/git:$PATH Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. ``` -git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git +git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg install cpprestsdk[websockets] diff --git a/CentOS8.md b/CentOS8.md index 10d97f2..2717bc4 100644 --- a/CentOS8.md +++ b/CentOS8.md @@ -28,7 +28,7 @@ sudo yum install cmake Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. ``` -git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git +git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg install cpprestsdk[websockets] From 2a460e90dc53b6d63c17e60349469d9cf16759be Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Thu, 26 Aug 2021 13:27:36 -0700 Subject: [PATCH 16/18] feat: update workflows and Docker build. --- .github/workflows/build_all.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- Dockerfile | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 1214b42..465f60d 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -24,7 +24,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git + run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git - name: Build VCPKG run: cd vcpkg && bootstrap-vcpkg.bat shell: cmd @@ -71,7 +71,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git + run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git - name: Build VCPKG run: cd vcpkg && ./bootstrap-vcpkg.sh shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6855388..1899092 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git + run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git - name: Build VCPKG run: cd vcpkg && bootstrap-vcpkg.bat shell: cmd @@ -54,7 +54,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git + run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git - name: Build VCPKG run: cd vcpkg && ./bootstrap-vcpkg.sh shell: bash diff --git a/Dockerfile b/Dockerfile index f9f37fc..59476cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN \ RUN git clone https://github.com/open-amt-cloud-toolkit/rpc.git WORKDIR /rpc RUN mkdir -p build -RUN git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git +RUN git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git RUN cd vcpkg && ./bootstrap-vcpkg.sh RUN ./vcpkg/vcpkg install cpprestsdk[websockets] From 739992cf29137f0be6deb2969dedb249e5604748 Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Tue, 31 Aug 2021 09:50:29 -0700 Subject: [PATCH 17/18] feat: update version for release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a256dad..94c76db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.1) -project (rpc VERSION 1.3.0) +project (rpc VERSION 2.0.0) set (CMAKE_CXX_STANDARD 11) From d596186feaf1aacf94afe7bc6ab2b8ae95061474 Mon Sep 17 00:00:00 2001 From: Mudit Vats Date: Thu, 9 Sep 2021 16:29:21 -0700 Subject: [PATCH 18/18] feat: update to OpenSSL 1.1.1l --- .github/workflows/build_all.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- Build.md | 6 ++++-- CentOS7.md | 3 ++- CentOS8.md | 3 ++- Dockerfile | 2 +- scripts/jenkins-pre-build.cmd | 3 ++- scripts/jenkins-pre-build.sh | 3 ++- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 465f60d..18670e9 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -24,7 +24,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git + run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 - name: Build VCPKG run: cd vcpkg && bootstrap-vcpkg.bat shell: cmd @@ -71,7 +71,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git + run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 - name: Build VCPKG run: cd vcpkg && ./bootstrap-vcpkg.sh shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1899092..90e95f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git + run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 - name: Build VCPKG run: cd vcpkg && bootstrap-vcpkg.bat shell: cmd @@ -54,7 +54,7 @@ jobs: - name: Create Build Dir run: mkdir build - name: Clone - run: git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git + run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 - name: Build VCPKG run: cd vcpkg && ./bootstrap-vcpkg.sh shell: bash diff --git a/Build.md b/Build.md index ba41e22..08df889 100644 --- a/Build.md +++ b/Build.md @@ -25,8 +25,9 @@ sudo apt install git cmake build-essential curl zip unzip tar pkg-config Open a Terminal window. ``` -git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git +git clone https://github.com/microsoft/vcpkg.git cd vcpkg +git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 ./bootstrap-vcpkg.sh ./vcpkg install cpprestsdk[websockets] ``` @@ -68,8 +69,9 @@ Steps below are for Windows 10 and Visual Studio 2019 Professional. Open an x64 Native Tools Command Prompt for Visual Studio 2019. ``` -git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git +git clone https://github.com/microsoft/vcpkg.git cd vcpkg +git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 bootstrap-vcpkg.bat vcpkg install cpprestsdk[websockets]:x64-windows-static ``` diff --git a/CentOS7.md b/CentOS7.md index a3e0dc5..82acf9c 100644 --- a/CentOS7.md +++ b/CentOS7.md @@ -50,8 +50,9 @@ export PATH=/home/user/Downloads/git:$PATH Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. ``` -git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git +git clone https://github.com/microsoft/vcpkg.git cd vcpkg +git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 ./bootstrap-vcpkg.sh ./vcpkg install cpprestsdk[websockets] ``` diff --git a/CentOS8.md b/CentOS8.md index 2717bc4..6f53df0 100644 --- a/CentOS8.md +++ b/CentOS8.md @@ -28,8 +28,9 @@ sudo yum install cmake Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. ``` -git clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git +git clone https://github.com/microsoft/vcpkg.git cd vcpkg +git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 ./bootstrap-vcpkg.sh ./vcpkg install cpprestsdk[websockets] ``` diff --git a/Dockerfile b/Dockerfile index 59476cd..28e0946 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN \ RUN git clone https://github.com/open-amt-cloud-toolkit/rpc.git WORKDIR /rpc RUN mkdir -p build -RUN git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git +RUN git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 RUN cd vcpkg && ./bootstrap-vcpkg.sh RUN ./vcpkg/vcpkg install cpprestsdk[websockets] diff --git a/scripts/jenkins-pre-build.cmd b/scripts/jenkins-pre-build.cmd index 70e1c1e..d0cebb0 100755 --- a/scripts/jenkins-pre-build.cmd +++ b/scripts/jenkins-pre-build.cmd @@ -15,8 +15,9 @@ set VCPKG_DIR=C:\opt\vcpkg-source cd %VCPKG_DIR% REM build vcpkg -git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git +git clone https://github.com/microsoft/vcpkg.git cd vcpkg +git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 cmd /c bootstrap-vcpkg.bat REM install CPPRestSDK diff --git a/scripts/jenkins-pre-build.sh b/scripts/jenkins-pre-build.sh index 7e2c3b1..1868123 100755 --- a/scripts/jenkins-pre-build.sh +++ b/scripts/jenkins-pre-build.sh @@ -12,8 +12,9 @@ apt install git cmake build-essential curl zip unzip tar pkg-config -y #cd "$BASE_DIR"/rpc ## build vcpkg -git -C vcpkg pull || git clone --branch 2021.05.12 https://github.com/microsoft/vcpkg.git vcpkg +git -C vcpkg pull || git clone https://github.com/microsoft/vcpkg.git vcpkg cd vcpkg +git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0 ./bootstrap-vcpkg.sh ## install CPPRestSDK