Skip to content

Commit

Permalink
Merge pull request #1853 from microsoft/bilong-curlyquotescheck
Browse files Browse the repository at this point in the history
Add CodeFormatter check for curly quotes
  • Loading branch information
bill-long authored Oct 27, 2023
2 parents 04f30a4 + 8640c32 commit cc0918b
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .build/CodeFormatter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ param(
Set-StrictMode -Version Latest

. $PSScriptRoot\Load-Module.ps1
. $PSScriptRoot\CodeFormatterChecks\CheckContainsCurlyQuotes.ps1
. $PSScriptRoot\CodeFormatterChecks\CheckFileHasNewlineAtEndOfFile.ps1
. $PSScriptRoot\CodeFormatterChecks\CheckMarkdownFileHasNoBOM.ps1
. $PSScriptRoot\CodeFormatterChecks\CheckMultipleEmptyLines.ps1
Expand Down Expand Up @@ -69,6 +70,7 @@ foreach ($fileInfo in $filesToCheck) {
$errorCount += (CheckScriptFileHasComplianceHeader $fileInfo $Save) ? 1 : 0
$errorCount += (CheckKeywordCasing $fileInfo $Save) ? 1 : 0
$errorCount += (CheckMultipleEmptyLines $fileInfo $Save) ? 1 : 0
$errorCount += (CheckContainsCurlyQuotes $fileInfo $Save) ? 1 : 0

# This one is tricky. It returns $true or $false like the others, but in the case
# of an error, we also want to get the diff output. Piping to Out-Host from within
Expand Down
51 changes: 51 additions & 0 deletions .build/CodeFormatterChecks/CheckContainsCurlyQuotes.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

function CheckContainsCurlyQuotes {
[CmdletBinding()]
[OutputType([boolean])]
param (
[Parameter()]
[System.IO.FileInfo]
$FileInfo,

[Parameter()]
[boolean]
$Save
)

# Skip this file
if ($FileInfo.FullName -eq "$PSScriptRoot\CheckContainsCurlyQuotes.ps1") {
return $false
}

$curlyQuotes = $FileInfo | Select-String "‘|’|`“|`”"
if ($curlyQuotes) {
$content = Get-Content -Path $FileInfo.FullName -Raw
if ($Save) {
try {
$content = $content -replace "", "'"
$content = $content -replace "", "'"
$content = $content -replace "`“", '"'
$content = $content -replace "`”", '"'
if ($FileInfo.Extension -eq ".ps1") {
Set-Content -Path $FileInfo.FullName -Value $content.TrimEnd() -Encoding utf8BOM
} else {
Set-Content -Path $FileInfo.FullName -Value $content.TrimEnd() -Encoding utf8NoBOM
}

Write-Host "Saved with curly quotes replaced: $($FileInfo.FullName)"
$false
} catch {
Write-Warning "Failed to save with curly quotes replaced: $($FileInfo.FullName). Error: $_"
$true
}
} else {
Write-Warning "File contains curly quotes: $($FileInfo.FullName)"
$curlyQuotes | Out-Host
$true
}
} else {
$false
}
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@
"internal-terms": false // Disable the `internal-terms` dictionary
},
"cSpell.caseSensitive": true,
"editor.detectIndentation": false
"editor.detectIndentation": false,
"editor.unicodeHighlight.includeComments": true,
"editor.unicodeHighlight.nonBasicASCII": true
}
2 changes: 1 addition & 1 deletion Calendar/Get-RBASummary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function RBAProcessingValidation {
-and $RbaSettings.AllBookInPolicy -eq $false `
-and $RbaSettings.RequestInPolicy.Count -eq 0 `
-and $RbaSettings.AllRequestInPolicy -eq $false ) {
Write-Host -ForegroundColor Red "`r`n Error: The RBA isnt configured to process items. No RBA processing of Meeting Requests will occur."
Write-Host -ForegroundColor Red "`r`n Error: The RBA isn't configured to process items. No RBA processing of Meeting Requests will occur."
Write-Host -ForegroundColor Red "Consider configuring the properties below to process all requests. (Default is null, True, null, False, null, True)."
Write-Host
Write-Host "`t RequestOutOfPolicy: {$($RbaSettings.RequestOutOfPolicy)}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function CheckIfThisCanBeAKnownIssueUsingMonitor {
}
if ($ServiceHealthMSExchangeReplEndpointPossibleDNSissue) {
Write-Host -foreground yellow "ServiceHealthMSExchangeReplEndpointMonitor is failing due to missing DNS entry."
Write-Host -foreground yellow "Make sure that the 'Register this connections addresses in DNS' property is selected on the network adapter"
Write-Host -foreground yellow "Make sure that the 'Register this connection's addresses in DNS' property is selected on the network adapter"
Write-Host -foreground yellow "https://support.microsoft.com/en-us/kb/2969070"
$Script:foundIssue = $true; return;
}
Expand Down
2 changes: 1 addition & 1 deletion Retention/Get-MRMDetails.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function funcRetentionProperties {
$Tags = $Tags | Add-Member @{OctetRetentionIDAsSeenInMFCMAPI = "" } -PassThru
foreach ($t in $Tags) {
#Convert each GUID to the Octet version that is seen in MFCMAPI's Properties
$t.OctetRetentionIDAsSeenInMFCMAPI = [System.String]::Join("", ($t.RetentionId.ToByteArray() | ForEach-Object { $_.ToString(x2) })).ToUpper()
$t.OctetRetentionIDAsSeenInMFCMAPI = [System.String]::Join("", ($t.RetentionId.ToByteArray() | ForEach-Object { $_.ToString('x2') })).ToUpper()
}
$Tags | Select-Object * | Export-Clixml "$Mailbox - MRM Retention Policies for entire Tenant.xml"

Expand Down
4 changes: 2 additions & 2 deletions Security/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ This will run the default mode which does the following:
3. Applies the URL rewrite mitigation **(only if vulnerable)**.
4. Runs the Microsoft Safety Scanner in "Quick Scan" mode **(vulnerable or not)**.

**Question**: What if I run a full scan and its affecting the resources of my servers?
**Question**: What if I run a full scan and it's affecting the resources of my servers?

**Answer**: You can terminate the process of the scan by running the following command in an Administrative PowerShell session.

Expand All @@ -98,7 +98,7 @@ This will run the default mode which does the following:
* Malware scan of the Exchange Server via the Microsoft Safety Scanner
* Attempt to reverse any changes made by identified threats.
#### ExchangeMitigations.ps1:
* Does mitigations for all 4 CVEs - CVE-2021-26855, CVE-2021-26857, CVE-2021-27065 & CVE-2021-26858.
* Does mitigations for all 4 CVE's - CVE-2021-26855, CVE-2021-26857, CVE-2021-27065 & CVE-2021-26858.
* Some of the mitigation methods impact Exchange functionality.
* Does not do any scanning for existing compromise or exploitation.
* Does not take response actions to existing active identified threats.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Test-FailedSearchFoundation {
"- Uninstall the Search Foundation",
" 1. Remove all SubFolders under C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data\Nodes\Fsis",
" 2. Open Powershell as Administrator and navigate to the folder C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Installer",
" 3. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`"
" 3. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`""
" 4. Run Setup again."
)
return
Expand All @@ -46,8 +46,8 @@ function Test-FailedSearchFoundation {
" 1. Stop the Microsoft Exchange Search and Microsoft Exchange Search Host Controller services.",
" 2. Remove all SubFolders under C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data\Nodes\Fsis",
" 3. Open Powershell as Administrator and navigate to the folder C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Installer",
" 4. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`"
" 5. Now install the Search Foundation with this command: .\InstallConfig.ps1 -action I -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`"
" 4. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`""
" 5. Now install the Search Foundation with this command: .\InstallConfig.ps1 -action I -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`""
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Setup/Tests/SetupLogReviewer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ Describe "Testing SetupLogReviewer" {
Assert-MockCalled -Exactly 1 -CommandName Write-Host `
-ParameterFilter { $Object -like "* 3. Open Powershell as Administrator and navigate to the folder C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Installer" }
Assert-MockCalled -Exactly 1 -CommandName Write-Host `
-ParameterFilter { $Object -like "* 4. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`" }
-ParameterFilter { $Object -like "* 4. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`"" }
Assert-MockCalled -Exactly 1 -CommandName Write-Host `
-ParameterFilter { $Object -like "* 5. Now install the Search Foundation with this command: .\InstallConfig.ps1 -action I -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`" }
-ParameterFilter { $Object -like "* 5. Now install the Search Foundation with this command: .\InstallConfig.ps1 -action I -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`"" }
}

It "Search Foundation Failure - Install" {
Expand All @@ -503,7 +503,7 @@ Describe "Testing SetupLogReviewer" {
Assert-MockCalled -Exactly 1 -CommandName Write-Host `
-ParameterFilter { $Object -like "* 2. Open Powershell as Administrator and navigate to the folder C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Installer" }
Assert-MockCalled -Exactly 1 -CommandName Write-Host `
-ParameterFilter { $Object -like "* 3. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`" }
-ParameterFilter { $Object -like "* 3. Now uninstall the Search Foundation with this command: .\InstallConfig.ps1 -action U -DataFolder `"C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\HostController\Data`"" }
}

It "Missing HomeMdb" {
Expand Down
2 changes: 1 addition & 1 deletion docs/Admin/MonitorExchangeAuthCertificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ It's not recommended to replace the internal transport certificate with the newl

The following syntax executes the script in renewal mode without user interaction. The required Auth Certificate renewal action will be performed. In unattended mode the internal SMTP certificate is replaced with the new Auth Certificate and then set back to the previous one. The script also restarts the `MSExchangeServiceHost` service and the `MSExchangeOWAAppPool` and `MSExchangeECPAppPool` WebApp Pools when the primary Auth Certificate has been replaced.

**NOTE:** The script creates a new internal transport certificate if the previously configured one wasnt found on the machine where the script is run.
**NOTE:** The script creates a new internal transport certificate if the previously configured one wasn't found on the machine where the script is run.

```powershell
PS C:\> .\MonitorExchangeAuthCertificate.ps1 -ValidateAndRenewAuthCertificate $true -Confirm:$false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

By default, Outlook Anywhere opens two default connections to the Exchange CAS called `RPC_InData` and `RPC_OutData`. The Outlook Anywhere client to server used a default timeout of `12 minutes (720 seconds)` of inactivity and the server to the client timeout is `15 minutes (900 seconds)`.

These default Keep-Alive intervals are not aggressive enough for some of todays home networking devices and/or aggressive network devices on the Internet. Some of those devices are dropping TCP connections after as little as `5 minutes (300 seconds)` of inactivity. When one or both of the two default connections are dropped, the connection to the Exchange server is essentially broken and not useable.
These default Keep-Alive intervals are not aggressive enough for some of today's home networking devices and/or aggressive network devices on the Internet. Some of those devices are dropping TCP connections after as little as `5 minutes (300 seconds)` of inactivity. When one or both of the two default connections are dropped, the connection to the Exchange server is essentially broken and not useable.

**Included in HTML Report?**

Expand All @@ -13,4 +13,3 @@ Yes
**Additional resources:**

[Outlook Anywhere Network Timeout Issue](https://docs.microsoft.com/archive/blogs/messaging_with_communications/outlook-anywhere-network-timeout-issue)

5 changes: 2 additions & 3 deletions docs/Diagnostics/HealthChecker/SMBv1Check.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SMBv1 Check

To make sure that your Exchange organization is better protected against the latest threats (for example Emotet, TrickBot or WannaCry to name a few) we recommend disabling SMBv1 if its enabled on your Exchange (2013/2016/2019) server.
To make sure that your Exchange organization is better protected against the latest threats (for example Emotet, TrickBot or WannaCry to name a few) we recommend disabling SMBv1 if it's enabled on your Exchange (2013/2016/2019) server.

There is no need to run the nearly 30-year-old SMBv1 protocol when Exchange 2013/2016/2019 is installed on your system. SMBv1 isnt safe and you lose key protections offered by later SMB protocol versions.
There is no need to run the nearly 30-year-old SMBv1 protocol when Exchange 2013/2016/2019 is installed on your system. SMBv1 isn't safe and you lose key protections offered by later SMB protocol versions.

This check verifies that SMBv1 is not installed (if OS allows) and that its activation is blocked.

Expand All @@ -13,4 +13,3 @@ Yes
**Additional resources:**

[Exchange Server and SMBv1](https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-server-and-smbv1/ba-p/1165615)

Loading

0 comments on commit cc0918b

Please sign in to comment.