cmtrace-open 1.5.0

Free, open-source CMTrace replacement: Windows log viewer with ConfigMgr/SCCM, Intune, and Autopilot ESP diagnostics, DSRegCmd triage, and real-time tailing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
use serde::{Deserialize, Serialize};

use super::file_ops::{LogSource, LogSourceKind};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum KnownSourcePathKind {
    File,
    Folder,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum PlatformKind {
    All,
    Windows,
    Macos,
    Linux,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum KnownSourceDefaultFileSelectionBehavior {
    None,
    PreferFileName,
    PreferFileNameThenPattern,
    PreferPattern,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KnownSourceGroupingMetadata {
    pub family_id: String,
    pub family_label: String,
    pub group_id: String,
    pub group_label: String,
    pub group_order: u32,
    pub source_order: u32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KnownSourceDefaultFileIntent {
    pub selection_behavior: KnownSourceDefaultFileSelectionBehavior,
    pub preferred_file_names: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KnownSourceMetadata {
    pub id: String,
    pub label: String,
    pub description: String,
    pub platform: PlatformKind,
    pub source_kind: LogSourceKind,
    pub source: LogSource,
    pub file_patterns: Vec<String>,
    #[serde(default)]
    pub grouping: Option<KnownSourceGroupingMetadata>,
    #[serde(default)]
    pub default_file_intent: Option<KnownSourceDefaultFileIntent>,
}

// ── Tauri Commands ──────────────────────────────────────────────────────

#[tauri::command]
pub fn get_known_log_sources() -> Result<Vec<KnownSourceMetadata>, crate::error::AppError> {
    let sources = build_known_log_sources();

    log::info!("event=get_known_log_sources count={}", sources.len());

    Ok(sources)
}

// ── Public helpers (used by menu.rs) ────────────────────────────────────

pub fn build_known_log_sources() -> Vec<KnownSourceMetadata> {
    #[cfg(target_os = "windows")]
    {
        windows_known_log_sources()
    }

    #[cfg(target_os = "macos")]
    {
        macos_known_log_sources()
    }

    #[cfg(not(any(target_os = "windows", target_os = "macos")))]
    {
        Vec::new()
    }
}

// ── Platform-specific builders ──────────────────────────────────────────

#[cfg(target_os = "windows")]
#[allow(clippy::too_many_arguments)]
fn windows_known_source(
    id: &str,
    label: &str,
    description: &str,
    path_kind: KnownSourcePathKind,
    default_path: &str,
    file_patterns: &[&str],
    grouping: KnownSourceGroupingMetadata,
    default_file_intent: Option<KnownSourceDefaultFileIntent>,
) -> KnownSourceMetadata {
    let id_text = id.to_string();

    KnownSourceMetadata {
        id: id_text.clone(),
        label: label.to_string(),
        description: description.to_string(),
        platform: PlatformKind::Windows,
        source_kind: LogSourceKind::Known,
        source: LogSource::Known {
            source_id: id_text,
            default_path: default_path.to_string(),
            path_kind,
        },
        file_patterns: file_patterns
            .iter()
            .map(|value| (*value).to_string())
            .collect(),
        grouping: Some(grouping),
        default_file_intent,
    }
}

#[cfg(target_os = "windows")]
fn windows_known_log_sources() -> Vec<KnownSourceMetadata> {
    vec![
        windows_known_source(
            "windows-intune-ime-logs",
            "Intune IME Logs Folder",
            "Known log source for Intune Management Extension (IME) app and script diagnostics.",
            KnownSourcePathKind::Folder,
            "C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs",
            &[
                "IntuneManagementExtension.log",
                "AppWorkload.log",
                "AppActionProcessor.log",
                "AgentExecutor.log",
                "HealthScripts.log",
                "*.log",
            ],
            KnownSourceGroupingMetadata {
                family_id: "windows-intune".to_string(),
                family_label: "Windows Intune".to_string(),
                group_id: "intune-ime".to_string(),
                group_label: "Intune IME".to_string(),
                group_order: 10,
                source_order: 10,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior:
                    KnownSourceDefaultFileSelectionBehavior::PreferFileNameThenPattern,
                preferred_file_names: vec![
                    "IntuneManagementExtension.log".to_string(),
                    "AppWorkload.log".to_string(),
                    "AppActionProcessor.log".to_string(),
                    "AgentExecutor.log".to_string(),
                    "HealthScripts.log".to_string(),
                ],
            }),
        ),
        windows_known_source(
            "windows-intune-ime-intunemanagementextension-log",
            "Intune IME: IntuneManagementExtension.log",
            "Primary IME log for check-ins, policy processing, and app orchestration.",
            KnownSourcePathKind::File,
            "C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs\\IntuneManagementExtension.log",
            &["IntuneManagementExtension*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-intune".to_string(),
                family_label: "Windows Intune".to_string(),
                group_id: "intune-ime".to_string(),
                group_label: "Intune IME".to_string(),
                group_order: 10,
                source_order: 20,
            },
            None,
        ),
        windows_known_source(
            "windows-intune-ime-appworkload-log",
            "Intune IME: AppWorkload.log",
            "Win32 and WinGet app download/staging/install diagnostics.",
            KnownSourcePathKind::File,
            "C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs\\AppWorkload.log",
            &["AppWorkload*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-intune".to_string(),
                family_label: "Windows Intune".to_string(),
                group_id: "intune-ime".to_string(),
                group_label: "Intune IME".to_string(),
                group_order: 10,
                source_order: 30,
            },
            None,
        ),
        windows_known_source(
            "windows-intune-ime-agentexecutor-log",
            "Intune IME: AgentExecutor.log",
            "Script execution and remediation output with exit code tracking.",
            KnownSourcePathKind::File,
            "C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs\\AgentExecutor.log",
            &["AgentExecutor*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-intune".to_string(),
                family_label: "Windows Intune".to_string(),
                group_id: "intune-ime".to_string(),
                group_label: "Intune IME".to_string(),
                group_order: 10,
                source_order: 40,
            },
            None,
        ),
        windows_known_source(
            "windows-dmclient-logs",
            "DMClient Local Logs",
            "MDM DMClient log folder used for local sync diagnostics.",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\System32\\config\\systemprofile\\AppData\\Local\\mdm",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-intune".to_string(),
                family_label: "Windows Intune".to_string(),
                group_id: "intune-mdm".to_string(),
                group_label: "MDM and Enrollment".to_string(),
                group_order: 20,
                source_order: 10,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior: KnownSourceDefaultFileSelectionBehavior::PreferPattern,
                preferred_file_names: Vec::new(),
            }),
        ),
        // ── ConfigMgr ──
        windows_known_source(
            "windows-configmgr-ccm-logs",
            "CCM Logs Folder",
            "ConfigMgr client operational logs (policy, inventory, software distribution).",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\CCM\\Logs",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-configmgr".to_string(),
                family_label: "ConfigMgr".to_string(),
                group_id: "configmgr-logs".to_string(),
                group_label: "ConfigMgr Logs".to_string(),
                group_order: 25,
                source_order: 10,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior: KnownSourceDefaultFileSelectionBehavior::PreferPattern,
                preferred_file_names: Vec::new(),
            }),
        ),
        windows_known_source(
            "windows-configmgr-ccmsetup-logs",
            "ccmsetup Logs Folder",
            "ConfigMgr client installation and setup logs.",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\ccmsetup\\Logs",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-configmgr".to_string(),
                family_label: "ConfigMgr".to_string(),
                group_id: "configmgr-logs".to_string(),
                group_label: "ConfigMgr Logs".to_string(),
                group_order: 25,
                source_order: 20,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior: KnownSourceDefaultFileSelectionBehavior::PreferPattern,
                preferred_file_names: Vec::new(),
            }),
        ),
        windows_known_source(
            "windows-configmgr-swmtr",
            "Software Metering Logs",
            "ConfigMgr software metering usage reporting data.",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\System32\\SWMTRReporting",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-configmgr".to_string(),
                family_label: "ConfigMgr".to_string(),
                group_id: "configmgr-logs".to_string(),
                group_label: "ConfigMgr Logs".to_string(),
                group_order: 25,
                source_order: 30,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior: KnownSourceDefaultFileSelectionBehavior::PreferPattern,
                preferred_file_names: Vec::new(),
            }),
        ),
        windows_known_source(
            "windows-panther-setupact-log",
            "setupact.log (Panther)",
            "Primary Windows setup and Autopilot/OOBE action log.",
            KnownSourcePathKind::File,
            "C:\\Windows\\Panther\\setupact.log",
            &["setupact.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-setup".to_string(),
                family_label: "Windows Setup".to_string(),
                group_id: "setup-panther".to_string(),
                group_label: "Panther".to_string(),
                group_order: 40,
                source_order: 10,
            },
            None,
        ),
        windows_known_source(
            "windows-panther-setuperr-log",
            "setuperr.log (Panther)",
            "Error-focused Windows setup and Autopilot/OOBE triage log.",
            KnownSourcePathKind::File,
            "C:\\Windows\\Panther\\setuperr.log",
            &["setuperr.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-setup".to_string(),
                family_label: "Windows Setup".to_string(),
                group_id: "setup-panther".to_string(),
                group_label: "Panther".to_string(),
                group_order: 40,
                source_order: 20,
            },
            None,
        ),
        windows_known_source(
            "windows-cbs-log",
            "CBS.log",
            "Component-Based Servicing log for update and servicing failures.",
            KnownSourcePathKind::File,
            "C:\\Windows\\Logs\\CBS\\CBS.log",
            &["CBS.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-servicing".to_string(),
                family_label: "Windows Servicing".to_string(),
                group_id: "servicing-core".to_string(),
                group_label: "CBS and DISM".to_string(),
                group_order: 50,
                source_order: 10,
            },
            None,
        ),
        windows_known_source(
            "windows-dism-log",
            "DISM.log",
            "Deployment Image Servicing and Management diagnostics log.",
            KnownSourcePathKind::File,
            "C:\\Windows\\Logs\\DISM\\dism.log",
            &["dism.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-servicing".to_string(),
                family_label: "Windows Servicing".to_string(),
                group_id: "servicing-core".to_string(),
                group_label: "CBS and DISM".to_string(),
                group_order: 50,
                source_order: 20,
            },
            None,
        ),
        windows_known_source(
            "windows-reporting-events-log",
            "ReportingEvents.log",
            "Windows Update transaction history in tab-delimited text.",
            KnownSourcePathKind::File,
            "C:\\Windows\\SoftwareDistribution\\ReportingEvents.log",
            &["ReportingEvents.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-servicing".to_string(),
                family_label: "Windows Servicing".to_string(),
                group_id: "servicing-update".to_string(),
                group_label: "Windows Update".to_string(),
                group_order: 50,
                source_order: 30,
            },
            None,
        ),
        windows_known_source(
            "windows-iis-logs",
            "IIS Logs",
            "IIS W3C extended log folder (W3SVC*) under inetpub log files.",
            KnownSourcePathKind::Folder,
            "C:\\inetpub\\logs\\LogFiles",
            &["u_ex*.log", "*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-iis".to_string(),
                family_label: "Windows IIS".to_string(),
                group_id: "iis-w3c".to_string(),
                group_label: "W3C Logs".to_string(),
                group_order: 55,
                source_order: 10,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior: KnownSourceDefaultFileSelectionBehavior::PreferPattern,
                preferred_file_names: Vec::new(),
            }),
        ),
        // ── Software Deployment ──────────────────────────────────────
        windows_known_source(
            "windows-deployment-logs-software",
            "Software Logs Folder",
            "Common deployment log output folder used by PSADT, SCCM, and custom installers.",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\Logs\\Software",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-deployment".to_string(),
                family_label: "Software Deployment".to_string(),
                group_id: "deployment-logs".to_string(),
                group_label: "Deployment Logs".to_string(),
                group_order: 30,
                source_order: 10,
            },
            None,
        ),
        windows_known_source(
            "windows-deployment-ccmcache",
            "ccmcache Folder",
            "ConfigMgr client cache folder where packages and scripts are staged.",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\ccmcache",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-deployment".to_string(),
                family_label: "Software Deployment".to_string(),
                group_id: "deployment-logs".to_string(),
                group_label: "Deployment Logs".to_string(),
                group_order: 30,
                source_order: 20,
            },
            None,
        ),
        windows_known_source(
            "windows-deployment-psadt",
            "PSADT Logs Folder",
            "Default PSAppDeployToolkit log output directory.",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\Logs\\Software",
            &["*_PSAppDeployToolkit*.log", "*Deploy-Application*.log", "*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-deployment".to_string(),
                family_label: "Software Deployment".to_string(),
                group_id: "deployment-psadt".to_string(),
                group_label: "PSADT".to_string(),
                group_order: 30,
                source_order: 30,
            },
            None,
        ),
        windows_known_source(
            "windows-deployment-msi-log",
            "MSI Verbose Log Folder",
            "Default location for MSI verbose install logs (%TEMP%).",
            KnownSourcePathKind::Folder,
            "C:\\Windows\\Temp",
            &["MSI*.LOG", "MSI*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-deployment".to_string(),
                family_label: "Software Deployment".to_string(),
                group_id: "deployment-msi".to_string(),
                group_label: "MSI Logs".to_string(),
                group_order: 30,
                source_order: 40,
            },
            None,
        ),
        // ── PatchMyPC ───────────────────────────────────────────────────
        windows_known_source(
            "windows-deployment-patchmypc-logs",
            "PatchMyPC Logs Folder",
            "PatchMyPC client and notification logs (CMTrace format).",
            KnownSourcePathKind::Folder,
            "C:\\ProgramData\\PatchMyPC\\Logs",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-deployment".to_string(),
                family_label: "Software Deployment".to_string(),
                group_id: "deployment-patchmypc".to_string(),
                group_label: "PatchMyPC".to_string(),
                group_order: 30,
                source_order: 50,
            },
            None,
        ),
        windows_known_source(
            "windows-deployment-patchmypc-install-logs",
            "PatchMyPC Install Logs",
            "MSI verbose and WiX/Burn bootstrapper logs from PatchMyPC-managed installations.",
            KnownSourcePathKind::Folder,
            "C:\\ProgramData\\PatchMyPCInstallLogs",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-deployment".to_string(),
                family_label: "Software Deployment".to_string(),
                group_id: "deployment-patchmypc".to_string(),
                group_label: "PatchMyPC".to_string(),
                group_order: 30,
                source_order: 60,
            },
            None,
        ),
        windows_known_source(
            "windows-deployment-patchmypc-intune-logs",
            "PatchMyPC Intune Logs",
            "PatchMyPC ScriptRunner and software detection/requirement script logs.",
            KnownSourcePathKind::Folder,
            "C:\\ProgramData\\PatchMyPCIntuneLogs",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "windows-deployment".to_string(),
                family_label: "Software Deployment".to_string(),
                group_id: "deployment-patchmypc".to_string(),
                group_label: "PatchMyPC".to_string(),
                group_order: 30,
                source_order: 70,
            },
            None,
        ),
    ]
}

