OpenHarmony之编译配置白名单机制深度解析:构建系统的安全防线

一、白名单机制概述

在OpenHarmony的构建系统中,compile_standard_whitelist.json是一个关键的安全验证机制,它作为编译过程中的"守门人",确保只有经过验证的组件和依赖关系才能被纳入最终构建产物。这个机制是OpenHarmony构建系统安全性和规范性的重要保障。

1.1 什么是编译配置白名单

编译配置白名单是OpenHarmony构建系统(hb)中用于验证构建配置合法性的机制。在构建过程中,系统会生成compile_standard_whitelist.json文件到/home/openharmony/out/preloader/{product_name}/目录下,用于记录允许通过的构建项。

1.2 白名单的工作原理

当执行hb build命令进行编译时,构建系统会按照以下流程工作:

  1. 读取编译配置:根据产品选择进行初始化 ,(主要是preloader阶段对系统所需配置进行扫描)
    编译流程可见我的主页文章
  2. 生成预加载信息:包括compile_standard_whitelist.json在内的各种配置文件
  3. 进行白名单验证:检查所有构建项是否符合安全规范
  4. 执行实际编译:通过验证的组件才会被编译

二、白名单的核心类别与功能

根据源码分析,OpenHarmony的编译白名单主要包含七大核心验证类别,每种类别负责不同维度的安全检查。

这里以Openharmony 6.0的白名单为例(像Openharmony 5.0会有部分差异):

