From 7ac8e1fa7dc035a1f512876bef15a55fe0c0327e Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:54:14 -0700 Subject: [PATCH 1/4] Remove old build and CI scripts --- .ci/ci.yml | 132 --- .ci/ci_auto.yml | 200 ---- .ci/ci_release.yml | 218 ----- .ci/release.yml | 36 - .ci/test.yml | 68 -- .github/workflows/codeql-analysis.yml | 39 - LICENSE | 8 +- build.ps1 | 94 -- buildtools.psd1 | 51 - buildtools.psm1 | 200 ---- doBuild.ps1 | 104 -- help/Microsoft.PowerShell.SecretStore.md | 27 - ...rosoft.PowerShell.SecretStore.dll-Help.xml | 923 ------------------ .../about_Microsoft.PowerShell.SecretStore.md | 43 - package.config.json | 9 - 15 files changed, 4 insertions(+), 2148 deletions(-) delete mode 100644 .ci/ci.yml delete mode 100644 .ci/ci_auto.yml delete mode 100644 .ci/ci_release.yml delete mode 100644 .ci/release.yml delete mode 100644 .ci/test.yml delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 build.ps1 delete mode 100644 buildtools.psd1 delete mode 100644 buildtools.psm1 delete mode 100644 doBuild.ps1 delete mode 100644 help/Microsoft.PowerShell.SecretStore.md delete mode 100644 help/en-US/Microsoft.PowerShell.SecretStore.dll-Help.xml delete mode 100644 help/en-US/about_Microsoft.PowerShell.SecretStore.md delete mode 100644 package.config.json diff --git a/.ci/ci.yml b/.ci/ci.yml deleted file mode 100644 index 1f88c9a..0000000 --- a/.ci/ci.yml +++ /dev/null @@ -1,132 +0,0 @@ -name: $(BuildDefinitionName)-$(date:yyMM).$(date:dd)$(rev:rrr) -trigger: - # Batch merge builds together while a merge build is running - batch: true - branches: - include: - - master -pr: - branches: - include: - - master - -resources: - repositories: - - repository: ComplianceRepo - type: github - endpoint: ComplianceGHRepo - name: PowerShell/compliance - -stages: -- stage: Build - displayName: Build SecretStore Module Package - jobs: - - job: BuildPkg - displayName: Build Package - pool: - vmImage: windows-latest - - steps: - - - pwsh: | - Get-ChildItem -Path env: - Get-ChildItem -Path . -Recurse -Directory - displayName: Capture environment for build - condition: succeededOrFailed() - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - if (Test-Path -Path $modulePath) { - Write-Verbose -Verbose "Deleting existing temp module path: $modulePath" - Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore - } - if (! (Test-Path -Path $modulePath)) { - Write-Verbose -Verbose "Creating new temp module path: $modulePath" - $null = New-Item -Path $modulePath -ItemType Directory - } - displayName: Create temporary module path - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path" - Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force - displayName: Install PowerShellGetV3 - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $(Build.SourcesDirectory)/build.ps1 -Build -Clean -BuildConfiguration Release - displayName: Build module - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $(Build.SourcesDirectory)/build.ps1 -Publish - displayName: Publish module nuget package and upload package artifact - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - $config = Get-BuildConfiguration - # - $srcModulePath = Resolve-Path -Path "$($config.BuildOutputPath)/$($config.ModuleName)" - Get-ChildItem $srcModulePath - $artifactName = "$($config.ModuleName)" - Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$srcModulePath" - displayName: Upload module artifact - -- stage: Compliance - displayName: Compliance - dependsOn: Build - jobs: - - job: ComplianceJob - pool: - vmImage: windows-latest - steps: - - checkout: self - clean: true - - checkout: ComplianceRepo - clean: true - - download: current - artifact: 'Microsoft.PowerShell.SecretStore' - - template: ci-compliance.yml@ComplianceRepo - parameters: - # credscan - suppressionsFile: '' - -- stage: Test - displayName: Test Package - dependsOn: Build - jobs: - - template: test.yml - parameters: - jobName: TestPkgWin - displayName: PowerShell Core on Windows - imageName: windows-latest - - - template: test.yml - parameters: - jobName: TestPkgWinPS - displayName: Windows PowerShell on Windows - imageName: windows-latest - powershellExecutable: powershell - - - template: test.yml - parameters: - jobName: TestPkgUbuntu16 - displayName: PowerShell Core on Ubuntu 16.04 - imageName: ubuntu-latest - - - template: test.yml - parameters: - jobName: TestPkgWinMacOS - displayName: PowerShell Core on macOS - imageName: macOS-latest diff --git a/.ci/ci_auto.yml b/.ci/ci_auto.yml deleted file mode 100644 index 3edb79c..0000000 --- a/.ci/ci_auto.yml +++ /dev/null @@ -1,200 +0,0 @@ -name: $(BuildDefinitionName)-$(date:yyMM).$(date:dd)$(rev:rrr) -trigger: none -pr: none - -schedules: -# Use https://crontab.guru/#0_8_*_*_* to compute crontab expression -# Run signed build, with limited signing cert, every day at 9 am -- cron: 0 9 * * * - branches: - include: - - refs/heads/master - always: true - -variables: - - group: ESRP - # Prevents auto-injection of nuget-security-analysis (not needed for open source projects) - - name: skipNugetSecurityAnalysis - value: true - -resources: - repositories: - - repository: ComplianceRepo - type: github - endpoint: ComplianceGHRepo - name: PowerShell/compliance - -stages: -- stage: Build - displayName: Build SecretStore Module Package - jobs: - - job: BuildPkg - displayName: Build Package - pool: - name: 1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - - steps: - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - if (Test-Path -Path $modulePath) { - Write-Verbose -Verbose "Deleting existing temp module path: $modulePath" - Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore - } - if (! (Test-Path -Path $modulePath)) { - Write-Verbose -Verbose "Creating new temp module path: $modulePath" - $null = New-Item -Path $modulePath -ItemType Directory - } - displayName: Create temporary module path - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path" - Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force - displayName: Install PowerShellGetV3 - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $(Build.SourcesDirectory)/build.ps1 -Build -Clean -BuildConfiguration Release - displayName: Build module - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $config = Get-BuildConfiguration - $signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)" - $signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)" - if (! (Test-Path -Path $signOutPath)) { - $null = New-Item -Path $signOutPath -ItemType Directory - } - - # Set signing src path variable - $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - - # Set signing out path variable - $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: Set signing path variables for module code signing - - - pwsh: | - Get-ChildItem -Path env: - Get-ChildItem -Path . -Recurse -Directory - displayName: Capture environment for code signing - condition: succeededOrFailed() - - - template: EsrpSign.yml@ComplianceRepo - parameters: - buildOutputPath: $(signSrcPath) - signOutputPath: $(signOutPath) - certificateId: "CP-460906" - shouldSign: $(ShouldSign) - pattern: | - *.dll - *.psd1 - *.ps1xml - useMinimatch: true - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - if ($env:ShouldSign -ne 'True') - { - $(Build.SourcesDirectory)/build.ps1 -Publish - } - else - { - $(Build.SourcesDirectory)/build.ps1 -Publish -Signed - } - displayName: Publish module nuget package and upload package artifact - condition: succeeded() - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $config = Get-BuildConfiguration - $srcModulePath = Resolve-Path -Path "$($config.SignedOutputPath)/$($config.ModuleName)" - Get-ChildItem $srcModulePath - $artifactName = "$($config.ModuleName)" - Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$srcModulePath" - displayName: Upload the module artifact - condition: succeeded() - -- stage: Compliance - displayName: Compliance - dependsOn: Build - jobs: - - job: ComplianceJob - pool: - name: 1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - steps: - - checkout: self - clean: true - - checkout: ComplianceRepo - clean: true - - download: current - artifact: 'Microsoft.PowerShell.SecretStore' - - template: assembly-module-compliance.yml@ComplianceRepo - parameters: - # binskim - AnalyzeTarget: '$(Pipeline.Workspace)/Microsoft.PowerShell.SecretStore/*.dll' - AnalyzeSymPath: 'SRV*' - # component-governance - sourceScanPath: '$(Build.SourcesDirectory)' - # credscan - suppressionsFile: '' - # TermCheck - optionsRulesDBPath: '' - optionsFTPath: '' - # tsa-upload - codeBaseName: 'PSSecretStore_201508' - # selections - APIScan: false # set to false when not using Windows APIs - -- stage: Test - displayName: Test Package - dependsOn: Build - jobs: - - template: test.yml - parameters: - jobName: TestPkgWin - displayName: PowerShell Core on Windows - imageName: windows-latest - - - template: test.yml - parameters: - jobName: TestPkgWinPS - displayName: Windows PowerShell on Windows - imageName: windows-latest - powershellExecutable: powershell - - - template: test.yml - parameters: - jobName: TestPkgUbuntu16 - displayName: PowerShell Core on Ubuntu - imageName: ubuntu-latest - - - template: test.yml - parameters: - jobName: TestPkgWinMacOS - displayName: PowerShell Core on macOS - imageName: macOS-latest diff --git a/.ci/ci_release.yml b/.ci/ci_release.yml deleted file mode 100644 index 2cfe386..0000000 --- a/.ci/ci_release.yml +++ /dev/null @@ -1,218 +0,0 @@ -name: $(BuildDefinitionName)-$(date:yyMM).$(date:dd)$(rev:rrr) -trigger: none -pr: none - -variables: - - group: ESRP - # Prevents auto-injection of nuget-security-analysis (not needed for open source projects) - - name: skipNugetSecurityAnalysis - value: true - -resources: - repositories: - - repository: ComplianceRepo - type: github - endpoint: ComplianceGHRepo - name: PowerShell/compliance - -stages: -- stage: Build - displayName: Build SecretStore Module Package - jobs: - - job: BuildPkg - displayName: Build Package - pool: - name: 1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - - steps: - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - if (Test-Path -Path $modulePath) { - Write-Verbose -Verbose "Deleting existing temp module path: $modulePath" - Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore - } - if (! (Test-Path -Path $modulePath)) { - Write-Verbose -Verbose "Creating new temp module path: $modulePath" - $null = New-Item -Path $modulePath -ItemType Directory - } - displayName: Create temporary module path - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path" - Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force - displayName: Install PowerShellGetV3 - - - pwsh: | - Get-ChildItem -Path env: - Get-ChildItem -Path . -Recurse -Directory - displayName: Capture environment for build - condition: succeededOrFailed() - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $(Build.SourcesDirectory)/build.ps1 -Build -Clean -BuildConfiguration Release - displayName: Build module - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $config = Get-BuildConfiguration - $signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)" - $signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)" - if (! (Test-Path -Path $signOutPath)) { - $null = New-Item -Path $signOutPath -ItemType Directory - } - - # Set signing src path variable - $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - - # Set signing out path variable - $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: Set signing variables for module code signing - - - pwsh: | - Get-ChildItem -Path env: - Get-ChildItem -Path . -Recurse -Directory - displayName: Capture environment for module code signing - condition: succeededOrFailed() - - - template: EsrpSign.yml@ComplianceRepo - parameters: - buildOutputPath: $(signSrcPath) - signOutputPath: $(signOutPath) - certificateId: "CP-230012" - pattern: | - Microsoft.PowerShell.SecretStore.dll - **\*.psd1 - **\*.psm1 - useMinimatch: true - - - ${{ if ne(variables.SkipSigning, 'True') }}: - - template: Sbom.yml@ComplianceRepo - parameters: - BuildDropPath: $(signOutPath) - Build_Repository_Uri: 'https://github.com/powershell/secretstore' - PackageName: 'Microsoft.PowerShell.SecretStore' - PackageVersion: '1.0.6' - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - if ($env:SkipSigning -eq 'True') - { - $(Build.SourcesDirectory)/build.ps1 -Publish - } - else - { - $(Build.SourcesDirectory)/build.ps1 -Publish -Signed - } - displayName: Publish module nuget package and upload package artifact - condition: succeeded() - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force - # - $config = Get-BuildConfiguration - if ($env:SkipSigning -eq 'True') - { - $srcModulePath = Resolve-Path -Path "$($config.BuildOutputPath)/$($config.ModuleName)" - } - else - { - $srcModulePath = Resolve-Path -Path "$($config.SignedOutputPath)/$($config.ModuleName)" - } - # Publish un-packaged module directory - Get-ChildItem $srcModulePath - $artifactName = "$($config.ModuleName)" - Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$srcModulePath" - displayName: Upload the module artifact - -- stage: Compliance - displayName: Compliance - dependsOn: Build - jobs: - - job: ComplianceJob - pool: - name: 1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - - steps: - - checkout: self - clean: true - - checkout: ComplianceRepo - clean: true - - download: current - artifact: 'Microsoft.PowerShell.SecretStore' - - template: assembly-module-compliance.yml@ComplianceRepo - parameters: - # binskim - AnalyzeTarget: '$(Pipeline.Workspace)/Microsoft.PowerShell.SecretStore/*.dll' - AnalyzeSymPath: 'SRV*' - # component-governance - sourceScanPath: '$(Build.SourcesDirectory)' - # credscan - suppressionsFile: '' - # TermCheck - optionsRulesDBPath: '' - optionsFTPath: '' - # tsa-upload - codeBaseName: 'PSSecretStore_201508' - # selections - APIScan: false # set to false when not using Windows APIs - -- stage: Test - displayName: Test Package - dependsOn: Build - jobs: - - template: test.yml - parameters: - jobName: TestPkgWin - displayName: PowerShell Core on Windows - imageName: windows-2019 - - - template: test.yml - parameters: - jobName: TestPkgWinPS - displayName: Windows PowerShell on Windows - imageName: windows-2019 - powershellExecutable: powershell - - - template: test.yml - parameters: - jobName: TestPkgUbuntu16 - displayName: PowerShell Core on Ubuntu 16.04 - imageName: ubuntu-latest - - - template: test.yml - parameters: - jobName: TestPkgWinMacOS - displayName: PowerShell Core on macOS - imageName: macOS-latest - -- stage: Release - displayName: Release Package to PSGallery - condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), eq(variables['Publish'], 'True')) - jobs: - - template: release.yml diff --git a/.ci/release.yml b/.ci/release.yml deleted file mode 100644 index a5d92ab..0000000 --- a/.ci/release.yml +++ /dev/null @@ -1,36 +0,0 @@ -parameters: - jobName: release - displayName: 'Release Microsoft.PowerShell.SecretStore to PSGallery' - -jobs: -- job: ${{ parameters.jobName }} - pool: - name: 1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - displayName: ${{ parameters.displayName }} - - steps: - - - task: DownloadPipelineArtifact@2 - displayName: 'Download SecretStore module artifacts' - inputs: - artifact: nupkg - patterns: '**/*.nupkg' - downloadPath: '$(Pipeline.Workspace)/nuget' - - - powershell: | - $package = (Get-ChildItem '$(Pipeline.Workspace)/nuget/Microsoft.PowerShell.SecretStore.*.nupkg').FullName - $package - $vstsCommandString = "vso[task.setvariable variable=NugetPkgPath]${package}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: 'Capture SecretStore module NuGet package path and set environment variable' - - - task: NuGetCommand@2 - displayName: 'Push Microsoft.PowerShell.Store module artifacts to PSGallery feed' - inputs: - command: push - packagesToPush: '$(NugetPkgPath)' - nuGetFeedType: external - publishFeedCredentials: PSGalleryPush diff --git a/.ci/test.yml b/.ci/test.yml deleted file mode 100644 index be6c153..0000000 --- a/.ci/test.yml +++ /dev/null @@ -1,68 +0,0 @@ -parameters: - jobName: TestPkgWin - imageName: windows-latest - displayName: PowerShell Core on Windows - powershellExecutable: pwsh - buildDirectory: '.' - -jobs: -- job: ${{ parameters.jobName }} - pool: - vmImage: ${{ parameters.imageName }} - displayName: ${{ parameters.displayName }} - steps: - - task: DownloadBuildArtifacts@0 - displayName: 'Download artifacts' - inputs: - buildType: current - downloadType: specific - itemPattern: '**/*.nupkg' - downloadPath: '$(System.ArtifactsDirectory)' - - - ${{ parameters.powershellExecutable }}: | - Get-ChildItem -Path "$(System.ArtifactsDirectory)" - displayName: Capture artifacts directory - - - ${{ parameters.powershellExecutable }}: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - if (Test-Path -Path $modulePath) { - Write-Verbose -Verbose "Deleting existing temp module path: $modulePath" - Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore - } - if (! (Test-Path -Path $modulePath)) { - Write-Verbose -Verbose "Creating new temp module path: $modulePath" - $null = New-Item -Path $modulePath -ItemType Directory - } - displayName: Create temporary module path - - - ${{ parameters.powershellExecutable }}: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path" - Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force - Write-Verbose -Verbose "Install Pester 4.X to temp module path" - Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force - Write-Verbose -Verbose "Install Microsoft.PowerShell.SecretManagement to temp module path" - Save-Module -Name "Microsoft.PowerShell.SecretManagement" -Path $modulePath -Force - displayName: Install PowerShellGetV3, Pester, and SecretManagment - - - ${{ parameters.powershellExecutable }}: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name (Join-Path -Path '${{ parameters.buildDirectory }}' -ChildPath 'buildtools.psd1') -Force - # - Install-ModulePackageForTest -PackagePath "$(System.ArtifactsDirectory)" - displayName: Install module for test from downloaded artifact - workingDirectory: ${{ parameters.buildDirectory }} - - - ${{ parameters.powershellExecutable }}: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)" - Import-Module -Name (Join-Path -Path '${{ parameters.buildDirectory }}' -ChildPath 'buildtools.psd1') -Force - # - Invoke-ModuleTests -Type Functional - displayName: Execute functional tests - workingDirectory: ${{ parameters.buildDirectory }} - errorActionPreference: continue - condition: succeededOrFailed() diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index efbe954..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: CodeQL - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - schedule: - - cron: '23 16 * * 4' - -jobs: - analyze: - name: Analyze (${{ matrix.language }}) - runs-on: ubuntu-latest - permissions: - security-events: write - packages: read - actions: read - contents: read - strategy: - fail-fast: false - matrix: - include: - - language: csharp - build-mode: autobuild - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: '/language:${{matrix.language}}' diff --git a/LICENSE b/LICENSE index b2f52a2..48ea661 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ -Copyright (c) Microsoft Corporation. - MIT License +Copyright (c) Microsoft Corporation. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index 4ae7556..0000000 --- a/build.ps1 +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -# Do NOT edit this file. Edit dobuild.ps1 -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")] -param ( - [Parameter(ParameterSetName="build")] - [switch] - $Clean, - - [Parameter(ParameterSetName="build")] - [switch] - $Build, - - [Parameter(ParameterSetName="publish")] - [switch] - $Publish, - - [Parameter(ParameterSetName="publish")] - [switch] - $Signed, - - [ValidateSet("Debug", "Release")] - [string] $BuildConfiguration = "Debug", - - [ValidateSet("net461")] - [string] $BuildFramework = "net461" -) - -Import-Module -Name "$PSScriptRoot/buildtools.psd1" -Force - -$config = Get-BuildConfiguration -ConfigPath $PSScriptRoot - -$script:ModuleName = $config.ModuleName -$script:SrcPath = $config.SourcePath -$script:OutDirectory = $config.BuildOutputPath -$script:SignedDirectory = $config.SignedOutputPath -$script:TestPath = $config.TestPath -$ExtensionModuleName = '{0}.{1}' -f $config.ModuleName,"Extension" -$script:ExtensionModulePath = Join-Path -Path $config.SourcePath -ChildPath $ExtensionModuleName - -$script:ModuleRoot = $PSScriptRoot -$script:Culture = $config.Culture -$script:HelpPath = $config.HelpPath - -$script:BuildConfiguration = $BuildConfiguration -$script:BuildFramework = $BuildFramework - -if ($env:TF_BUILD) { - $vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" - - $vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" -} - -. $PSScriptRoot/doBuild.ps1 - -if ($Clean -and (Test-Path $OutDirectory)) -{ - Remove-Item -Path $OutDirectory -Force -Recurse -ErrorAction Stop -Verbose - - if (Test-Path "${SrcPath}/code/bin") - { - Remove-Item -Path "${SrcPath}/code/bin" -Recurse -Force -ErrorAction Stop -Verbose - } - - if (Test-Path "${SrcPath}/code/obj") - { - Remove-Item -Path "${SrcPath}/code/obj" -Recurse -Force -ErrorAction Stop -Verbose - } -} - -if (-not (Test-Path $OutDirectory)) -{ - $script:OutModule = New-Item -ItemType Directory -Path (Join-Path $OutDirectory $ModuleName) -} -else -{ - $script:OutModule = Join-Path $OutDirectory $ModuleName -} - -if ($Build.IsPresent) -{ - $sb = (Get-Item Function:DoBuild).ScriptBlock - Invoke-ModuleBuild -BuildScript $sb -} - -if ($Publish.IsPresent) -{ - Publish-ModulePackage -Signed:$Signed.IsPresent -} diff --git a/buildtools.psd1 b/buildtools.psd1 deleted file mode 100644 index 6542e45..0000000 --- a/buildtools.psd1 +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -@{ - # Script module or binary module file associated with this manifest. - RootModule = '.\buildtools.psm1' - - # Version number of this module. - ModuleVersion = '1.0.0' - - # Supported PSEditions - CompatiblePSEditions = @('Core') - - # ID used to uniquely identify this module - GUID = 'fcdd259e-1163-4da2-8bfa-ce36a839f337' - - # Author of this module - Author = 'Microsoft Corporation' - - # Company or vendor of this module - CompanyName = 'Microsoft Corporation' - - # Copyright statement for this module - Copyright = '(c) Microsoft Corporation. All rights reserved.' - - # Description of the functionality provided by this module - Description = "Build utilties." - - # Modules that must be imported into the global environment prior to importing this module - #RequiredModules = @( - # @{ ModuleName = 'platyPS'; ModuleVersion = '0.14.0' }, - # @{ ModuleName = 'Pester'; ModuleVersion = '4.8.1' }, - # @{ ModuleName = 'PSScriptAnalyzer'; ModuleVersion = '1.18.0' } - #) - - # Minimum version of the PowerShell engine required by this module - PowerShellVersion = '5.1' - - # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @() - - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = @( - 'Get-BuildConfiguration', 'Invoke-ModuleBuild', 'Publish-ModulePackage', 'Install-ModulePackageForTest', 'Invoke-ModuleTests') - - # Variables to export from this module - VariablesToExport = '*' - - # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = @() -} diff --git a/buildtools.psm1 b/buildtools.psm1 deleted file mode 100644 index dcebebc..0000000 --- a/buildtools.psm1 +++ /dev/null @@ -1,200 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -$ConfigurationFileName = 'package.config.json' -Import-Module -Name PowerShellGet -MinimumVersion 3.0.19 - -function Get-BuildConfiguration { - [CmdletBinding()] - param ( - [Parameter()] - [string] $ConfigPath = '.' - ) - - $resolvedPath = Resolve-Path $ConfigPath - - if (Test-Path $resolvedPath -PathType Container) { - $fileNamePath = Join-Path -Path $resolvedPath -ChildPath $ConfigurationFileName - } - else { - $fileName = Split-Path -Path $resolvedPath -Leaf - if ($fileName -ne $ConfigurationFileName) { - throw "$ConfigurationFileName not found in provided pathname: $resolvedPath" - } - $fileNamePath = $resolvedPath - } - - if (! (Test-Path -Path $fileNamePath -PathType Leaf)) { - throw "$ConfigurationFileName not found at path: $resolvedPath" - } - - $configObj = Get-Content -Path $fileNamePath | ConvertFrom-Json - - # Expand config paths to full paths - $projectRoot = Split-Path $fileNamePath - $configObj.SourcePath = Join-Path $projectRoot -ChildPath $configObj.SourcePath - $configObj.TestPath = Join-Path $projectRoot -ChildPath $configObj.TestPath - $configObj.HelpPath = Join-Path $projectRoot -ChildPath $configObj.HelpPath - $configObj.BuildOutputPath = Join-Path $projectRoot -ChildPath $configObj.BuildOutputPath - if ($configObj.SignedOutputPath) { - $configObj.SignedOutputPath = Join-Path $projectRoot -ChildPath $configObj.SignedOutputPath - } - else { - $configObj | Add-Member -MemberType NoteProperty -Name SignedOutputPath -Value (Join-Path $projectRoot -ChildPath 'signed') - } - - return $configObj -} - -function Invoke-ModuleBuild { - [CmdletBinding()] - param ( - [Parameter(Mandatory=$true)] - [ScriptBlock] $BuildScript - ) - - Write-Verbose -Verbose -Message "Invoking build script" - - $BuildScript.Invoke() - - Write-Verbose -Verbose -Message "Finished invoking build script" -} - -function Publish-ModulePackage -{ - [CmdletBinding()] - param ( - [Parameter()] - [Switch] $Signed - ) - - Write-Verbose -Verbose -Message "Creating new local package repo" - $localRepoName = 'packagebuild-local-repo' - $localRepoLocation = Join-Path -Path ([System.io.path]::GetTempPath()) -ChildPath $localRepoName - if (Test-Path -Path $localRepoLocation) { - Remove-Item -Path $localRepoLocation -Recurse -Force -ErrorAction Ignore - } - $null = New-Item -Path $localRepoLocation -ItemType Directory -Force - - Write-Verbose -Verbose -Message "Registering local package repo: $localRepoName" - Register-PSResourceRepository -Name $localRepoName -Uri $localRepoLocation -Trusted -Force - - Write-Verbose -Verbose -Message "Publishing package to local repo: $localRepoName" - $config = Get-BuildConfiguration - if (! $Signed.IsPresent) { - $modulePath = Join-Path -Path $config.BuildOutputPath -ChildPath $config.ModuleName - } else { - $modulePath = Join-Path -Path $config.SignedOutputPath -ChildPath $config.ModuleName - } - Publish-PSResource -Path $modulePath -Repository $localRepoName -SkipDependenciesCheck -SkipModuleManifestValidate -Confirm:$false -Verbose - - if ($env:TF_BUILD) { - Write-Verbose -Verbose -Message "Uploading module nuget package artifact to AzDevOps" - $artifactName = "nupkg" - $artifactPath = (Get-ChildItem -Path $localRepoLocation -Filter "$($config.ModuleName)*.nupkg").FullName - $artifactPath = Resolve-Path -Path $artifactPath - Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$artifactPath" - } - - Write-Verbose -Verbose -Message "Unregistering local package repo: $localRepoName" - Unregister-PSResourceRepository -Name $localRepoName -Confirm:$false -} - -function Install-ModulePackageForTest { - [CmdletBinding()] - param ( - [Parameter(Mandatory=$true)] - [string] $PackagePath - ) - - $config = Get-BuildConfiguration - - $localRepoName = 'packagebuild-local-repo' - Write-Verbose -Verbose -Message "Registering local package repo: $localRepoName to path: $PackagePath" - Register-PSResourceRepository -Name $localRepoName -Uri $PackagePath -Trusted -Force - - $installationPath = $config.BuildOutputPath - if ( !(Test-Path $installationPath)) { - Write-Verbose -Verbose -Message "Creating module directory location for tests: $installationPath" - $null = New-Item -Path $installationPath -ItemType Directory -Verbose - } - - Write-Verbose -Verbose -Message "Installing module $($config.ModuleName) to build output path $installationPath" - Save-PSResource -Name $config.ModuleName -Repository $localRepoName -Path $installationPath -SkipDependencyCheck -Prerelease -Confirm:$false - - Write-Verbose -Verbose -Message "Unregistering local package repo: $localRepoName" - Unregister-PSResourceRepository -Name $localRepoName -Confirm:$false -} - -function Invoke-ModuleTests { - [CmdletBinding()] - param ( - [ValidateSet("Functional", "StaticAnalysis")] - [string[]] $Type = "Functional" - ) - - Write-Verbose -Verbose -Message "Starting module Pester tests..." - - # Run module Pester tests. - $config = Get-BuildConfiguration - $tags = 'CI' - $testResultFileName = 'result.pester.xml' - $testPath = $config.TestPath - $moduleToTest = Join-Path -Path $config.BuildOutputPath -ChildPath $config.ModuleName - $command = "Import-Module -Name ${moduleToTest} -Force -Verbose; Set-Location -Path ${testPath}; Invoke-Pester -Path . -OutputFile ${testResultFileName} -Tags '${tags}'" - $pwshExePath = (Get-Process -Id $pid).Path - try { - $output = & $pwshExePath -NoProfile -NoLogo -Command $command - } - catch { - Write-Error -Message "Error invoking module Pester tests." - } - $output | Foreach-Object { Write-Warning -Message "$_" } - $testResultsFilePath = Join-Path -Path $testPath -ChildPath $testResultFileName - - # Examine Pester test results. - if (! (Test-Path -Path $testResultsFilePath)) { - throw "Module test result file not found: '$testResultsFilePath'" - } - $xmlDoc = [xml] (Get-Content -Path $testResultsFilePath -Raw) - if ([int] ($xmlDoc.'test-results'.failures) -gt 0) { - $failures = [System.Xml.XmlDocumentXPathExtensions]::SelectNodes($xmlDoc."test-results", './/test-case[@result = "Failure"]') - } - else { - $failures = $xmlDoc.SelectNodes('.//test-case[@result = "Failure"]') - } - foreach ($testfailure in $failures) { - Show-PSPesterError -TestFailure $testfailure - } - - # Publish test results to AzDevOps - if ($env:TF_BUILD) { - Write-Verbose -Verbose -Message "Uploading test results to AzDevOps" - $powerShellName = if ($PSVersionTable.PSEdition -eq 'Core') { 'PowerShell Core' } else { 'Windows PowerShell' } - $TestType = 'NUnit' - $Title = "Functional Tests - $env:AGENT_OS - $powershellName Results" - $ArtifactPath = (Resolve-Path -Path $testResultsFilePath).ProviderPath - $FailTaskOnFailedTests = 'true' - $message = "vso[results.publish type=$TestType;mergeResults=true;runTitle=$Title;publishRunAttachments=true;resultFiles=$ArtifactPath;failTaskOnFailedTests=$FailTaskOnFailedTests;]" - Write-Host "##$message" - } - - Write-Verbose -Verbose -Message "Module Pester tests complete." -} - -function Show-PSPesterError { - [CmdletBinding()] - param ( - [Parameter(Mandatory)] - [Xml.XmlElement]$testFailure - ) - - $description = $testFailure.description - $name = $testFailure.name - $message = $testFailure.failure.message - $stackTrace = $testFailure.failure."stack-trace" - - $fullMsg = "`n{0}`n{1}`n{2}`n{3}`{4}" -f ("Description: " + $description), ("Name: " + $name), "message:", $message, "stack-trace:", $stackTrace - - Write-Error $fullMsg -} diff --git a/doBuild.ps1 b/doBuild.ps1 deleted file mode 100644 index 0a2d122..0000000 --- a/doBuild.ps1 +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -<# -.DESCRIPTION -Implement build and packaging of the package and place the output $OutDirectory/$ModuleName -#> -function DoBuild -{ - Write-Verbose -Verbose -Message "Starting DoBuild with configuration: $BuildConfiguration, framework: $BuildFramework" - - # Module build out path - $BuildOutPath = "${OutDirectory}/${ModuleName}" - Write-Verbose -Verbose -Message "Module output file path: '$BuildOutPath'" - - # Module build source path - $BuildSrcPath = "bin/${BuildConfiguration}/${BuildFramework}/publish" - Write-Verbose -Verbose -Message "Module build source path: '$BuildSrcPath'" - - # Copy psd1 file - Write-Verbose -Verbose "Copy-Item ${SrcPath}/${ModuleName}.psd1 to ${OutDirectory}/${ModuleName}" - Copy-Item "${SrcPath}/${ModuleName}.psd1" "${OutDirectory}/${ModuleName}" - - # Copy vault extension module files here - Write-Verbose -Verbose "Copy-Item ${ExtensionModulePath} to ${OutDirectory}/${ModuleName}" - Copy-Item "${ExtensionModulePath}" "${OutDirectory}/${ModuleName}" -Recurse - - # Copy help - Write-Verbose -Verbose -Message "Copying help files to '$BuildOutPath'" - copy-item -Recurse "${HelpPath}/${Culture}" "$BuildOutPath" - - # Copy license - Write-Verbose -Verbose -Message "Copying LICENSE file to '$BuildOutPath'" - Copy-Item -Path "./LICENSE" -Dest "$BuildOutPath" - - # Copy notice - Write-Verbose -Verbose -Message "Copying ThirdPartyNotices.txt to '$BuildOutPath'" - Copy-Item -Path "./ThirdPartyNotices.txt" -Dest "$BuildOutPath" - - if ( Test-Path "${SrcPath}/code" ) { - Write-Verbose -Verbose -Message "Building assembly and copying to '$BuildOutPath'" - # build code and place it in the staging location - Push-Location "${SrcPath}/code" - try { - # Get dotnet.exe command path. - $dotnetCommand = Get-Command -Name 'dotnet' -ErrorAction Ignore - - # Check for dotnet for Windows (we only build on Windows platforms). - if ($null -eq $dotnetCommand) { - Write-Verbose -Verbose -Message "dotnet.exe cannot be found in current path. Looking in ProgramFiles path." - $dotnetCommandPath = Join-Path -Path $env:ProgramFiles -ChildPath "dotnet\dotnet.exe" - $dotnetCommand = Get-Command -Name $dotnetCommandPath -ErrorAction Ignore - if ($null -eq $dotnetCommand) { - throw "Dotnet.exe cannot be found: $dotnetCommandPath is unavailable for build." - } - } - - Write-Verbose -Verbose -Message "dotnet.exe command found in path: $($dotnetCommand.Path)" - - # Check dotnet version - Write-Verbose -Verbose -Message "DotNet version: $(& ($dotnetCommand) --version)" - - # Build source - Write-Verbose -Verbose -Message "Building location: PSScriptRoot: $PSScriptRoot, PWD: $pwd" - $buildCommand = "$($dotnetCommand.Name) publish --configuration $BuildConfiguration --framework $BuildFramework --output $BuildSrcPath" - Write-Verbose -Verbose -Message "Starting dotnet build command: $buildCommand" - Invoke-Expression -Command $buildCommand - - # Place build results - if (! (Test-Path -Path "$BuildSrcPath/${ModuleName}.dll")) - { - throw "Expected binary was not created: $BuildSrcPath/${ModuleName}.dll" - } - - Write-Verbose -Verbose -Message "Copying $BuildSrcPath/${ModuleName}.dll to $BuildOutPath" - Copy-Item -Path "$BuildSrcPath/${ModuleName}.dll" -Dest "$BuildOutPath" - - if (Test-Path -Path "$BuildSrcPath/${ModuleName}.pdb") - { - Write-Verbose -Verbose -Message "Copying $BuildSrcPath/${ModuleName}.pdb to $BuildOutPath" - Copy-Item -Path "$BuildSrcPath/${ModuleName}.pdb" -Dest "$BuildOutPath" - } - - Write-Verbose -Verbose "$BuildSrcPath/System.IO.FileSystem.AccessControl.dll to $BuildOutPath" - Copy-Item -Path "$BuildSrcPath/System.IO.FileSystem.AccessControl.dll" -Dest "$BuildOutPath" - - Write-Verbose -Verbose "$BuildSrcPath/System.Runtime.InteropServices.RuntimeInformation.dll to $BuildOutPath" - Copy-Item -Path "$BuildSrcPath/System.Runtime.InteropServices.RuntimeInformation.dll" -Dest "$BuildOutPath" - } - catch { - Write-Verbose -Verbose -Message "dotnet build failed with error: $_" - Write-Error "dotnet build failed with error: $_" - } - finally { - Pop-Location - } - } - else { - Write-Verbose -Verbose -Message "No code to build in '${SrcPath}/code'" - } - - ## Add build and packaging here - Write-Verbose -Verbose -Message "Ending DoBuild" -} diff --git a/help/Microsoft.PowerShell.SecretStore.md b/help/Microsoft.PowerShell.SecretStore.md deleted file mode 100644 index 9ca48fc..0000000 --- a/help/Microsoft.PowerShell.SecretStore.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -Module Name: Microsoft.PowerShell.SecretStore -Module Guid: 6b983e67-c297-431a-916c-f4ce24dd7bac -Download Help Link: {{ Update Download Link }} -Help Version: {{ Please enter version of help manually (X.X.X.X) format }} -Locale: en-US ---- - -# Microsoft.PowerShell.SecretStore Module -## Description -Local secure store extension vault for Microsoft.PowerShell.SecretManagement module. - -## Microsoft.PowerShell.SecretStore Cmdlets -### [Get-SecretStoreConfiguration](Get-SecretStoreConfiguration.md) -Writes the SecretStore configuration information. - -### [Reset-SecretStore](Reset-SecretStore.md) -Resets the SecretStore by deleting all current secret data, and setting the configuration properties to default values. - -### [Set-SecretStoreConfiguration](Set-SecretStoreConfiguration.md) -Applies configuration settings to the SecretStore. - -### [Unlock-SecretStore](Unlock-SecretStore.md) -Unlocks the SecretStore with the provided password. - -### [Set-SecretStorePassword](Set-SecretStorePassword.md) -Replaces the current SecretStore password with a new password. diff --git a/help/en-US/Microsoft.PowerShell.SecretStore.dll-Help.xml b/help/en-US/Microsoft.PowerShell.SecretStore.dll-Help.xml deleted file mode 100644 index 31b0a34..0000000 --- a/help/en-US/Microsoft.PowerShell.SecretStore.dll-Help.xml +++ /dev/null @@ -1,923 +0,0 @@ - - - - - Get-SecretStoreConfiguration - Get - SecretStoreConfiguration - - Returns SecretStore configuration information. - - - - This cmdlet reads the SecretStore configuration file and writes configuration information to the pipeline. Configuration information includes: - - Scope - - Authentication - - PasswordTimeout (in seconds) - - Interaction - - - - Get-SecretStoreConfiguration - - - - - - - None - - - - - - - - - - Microsoft.PowerShell.SecretStore.SecureStoreConfig - - - - - - - - - 'AllUsers' scope is currently not supported. Configuration scope is always 'CurrentUser'. - - - - - -------------------------- Example 1 -------------------------- - PS C:\> Get-SecretStoreConfiguration - - Scope Authentication PasswordTimeout Interaction - ----- -------------- --------------- ----------- -CurrentUser Password 900 Prompt - - This example runs the command from a command shell prompt and displays four SecretStore configuration properties: Scope : 'CurrentUser'. Authentication : A password is required to access the SecretStore. PasswordTimeout : The session password timeout time is 15 minutes. Interaction : The user will be prompted for a password if the command is run in an interactive session. - - - - - - - - Reset-SecretStore - Reset - SecretStore - - Resets the SecretStore by deleting all secret data and configuring the store with default options. - - - - This cmdlet completely resets the SecretStore by deleting all secret data it may contain, and resetting configuration options to their default values. It is intended to be used only if a required password is lost, or data files become corrupted so that SecretStore no longer functions and secret data cannot be accessed. Default configuration options can be overridden by specifying individual command configuration option parameters. - - - - Reset-SecretStore - - Authentication - - Configuration option to set authentication for store access. Configuration options are 'Password' or 'None'. When 'Password' is selected, SecretStore is configured to require a password for accessing secrets. Default authentication is 'Password', as this provides the strongest protection of secret data. - - Authenticate - - Authenticate - - - Password - - - Force - - When used, the user will not be asked to confirm and the SecretStore will be reset without prompting. Default value is false, and user will be asked to confirm the operation. - - - SwitchParameter - - - False - - - Password - - Sets the provided Password to the newly reset store. If the reset store is not configured for password authentication, an error will be returned. - - SecureString - - SecureString - - - None - - - PassThru - - Writes the newly reset store configuration object (SecureStorConfig) to the pipeline. - - - SwitchParameter - - - False - - - PasswordTimeout - - Configuration option that provides the session password timeout in seconds. Takes an argument whose value determines the session password timeout in seconds. When the timeout value is reached, the current password value is invalidated for the session. - - Int32 - - Int32 - - - 900 - - - Scope - - Configuration option that determines SecretStore operation scope. Currently only 'CurrentUser' scope is supported. - - - CurrentUser - AllUsers - - SecureStoreScope - - SecureStoreScope - - - CurrentUser - - - Interaction - - Configuration option to allow or suppress user prompting. Configuration options are 'Prompt' or 'None'. When 'None' is selected, no prompt will be presented in an interactive session to provide a session password. Default value is 'Prompt', and users will be prompted for password when needed. When 'None' is selected and a session password is required, a Microsoft.PowerShell.SecretStore.PasswordRequiredException error is thrown. - - Interaction - - Interaction - - - Prompt - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - - - - Authentication - - Configuration option to set authentication for store access. Configuration options are 'Password' or 'None'. When 'Password' is selected, SecretStore is configured to require a password for accessing secrets. Default authentication is 'Password', as this provides the strongest protection of secret data. - - Authenticate - - Authenticate - - - Password - - - Force - - When used, the user will not be asked to confirm and the SecretStore will be reset without prompting. Default value is false, and user will be asked to confirm the operation. - - SwitchParameter - - SwitchParameter - - - False - - - Password - - Sets the provided Password to the newly reset store. If the reset store is not configured for password authentication, an error will be returned. - - SecureString - - SecureString - - - None - - - PassThru - - Writes the newly reset store configuration object (SecureStorConfig) to the pipeline. - - SwitchParameter - - SwitchParameter - - - False - - - PasswordTimeout - - Configuration option that provides the session password timeout in seconds. Takes an argument whose value determines the session password timeout in seconds. When the timeout value is reached, the current password value is invalidated for the session. - - Int32 - - Int32 - - - 900 - - - Scope - - Configuration option that determines SecretStore operation scope. Currently only 'CurrentUser' scope is supported. - - SecureStoreScope - - SecureStoreScope - - - CurrentUser - - - Interaction - - Configuration option to allow or suppress user prompting. Configuration options are 'Prompt' or 'None'. When 'None' is selected, no prompt will be presented in an interactive session to provide a session password. Default value is 'Prompt', and users will be prompted for password when needed. When 'None' is selected and a session password is required, a Microsoft.PowerShell.SecretStore.PasswordRequiredException error is thrown. - - Interaction - - Interaction - - - Prompt - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - SwitchParameter - - SwitchParameter - - - False - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - SwitchParameter - - SwitchParameter - - - False - - - - - - None - - - - - - - - - - Microsoft.PowerShell.SecretStore.SecureStoreConfig - - - - - - - - - - - - - - -------------------------- Example 1 -------------------------- - PS C:\> Reset-SecretStore -PassThru -WARNING: !!This operation will completely remove all SecretStore module secrets and reset configuration settings to default values!! - -Reset SecretStore -Are you sure you want to erase all secrets in SecretStore and reset configuration settings to default? -[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y -Creating a new Microsoft.PowerShell.SecretStore vault. A password is required by the current store configuration. -Enter password: -******** -Enter password again for verification: -******** - - Scope Authentication PasswordTimeout Interaction - ----- -------------- --------------- ----------- -CurrentUser Password 900 Prompt - - This example resets the SecretStore for the current user, by deleting all secrets and forcing configuration settings to default values. The user is warned of the consequences of this action and prompted to confirm before continuing. - - - - - - - - Set-SecretStoreConfiguration - Set - SecretStoreConfiguration - - Sets SecretStore configuration properties. - - - - This cmdlet takes individual parameter arguments that determine SecretStore configuration. Or the '-Default' parameter can be used to restore SecretStore configuration to default settings. - - - - Set-SecretStoreConfiguration - - Authentication - - Configuration option to set authentication for store access. Configuration options are 'Password' or 'None'. When 'Password' is selected, SecretStore is configured to require a password for accessing secrets. Default authentication is 'Password', as this provides the strongest protection of secret data. - - Authenticate - - Authenticate - - - Password - - - PassThru - - When used, will write the current SecretStore configuration to the pipeline. - - - SwitchParameter - - - False - - - Password - - Password to be applied when changing the authentication configuration. When changing the configuration from no password required to password required, the provided password will be set as the new store password. When changing the configuration from password required to no password required, the provided password will be used to authorize the configuration change, and must be the current password used to unlock the store. This command cannot be used to change the store password. To change an existing password, use the `Set-SecretStorePassword` command. - - SecureString - - SecureString - - - None - - - PasswordTimeout - - Configuration option that provides the session password timeout in seconds. Takes an argument whose value determines the session password timeout in seconds. When the timeout value is reached, the current password value is invalidated for the session. - - Int32 - - Int32 - - - None - - - Scope - - Configuration option that determines SecretStore operation scope. Currently only 'CurrentUser' scope is supported. - - - CurrentUser - AllUsers - - SecureStoreScope - - SecureStoreScope - - - None - - - Interaction - - Configuration option to allow or suppress user prompting. Configuration options are 'Prompt' or 'None'. When 'None' is selected, no prompt will be presented in an interactive session to provide a session password. Default value is 'Prompt', and users will be prompted for password when needed. When 'None' is selected and a session password is required, a Microsoft.PowerShell.SecretStore.PasswordRequiredException error is thrown. - - Interaction - - Interaction - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - - Set-SecretStoreConfiguration - - Default - - This parameter switch sets SecretStore configuration to its default settings. - - - SwitchParameter - - - False - - - PassThru - - When used, will write the current SecretStore configuration to the pipeline. - - - SwitchParameter - - - False - - - Password - - Password to be applied when changing the authentication configuration. When changing the configuration from no password required to password required, the provided password will be set as the new store password. When changing the configuration from password required to no password required, the provided password will be used to authorize the configuration change, and must be the current password used to unlock the store. This command cannot be used to change the store password. To change an existing password, use the `Set-SecretStorePassword` command. - - SecureString - - SecureString - - - None - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - - - - Authentication - - Configuration option to set authentication for store access. Configuration options are 'Password' or 'None'. When 'Password' is selected, SecretStore is configured to require a password for accessing secrets. Default authentication is 'Password', as this provides the strongest protection of secret data. - - Authenticate - - Authenticate - - - Password - - - Default - - This parameter switch sets SecretStore configuration to its default settings. - - SwitchParameter - - SwitchParameter - - - False - - - PassThru - - When used, will write the current SecretStore configuration to the pipeline. - - SwitchParameter - - SwitchParameter - - - False - - - Password - - Password to be applied when changing the authentication configuration. When changing the configuration from no password required to password required, the provided password will be set as the new store password. When changing the configuration from password required to no password required, the provided password will be used to authorize the configuration change, and must be the current password used to unlock the store. This command cannot be used to change the store password. To change an existing password, use the `Set-SecretStorePassword` command. - - SecureString - - SecureString - - - None - - - PasswordTimeout - - Configuration option that provides the session password timeout in seconds. Takes an argument whose value determines the session password timeout in seconds. When the timeout value is reached, the current password value is invalidated for the session. - - Int32 - - Int32 - - - None - - - Scope - - Configuration option that determines SecretStore operation scope. Currently only 'CurrentUser' scope is supported. - - SecureStoreScope - - SecureStoreScope - - - None - - - Interaction - - Configuration option to allow or suppress user prompting. Configuration options are 'Prompt' or 'None'. When 'None' is selected, no prompt will be presented in an interactive session to provide a session password. Default value is 'Prompt', and users will be prompted for password when needed. When 'None' is selected and a session password is required, a Microsoft.PowerShell.SecretStore.PasswordRequiredException error is thrown. - - Interaction - - Interaction - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - SwitchParameter - - SwitchParameter - - - False - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - SwitchParameter - - SwitchParameter - - - False - - - - - - None - - - - - - - - - - Microsoft.PowerShell.SecretStore.SecureStoreConfig - - - - - - - - - - - - - - -------------------------- Example 1 -------------------------- - PS C:\> Set-SecretStoreConfiguration -Default - -Confirm -Are you sure you want to perform this action? -Performing the operation "Changes local store configuration" on target "SecretStore module local store". -[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y - - Scope Authentication PasswordTimeout Interaction - ----- -------------- --------------- ----------- -CurrentUser Password 900 Prompt - - This example uses the command to restore the SecretStore configuration settings to their default values. - - - - -------------------------- Example 2 -------------------------- - Install-Module -Name Microsoft.PowerShell.SecretStore -Repository PSGallery -Force -$password = Import-CliXml -Path $securePasswordPath.xml -Set-SecretStoreConfiguration -Scope CurrentUser -Authentication Password -PasswordTimeout 3600 -Interaction None -Password $password -Confirm:$false - -Install-Module -Name Microsoft.PowerShell.SecretManagement -Repository PSGallery -Force -Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault - -Unlock-SecretStore -Password $password - - This is an example of automation script that installs and configures the Microsoft.PowerShell.SecretStore module without user prompting. The configuration requires a password and sets user interaction to None, so that SecretStore will never prompt the user. The configuration also requires a password, and the password is passed in as a SecureString object. The `-Confirm:false` parameter is used so that PowerShell will not prompt for confirmation. - Next, the SecretManagement module is installed and the SecretStore module registered so that the SecretStore secrets can be managed. - The `Unlock-SecretStore` cmdlet is used to unlock the SecretStore for this session. The password timeout was configured for 1 hour and SecretStore will remain unlocked in the session for that amount of time, after which it will need to be unlocked again before secrets can be accessed. - - - - -------------------------- Example 3 -------------------------- - PS C:\> Get-SecretStoreConfiguration - - Scope Authentication PasswordTimeout Interaction - ----- -------------- --------------- ----------- -CurrentUser Password 900 None - -PS C:\> Set-SecretStoreConfiguration -Authentication Password -Password $password -Set-SecretStoreConfiguration: The Microsoft.PowerShell.SecretStore is already configured to require a password, and a new password cannot be added. -Use the Set-SecretStorePassword cmdlet to change an existing password. - - This example attempts to set the SecretStore configuration to require a password and provides a new password. But this results in an error. This command cannot be used to change an existing password but only to toggle authentication to require or not require a password. To change an existing SecretStore password, use the `Set-SecretStorePassword` command. - - - - - - - - Set-SecretStorePassword - Set - SecretStorePassword - - Replaces the current SecretStore password with a new one. - - - - This cmdlet updates the password for SecretStore. It takes no parameters and prompts the user for both the old and new passwords. - - - - Set-SecretStorePassword - - NewPassword - - New password to be applied to the store. - - SecureString - - SecureString - - - None - - - Password - - Existing password needed to unlock the store. This can be ignored if the store doesn't currently use a password. - - SecureString - - SecureString - - - None - - - - - - NewPassword - - New password to be applied to the store. - - SecureString - - SecureString - - - None - - - Password - - Existing password needed to unlock the store. This can be ignored if the store doesn't currently use a password. - - SecureString - - SecureString - - - None - - - - - - None - - - - - - - - - - - - - - - -------------------------- Example 1 -------------------------- - PS C:\> Set-SecretStorePassword -Old password -Enter password: -******* -New password -Enter password: -******* -Enter password again for verification: -******* - - This example runs the command with no parameter arguments. The user is first prompted for the old password. And then prompted for the new password twice for verification. - - - - -------------------------- Example 2 -------------------------- - PS C:\> Set-SecretStorePassword -NewPassword $newPassword -Password $oldPassword - - This example runs the command passing in both the current store password and the new password to be set. - - - - - - - - Unlock-SecretStore - Unlock - SecretStore - - Unlocks SecretStore with the provided password. - - - - This cmdlet unlocks SecretStore for the current user with the provided password. It can be used to unlock SecretStore when the configuration requires a password and the prompt configuration option is disabled. The provided password will be applied to the current session, and will become invalid after the 'PasswordTimeout' time elapses. If no password is provided by parameter argument, the user will be safely prompted for the password. - - - - Unlock-SecretStore - - Password - - This parameter takes the password argument as a SecureString object. - - SecureString - - SecureString - - - None - - - PasswordTimeout - - This parameter takes a password timeout argument in seconds, and overrides the configuration password timeout value. The password timeout value remains in effect for the session until changed. - - Int32 - - Int32 - - - None - - - - - - Password - - This parameter takes the password argument as a SecureString object. - - SecureString - - SecureString - - - None - - - PasswordTimeout - - This parameter takes a password timeout argument in seconds, and overrides the configuration password timeout value. The password timeout value remains in effect for the session until changed. - - Int32 - - Int32 - - - None - - - - - - System.Security.SecureString - - - - - - - - - - - - - - - -------------------------- Example 1 -------------------------- - PS C:\> Get-Secret secret1 -Vault LocalStore -Get-Secret: A valid password is required to access the Microsoft.PowerShell.SecretStore vault. -Get-Secret: The secret secret1 was not found. - -PS C:\> Unlock-SecretStore - -cmdlet Unlock-SecretStore at command pipeline position 1 -Supply values for the following parameters: -SecureStringPassword: ******* - -PS C:\> Get-Secret secret1 -Vault LocalStore -System.Security.SecureString - - In this example, the SecretManagement 'Get-Secret' command fails to retrieve secret1 because the SecretStore vault is locked. The 'Unlock-SecretStore' command is run to unlock the vault. No password parameter argument was provided to the 'Unlock-SecretStore' command, so the user is prompted for the password. Running 'Get-Secret' again now works and returns the secret as a SecureString object. - - - - - - \ No newline at end of file diff --git a/help/en-US/about_Microsoft.PowerShell.SecretStore.md b/help/en-US/about_Microsoft.PowerShell.SecretStore.md deleted file mode 100644 index c63885c..0000000 --- a/help/en-US/about_Microsoft.PowerShell.SecretStore.md +++ /dev/null @@ -1,43 +0,0 @@ -# Secret Management local store extension vault module -## Microsoft.PowerShell.SecretStore - -# SHORT DESCRIPTION -This is an extension module for the Microsoft.PowerShell.SecretManagement module. -It stores secrets on the local machine in the current user account context. - -``` -ABOUT TOPIC NOTE: -About topics can be no longer than 80 characters wide when rendered to text. -Any topics greater than 80 characters will be automatically wrapped. -The generated about topic will be encoded UTF-8. -``` - -# LONG DESCRIPTION -{{ Long Description Placeholder }} - -## Optional Subtopics -{{ Optional Subtopic Placeholder }} - -# EXAMPLES -{{ Code or descriptive examples of how to leverage the functions described. }} - -# NOTE -{{ Note Placeholder - Additional information that a user needs to know.}} - -# TROUBLESHOOTING NOTE -{{ Troubleshooting Placeholder - Warns users of bugs}} - -{{ Explains behavior that is likely to change with fixes }} - -# SEE ALSO -{{ See also placeholder }} - -{{ You can also list related articles, blogs, and video URLs. }} - -# KEYWORDS -{{List alternate names or titles for this topic that readers might use.}} - -- {{ Keyword Placeholder }} -- {{ Keyword Placeholder }} -- {{ Keyword Placeholder }} -- {{ Keyword Placeholder }} diff --git a/package.config.json b/package.config.json deleted file mode 100644 index 8c4e551..0000000 --- a/package.config.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ModuleName": "Microsoft.PowerShell.SecretStore", - "Culture": "en-US", - "BuildOutputPath": "out", - "SignedOutputPath": "signed", - "HelpPath": "help", - "TestPath": "test", - "SourcePath": "src" -} From bf3bd2f92431fb4ce52af189a67f5ef3247d4762 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:58:59 -0700 Subject: [PATCH 2/4] Setup prerequisites for new build --- .config/tsaoptions.json | 8 ++++++ .gitignore | 27 +++++-------------- Directory.Build.props | 7 +++++ global.json | 7 +++++ nuget.config | 5 +--- ...soft.PowerShell.SecretStore.Extension.psd1 | 2 +- src/Microsoft.PowerShell.SecretStore.psd1 | 10 +++---- tools/installPSResources.ps1 | 14 ++++++++++ tools/updateVersion.ps1 | 24 +++++++++++++++++ 9 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 .config/tsaoptions.json create mode 100644 Directory.Build.props create mode 100644 global.json create mode 100644 tools/installPSResources.ps1 create mode 100644 tools/updateVersion.ps1 diff --git a/.config/tsaoptions.json b/.config/tsaoptions.json new file mode 100644 index 0000000..0ddd6c3 --- /dev/null +++ b/.config/tsaoptions.json @@ -0,0 +1,8 @@ +{ + "instanceUrl": "https://msazure.visualstudio.com", + "projectName": "One", + "areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell", + "notificationAliases": [ "andschwa@microsoft.com", "slee@microsoft.com" ], + "codebaseName": "PowerShell_SecretStore_20240920", + "tools": [ "CredScan", "PoliCheck", "BinSkim" ] +} diff --git a/.gitignore b/.gitignore index 9587ceb..2889050 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,6 @@ -_site/ -_themes/ -.DS_Store -.openpublishing.build.mdproj -.openpublishing.buildcore.ps1 -.optemp/ -*.orig -**/.ignore/** -dependentPackages/ -log/ -maml/ -**/obj/** -packages.config -packages/ -Tools/NuGet/ -updatablehelp/ -xhtml/ -**/settings.json -**/.vscode/** -**/out/** -**/bin/** +artifacts/ +module/ +bin/ +obj/ +out/ +testResults.xml diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..a7f895e --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,7 @@ + + + + true + 1.0.6 + + diff --git a/global.json b/global.json new file mode 100644 index 0000000..ee4995e --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "8.0.300", + "rollForward": "latestFeature", + "allowPrerelease": false + } +} diff --git a/nuget.config b/nuget.config index 6548586..f003b0f 100644 --- a/nuget.config +++ b/nuget.config @@ -2,9 +2,6 @@ - + - - - diff --git a/src/Microsoft.PowerShell.SecretStore.Extension/Microsoft.PowerShell.SecretStore.Extension.psd1 b/src/Microsoft.PowerShell.SecretStore.Extension/Microsoft.PowerShell.SecretStore.Extension.psd1 index e797a50..f5f4936 100644 --- a/src/Microsoft.PowerShell.SecretStore.Extension/Microsoft.PowerShell.SecretStore.Extension.psd1 +++ b/src/Microsoft.PowerShell.SecretStore.Extension/Microsoft.PowerShell.SecretStore.Extension.psd1 @@ -11,5 +11,5 @@ RootModule = 'Microsoft.PowerShell.SecretStore.Extension.psm1' RequiredAssemblies = '../Microsoft.PowerShell.SecretStore.dll' FunctionsToExport = @('Set-Secret','Set-SecretInfo','Get-Secret','Remove-Secret','Get-SecretInfo','Unlock-SecretVault','Test-SecretVault') - PrivateData = @{ PSData = @{ ProjectUri = 'https://github.com/powershell/secretstore' } } + PrivateData = @{ PSData = @{ ProjectUri = 'https://github.com/PowerShell/SecretStore' } } } diff --git a/src/Microsoft.PowerShell.SecretStore.psd1 b/src/Microsoft.PowerShell.SecretStore.psd1 index c5a0c0a..1ccfe4c 100644 --- a/src/Microsoft.PowerShell.SecretStore.psd1 +++ b/src/Microsoft.PowerShell.SecretStore.psd1 @@ -11,10 +11,10 @@ NestedModules = @('.\Microsoft.PowerShell.SecretStore.Extension') RequiredModules = @('Microsoft.PowerShell.SecretManagement') # Version number of this module. -ModuleVersion = '1.0.6' +ModuleVersion = '{{ModuleVersion}}' # Supported PSEditions -CompatiblePSEditions = @('Core') +CompatiblePSEditions = @('Desktop', 'Core') # ID used to uniquely identify this module GUID = '6b983e67-c297-431a-916c-f4ce24dd7bac' @@ -36,7 +36,7 @@ account context. The secrets are encrypted on file using .NET Crypto APIs. A pas in the default configuration. The configuration can be changed with the provided cmdlets. Go to GitHub for more information about this module and to submit issues: -https://github.com/powershell/SecretStore +https://github.com/PowerShell/SecretStore " # Minimum version of the PowerShell engine required by this module @@ -58,10 +58,10 @@ PrivateData = @{ Tags = @('SecretManagement') # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/SecretStore/blob/master/LICENSE' + LicenseUri = 'https://github.com/PowerShell/SecretStore/blob/main/LICENSE' # A URL to the main website for this project. - ProjectUri = 'https://github.com/powershell/secretstore' + ProjectUri = 'https://github.com/PowerShell/SecretStore' # A URL to an icon representing this module. # IconUri = '' diff --git a/tools/installPSResources.ps1 b/tools/installPSResources.ps1 new file mode 100644 index 0000000..6668cb4 --- /dev/null +++ b/tools/installPSResources.ps1 @@ -0,0 +1,14 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +param( + [ValidateSet("PSGallery", "CFS")] + [string]$PSRepository = "PSGallery" +) + +if ($PSRepository -eq "CFS" -and -not (Get-PSResourceRepository -Name CFS -ErrorAction SilentlyContinue)) { + Register-PSResourceRepository -Name CFS -Uri "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" +} + +Install-PSResource -Repository $PSRepository -TrustRepository -Name InvokeBuild +Install-PSResource -Repository $PSRepository -TrustRepository -Name platyPS +Install-PSResource -Repository $PSRepository -TrustRepository -Name Pester diff --git a/tools/updateVersion.ps1 b/tools/updateVersion.ps1 new file mode 100644 index 0000000..be75435 --- /dev/null +++ b/tools/updateVersion.ps1 @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +param( + [Parameter(Mandatory)] + [semver]$Version, + + [Parameter(Mandatory)] + [string]$Changes +) + +git diff --staged --quiet --exit-code +if ($LASTEXITCODE -ne 0) { + throw "There are staged changes in the repository. Please commit or reset them before running this script." +} + +$Path = "Directory.Build.props" +$f = Get-Content -Path $Path +$f = $f -replace '^(?\s+)(.+)(?)$', "`${prefix}${Version}`${suffix}" +$f | Set-Content -Path $Path +git add $Path + +git commit --edit --message v${Version}: $Changes" +" From b43393c395d5abcaf406d268aaabdd418c902621 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:08:15 -0700 Subject: [PATCH 3/4] Fix unit tests --- .github/workflows/ci-test.yml | 60 ++++ ...Microsoft.PowerShell.SecretStore.Tests.ps1 | 274 ++++++++---------- tools/installPSResources.ps1 | 1 + 3 files changed, 183 insertions(+), 152 deletions(-) create mode 100644 .github/workflows/ci-test.yml diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000..0472ffe --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,60 @@ +name: CI Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + merge_group: + types: [ checks_requested ] + +jobs: + ci: + name: pester + strategy: + matrix: + os: [ windows-latest, macos-latest, ubuntu-latest ] + runs-on: ${{ matrix.os }} + env: + DOTNET_NOLOGO: true + DOTNET_GENERATE_ASPNET_CERTIFICATE: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dotnet + uses: actions/setup-dotnet@v4 + with: + cache: true + cache-dependency-path: '**/*.csproj' + dotnet-version: 8.x + + - name: Install PSResources + run: ./tools/installPSResources.ps1 + shell: pwsh + + - name: Build and test + run: Invoke-Build -Configuration Release -Task Build, Package, Test + shell: pwsh + + - name: Test Windows PowerShell + run: | + Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck + Install-Module Microsoft.PowerShell.SecretManagement -Scope CurrentUser -Force -SkipPublisherCheck + Invoke-Pester Test + if: matrix.os == 'windows-latest' + shell: powershell + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: SecretStore-package-${{ matrix.os }} + path: out/**/*.nupkg + + - name: Upload test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: SecretStore-tests-${{ matrix.os }} + path: testResults.xml diff --git a/test/Microsoft.PowerShell.SecretStore.Tests.ps1 b/test/Microsoft.PowerShell.SecretStore.Tests.ps1 index d4230f6..6d1e964 100644 --- a/test/Microsoft.PowerShell.SecretStore.Tests.ps1 +++ b/test/Microsoft.PowerShell.SecretStore.Tests.ps1 @@ -1,151 +1,115 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { - +Describe "Test Microsoft.PowerShell.SecretStore module" { BeforeAll { - - if (($IsWindows -eq $true) -or ($PSVersionTable.PSVersion.Major -eq 5)) { - $IsWindowsPlatform = $true - } - else { - $IsWindowsPlatform = $false; - } - - if ((Get-Module -Name Microsoft.PowerShell.SecretManagement -ErrorAction Ignore) -eq $null) - { - Import-Module -Name Microsoft.PowerShell.SecretManagement - } - - if ((Get-Module -Name Microsoft.PowerShell.SecretStore -ErrorAction Ignore) -eq $null) - { - Import-Module -Name Microsoft.PowerShell.SecretStore - } - - <# - $choices = @( - [System.Management.Automation.Host.ChoiceDescription]::new('Yes'), - [System.Management.Automation.Host.ChoiceDescription]::new('No')) - $choice = $host.UI.PromptForChoice( - "!!! These tests will remove all secrets in the store for the current user !!!", - "Type 'Yes' to continue", - $choices, - 1) - if ($choice -eq 1) - { - # User choosed not to run tests - throw 'Tests aborted' - } - #> + Import-Module -Force -Name Microsoft.PowerShell.SecretManagement + Import-Module -Force -Name $PSScriptRoot/../module/Microsoft.PowerShell.SecretStore.psd1 # Reset the SecretStore and configure it for no-password access # This deletes all SecretStore data!! - Write-Warning "!!! These tests will remove all secrets in the store for the current user !!!" Reset-SecretStore -Scope CurrentUser -Authentication None -PasswordTimeout -1 -Interaction None -Force - $null = Set-SecretStoreConfiguration -Scope CurrentUser -Authentication None -PasswordTimeout -1 -Interaction None -Confirm:$false + Set-SecretStoreConfiguration -Scope CurrentUser -Authentication None -PasswordTimeout -1 -Interaction None -Confirm:$false } - Context "SecretStore file permission tests" { + AfterAll { + Remove-Module -Name Microsoft.PowerShell.SecretStore -Force -ErrorAction Ignore + Remove-Module -Name Microsoft.PowerShell.SecretManagement -Force -ErrorAction Ignore + } + Context "Windows SecretStore file permission tests" -Skip:($IsLinux -or $IsMacOS) { BeforeAll { - if ($IsWindowsPlatform) - { - $storePath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData) - $storePath = Join-Path -Path $storePath -ChildPath 'Microsoft\PowerShell\secretmanagement\localstore' - $storeConfigFilePath = Join-Path -Path $storePath -ChildPath 'storeconfig' - $storeFilePath = Join-Path -Path $storePath -ChildPath 'storefile' - $storeKeyFilePath = Join-Path -Path $storePath -ChildPath 'storeaux' - } - else - { - $storePath = Join-Path -Path "$home" -ChildPath '.secretmanagement/localstore' - $storeConfigFilePath = Join-Path -Path $storePath -ChildPath 'storeconfig' - $storeFilePath = Join-Path -Path $storePath -ChildPath 'storefile' - $storeKeyFilePath = Join-Path -Path $storePath -ChildPath 'storeaux' - } + $storePath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData) + $storePath = Join-Path -Path $storePath -ChildPath 'Microsoft\PowerShell\secretmanagement\localstore' + $storeConfigFilePath = Join-Path -Path $storePath -ChildPath 'storeconfig' + $storeFilePath = Join-Path -Path $storePath -ChildPath 'storefile' + $storeKeyFilePath = Join-Path -Path $storePath -ChildPath 'storeaux' + } + + It "Verifies SecretStore directory ACLs" { + $acl = Get-Acl $storePath + $acl.Access | Should -HaveCount 1 + $accessRule = $acl.Access[0] + + $accessRule.FileSystemRights | Should -BeExactly 'FullControl' + $accessRule.AccessControlType | Should -BeExactly 'Allow' + $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name + $accessRule.IsInherited | Should -BeFalse + $accessRule.InheritanceFlags | Should -BeExactly 'ContainerInherit, ObjectInherit' + $accessRule.PropagationFlags | Should -BeExactly 'None' + } + + It "Verifies SecretStore configuration file ACLs" { + $acl = Get-Acl $storeConfigFilePath + $acl.Access | Should -HaveCount 1 + $accessRule = $acl.Access[0] + + $accessRule.FileSystemRights | Should -BeExactly 'FullControl' + $accessRule.AccessControlType | Should -BeExactly 'Allow' + $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name + $accessRule.IsInherited | Should -BeTrue + $accessRule.InheritanceFlags | Should -BeExactly 'None' + $accessRule.PropagationFlags | Should -BeExactly 'None' + } + + It "Verifies SecretStore file ACLs" { + $acl = Get-Acl $storeFilePath + $acl.Access | Should -HaveCount 1 + $accessRule = $acl.Access[0] + + $accessRule.FileSystemRights | Should -BeExactly 'FullControl' + $accessRule.AccessControlType | Should -BeExactly 'Allow' + $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name + $accessRule.IsInherited | Should -BeTrue + $accessRule.InheritanceFlags | Should -BeExactly 'None' + $accessRule.PropagationFlags | Should -BeExactly 'None' + } + + It "Verifies SecretStore key file ACLs" { + $acl = Get-Acl $storeKeyFilePath + $acl.Access | Should -HaveCount 1 + $accessRule = $acl.Access[0] + + $accessRule.FileSystemRights | Should -BeExactly 'FullControl' + $accessRule.AccessControlType | Should -BeExactly 'Allow' + $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name + $accessRule.IsInherited | Should -BeTrue + $accessRule.InheritanceFlags | Should -BeExactly 'None' + $accessRule.PropagationFlags | Should -BeExactly 'None' } + } - if ($IsWindowsPlatform) - { - It "Verifies SecretStore directory ACLs" { - $acl = Get-Acl $storePath - $acl.Access | Should -HaveCount 1 - $accessRule = $acl.Access[0] - - $accessRule.FileSystemRights | Should -BeExactly 'FullControl' - $accessRule.AccessControlType | Should -BeExactly 'Allow' - $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name - $accessRule.IsInherited | Should -BeFalse - $accessRule.InheritanceFlags | Should -BeExactly 'ContainerInherit, ObjectInherit' - $accessRule.PropagationFlags | Should -BeExactly 'None' - } - - It "Verifies SecretStore configuration file ACLs" { - $acl = Get-Acl $storeConfigFilePath - $acl.Access | Should -HaveCount 1 - $accessRule = $acl.Access[0] - - $accessRule.FileSystemRights | Should -BeExactly 'FullControl' - $accessRule.AccessControlType | Should -BeExactly 'Allow' - $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name - $accessRule.IsInherited | Should -BeTrue - $accessRule.InheritanceFlags | Should -BeExactly 'None' - $accessRule.PropagationFlags | Should -BeExactly 'None' - } - - It "Verifies SecretStore file ACLs" { - $acl = Get-Acl $storeFilePath - $acl.Access | Should -HaveCount 1 - $accessRule = $acl.Access[0] - - $accessRule.FileSystemRights | Should -BeExactly 'FullControl' - $accessRule.AccessControlType | Should -BeExactly 'Allow' - $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name - $accessRule.IsInherited | Should -BeTrue - $accessRule.InheritanceFlags | Should -BeExactly 'None' - $accessRule.PropagationFlags | Should -BeExactly 'None' - } + Context "Linux and macOS file permission tests" -Skip:((-not $IsLinux) -and (-not $IsMacOS)) { + BeforeAll { + $storePath = Join-Path -Path "$home" -ChildPath '.secretmanagement/localstore' + $storeConfigFilePath = Join-Path -Path $storePath -ChildPath 'storeconfig' + $storeFilePath = Join-Path -Path $storePath -ChildPath 'storefile' + $storeKeyFilePath = Join-Path -Path $storePath -ChildPath 'storeaux' + } - It "Verifies SecretStore key file ACLs" { - $acl = Get-Acl $storeKeyFilePath - $acl.Access | Should -HaveCount 1 - $accessRule = $acl.Access[0] - - $accessRule.FileSystemRights | Should -BeExactly 'FullControl' - $accessRule.AccessControlType | Should -BeExactly 'Allow' - $accessRule.IdentityReference | Should -BeExactly ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name - $accessRule.IsInherited | Should -BeTrue - $accessRule.InheritanceFlags | Should -BeExactly 'None' - $accessRule.PropagationFlags | Should -BeExactly 'None' - } + # drwx------ 2 4096 Jun 30 16:03 + It "Verifies SecretStore directory permissions" { + $permissions = (ls -ld "$storePath").Split(' ') + $permissions[0] | Should -BeExactly 'drwx------' } - else - { - # drwx------ 2 4096 Jun 30 16:03 - It "Verifies SecretStore directory permissions" { - $permissions = (ls -ld "$storePath").Split(' ') - $permissions[0] | Should -BeExactly 'drwx------' - } - It "Verfies SecretStore configuration file permissions" { - $permissions = (ls -ld "$storeConfigFilePath").Split(' ') - $permissions[0] | Should -BeExactly '-rw-------' - } + It "Verfies SecretStore configuration file permissions" { + $permissions = (ls -ld "$storeConfigFilePath").Split(' ') + $permissions[0] | Should -BeExactly '-rw-------' + } - It "Verifes SecretStore file permissions" { - $permissions = (ls -ld "$storeFilePath").Split(' ') - $permissions[0] | Should -BeExactly '-rw-------' - } + It "Verifes SecretStore file permissions" { + $permissions = (ls -ld "$storeFilePath").Split(' ') + $permissions[0] | Should -BeExactly '-rw-------' + } - It "Verifes SecretStore key file permissions" { - $permissions = (ls -ld "$storeKeyFilePath").Split(' ') - $permissions[0] | Should -BeExactly '-rw-------' - } + It "Verifes SecretStore key file permissions" { + $permissions = (ls -ld "$storeKeyFilePath").Split(' ') + $permissions[0] | Should -BeExactly '-rw-------' } } Context "SecretStore Vault cmdlet tests" { - It "Verifies SecretStore configuration for tests" { $config = Get-SecretStoreConfiguration $config.Scope | Should -BeExactly "CurrentUser" @@ -166,9 +130,10 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { # Setting and retrieving additional metadata. Context "SecretStore metadata function" { - - $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) - $secretContent = "TestStoreString" + BeforeAll { + $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + $secretContent = "TestStoreString" + } It "Verifies writing metadata along with secret content" { $errorMsg = "" @@ -180,7 +145,7 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { $success | Should -BeTrue $errorMsg | Should -BeNullOrEmpty - # + $outInfo = $null $success = [Microsoft.PowerShell.SecretStore.LocalSecretStore]::GetInstance().EnumerateObjectInfo( $secretName, @@ -200,7 +165,7 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { [ref] $errorMsg) $success | Should -BeTrue $errorMsg | Should -BeNullOrEmpty - # + $outInfo = $null $success = [Microsoft.PowerShell.SecretStore.LocalSecretStore]::GetInstance().EnumerateObjectInfo( $secretName, @@ -241,10 +206,11 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { } Context "SecretStore Vault Byte[] type" { - - $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) - $bytesToWrite = [System.Text.Encoding]::UTF8.GetBytes("TestBytesStringToTest") - $errorMsg = "" + BeforeAll { + $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + $bytesToWrite = [System.Text.Encoding]::UTF8.GetBytes("TestBytesStringToTest") + $errorMsg = "" + } It "Verifies byte[] write to SecretStore" { $success = [Microsoft.PowerShell.SecretStore.LocalSecretStore]::GetInstance().WriteObject( @@ -300,10 +266,11 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { } Context "SecretStore Vault String type" { - - $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) - $stringToWrite = "TestStoreString" - $errorMsg = "" + BeforeAll { + $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + $stringToWrite = "TestStoreString" + $errorMsg = "" + } It "Verifes String write to SecretStore" { $success = [Microsoft.PowerShell.SecretStore.LocalSecretStore]::GetInstance().WriteObject( @@ -359,11 +326,12 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { } Context "SecretStore Vault SecureString type" { - - $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) - $randomSecret = [System.IO.Path]::GetRandomFileName() - $secureStringToWrite = ConvertTo-SecureString -String $randomSecret -AsPlainText -Force - $errorMsg = "" + BeforeAll { + $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + $randomSecret = [System.IO.Path]::GetRandomFileName() + $secureStringToWrite = ConvertTo-SecureString -String $randomSecret -AsPlainText -Force + $errorMsg = "" + } It "Verifies SecureString write to SecretStore" { $success = [Microsoft.PowerShell.SecretStore.LocalSecretStore]::GetInstance().WriteObject( @@ -420,10 +388,11 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { } Context "SecretStore Vault PSCredential type" { - - $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) - $randomSecret = [System.IO.Path]::GetRandomFileName() - $errorMsg = "" + BeforeAll { + $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + $randomSecret = [System.IO.Path]::GetRandomFileName() + $errorMsg = "" + } It "Verifies PSCredential type write to SecretStore" { $cred = [pscredential]::new('UserL', (ConvertTo-SecureString $randomSecret -AsPlainText -Force)) @@ -482,11 +451,12 @@ Describe "Test Microsoft.PowerShell.SecretStore module" -tags CI { } Context "SecretStore Vault Hashtable type" { - - $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) - $randomSecretA = [System.IO.Path]::GetRandomFileName() - $randomSecretB = [System.IO.Path]::GetRandomFileName() - $errorMsg = "" + BeforeAll { + $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + $randomSecretA = [System.IO.Path]::GetRandomFileName() + $randomSecretB = [System.IO.Path]::GetRandomFileName() + $errorMsg = "" + } It "Verifies Hashtable type write to SecretStore" { $ht = @{ diff --git a/tools/installPSResources.ps1 b/tools/installPSResources.ps1 index 6668cb4..3745f82 100644 --- a/tools/installPSResources.ps1 +++ b/tools/installPSResources.ps1 @@ -12,3 +12,4 @@ if ($PSRepository -eq "CFS" -and -not (Get-PSResourceRepository -Name CFS -Error Install-PSResource -Repository $PSRepository -TrustRepository -Name InvokeBuild Install-PSResource -Repository $PSRepository -TrustRepository -Name platyPS Install-PSResource -Repository $PSRepository -TrustRepository -Name Pester +Install-PSResource -Repository $PSRepository -TrustRepository -Name Microsoft.PowerShell.SecretManagement From dd8e1cd8d15c1582d8e4636d2e61adfd12012c63 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:52:20 -0700 Subject: [PATCH 4/4] Setup Invoke-Build and OneBranch pipeline --- .pipelines/SecretStore-Official.yml | 173 ++++++++++++++++++ SecretStore.build.ps1 | 81 ++++++++ .../Microsoft.PowerShell.SecretStore.csproj | 13 +- 3 files changed, 261 insertions(+), 6 deletions(-) create mode 100644 .pipelines/SecretStore-Official.yml create mode 100644 SecretStore.build.ps1 diff --git a/.pipelines/SecretStore-Official.yml b/.pipelines/SecretStore-Official.yml new file mode 100644 index 0000000..d3d3b8c --- /dev/null +++ b/.pipelines/SecretStore-Official.yml @@ -0,0 +1,173 @@ +################################################################################# +# OneBranch Pipelines # +# This pipeline was created by EasyStart from a sample located at: # +# https://aka.ms/obpipelines/easystart/samples # +# Documentation: https://aka.ms/obpipelines # +# Yaml Schema: https://aka.ms/obpipelines/yaml/schema # +# Retail Tasks: https://aka.ms/obpipelines/tasks # +# Support: https://aka.ms/onebranchsup # +################################################################################# + +trigger: +- main + +schedules: +- cron: '23 16 * * 4' + displayName: Weekly CodeQL + branches: + include: + - main + always: true + +parameters: +- name: debug + displayName: Enable debug output + type: boolean + default: false + +variables: + system.debug: ${{ parameters.debug }} + BuildConfiguration: Release + WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest + DOTNET_NOLOGO: true + DOTNET_GENERATE_ASPNET_CERTIFICATE: false + +resources: + repositories: + - repository: templates + type: git + name: OneBranch.Pipelines/GovernedTemplates + ref: refs/heads/main + +extends: + # https://aka.ms/obpipelines/templates + template: v2/OneBranch.Official.CrossPlat.yml@templates + parameters: + globalSdl: # https://aka.ms/obpipelines/sdl + asyncSdl: + enabled: true + forStages: [build] + featureFlags: + EnableCDPxPAT: false + WindowsHostVersion: + Version: 2022 + Network: Netlock + stages: + - stage: build + jobs: + - job: main + displayName: Build package + pool: + type: windows + variables: + ob_outputDirectory: $(Build.SourcesDirectory)/out + steps: + - pwsh: | + [xml]$xml = Get-Content Directory.Build.props + $version = $xml.Project.PropertyGroup.ModuleVersion + Write-Output "##vso[task.setvariable variable=version;isOutput=true]$version" + name: package + displayName: Get version from project properties + - task: onebranch.pipeline.version@1 + displayName: Set OneBranch version + inputs: + system: Custom + customVersion: $(package.version) + - task: UseDotNet@2 + displayName: Use .NET SDK + inputs: + packageType: sdk + useGlobalJson: true + - pwsh: | + Register-PSRepository -Name CFS -SourceLocation "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v2" -InstallationPolicy Trusted + Install-Module -Repository CFS -Name Microsoft.PowerShell.PSResourceGet + ./tools/installPSResources.ps1 -PSRepository CFS + displayName: Install PSResources + - pwsh: Invoke-Build -Configuration $(BuildConfiguration) -Task Build, Test + displayName: Build + - task: onebranch.pipeline.signing@1 + displayName: Sign 1st-party files in module + inputs: + command: sign + signing_profile: external_distribution + search_root: $(Build.SourcesDirectory)/module + files_to_sign: | + Microsoft.*.dll; + **/Microsoft.*.psd1; + **/Microsoft.*.psm1; + - task: ArchiveFiles@2 + displayName: Zip module + inputs: + rootFolderOrFile: $(Build.SourcesDirectory)/module + includeRootFolder: false + archiveType: zip + archiveFile: out/SecretStore-v$(package.version).zip + - pwsh: Invoke-Build -Configuration $(BuildConfiguration) Package + displayName: Package module + - task: onebranch.pipeline.signing@1 + displayName: Sign NuGet package + inputs: + command: sign + signing_profile: external_distribution + search_root: $(Build.SourcesDirectory)/out + files_to_sign: | + *.nupkg + - stage: release + dependsOn: build + condition: eq(variables['Build.Reason'], 'Manual') + variables: + version: $[ stageDependencies.build.main.outputs['package.version'] ] + drop: $(Pipeline.Workspace)/drop_build_main + jobs: + - job: github + displayName: Publish draft to GitHub + pool: + type: windows + variables: + ob_outputDirectory: $(Build.SourcesDirectory)/out + steps: + - download: current + displayName: Download artifacts + - task: GitHubRelease@1 + displayName: Create GitHub release + inputs: + gitHubConnection: GitHub + repositoryName: PowerShell/SecretStore + assets: | + $(drop)/Microsoft.PowerShell.SecretStore.$(version).nupkg + $(drop)/SecretStore-v$(version).zip + tagSource: userSpecifiedTag + tag: v$(version) + isDraft: true + addChangeLog: false + releaseNotesSource: inline + releaseNotesInline: "" + - job: validation + displayName: Manual validation + pool: + type: agentless + timeoutInMinutes: 1440 + steps: + - task: ManualValidation@0 + displayName: Wait 24 hours for validation + inputs: + notifyUsers: $(Build.RequestedForEmail) + instructions: Please validate the release and then publish it! + timeoutInMinutes: 1440 + - job: publish + dependsOn: validation + displayName: Publish to PowerShell Gallery + pool: + type: windows + variables: + ob_outputDirectory: $(Build.SourcesDirectory)/out + steps: + - download: current + displayName: Download artifacts + - task: NuGetCommand@2 + displayName: Publish module to PowerShell Gallery + inputs: + command: push + packagesToPush: $(drop)/Microsoft.PowerShell.SecretStore.$(version).nupkg + nuGetFeedType: external + publishFeedCredentials: PowerShellGallery diff --git a/SecretStore.build.ps1 b/SecretStore.build.ps1 new file mode 100644 index 0000000..fec96d6 --- /dev/null +++ b/SecretStore.build.ps1 @@ -0,0 +1,81 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +[CmdletBinding()] +param( + [ValidateSet("Debug", "Release")] + [string]$Configuration = "Debug" +) + +#Requires -Modules @{ ModuleName = "InvokeBuild"; ModuleVersion = "5.0.0" } + +task FindDotNet -Before Clean, Build { + Assert (Get-Command dotnet -ErrorAction SilentlyContinue) "The dotnet CLI was not found, please install it: https://aka.ms/dotnet-cli" + $DotnetVersion = dotnet --version + Assert ($?) "The required .NET SDK was not found, please install it: https://aka.ms/dotnet-cli" + Write-Host "Using dotnet $DotnetVersion at path $((Get-Command dotnet).Source)" -ForegroundColor Green +} + +task Clean { + Remove-BuildItem ./artifacts, ./module, ./out + Invoke-BuildExec { dotnet clean ./src/code } +} + +task BuildDocs -If { Test-Path -LiteralPath ./help } { + New-ExternalHelp -Path ./help -OutputPath ./module/en-US +} + +task BuildModule { + New-Item -ItemType Directory -Force ./module | Out-Null + + Invoke-BuildExec { dotnet publish ./src/code -c $Configuration } + + $FullModuleName = "Microsoft.PowerShell.SecretStore" + + $CSharpArtifacts = @( + "$FullModuleName.dll", + "$FullModuleName.pdb", + "System.IO.FileSystem.AccessControl.dll", + "System.Runtime.InteropServices.RuntimeInformation.dll") + + $CSharpArtifacts | ForEach-Object { + $item = "./artifacts/publish/$FullModuleName/$($Configuration.ToLower())/$_" + Copy-Item -Force -LiteralPath $item -Destination ./module + } + + $BaseArtifacts = @( + "README.md", + "LICENSE", + "ThirdPartyNotices.txt") + + $BaseArtifacts | ForEach-Object { + $itemToCopy = Join-Path $PSScriptRoot $_ + Copy-Item -Force -LiteralPath $itemToCopy -Destination ./module + } + + Copy-Item -Force -Recurse "./src/$FullModuleName.Extension/" -Destination ./module + + [xml]$xml = Get-Content Directory.Build.props + $moduleVersion = $xml.Project.PropertyGroup.ModuleVersion + $manifestContent = Get-Content -LiteralPath "./src/$FullModuleName.psd1" -Raw + $newManifestContent = $manifestContent -replace '{{ModuleVersion}}', $moduleVersion + Set-Content -LiteralPath "./module/$FullModuleName.psd1" -Encoding utf8 -Value $newManifestContent +} + +task Package { + New-Item -ItemType Directory -Force ./out | Out-Null + + try { + Register-PSResourceRepository -Name SecretStore -Uri ./out -ErrorAction Stop + Publish-PSResource -Path ./module -Repository SecretStore -SkipDependenciesCheck -Verbose + } finally { + Unregister-PSResourceRepository -Name SecretStore + } +} + +task Test { + Invoke-Pester -CI -Output Diagnostic +} + +task Build BuildModule, BuildDocs + +task . Clean, Build diff --git a/src/code/Microsoft.PowerShell.SecretStore.csproj b/src/code/Microsoft.PowerShell.SecretStore.csproj index 0ec068d..1e5287a 100644 --- a/src/code/Microsoft.PowerShell.SecretStore.csproj +++ b/src/code/Microsoft.PowerShell.SecretStore.csproj @@ -2,20 +2,21 @@ + true Library Microsoft.PowerShell.SecretStore Microsoft.PowerShell.SecretStore - 1.0.6.0 - 1.0.6 - 1.0.6 - net461 + $(ModuleVersion).0 + $(ModuleVersion) + $(ModuleVersion) + net462 - - + +