diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 333c60b5bd795df04b106f782c2732b54b836436..3064c83c70a9dc2c6f1c1d13e4b7c5ca9770c926 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 3604d2f8f0e54ae89e5283352271e9a24edf82b9..6086337ffb7fee19608a64278dfd00bc217b3d9a 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 0e7968bb63d07564a6ed8ef07b1c38eeba666222..c75c02c8b88ed3516d045c4f78ab4dbe704e3cd5 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",