#[cfg(target_os = "macos")]
#[allow(clippy::too_many_arguments)]
fn macos_known_source(
    id: &str,
    label: &str,
    description: &str,
    path_kind: KnownSourcePathKind,
    default_path: &str,
    file_patterns: &[&str],
    grouping: KnownSourceGroupingMetadata,
    default_file_intent: Option<KnownSourceDefaultFileIntent>,
) -> KnownSourceMetadata {
    let id_text = id.to_string();

    KnownSourceMetadata {
        id: id_text.clone(),
        label: label.to_string(),
        description: description.to_string(),
        platform: PlatformKind::Macos,
        source_kind: LogSourceKind::Known,
        source: LogSource::Known {
            source_id: id_text,
            default_path: default_path.to_string(),
            path_kind,
        },
        file_patterns: file_patterns
            .iter()
            .map(|value| (*value).to_string())
            .collect(),
        grouping: Some(grouping),
        default_file_intent,
    }
}

#[cfg(target_os = "macos")]
fn macos_known_log_sources() -> Vec<KnownSourceMetadata> {
    let home = std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string());

    vec![
        // --- macOS Intune: System-level MDM daemon logs ---
        macos_known_source(
            "macos-intune-system-logs",
            "Intune System Logs",
            "System-level MDM daemon logs for PKG/DMG installs and root script execution.",
            KnownSourcePathKind::Folder,
            "/Library/Logs/Microsoft/Intune",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-intune".to_string(),
                family_label: "macOS Intune".to_string(),
                group_id: "intune-logs".to_string(),
                group_label: "Intune Logs".to_string(),
                group_order: 10,
                source_order: 10,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior:
                    KnownSourceDefaultFileSelectionBehavior::PreferFileNameThenPattern,
                preferred_file_names: vec!["IntuneMDMDaemon.log".to_string()],
            }),
        ),
        // --- macOS Intune: User-level MDM agent logs ---
        macos_known_source(
            "macos-intune-user-logs",
            "Intune User Agent Logs",
            "User-level MDM agent logs for user-context scripts and policies.",
            KnownSourcePathKind::Folder,
            &format!("{}/Library/Logs/Microsoft/Intune", home),
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-intune".to_string(),
                family_label: "macOS Intune".to_string(),
                group_id: "intune-logs".to_string(),
                group_label: "Intune Logs".to_string(),
                group_order: 10,
                source_order: 20,
            },
            None,
        ),
        // --- macOS Intune: Script execution logs ---
        macos_known_source(
            "macos-intune-scripts-logs",
            "Intune Script Logs",
            "Shell script execution logs from Intune script deployments.",
            KnownSourcePathKind::Folder,
            "/Library/Logs/Microsoft/IntuneScripts",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-intune".to_string(),
                family_label: "macOS Intune".to_string(),
                group_id: "intune-logs".to_string(),
                group_label: "Intune Logs".to_string(),
                group_order: 10,
                source_order: 30,
            },
            None,
        ),
        // --- Company Portal ---
        macos_known_source(
            "macos-company-portal-logs",
            "Company Portal Logs",
            "Company Portal app logs for enrollment, device info, and user registration.",
            KnownSourcePathKind::Folder,
            &format!("{}/Library/Logs/CompanyPortal", home),
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-intune".to_string(),
                family_label: "macOS Intune".to_string(),
                group_id: "intune-portal".to_string(),
                group_label: "Company Portal".to_string(),
                group_order: 20,
                source_order: 10,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior:
                    KnownSourceDefaultFileSelectionBehavior::PreferFileNameThenPattern,
                preferred_file_names: vec!["CompanyPortal.log".to_string()],
            }),
        ),
        // --- macOS install.log ---
        macos_known_source(
            "macos-install-log",
            "install.log",
            "macOS installer log — PKG installs from Intune and Software Update show up here.",
            KnownSourcePathKind::File,
            "/var/log/install.log",
            &["install.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-system".to_string(),
                family_label: "macOS System".to_string(),
                group_id: "system-logs".to_string(),
                group_label: "System Logs".to_string(),
                group_order: 30,
                source_order: 10,
            },
            None,
        ),
        // --- macOS system.log ---
        macos_known_source(
            "macos-system-log",
            "system.log",
            "macOS system log — MDM profile installs, daemon crashes, and system events.",
            KnownSourcePathKind::File,
            "/var/log/system.log",
            &["system.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-system".to_string(),
                family_label: "macOS System".to_string(),
                group_id: "system-logs".to_string(),
                group_label: "System Logs".to_string(),
                group_order: 30,
                source_order: 20,
            },
            None,
        ),
        // --- macOS wifi.log ---
        macos_known_source(
            "macos-wifi-log",
            "Wi-Fi Log",
            "macOS Wi-Fi diagnostic log",
            KnownSourcePathKind::File,
            "/var/log/wifi.log",
            &["wifi.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-system".to_string(),
                family_label: "macOS System".to_string(),
                group_id: "system-logs".to_string(),
                group_label: "System Logs".to_string(),
                group_order: 30,
                source_order: 30,
            },
            None,
        ),
        // --- macOS appfirewall.log ---
        macos_known_source(
            "macos-appfirewall-log",
            "Application Firewall Log",
            "macOS application firewall log",
            KnownSourcePathKind::File,
            "/var/log/appfirewall.log",
            &["appfirewall.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-system".to_string(),
                family_label: "macOS System".to_string(),
                group_id: "system-logs".to_string(),
                group_label: "System Logs".to_string(),
                group_order: 30,
                source_order: 40,
            },
            None,
        ),
        // --- Microsoft Defender logs ---
        macos_known_source(
            "macos-defender-logs",
            "Defender Logs",
            "Microsoft Defender for Endpoint install and error logs.",
            KnownSourcePathKind::Folder,
            "/Library/Logs/Microsoft/mdatp",
            &["*.log"],
            KnownSourceGroupingMetadata {
                family_id: "macos-defender".to_string(),
                family_label: "macOS Defender".to_string(),
                group_id: "defender-logs".to_string(),
                group_label: "Defender Logs".to_string(),
                group_order: 40,
                source_order: 10,
            },
            Some(KnownSourceDefaultFileIntent {
                selection_behavior:
                    KnownSourceDefaultFileSelectionBehavior::PreferFileNameThenPattern,
                preferred_file_names: vec![
                    "microsoft_defender_core_err.log".to_string(),
                    "install.log".to_string(),
                ],
            }),
        ),
    ]
}