Skip to content

Enhance customALGoFiles feature - #2273

Open
Ole Wunschmann (OleWunschmann) wants to merge 43 commits into
microsoft:mainfrom
OleWunschmann:enhance-customALGoFiles-feature
Open

Ole Wunschmann (OleWunschmann) wants to merge 43 commits into
microsoft:mainfrom
OleWunschmann:enhance-customALGoFiles-feature

Conversation

@OleWunschmann

@OleWunschmann Ole Wunschmann (OleWunschmann) commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

❔What, Why & How

This pull request introduces significant improvements to the handling of custom template file inclusion and exclusion in AL-Go actions, focusing on robust path resolution, improved deduplication, and enhanced cross-platform compatibility. The changes also clarify and expand the documentation for settings, and add a new utility function for reading settings with custom templates.

Improvements to custom template file handling:

  • The current customALGoFiles settings from the custom template are now merged and used directly during updates, ensuring that the latest template configuration is always applied without waiting for a new update cycle.
  • Both filesToInclude and filesToExclude are now resolved against both the custom template and the original AL-Go template, ensuring that files added or removed upstream are properly propagated to consumer repositories.
  • A new destinationName property is added to filesToInclude, allowing files to be renamed when copied to the destination. This is reflected in both the schema and implementation.

**Path Handling and Cross-Platform Support

  • Introduced GetPathStringComparison and GetPathStringComparer utility functions to ensure path comparisons and deduplication are case-insensitive on Windows/macOS and case-sensitive on Linux, improving cross-platform reliability.
  • Updated ResolveFilePaths to canonicalize all paths, enforce that destination folders/files are within allowed directories, and use the new path comparison utilities for accurate and secure file operations.

Documentation and schema updates:

  • The schema and documentation for filesToInclude and filesToExclude have been updated to clarify their new behavior and the new destinationName property.

These changes make custom template management more robust, predictable, and safer for consumer repositories.

Related to discussion: #2227

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

Copilot AI review requested due to automatic review settings June 3, 2026 15:24
@OleWunschmann
Ole Wunschmann (OleWunschmann) requested a review from a team as a code owner June 3, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR enhances the customALGoFiles behavior during “Update AL-Go System Files”, adding support for unconditional removals (filesToRemove) and improving custom-template behavior by merging template settings directly and resolving files from the original AL-Go template where applicable.

Changes:

  • Add customALGoFiles.filesToRemove support end-to-end (schema, defaults, resolution logic, docs, and release notes).
  • Update CheckForUpdates to read template repo settings via ReadSettings and merge template settings during file resolution.
  • Expand automated coverage (unit + e2e) for include/exclude/remove resolution and custom-template propagation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
e2eTests/scenarios/CustomTemplate/runtest.ps1 Extends e2e scenario to validate custom-template file include/exclude/remove propagation and workflow presence.
Tests/CheckForUpdates.Action.Test.ps1 Adds unit tests for destination-folder resolution and expanded GetFilesToUpdate behaviors (including filesToRemove).
Actions/CheckForUpdates/CheckForUpdates.ps1 Updates settings reading (incl. trigger) and wires template settings + filesToRemove into update/removal flow.
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Implements ResolveFilePathsInDestinationFolder and extends GetFilesToUpdate to produce include/exclude/remove lists.
Actions/.Modules/settings.schema.json Extends settings schema with customALGoFiles.filesToRemove and clarifying descriptions.
Actions/.Modules/ReadSettings.psm1 Adds default filesToRemove array under customALGoFiles.
Scenarios/settings.md Documents customALGoFiles.filesToRemove in settings reference.
Scenarios/CustomizingALGoForGitHub.md Adds conceptual docs + examples for original-template resolution and filesToRemove.
RELEASENOTES.md Documents enhanced customALGoFiles behavior and new filesToRemove.

Comment thread Tests/CheckForUpdates.Action.Test.ps1 Outdated
Comment thread Tests/CheckForUpdates.Action.Test.ps1 Outdated
Comment thread e2eTests/scenarios/CustomTemplate/runtest.ps1
Comment thread e2eTests/scenarios/CustomTemplate/runtest.ps1
Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Outdated
Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Comment thread e2eTests/scenarios/CustomTemplate/runtest.ps1 Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Outdated
Comment thread Scenarios/CustomizingALGoForGitHub.md Outdated
Comment thread Actions/.Modules/settings.schema.json Outdated
@OleWunschmann

