Skip to content

Stop MgApp_CertificatePath from running code in the configuration file - #15

Merged
Sekers merged 3 commits into
developfrom
fix/certificate-path-code
Sep 22, 2026
Merged

Sekers merged 3 commits into
developfrom
fix/certificate-path-code

Conversation

@Sekers

@Sekers Sekers commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Connect-ScriptMessage_MicrosoftGraph passed MgApp_CertificatePath through ExpandString, so a $(...) subexpression in the configuration file ran as the sending account on PowerShell 7.4 and later. It now expands only $env:NAME and ${env:NAME} and uses the rest of the path as written, which also stops a literal $name folder or a backtick in the path from being mangled.

Nothing published documented the expansion, and $PSScriptRoot in the setting always meant the module's Services folder, so environment variables are the only use kept. Measurements are in Research_Notes/PowerShell-Language-Behavior.md section 4.

Changelog: the Security entry.

This branch is built on #14, so merge that first; this PR then shows only its own commit.

- Four places said quoted text in a boolean setting reads as off, but the
  text "true" in any letter case compares equal to $true, so it reads as on:
  the rule in AGENTS.md, the From source paragraph in
  Research_Notes/PowerShell-Language-Behavior.md section 10, the
  IncludeBCCInGroupChat comment in Send-ScriptMessage, and the comment above
  the quoted-"false" tests. The code already behaved this way; only the
  wording changes.
- Changelog: the Minor entry about validating configuration file settings
  overstated it. Nothing is validated, and only IncludeBCCInGroupChat and
  MgDisconnectWhenDone read differently from 1.1.1; the
  MgDelegatedPermission_* settings already used -eq $true. Reword it as
  reading every true/false setting the same way.
- Fix the installed-module scratch script, which imported Script-Message
  instead of ScriptMessage.
- Delete Tests/MgGraphDynamicParams.ps1, an unused DynamicParam snippet that
  nothing in the module or tests references.
Get-ScriptMessageConfig reported every failure as "Can't find the JSON
configuration file" and told the caller to create one with
Set-ScriptMessageConfigFilePath, which only stores the path. A missing
file, a file that cannot be read, and a file that is not valid JSON now
get separate messages that include the reason.

Windows PowerShell 5.1's ConvertFrom-Json ends many of its messages with
the entire input, which here is the configuration file and its secrets,
so the parse error keeps only the reason in front of it. Measured in
Research_Notes/PowerShell-Language-Behavior.md section 11.
Connect-ScriptMessage_MicrosoftGraph passed the setting through
ExpandString, so a $(...) subexpression in the configuration file ran as
the sending account on PowerShell 7.4 and later. It now expands only
$env:NAME and ${env:NAME} and uses the rest of the path as written,
which also stops a literal '$name' folder or a backtick in the path from
being mangled.

Nothing published documented the expansion, and $PSScriptRoot in the
setting always meant the module's Services folder, so environment
variables are the only use kept. Measurements are in
Research_Notes/PowerShell-Language-Behavior.md section 4.
@Sekers
Sekers merged commit 9baaa68 into develop Sep 22, 2026
4 checks passed
@Sekers
Sekers deleted the fix/certificate-path-code branch September 22, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant