How compliantsec/m365sat works
Project Type and Purpose
• M365SAT is an open-source, modular PowerShell-based security assessment tool for Microsoft 365 and Azure.
• It exposes a CLI entrypoint (M365SATTester.ps1 and Get-M365SATReport) that orchestrates authentication, module loading, inspections, and report generation across M365 workloads.
File Structure
• Top-level scripts & manifests:
• M365SAT.psd1 / .psm1 (PowerShell module definitions)
• M365SATTester.ps1 (CLI orchestration)
• Core engine (/core):
• Core cmdlets (Connect, Invoke checks, logging, update modules, CSV/HTML report builders)
• Authentication Connectors (/core/m365connectors)
• Inspector modules (/inspectors):
• Organized by environment (AZURE, M365, CUSTOM) → product family → license level → L1/L2 checks
• Each .ps1 implements a standard Audit-Build pattern returning PSCustomObject
• Support directories:
• modules/welcome (welcome banner)
• log (runtime logs)
• docs & metadata (README, LICENSE, SECURITY, TODO)
Extract Key Architecture Insights from README
• Modular/plugin architecture: new inspectors are simply new scripts under /inspectors
• Core engine orchestrates scanning, error handling (PoShLog), and report formatting (HTML/CSV)
• Connects to external services via PowerShell modules (Az, ExchangeOnlineManagement, Microsoft.Graph, PnP.PowerShell)
Components & Interactions
a. Main Components
• CLI Launcher: M365SATTester.ps1 or Get-M365SATReport
• Core Orchestrator Module: loads configurations, update checks, duplicate checks
• Authentication Connectors: Azure, Exchange, Graph, Teams, SharePoint
• Inspector Plugin Layer: folder of PowerShell inspector scripts
• Reporting Engine: CSV/HTML builders
• Logging Service: PoShLog integration writing to /log
• Output: Report files on disk
• External Systems: Microsoft 365 Tenant, Azure APIs
b. Relationships & Data Flow
1. User invokes CLI → CLI Launcher
2. CLI Launcher calls Core Orchestrator
3. Core Orchestrator establishes connections via Authentication Connectors
4. Core Orchestrator loads Inspector Plugins dynamically
5. For each plugin: execute audit → return PSCustomObject
6. Core collects all results → Reporting Engine
7. Reporting Engine writes CSV/HTML; Logging Service writes logs
c. Architectural Patterns & Principles
• Plugin/Extension pattern: inspectors are discovered at runtime
• Single Responsibility: core handles orchestration, connectors handle auth, inspectors handle checks, reporting handles output
• Dependency on external PS modules abstracted via connectors
d. Key Technologies & Frameworks
• PowerShell 5.1 / 7
• PoShLog
• Az PowerShell modules
• ExchangeOnlineManagement, PnP.PowerShell, Microsoft.Graph, MicrosoftTeams