Title: Get-Module [-ListAvailable] -FullyQualifiedName with path ignores other constraints · Issue #8262 · PowerShell/PowerShell · GitHub
Open Graph Title: Get-Module [-ListAvailable] -FullyQualifiedName with path ignores other constraints · Issue #8262 · PowerShell/PowerShell
X Title: Get-Module [-ListAvailable] -FullyQualifiedName with path ignores other constraints · Issue #8262 · PowerShell/PowerShell
Description: From #8218. Get-Module using a path in a fully qualified name will skip other constraints in the fully qualified name and be too permissive. Steps to reproduce Describe 'Get-Module -ListAvailable with path' { BeforeAll { $moduleName = 'B...
Open Graph Description: From #8218. Get-Module using a path in a fully qualified name will skip other constraints in the fully qualified name and be too permissive. Steps to reproduce Describe 'Get-Module -ListAvailable w...
X Description: From #8218. Get-Module using a path in a fully qualified name will skip other constraints in the fully qualified name and be too permissive. Steps to reproduce Describe 'Get-Module -ListAvailab...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/8262
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Get-Module [-ListAvailable] -FullyQualifiedName with path ignores other constraints","articleBody":"From https://github.com/PowerShell/PowerShell/pull/8218.\r\n\r\n`Get-Module` using a path in a fully qualified name will skip other constraints in the fully qualified name and be too permissive.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\nDescribe 'Get-Module -ListAvailable with path' {\r\n BeforeAll {\r\n $moduleName = 'Banana'\r\n $modulePath = Join-Path $TestDrive $moduleName\r\n $v1 = '1.2.3'\r\n $v2 = '4.8.3'\r\n $v1DirPath = Join-Path $modulePath $v1\r\n $v2DirPath = Join-Path $modulePath $v2\r\n $manifestV1Path = Join-Path $v1DirPath \"$moduleName.psd1\"\r\n $manifestV2Path = Join-Path $v2DirPath \"$moduleName.psd1\"\r\n\r\n New-Item -ItemType Directory $modulePath\r\n New-Item -ItemType Directory -Path $v1DirPath\r\n New-Item -ItemType Directory -Path $v2DirPath\r\n New-ModuleManifest -Path $manifestV1Path -ModuleVersion $v1\r\n New-ModuleManifest -Path $manifestV2Path -ModuleVersion $v2\r\n }\r\n\r\n It \"Gets all versions by path\" {\r\n $modules = Get-Module -ListAvailable $modulePath | Sort-Object -Property Version\r\n\r\n $modules | Should -HaveCount 2\r\n $modules[0].Name | Should -BeExactly $moduleName\r\n $modules[0].Path | Should -BeExactly $manifestV1Path\r\n $modules[0].Version | Should -Be $v1\r\n $modules[1].Name | Should -BeExactly $moduleName\r\n $modules[1].Path | Should -BeExactly $manifestV2Path\r\n $modules[1].Version | Should -Be $v2\r\n }\r\n\r\n It \"Gets all versions by FullyQualifiedName with path with lower version\" {\r\n $modules = Get-Module -ListAvailable -FullyQualifiedName @{ ModuleName = $modulePath; ModuleVersion = '0.0' } | Sort-Object -Property Version\r\n\r\n $modules | Should -HaveCount 2\r\n $modules[0].Name | Should -BeExactly $moduleName\r\n $modules[0].Path | Should -BeExactly $manifestV1Path\r\n $modules[0].Version | Should -Be $v1\r\n $modules[1].Name | Should -BeExactly $moduleName\r\n $modules[1].Path | Should -BeExactly $manifestV2Path\r\n $modules[1].Version | Should -Be $v2\r\n }\r\n\r\n It \"Gets high version by FullyQualifiedName with path with high version\" {\r\n $modules = Get-Module -ListAvailable -FullyQualifiedName @{ ModuleName = $modulePath; ModuleVersion = '2.0' } | Sort-Object -Property Version\r\n\r\n $modules | Should -HaveCount 1\r\n $modules[0].Name | Should -BeExactly $moduleName\r\n $modules[0].Path | Should -BeExactly $manifestV2Path\r\n $modules[0].Version | Should -Be $v2\r\n }\r\n\r\n It \"Gets low version by FullyQualifiedName with path with low maximum version\" {\r\n $modules = Get-Module -ListAvailable -FullyQualifiedName @{ ModuleName = $modulePath; MaximumVersion = '2.0' } | Sort-Object -Property Version\r\n\r\n $modules | Should -HaveCount 1\r\n $modules[0].Name | Should -BeExactly $moduleName\r\n $modules[0].Path | Should -BeExactly $manifestV1Path\r\n $modules[0].Version | Should -Be $v1\r\n }\r\n\r\n It \"Gets low version by FullyQualifiedName with path with low maximum version and version\" {\r\n $modules = Get-Module -ListAvailable -FullyQualifiedName @{ ModuleName = $modulePath; MaximumVersion = '2.0'; ModuleVersion = '1.0' } | Sort-Object -Property Version\r\n\r\n $modules | Should -HaveCount 1\r\n $modules[0].Name | Should -BeExactly $moduleName\r\n $modules[0].Path | Should -BeExactly $manifestV1Path\r\n $modules[0].Version | Should -Be $v1\r\n }\r\n\r\n It \"Gets correct version by FullyQualifiedName with path with required version\" -TestCases @(\r\n @{ Version = $v1 }\r\n @{ Version = $v2 }\r\n ) {\r\n param([version]$Version)\r\n\r\n switch ($Version)\r\n {\r\n $v1\r\n {\r\n $expectedPath = $manifestV1Path\r\n break\r\n }\r\n\r\n $v2\r\n {\r\n $expectedPath = $manifestV2Path\r\n }\r\n }\r\n\r\n $modules = Get-Module -ListAvailable -FullyQualifiedName @{ ModuleName = $modulePath; RequiredVersion = $Version }\r\n\r\n $modules | Should -HaveCount 1\r\n $modules[0].Name | Should -BeExactly $moduleName\r\n $modules[0].Path | Should -BeExactly $expectedPath\r\n $modules[0].Version | Should -Be $Version\r\n }\r\n}\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nAll tests pass\r\n\r\nActual behavior\r\n---------------\r\n\r\nTests with additional version checks in fully qualified names have their checks ignored.\r\nThis is of the following code:\r\n\r\nhttps://github.com/PowerShell/PowerShell/blob/79f21b41de0de9b2f68a19ba1fdef0b98f3fb1cb/src/System.Management.Automation/engine/Modules/GetModuleCommand.cs#L547-L557\r\n\r\nWhen a path is specified, the lookup fails and we (perversely) return the module.","author":{"url":"https://github.com/rjmholt","@type":"Person","name":"rjmholt"},"datePublished":"2018-11-14T00:26:48Z","url":"https://github.com/PowerShell/PowerShell/issues/8262"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0085d0b9-b0a7-3534-8d55-40a8c53df78c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBB6:25F138:2394DA:305A18:6AFD5297 |
| html-safe-nonce | 5a03dd47c15e437b826c2a29dc1da897ebedcd8f9b6bcc63b63651b082f041fb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkI2OjI1RjEzODoyMzk0REE6MzA1QTE4OjZBRkQ1Mjk3IiwidmlzaXRvcl9pZCI6IjU0OTYzOTQ0NzA4MjU3NDI5OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8287436405e60800c7de789a6a578bd14f5fab632284f55c0a1464639190a85c |
| hovercard-subject-tag | issue:380483587 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/8262/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5cb8050308fe2624083aa47f3ef856c3d061fb170f328701b4042787b26ebdc5/PowerShell/PowerShell/issues/8262 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5cb8050308fe2624083aa47f3ef856c3d061fb170f328701b4042787b26ebdc5/PowerShell/PowerShell/issues/8262 |
| og:image:alt | From #8218. Get-Module using a path in a fully qualified name will skip other constraints in the fully qualified name and be too permissive. Steps to reproduce Describe 'Get-Module -ListAvailable w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rjmholt |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width