Beispiel #1
0
        /// <nodoc />
        public SandboxExecRunner(Options options)
        {
            m_options           = options;
            s_crashCollector    = OperatingSystemHelper.IsUnixOS ? new CrashCollectorMacOS(new[] { CrashType.SandboxExec, CrashType.Kernel }) : null;
            m_sandboxConnection = OperatingSystemHelper.IsUnixOS
                ?
#if PLATFORM_OSX
                                  m_options.UseEndpointSecuritySandbox
                    ? (ISandboxConnection) new SandboxConnectionES()
                    :
#endif
                                  (ISandboxConnection) new SandboxConnectionKext(
                new SandboxConnectionKext.Config
            {
                FailureCallback = (int status, string description) =>
                {
                    m_sandboxConnection.Dispose();
                    throw new SystemException($"Received unrecoverable error from the sandbox (Code: {status.ToString("X")}, Description: {description}), please reload the extension and retry.");
                },
                KextConfig = new Sandbox.KextConfig
                {
                    ReportQueueSizeMB    = m_options.ReportQueueSizeMB,
                    EnableReportBatching = m_options.EnableReportBatching,
#if PLATFORM_OSX
                    EnableCatalinaDataPartitionFiltering = OperatingSystemHelper.IsMacOSCatalinaOrHigher
#endif
                },
            })
                : null;
        }
Beispiel #2
0
        public CrashCollectorMacOSTests(ITestOutputHelper output)
            : base(output)
        {
            m_systemCrashReportFolder = CreateCrashReportsFolder(CrashType.Kernel);
            m_userCrashReportFolder   = CreateCrashReportsFolder(CrashType.BuildXL);

            m_crashCollector = new CrashCollectorMacOS(m_systemCrashReportFolder, m_userCrashReportFolder);
        }
Beispiel #3
0
        /// <nodoc />
        public SandboxExecRunner(Options options)
        {
            m_options        = options;
            s_crashCollector = OperatingSystemHelper.IsMacOS
                ? new CrashCollectorMacOS(new[] { CrashType.SandboxExec, CrashType.Kernel })
                : null;

            if (!OperatingSystemHelper.IsMacOSCatalinaOrHigher &&
                (m_options.SandboxKindUsed == SandboxKind.MacOsEndpointSecurity || m_options.SandboxKindUsed == SandboxKind.MacOsHybrid))
            {
                throw new NotSupportedException("EndpointSecurity and Hybrid sandbox types can't be run on system older than macOS Catalina (10.15+).");
            }

            // m_sandboxConnection
            if (OperatingSystemHelper.IsLinuxOS)
            {
                m_sandboxConnection = new SandboxConnectionLinuxDetours(FailureCallback);
            }
            else if (OperatingSystemHelper.IsMacOS)
            {
                if (m_options.SandboxKindUsed == SandboxKind.MacOsKext)
                {
                    m_sandboxConnection = new SandboxConnectionKext(new SandboxConnectionKext.Config
                    {
                        FailureCallback = FailureCallback,
                        KextConfig      = new Sandbox.KextConfig
                        {
                            ReportQueueSizeMB    = m_options.ReportQueueSizeMB,
                            EnableReportBatching = m_options.EnableReportBatching,
#if PLATFORM_OSX
                            EnableCatalinaDataPartitionFiltering = OperatingSystemHelper.IsMacOSCatalinaOrHigher
#endif
                        }
                    });
                }
                else
                {
                    m_sandboxConnection = new SandboxConnection(m_options.SandboxKindUsed, isInTestMode: false, measureCpuTimes: true);
                }
            }
            else
            {
                m_sandboxConnection = null;
            }
        }
Beispiel #4
0
        public void TestCrashCollectorMacOSConstruction()
        {
            var date           = DateTime.Now;
            var crashCollector = new CrashCollectorMacOS(m_systemCrashReportFolder, m_userCrashReportFolder, new[] { CrashType.Kernel, CrashType.SandboxExec });

            CreateCrashReports(m_userCrashReportFolder, CrashType.SandboxExec, 4, date.AddHours(1), "Some sandbox exec crash report");
            CreateCrashReports(m_systemCrashReportFolder, CrashType.Kernel, 8, date.AddHours(1), SystemCrashReportFilter);
            CreateCrashReports(m_userCrashReportFolder, CrashType.BuildXL, 2, date.AddHours(1), "Some user crash report");

            var systemReports = crashCollector.GetCrashReports(CrashType.Kernel);

            XAssert.IsTrue(systemReports.Count == 8);

            var userReports = crashCollector.GetCrashReports(CrashType.BuildXL);

            XAssert.IsTrue(userReports.Count == 0);

            var sandboxReports = crashCollector.GetCrashReports(CrashType.SandboxExec);

            XAssert.IsTrue(sandboxReports.Count == 4);
        }
Beispiel #5
0
        /// <nodoc />
        public SandboxExecRunner(Options options)
        {
            m_options        = options;
            s_crashCollector = OperatingSystemHelper.IsUnixOS ? new CrashCollectorMacOS(new[] { CrashType.SandboxExec, CrashType.Kernel }) : null;

            m_kextConnection = OperatingSystemHelper.IsUnixOS
                ? new KextConnection(
                new KextConnection.Config
            {
                FailureCallback = (int status, string description) =>
                {
                    m_kextConnection.Dispose();
                    throw new SystemException($"Received unrecoverable error from the sandbox (Code: {status.ToString("X")}, Description: {description}), please reload the extension and retry.");
                },
                KextConfig = new Sandbox.KextConfig
                {
                    ReportQueueSizeMB    = m_options.ReportQueueSizeMB,
                    EnableReportBatching = m_options.EnableReportBatching
                },
            })
                : null;
        }