Copy link
Copy Markdown
Contributor Author

Maria Zhelezova (@mazhelez) The failing PS5 tests should be fixed now.

Comment thread RELEASENOTES.md
Comment thread RELEASENOTES.md
Comment thread Actions/.Modules/settings.schema.json Outdated
Copilot AI review requested due to automatic review settings July 21, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1205

  • Removal destinations are not constrained to $baseFolder. A filesToRemove entry with a matching template file and destinationFolder = '..' produces a destinationFullPath outside the repository; CheckForUpdates.ps1 later converts it to a relative path and passes it to Remove-Item. Normalize every removal destination and reject paths that are not descendants of the repository root before returning this list.
        $filesToRemove += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    }
    $filesToRemove += @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    $filesToRemove += @(ResolveFilePathsInDestinationFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)

Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Outdated
Comment thread Actions/CheckForUpdates/CheckForUpdates.ps1 Outdated
Comment thread Scenarios/CustomizingALGoForGitHub.md Outdated
@OleWunschmann

Ole Wunschmann (OleWunschmann) commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Maria Zhelezova (@mazhelez)
Please excuse the radio silence over the last four weeks.
I was on vacation and therefore couldn’t continue working on this pull request.

I’ve gone ahead and resolved the merge conflicts, since I suspect that Copilot struggled with the fact that the source branch comes from my fork.

I saw that there were already approvals, but there are still two Copilot comments open:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Outdated
@mazhelez

Copy link
Copy Markdown
Collaborator

Maria Zhelezova (Maria Zhelezova (@mazhelez)) Please excuse the radio silence over the last four weeks. I was on vacation and therefore couldn’t continue working on this pull request.

I’ve gone ahead and resolved the merge conflicts, since I suspect that Copilot struggled with the fact that the source branch comes from my fork.

I saw that there were already approvals, but there are still two Copilot comments open:

Welcome back! I hope your vacation was splendid!

On the comments: I resolved the first one. As for the second one, I'll need to take a proper look.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Comment thread Tests/CheckForUpdates.Action.Test.ps1 Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new containment logic still permits two symlink-based repository-boundary escapes.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 6/7 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Outdated
Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Outdated
Comment thread Actions/.Modules/settings.schema.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two symlink containment gaps can still permit reads or writes outside trusted template and repository roots.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 7/8 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment on lines +1016 to +1018
if (Test-Path -LiteralPath $originalSourceFile -PathType Leaf) {
# If the file exists in the original template folder, use that file instead
$fullFilePath.originalSourceFullPath = Join-Path $originalSourceFolder $relativePath -Resolve
$fullFilePath.originalSourceFullPath = $originalSourceFile

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maria Zhelezova (@mazhelez) Alexander Holstrup (@aholstrup1) spetersenms
What do you think about this comment/issue?
Right now there is no escape check for the original-template files and I'm not sure what should happen with these cases.

Possible solutions:

  • Ignore this
  • Handle this cases by
    • throwing an error for escaping original-template files
    • ignoring the escaping original-template files

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A guard for going outside $originalSourceFolder sounds like a good solution here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. But how should we handle violations: throw an error or ignore the escaping file?

Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Original-template matches still lack the physical source-containment validation applied to normal source paths.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 7/8 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Destination containment remains bypassable through dangling links and can become invalid after cloning.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 7/8 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment on lines +846 to +849
if (-not (Test-Path -LiteralPath $realPath)) {
$resolveReparsePoints = $false
continue
}
Comment on lines +1098 to +1101
# Check if the destination file is under the file destination folder (symlink/junction-aware)
if (-not (Test-PathPhysicallyContained -Path $fullFilePath.destinationFullPath -RootFolder $fileDestinationFolder)) {
OutputWarning "Skipping file '$srcFile': destination file '$($fullFilePath.destinationFullPath)' is outside the file destination folder '$fileDestinationFolder'."
continue
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.

7 participants