Remove public PSGallery in isolated builds to fix CFSClean2 violations#1608
Draft
givinalis wants to merge 1 commit into
Draft
Remove public PSGallery in isolated builds to fix CFSClean2 violations#1608givinalis wants to merge 1 commit into
givinalis wants to merge 1 commit into
Conversation
Under network isolation, PowerShellGet still probed the default PSGallery source while resolving package sources and Publish-Module RequiredModules dependencies, even though every install/publish targeted the CFS feed. These probes were the 3 residual CFSClean2 violations to www.powershellgallery.com. Add build/Remove-PublicPSGallery.ps1 and run it (guarded by CfsFeedUrl) right after NuGetAuthenticate in both generation templates. It unregisters PSGallery from PowerShellGet and PSResourceGet so the feed and local gallery are the only sources for the rest of the job. Local development is unaffected: it is a no-op unless DEPENDENCY_PS_REPO points at a private feed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Learn Build status updates of commit 21a9e69: ❌ Validation status: errorsPlease follow instructions here which may help to resolve issue.
For more details, please refer to the build report. Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the 3 residual
CFSClean2violations towww.powershellgallery.comobserved in the network-isolated 1ES PR/CI builds (e.g. build 172485127, "Stop Network Isolation" step). Follow-up to #1607.Root cause
All 3 violations are
Task name: PowerShell,Process path: C:\Program Files\PowerShell\7\pwsh.exe→www.powershellgallery.com. They are not from thePSScriptAnalyzer@1task.Even though every
Install-Module/Publish-Modulein the build already targets the CFS feed (or the build's local gallery) via-Repository, the defaultPSGalleryrepository is still registered on the agent. PowerShellGet contacts it while:RequiredModulesdependencies duringPublish-Module(the Microsoft.Graph.* compat modules declareMicrosoft.Graph.Authenticationas a required module — seebuild/Publish-LocalCompatModule.ps1).Those probes are the leak. The build still succeeds because
CFSClean2is currently audit/warn (no blocked connections), but the connections are flagged.Fix
build/Remove-PublicPSGallery.ps1— unregistersPSGalleryfrom both PowerShellGet (Unregister-PSRepository) and PSResourceGet (Unregister-PSResourceRepository). Idempotent, and a no-op unlessDEPENDENCY_PS_REPOpoints at a private feed, so local development keeps PSGallery.NuGetAuthenticate@1(inside the existingif ne(CfsFeedUrl,'')guard) in both generation templates:.azure-pipelines/generation-templates/generate_adapter-1es.yml(PR + CI).azure-pipelines/generation-templates/generate_adapter.yml(integration tests)Repository un-registration persists on the agent for the rest of the job, so every subsequent PowerShell step (installs and publishes) resolves modules exclusively from the feed and the local gallery — leaving no route to the public gallery.
Why this is safe
Install-Module/Publish-Moduleinbuild/already passes an explicit-Repository(feed or local gallery); none rely on an implicit PSGallery.Microsoft.Graph.Authentication(the publish-time dependency) resolves from the local gallery (published first for Entra) or the feed, soPublish-Modulevalidation still succeeds without PSGallery.1es-entra-powershell-release.yml) only republishes the prebuilt.nupkgto the public gallery in a release job and does not install modules under isolation, so it is unaffected.Pipelines covered
1es-entra-powershell-pr.yml1es-entra-powershell-ci-build.ymlintegration-tests.ymlExpected result
CFSClean2 = COMPLIANT(0 violations), matchingCFSClean/CFSClean3/Default Deny.