{
   
   
    "bundle_subsystem_error": [
        "device/board/hihope/rk3568/ohos.build",
        "device/board/hisilicon/hispark_taurus/linux/ohos.build",
        "device/board/hisilicon/hispark_taurus/ohos.build",
        "device/qemu/arm_virt/linux/ohos.build",
        "third_party/flutter/glfw/bundle.json",
        "vendor/hihope/rk3568/ohos.build",
        "vendor/hihope/ipcamera/ohos.build"
    ],
    "subsystem_components": [],
    "gn_part_or_subsystem_error": [
        "//arkcompiler/toolchain/tooling/test:debugger_entry",
        "//arkcompiler/toolchain/tooling/test:jsdebugtest",
        "//arkcompiler/toolchain/tooling:libark_ecma_debugger_test",
        "//arkcompiler/toolchain/tooling/client:libark_client",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2/device_manager:camera_device_manager",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2/driver_adapter:camera_v4l2_adapter",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2/metadata_manager:camera_metadata_manager",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2/pipeline_core:camera_ipp_algo_example",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2/pipeline_core:camera_pipeline_core",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2:camera_host_vdi_impl_1.0",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2:camera_pipeline_config",
        "//device/soc/rockchip/rk3568/hardware/codec/jpeg:libjpeg_vdi_impl",
        "//device/soc/rockchip/rk3568/hardware/codec:libcodec_oem_interface",
        "//device/soc/rockchip/rk3568/hardware/display:display_composer_vendor",
        "//device/soc/rockchip/rk3568/hardware/display:display_gfx",
        "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vdi_impl",
        "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vendor",
        "//device/soc/rockchip/rk3568/hardware/display:libdisplay_composer_vdi_impl",
        "//device/soc/rockchip/rk3568/hardware/mpp/mpp/legacy:librockchip_vpu",
        "//device/soc/rockchip/rk3568/hardware/omx_il/component/common:libRkOMX_Resourcemanager",
        "//device/soc/rockchip/rk3568/hardware/omx_il/component/video/dec:libomxvpu_dec",
        "//device/soc/rockchip/rk3568/hardware/omx_il/component/video/enc:libomxvpu_enc",
        "//device/soc/rockchip/rk3568/hardware/omx_il/core:libOMX_Core",
        "//device/soc/rockchip/rk3568/hardware/omx_il/libOMXPlugin:libOMX_Pluginhw",
        "//ide/tools/previewer:lite_previewer",
        "//vendor/hihope/rk3568/bluetooth:libbt_vendor",
        "//vendor/hihope/ipcamera/bluetooth:libbt_vendor"
    ],
    "deps_added_external_part_module": [
        "//arkcompiler/toolchain/inspector:ark_debugger_static",
        "//arkcompiler/toolchain/tooling:libark_ecma_debugger",
        "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set",
        "//arkcompiler/toolchain/websocket:websocket",
        "//base/hiviewdfx/hilog/interfaces/js/kits/napi:libhilognapi_src",
        "//base/hiviewdfx/hiview/test/plugins/examples/event_processor_example1:event_processor_example1",
        "//base/hiviewdfx/hiview/test/plugins/examples/event_processor_example2:event_processor_example2",
        "//base/hiviewdfx/hiview/test/plugins/examples/event_processor_example3:event_processor_example3",
        "//base/hiviewdfx/hiview/test/plugins/examples/event_processor_example4:event_processor_example4",
        "//base/hiviewdfx/hiview/test/plugins/examples/event_processor_example5:event_processor_example5",
        "//base/hiviewdfx/hiview/test/plugins/examples/event_source_example:event_source_example",
        "//base/hiviewdfx/hiview/test/plugins/examples_bundle/bundle_event_source_example:bundle_event_source_example",
        "//base/hiviewdfx/hiview/test/plugins/examples_bundle/bundle_plugin_example1:bundle_plugin_example1",
        "//base/hiviewdfx/hiview/test/plugins/examples_bundle/bundle_plugin_example2:bundle_plugin_example2",
        "//base/hiviewdfx/hiview/test/plugins/examples_bundle/bundle_plugin_example3:bundle_plugin_example3",
        "//base/security/device_security_level/baselib/msglib:messenger_static",
        "//base/security/device_security_level/baselib/utils:utils_static",
        "//base/security/device_security_level/interfaces/inner_api:dslm_sdk",
	"//base/security/device_security_level/interfaces/inner_api:dslm_sdk_small",
        "//base/security/device_security_level/oem_property/ohos/lite:dslm_ohos_cred_obj",
        "//base/security/device_security_level/services/common:service_common_obj",
        "//base/security/device_security_level/services/dslm:service_dslm_obj",
        "//base/security/device_security_level/services/msg:service_msg_obj",
        "//base/security/device_security_level/services/sa:dslm_server",
        "//base/security/device_security_level/services/sa:service_sa_static",
        "//base/security/huks/frameworks/huks_standard/main/core:libhuks_core_small_static",
        "//base/security/huks/frameworks/huks_standard/main/crypto_engine/mbedtls:libhuks_mbedtls_small_static",
        "//base/security/huks/frameworks/huks_standard/main/crypto_engine:libhuks_crypto_engine_small_static",
        "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_small_static",
        "//base/security/huks/interfaces/inner_api/huks_lite:huks_3.0_sdk",
        "//base/security/huks/interfaces/inner_api/huks_lite:huks_server",
        "//base/security/huks/services/huks_standard/huks_engine/main/core:huks_engine_core_standard",
        "//base/security/huks/services/huks_standard/huks_service/main/core:libhuks_service_core_small_static",
        "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl:libhuks_service_idl_small_static",
        "//base/security/huks/services/huks_standard/huks_service/main:libhuks_service_small_static",
        "//base/security/huks/utils/crypto_adapter:libhuks_utils_client_service_adapter_static",
        "//base/security/huks/utils/file_operator:libhuks_utils_file_operator_static",
        "//base/security/huks/utils/mutex:libhuks_utils_mutex_static",
        "//base/startup/init/interfaces/innerkits:libbegetutil",
        "//base/startup/init/services/begetctl:begetctl",
        "//base/startup/init/services/begetctl:param",
        "//base/startup/init/services/begetctl:paramshell",
        "//base/startup/init/services/init/standard:init",
        "//base/startup/init/services/param/base:parameterbase_ext",
        "//base/startup/init/services/sandbox:sandbox",
        "//build/rust/tests/test_bin_cargo_crate:test_bin_cargo_crate",
        "//build/rust/tests/test_bindgen_test/test_for_h:bindgen_test_for_h",
        "//build/rust/tests/test_bindgen_test/test_for_hello_world:bindgen_test",
        "//build/rust/tests/test_bindgen_test/test_for_hpp:bindgen_test_hpp",
        "//build/rust/tests/test_cdylib_crate:test_cdylib_crate",
        "//build/rust/tests/test_cxx:test_cxx_exe",
        "//build/rust/tests/test_cxx_rust:test_cxx_rust",
        "//build/rust/tests/test_cxx_rust:test_cxx_rust_staticlib",
        "//build/rust/tests/test_dylib_crate:test_dylib_crate",
        "//build/rust/tests/test_proc_macro_crate/test_attribute_macro:test_attribute_macro",
        "//build/rust/tests/test_proc_macro_crate/test_derive_helper_macro:test_derive_helper_macro",
        "//build/rust/tests/test_proc_macro_crate/test_function_macro:test_function_macro",
        "//build/rust/tests/test_rlib_cargo_crate:target",
        "//build/rust/tests/test_rlib_cargo_crate:test_rlib_crate_associated_bin",
        "//build/rust/tests/test_rlib_crate:test_rlib_crate",
        "//build/rust/tests/test_staticlib_crate:test_staticlib_crate",
        "//commonlibrary/utils_lite/js/builtin/simulator:ace_kit_deviceinfo_simulator",
        "//commonlibrary/utils_lite/js/builtin/simulator:ace_kit_file_simulator",
        "//commonlibrary/utils_lite/js/builtin/simulator:ace_kit_kvstore_simulator",
        "//developtools/syscap_codec:syscap_tool_bin",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2/pipeline_core:camera_pipeline_core",
        "//device/board/hihope/rk3568/camera/vdi_impl/v4l2:camera_host_vdi_impl_1.0",
        "//device/soc/rockchip/rk3568/hardware/codec:libcodec_oem_interface",
        "//device/soc/rockchip/rk3568/hardware/display:display_composer_vendor",
        "//device/soc/rockchip/rk3568/hardware/display:display_gfx",
        "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vdi_impl",
        "//device/soc/rockchip/rk3568/hardware/display:libdisplay_buffer_vendor",
        "//device/soc/rockchip/rk3568/hardware/display:libdisplay_composer_vdi_impl",
        "//device/soc/rockchip/rk3568/hardware/mpp/mpp/hdi_mpp:hdi_mpp",
        "//device/soc/rockchip/rk3568/hardware/mpp/mpp/legacy:librockchip_vpu",
        "//device/soc/rockchip/rk3568/hardware/mpp/mpp/legacy:rockchip_vpu_src",
        "//device/soc/rockchip/rk3568/hardware/omx_il/component/common:RkOMX_Basecomponent",
        "//device/soc/rockchip/rk3568/hardware/omx_il/component/common:libRkOMX_Resourcemanager",
        "//device/soc/rockchip/rk3568/hardware/omx_il/component/video/dec:libomxvpu_dec",
        "//device/soc/rockchip/rk3568/hardware/omx_il/component/video/enc:libomxvpu_enc",
        "//device/soc/rockchip/rk3568/hardware/omx_il/core:libOMX_Core",
        "//device/soc/rockchip/rk3568/hardware/omx_il/osal:RkOMX_OSAL",
        "//drivers/hdf_core/adapter/build/test_common:libhdf_test_common",
        "//drivers/hdf_core/adapter/uhdf/manager:hdf_core",
        "//drivers/hdf_core/adapter/uhdf/posix:hdf_posix_osal",
        "//drivers/hdf_core/adapter/uhdf2/hdi:libhdi",
        "//drivers/hdf_core/adapter/uhdf2/utils:libhdf_utils",
        "//drivers/peripheral/bluetooth/audio/hal/hdi_passthrough:hdi_audio_bluetooth",
        "//drivers/peripheral/partitionslot/hdi_service:libpartitionslot_driver",
        "//drivers/peripheral/usb/sample/device/liteos:usb_dev_test",
        "//drivers/peripheral/usb/sample/host/liteos_test:liteos_host_speed_test",
        "//drivers/peripheral/usb/sample/host:usbhost_ddk_test",
        "//foundation/arkui/ace_engine/adapter/preview/entrance:preview_entrance_source",
        "//foundation/arkui/ace_engine/adapter/preview/osal:preview_osal_source",
        "//foundation/arkui/ace_engine/frameworks/bridge/js_frontend/engine/jsi:js_engine_bridge_ark_linux",
        "//foundation/arkui/ace_engine/frameworks/bridge/js_frontend/engine/jsi:js_engine_bridge_ark_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/animation:ace_core_components_animation_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/animation:ace_core_components_animation_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/base:ace_core_components_base_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/base:ace_core_components_base_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/event:ace_core_components_event_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/event:ace_core_components_event_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/gestures:ace_core_components_gestures_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/gestures:ace_core_components_gestures_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/image_provider:ace_core_components_image_provider_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/image_provider:ace_core_components_image_provider_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/layout:ace_core_components_layout_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/layout:ace_core_components_layout_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/manager:ace_core_components_manager_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/manager:ace_core_components_manager_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/patternlock:ace_core_components_patternlock_pattern_ng_linux",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/patternlock:ace_core_components_patternlock_pattern_ng_windows",
        "//foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/preview_mock:ace_core_components_preview_mock_pattern_ng_linux"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值