diff --git a/munki_script_checks.tf b/munki_script_checks.tf new file mode 100644 index 0000000..6342392 --- /dev/null +++ b/munki_script_checks.tf @@ -0,0 +1,1958 @@ +resource "zentral_munki_script_check" "mcs-auditing-audit_acls_files_configure" { + name = "[mSCP] - Auditing - Configure Audit Log Files to Not Contain Access Control Lists" + description = trimspace(< disabled' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_install_log_retention_configure" { + name = "[mSCP] - macOS - Configure Install.log Retention to 365" + description = trimspace(<&1 | /usr/bin/awk '/\/var\/log\/install.log$/ {count++} /Processing module com.apple.install/,/Finished/ { for (i=1;i<=NR;i++) { if ($i == "TTL" && $(i+2) >= 365) { ttl="True" }; if ($i == "MAX") {max="True"}}} END{if (count > 1) { print "Multiple config files for /var/log/install, manually remove the extra files"} else if (max == "True") { print "all_max setting is configured, must be removed" } if (ttl != "True") { print "TTL not configured" } else { print "Yes" }}' +EOSRC + ) + expected_result = "Yes" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_mdm_require" { + name = "[mSCP] - macOS - Enforce Enrollment in Mobile Device Management" + description = trimspace(< disabled' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_on_device_dictation_enforce" { + name = "[mSCP] - macOS - Enforce On Device Dictation" + description = trimspace(<&1 | /usr/bin/grep -c "/usr/bin/false" +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_safari_advertising_privacy_protection_enable" { + name = "[mSCP] - macOS - Ensure Advertising Privacy Protection in Safari Is Enabled" + description = trimspace(<= 1) {print "1"} else {print "0"}}' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_safari_open_safe_downloads_disable" { + name = "[mSCP] - macOS - Disable Automatic Opening of Safe Files in Safari" + description = trimspace(<= 1) {print "1"} else {print "0"}}' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_safari_popups_disabled" { + name = "[mSCP] - macOS - Ensure Pop-Up Windows are Blocked in Safari" + description = trimspace(<= 1) {print "1"} else {print "0"}}' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_safari_prevent_cross-site_tracking_enable" { + name = "[mSCP] - macOS - Ensure Prevent Cross-site Tracking in Safari Is Enabled" + description = trimspace(<= 1) {print "1"} else {print "0"}}' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_safari_show_full_website_address_enable" { + name = "[mSCP] - macOS - Ensure Show Full Website Address in Safari Is Enabled" + description = trimspace(<= 1) {print "1"} else {print "0"}}' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_safari_show_status_bar_enabled" { + name = "[mSCP] - macOS - Ensure Show Safari shows the Status Bar is Enabled" + description = trimspace(<= 1) {print "1"} else {print "0"}}' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_safari_warn_fraudulent_website_enable" { + name = "[mSCP] - macOS - Ensure Warn When Visiting A Fraudulent Website in Safari Is Enabled" + description = trimspace(<= 1) {print "1"} else {print "0"}}' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_show_filename_extensions_enable" { + name = "[mSCP] - macOS - Enable Show All Filename Extensions" + description = trimspace(</dev/null +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_sip_enable" { + name = "[mSCP] - macOS - Ensure System Integrity Protection is Enabled" + description = trimspace(<= 270) {print "No"} else {print "Yes"}}' +EOSRC + ) + expected_result = "Yes" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_unlock_active_user_session_disable" { + name = "[mSCP] - macOS - Disable Login to Other User's Active and Locked Sessions" + description = trimspace(<&1 | /usr/bin/grep -c 'authenticate-session-owner' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-macos-os_world_writable_system_folder_configure" { + name = "[mSCP] - macOS - Ensure No World Writable Files Exist in the System Folder" + description = trimspace(< /dev/null | /usr/bin/tail +2 | /usr/bin/xmllint --xpath '//dict/key[text()="policyAttributeMaximumFailedAuthentications"]/following-sibling::integer[1]/text()' - | /usr/bin/awk '{ if ($1 <= 3) {print "yes"} else {print "no"}}' +EOSRC + ) + expected_result = "yes" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-passwordpolicy-pwpolicy_account_lockout_timeout_enforce" { + name = "[mSCP] - Password Policy - Set Account Lockout Time to 15 Minutes" + description = trimspace(< /dev/null | /usr/bin/tail +2 | /usr/bin/xmllint --xpath '//dict/key[text()="autoEnableInSeconds"]/following-sibling::integer[1]/text()' - | /usr/bin/awk '{ if ($1/60 >= 15 ) {print "yes"} else {print "no"}}' +EOSRC + ) + expected_result = "yes" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-passwordpolicy-pwpolicy_history_enforce" { + name = "[mSCP] - Password Policy - Prohibit Password Reuse for a Minimum of 5 Generations" + description = trimspace(< /dev/null | /usr/bin/tail +2 | /usr/bin/xmllint --xpath '//dict/key[text()="policyAttributePasswordHistoryDepth"]/following-sibling::*[1]/text()' - | /usr/bin/awk '{ if ($1 >= 5 ) {print "yes"} else {print "no"}}' +EOSRC + ) + expected_result = "yes" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-passwordpolicy-pwpolicy_max_lifetime_enforce" { + name = "[mSCP] - Password Policy - Restrict Maximum Password Lifetime to 60 Days" + description = trimspace(< /dev/null | /usr/bin/tail +2 | /usr/bin/xmllint --xpath '//dict/key[text()="policyAttributeExpiresEveryNDays"]/following-sibling::*[1]/text()' - +EOSRC + ) + expected_result = "60" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-passwordpolicy-pwpolicy_minimum_length_enforce" { + name = "[mSCP] - Password Policy - Require a Minimum Password Length of 15 Characters" + description = trimspace(< /dev/null | /usr/bin/tail +2 | /usr/bin/xmllint --xpath 'boolean(//*[contains(text(),"policyAttributePassword matches '\''.{15,}'\''")])' - +EOSRC + ) + expected_result = "true" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-systemsettings-system_settings_airplay_receiver_disable" { + name = "[mSCP] - System Settings - Disable Airplay Receiver" + description = trimspace(</dev/null) + +if [[ "$profile" == "true" ]] && [[ $plist == 1 ]]; then + echo "true" +else + echo "false" +fi +EOSRC + ) + expected_result = "true" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-systemsettings-system_settings_guest_access_smb_disable" { + name = "[mSCP] - System Settings - Disable Guest Access to Shared SMB Folders" + description = trimspace(< disabled' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-systemsettings-system_settings_remote_management_disable" { + name = "[mSCP] - System Settings - Disable Remote Management" + description = trimspace(< disabled' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-systemsettings-system_settings_screensaver_ask_for_password_delay_enforce" { + name = "[mSCP] - System Settings - Enforce Session Lock After Screen Saver is Started" + description = trimspace(< disabled' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-systemsettings-system_settings_software_update_app_update_enforce" { + name = "[mSCP] - System Settings - Enforce Software Update App Update Updates Automatically" + description = trimspace(< disabled' +EOSRC + ) + expected_result = "1" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-systemsettings-system_settings_system_wide_preferences_configure" { + name = "[mSCP] - System Settings - Require Administrator Password to Modify System-Wide Preferences" + description = trimspace(</dev/null| /usr/bin/awk -F': ' '/Name/{print $2}'); do + tmMounted=$(/usr/sbin/diskutil info "$${tm}" 2>/dev/null | /usr/bin/awk '/Mounted/{print $2}') + tmEncrypted=$(/usr/sbin/diskutil info "$${tm}" 2>/dev/null | /usr/bin/awk '/FileVault/{print $2}') + if [[ "$tmMounted" = "Yes" && "$tmEncrypted" = "No" ]]; then + ((error_count++)) + fi +done +echo "$error_count" +EOSRC + ) + expected_result = "0" + arch_amd64 = true + arch_arm64 = true + min_os_version = "14" + max_os_version = "15" +} + +resource "zentral_munki_script_check" "mcs-systemsettings-system_settings_time_server_configure" { + name = "[mSCP] - System Settings - Configure macOS to Use an Authorized Time Server" + description = trimspace(<