From 1c69666f397509b3cb69f00c359680cbc3a886d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Thu, 19 Sep 2024 08:34:31 +0000 Subject: [PATCH] =?UTF-8?q?update=20modulecheck/app.json.=20=EF=BC=88cherr?= =?UTF-8?q?y=20picked=20commit=20from=20=20Signed-off-by:=20sunxuhui=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapter/ohos/Compressor.java | 28 ++++++++++++++++++++++++++++ adapter/ohos/ModuleJsonUtil.java | 30 ++++++++++++++++++++++++++++++ modulecheck/app.json | 7 +++++++ 3 files changed, 65 insertions(+) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 333c60b5..3064c83c 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -431,6 +431,10 @@ public class Compressor { LOG.error("checkStageAtomicService failed."); throw new BundleException("checkStageAtomicService failed."); } + if (!checkStageHwasanEnabledValid(jsonString)) { + LOG.error("checkStageHwasanEnabledValid failed."); + throw new BundleException("compressHsp failed."); + } // check whether is an overlay hsp or not if (!checkStageOverlayCfg(jsonString)) { LOG.error("checkStageOverlayCfg failed."); @@ -737,6 +741,10 @@ public class Compressor { LOG.error("checkStageAsanTsanEnabledValid failed."); return false; } + if (!checkStageHwasanEnabledValid(jsonString)) { + LOG.error("checkStageHwasanEnabledValid failed."); + return false; + } // check atomicService in module.json if (!checkStageAtomicService(jsonString)) { LOG.error("checkStageAtomicService failed."); @@ -755,6 +763,26 @@ public class Compressor { return true; } + private static boolean checkStageHwasanEnabledValid(String jsonString) throws BundleException { + boolean asanEnabled = ModuleJsonUtil.getStageAsanEnabled(jsonString); + boolean tsanEnabled = ModuleJsonUtil.getStageTsanEnabled(jsonString); + boolean gwpAsanEnabled = ModuleJsonUtil.getStageGwpAsanEnabled(jsonString); + boolean hwasanEnabled = ModuleJsonUtil.getStageHwasanEnabled(jsonString); + if (hwasanEnabled && asanEnabled) { + LOG.error("hwasanEnabled and asanEnabled cannot be true at the same time."); + return false; + } + if (hwasanEnabled && tsanEnabled) { + LOG.error("hwasanEnabled and tsanEnabled cannot be true at the same time."); + return false; + } + if (hwasanEnabled && gwpAsanEnabled) { + LOG.error("hwasanEnabled and GWPAsanEnabled cannot be true at the same time."); + return false; + } + return true; + } + private static boolean checkStageAtomicService(String jsonString) throws BundleException { // check consistency of atomicService if (!ModuleJsonUtil.isModuleAtomicServiceValid(jsonString)) { diff --git a/adapter/ohos/ModuleJsonUtil.java b/adapter/ohos/ModuleJsonUtil.java index 3604d2f8..6086337f 100644 --- a/adapter/ohos/ModuleJsonUtil.java +++ b/adapter/ohos/ModuleJsonUtil.java @@ -79,6 +79,8 @@ class ModuleJsonUtil { private static final String COMPRESS_NATIVE_LIBS = "compressNativeLibs"; private static final String ASAN_ENABLED = "asanEnabled"; private static final String TSAN_ENABLED = "tsanEnabled"; + private static final String GWP_ASAN_ENABLED = "GWPAsanEnabled"; + private static final String HW_ASAN_ENABLED = "hwasanEnabled"; private static final String ATOMIC_SERVICE = "atomicService"; private static final String SPLIT = "split"; private static final String MAIN = "main"; @@ -1485,6 +1487,34 @@ class ModuleJsonUtil { return false; } + /** + * get gwpAsanEnabled in module.json + * + * @param jsonString is the file content of module.json + * @return the value of gwpAsanEnabled + */ + public static boolean getStageGwpAsanEnabled(String jsonString) throws BundleException { + JSONObject appObj = getAppObj(jsonString); + if (appObj.containsKey(GWP_ASAN_ENABLED)) { + return appObj.getBoolean(GWP_ASAN_ENABLED); + } + return false; + } + + /** + * get hwasanEnabled in module.json + * + * @param jsonString is the file content of module.json + * @return the value of hwasanEnabled + */ + public static boolean getStageHwasanEnabled(String jsonString) throws BundleException { + JSONObject appObj = getAppObj(jsonString); + if (appObj.containsKey(HW_ASAN_ENABLED)) { + return appObj.getBoolean(HW_ASAN_ENABLED); + } + return false; + } + /** * get apiReleaseType in module.json * diff --git a/modulecheck/app.json b/modulecheck/app.json index 0e7968bb..c75c02c8 100644 --- a/modulecheck/app.json +++ b/modulecheck/app.json @@ -128,6 +128,7 @@ "appEnvironments", "maxChildProcess", "multiAppMode", + "hwasanEnabled", "cloudFileSyncEnabled", "configuration" ] @@ -171,6 +172,7 @@ "tsanEnabled", "appEnvironments", "maxChildProcess", + "hwasanEnabled", "cloudFileSyncEnabled", "configuration" ] @@ -448,6 +450,11 @@ } } }, + "hwasanEnabled": { + "description": "Indicates whether to support hwasan.", + "type": "boolean", + "default": false + }, "cloudFileSyncEnabled": { "description": "Indicates whether the application enables cloud file sync.", "type": "boolean", -- Gitee