From fc81016dc695ce2593b97ae88d20edd488b64fdb Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Thu, 12 Apr 2018 21:38:27 -0400 Subject: [PATCH] More updates for Java validations on darwin. Also, now require version 8u52+, as pack200 algo changed after 8u45. --- app/assets/js/assetguard.js | 63 +++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index 0963505..cb6ca1d 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -612,7 +612,27 @@ class AssetGuard extends EventEmitter { } /** - * Validates the output of a JVM's properties. Currently validates that a JRE is x64. + * Parses a **full** Java Runtime version string and resolves + * the version information. Uses Java 8 formatting. + * + * @param {string} verString Full version string to parse. + * @returns Object containing the version information. + */ + static parseJavaRuntimeVersion(verString){ + // 1.{major}.0_{update}-b{build} + // ex. 1.8.0_152-b16 + const ret = {} + let pts = verString.split('-') + ret.build = parseInt(pts[1].substring(1)) + pts = verString[0].split('_') + ret.update = parseInt(pts[1]) + ret.major = parseInt(pts[0].split['.'][1]) + return ret + } + + /** + * Validates the output of a JVM's properties. Currently validates that a JRE is x64 + * and that the major = 8, update > 52. * * @param {string} stderr The output to validate. * @@ -622,15 +642,34 @@ class AssetGuard extends EventEmitter { static _validateJVMProperties(stderr){ const res = stderr const props = res.split('\n') + + const goal = 2 + let checksum = 0 + for(let i=0; i -1){ let arch = props[i].split('=')[1].trim() console.log(props[i].trim()) - return parseInt(arch) >= 64 + if(parseInt(arch) === 64){ + ++checksum + if(checksum === goal){ + return true + } + } + } else if(props[i].indexOf('java.runtime.version') > -1){ + let verString = props[i].split('=')[1].trim() + console.log(props[i].trim()) + const verOb = AssetGuard.parseJavaRuntimeVersion(verString) + if(verOb.major === 8 && verOb.update > 52){ + ++checksum + if(checksum === goal){ + return true + } + } } } - // sun.arch.data.model not found? - return false + + return checksum === goal } /** @@ -722,7 +761,12 @@ class AssetGuard extends EventEmitter { console.log(err) } else { for(let i=0; i