CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
82 lines
2.6 KiB
Python
82 lines
2.6 KiB
Python
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
|
|
|
|
def has_lldb_codesign():
|
|
"""Check if the lldb_codesign certificate is available."""
|
|
try:
|
|
if sys.platform != "darwin":
|
|
return False
|
|
result = subprocess.run(
|
|
[
|
|
"security",
|
|
"find-certificate",
|
|
"-c",
|
|
"lldb_codesign",
|
|
"/Library/Keychains/System.keychain",
|
|
],
|
|
capture_output=True,
|
|
)
|
|
return result.returncode == 0
|
|
except FileNotFoundError:
|
|
return False
|
|
|
|
|
|
@skipUnlessDarwin
|
|
class TestdSYMCodesign(TestBase):
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
SHARED_BUILD_TESTCASE = False
|
|
|
|
def build_dsym_with_script(self):
|
|
self.build(debug_info="dsym")
|
|
exe = self.getBuildArtifact("a.out")
|
|
dsym = self.getBuildArtifact("a.out.dSYM")
|
|
python_dir = os.path.join(dsym, "Contents", "Resources", "Python")
|
|
os.makedirs(python_dir, exist_ok=True)
|
|
shutil.copy(
|
|
os.path.join(self.getSourceDir(), "dsym_script.py"),
|
|
os.path.join(python_dir, "a.py"),
|
|
)
|
|
return exe, dsym
|
|
|
|
def test_adhoc_signed_dsym(self):
|
|
"""An ad-hoc signed dSYM should not be loaded because the
|
|
signature doesn't chain to a trusted root CA."""
|
|
exe, dsym = self.build_dsym_with_script()
|
|
subprocess.check_call(["codesign", "-f", "-s", "-", dsym])
|
|
|
|
self.runCmd("settings set target.load-script-from-symbol-file trusted")
|
|
self.createTestTarget(file_path=exe)
|
|
|
|
self.expect(
|
|
"script -- print('SENTINEL')",
|
|
substrs=["SENTINEL"],
|
|
)
|
|
# The script should NOT have been loaded.
|
|
self.assertFalse(
|
|
hasattr(lldb, "_dsym_codesign_test_loaded"),
|
|
"Script should not auto-load from ad-hoc signed dSYM",
|
|
)
|
|
|
|
@unittest.skipUnless(has_lldb_codesign(), "requires lldb_codesign certificate")
|
|
def test_trusted_signed_dsym_auto_loads(self):
|
|
"""A dSYM signed with the trusted lldb_codesign certificate should
|
|
auto-load scripts."""
|
|
exe, dsym = self.build_dsym_with_script()
|
|
subprocess.check_call(["codesign", "-f", "-s", "lldb_codesign", dsym])
|
|
|
|
self.runCmd("settings set target.load-script-from-symbol-file trusted")
|
|
self.createTestTarget(file_path=exe)
|
|
|
|
# The script sets a marker attribute on the lldb module.
|
|
self.assertTrue(
|
|
getattr(lldb, "_dsym_codesign_test_loaded", False),
|
|
"Script should auto-load from trusted signed dSYM",
|
|
)
|