Skip to content

Commit

Permalink
Merge pull request #15 from joshcorr/bump-secretmanagement
Browse files Browse the repository at this point in the history
Bump secretmanagement to 1.1.0
  • Loading branch information
joshcorr authored Aug 5, 2021
2 parents 21399a7 + aaaf05a commit bbed87f
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .github/linters/.powershell-psscriptanalyzer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
IncludeDefaultRules = ${true}
ExcludeRules = @(
'PSUseShouldProcessForStateChangingFunctions',
'PSAvoidUsingConvertToSecureStringWithPlainText'
'PSAvoidUsingConvertToSecureStringWithPlainText',
'PSUseDeclaredVarsMoreThanAssignments'

)
#IncludeRules = @(
# 'PSAvoidUsingWriteHost',
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
pull_request:
types: [closed]
branches:
- main
- main
push:
branches:
- main
- main

jobs:
publish:
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Build Module
shell: pwsh
run: |
Copy-Item -path src/ -Destination /tmp/artifacts/SecretManagement.Hashicorp.Vault.KV/ -Recurse -Force
Copy-Item -path SecretManagement.Hashicorp.Vault.KV/ -Destination /tmp/artifacts/SecretManagement.Hashicorp.Vault.KV/ -Recurse -Force
# No need for artifacts yet
# - name: Create Artifact
# if: ${{ success() }}
Expand All @@ -56,7 +56,6 @@ jobs:
NUGET_KEY: ${{ secrets.NUGET_APIKEY }}
run: |
Publish-Module -Path /tmp/artifacts/SecretManagement.Hashicorp.Vault.KV -NuGetApiKey $env:NUGET_KEY
# Need to figure out tagging in pipeline first
# - name: "Release"
# uses: ncipollo/release-action@v1
Expand All @@ -65,4 +64,4 @@ jobs:
# tag: ${{ env.tag }}
# prerelease: ${{ env.prerelease }}
# bodyFile: "body.md"
# token: ${{ secrets.GITHUB_TOKEN }}
# token: ${{ secrets.GITHUB_TOKEN }}
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: test
on:
pull_request:
branches:
- main
- development
- main
- development

jobs:
lint:
Expand Down Expand Up @@ -46,6 +46,11 @@ jobs:
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Microsoft.PowerShell.SecretManagement -ErrorAction Stop
Install-Module -Name Pester -MinimumVersion 5.2.0 -ErrorAction Stop
- name: Perform the import
shell: pwsh
run: Import-Module ./src/SecretManagement.Hashicorp.Vault.KV.Extension/SecretManagement.Hashicorp.Vault.KV.Extension.psd1 -ErrorAction Stop; (Get-Command -Module SecretManagement.Hashicorp.Vault.KV.Extension) -ne $null
run: Import-Module ./SecretManagement.Hashicorp.Vault.KV/SecretManagement.Hashicorp.Vault.KV.Extension/SecretManagement.Hashicorp.Vault.KV.Extension.psd1 -ErrorAction Stop
- name: Execute Pester Tests
shell: pwsh
run: |
Invoke-Pester ./tests/* -Output Detailed
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,64 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.1.0] - 2021-08-04

Tested with SecretManagement 1.1.0 [#14](https://github.com/joshcorr/SecretManagement.Hashicorp.Vault.KV/issues/14)
Adding tests

## [1.0.2] - 2021-06-10

Default to Hashtable output.

## [1.0.1] - 2021-06-04

Improve Logging. Make Health Checks optional.
Suggested by [Mounting to an existing path in Vault #7](https://github.com/joshcorr/SecretManagement.Hashicorp.Vault.KV/issues/7)

## [1.0.0] - 2021-06-04

Update About; remove Preview Tag

## [0.0.11] - 2021-03-16

More Bug fixes

## [0.0.10] - 2021-03-16

Fix login logic bug

## [0.0.9] - 2021-03-15

Better Token Management; Retrieving Metadata

## [0.0.8] - 2021-03-13

Support Hashtable; Creating Metadata; Removing Vaults

## [0.0.7] - 2021-03-09

Create New Vault; Fix Test-SecretVault

## [0.0.6] - 2021-03-08

Required Secrets Version; Fix folder structure

## [0.0.5] - 2021-03-08

Version Bump

## [0.0.4] - 2021-03-08

More Github Actions changes

## [0.0.3] - 2021-03-08

Github Actions changes

## [0.0.2] - 2021-03-08

Fixes for SecretsManagement RC1

## [0.0.1] - 2020-10-27
Initial Preview Release

Initial Preview Release
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ This module is an extension for [Microsoft.PowerShell.SecretManagement](https://
- Writing Tests

### Ground Rules

Here are some guidelines for Pull Requests (PR) in this project.

- All PRs to Development must have an issue
- PRs must pass PSscriptAnalyzer and Pester tests before being merged
- Keep PRs limited to as few files as possible (if major change 1-to-1 PR)

### Your First Contribution

If this is your first time contributing to an opensource project, welcome! Here are some helpful tips for your first PR.

- Look for items marked as "good first issue" (these usually only require a few easy changes)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SecretManagement.Hashicorp.Vault.KV

[![GitHubSuper-Linter][]][GitHubSuper-LinterLink]
[![PSGallery][]][PSGalleryLink]

Expand All @@ -9,10 +10,13 @@ A PowerShell SecretManagement extension for Hashicorp Vault Key Value (KV) Engin
> If Hashicorp would like to adopt this module please reach out.
## QuickStart

When registering a vault you need to provide at least these options:

```PowerShell
Register-SecretVault -ModuleName SecretManagement.Hashicorp.Vault.KV -Name PowerShellTest -VaultParameters @{ VaultServer = 'http://vault.domain.local:8200'; VaultAuthType = 'Token'}
```

The vault name should match exactly as Hashicorp vault is case sensitive. If no VaultParameters are provided the functions will prompt you on the first execution in your session. Additionally you may provide which version of KV you are using when registering. It defaults to version 2 of KV.

```PowerShell
Expand All @@ -23,22 +27,24 @@ $VaultParameters = @{ VaultServer = 'https://vault-cluster.domain.local'

If you stored your secrets in a flat structure (i.e. no slashes in your path).
You may want to return all secrets as a PSCredential. You can do this by providing the following:

```powershell
$VaultParameters @{ ...
OutputType = 'PSCredential'
}
```

The Default is to return it as a Hashtable.

You may provide either a single text string or a hashtable to the `-Secret` parameter.

## KV Version 2 distinctions

- Get-Secret only retrieves the newest secret
- Get-SecretInfo retrieves the Hashicorp Metadata.
- Set-Secret Adds/Updates without CheckAndSet. Althought it can be passed with `-Metadata @{cas=<versionNumber>}`
- Remove-Secret Completely Removes the secret and all versions


[GitHubSuper-Linter]: https://github.com/joshcorr/SecretManagement.Hashicorp.Vault.KV/workflows/ci/badge.svg
[GitHubSuper-LinterLink]: https://github.com/marketplace/actions/super-linter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '1.0.2'
ModuleVersion = '1.1.0'
RootModule = 'SecretManagement.Hashicorp.Vault.KV.Extension.psm1'
FunctionsToExport = @('Set-Secret', 'Get-Secret', 'Remove-Secret', 'Get-SecretInfo', 'Test-SecretVault', 'Unregister-SecretVault')
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@{
ModuleVersion = '1.0.2'
ModuleVersion = '1.1.0'
CompatiblePSEditions = @('Desktop', 'Core')
GUID = '5dbf943d-d9c0-4db5-88a2-1995043a6305'
Author = 'Josh Corrick'
Copyright = '(c) 2021 Josh Corrick. All rights reserved.'
Description = 'A PowerShell SecretManagement extension for Hashicorp Vault Key Value Engine'
RequiredModules = @(@{ModuleName = "Microsoft.PowerShell.SecretManagement"; ModuleVersion = "1.0.0"; GUID = "a5c858f6-4a8e-41f1-b1ee-0ff8f6ad69d3" })
#RequiredModules = @(@{ModuleName = "Microsoft.PowerShell.SecretManagement"; ModuleVersion = "1.1.0"; GUID = "a5c858f6-4a8e-41f1-b1ee-0ff8f6ad69d3" })
NestedModules = './SecretManagement.Hashicorp.Vault.KV.Extension'
PowershellVersion = '5.1'
FunctionsToExport = @()
Expand All @@ -16,7 +16,7 @@

PSData = @{
# Prerelease string of this module
Prerelease = 'Preview'
# Prerelease = 'Preview'
Tags = 'SecretManagement', 'HashiCorp', 'Secret', 'Vault', 'MacOS', 'Linux', 'Windows'
ExternalModuleDependencies = @('Microsoft.PowerShell.SecretManagement')
LicenseUri = 'https://raw.githubusercontent.com/joshcorr/SecretManagement.Hashicorp.Vault.KV/main/LICENSE'
Expand Down
23 changes: 23 additions & 0 deletions tests/SecretManagement.Hashicorp.Vault.KV.Extension.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
BeforeDiscovery {
$s = [io.path]::DirectorySeparatorChar
$ModulePath = $PSScriptRoot, '..' -join $s
$Folder = (Get-Item $ModulePath).FullName
$File = ($PSCommandPath).Replace('.Tests.ps1', '.psd1').Split($s)[-1]
$ModuleName = ($PSCommandPath).Replace('.Tests.ps1', '').Split($s)[-1]
$Path = $Folder, $ModuleName, $File -join $s
$Extension = Get-ChildItem -Path . -Include *.psm1 -Recurse
Import-Module $Extension.FullName
$commands = Get-Command -Module $Extension.BaseName
}
AfterAll {
$Extension = Get-ChildItem -Path . -Include *.psm1 -Recurse
Remove-Module -Name $Extension.BaseName -Force -ErrorAction SilentlyContinue
}
describe "Extension loading" {
It "Should load the Extension $ModuleName" {
Get-Module -Name 'SecretManagement.Hashicorp.Vault.KV.Extension' | Should -Not -Be $null
}
It "Should have <_> function loaded" -foreach $Commands {
(Get-Command -Name $PSItem).Name | Should -Be "$PSItem"
}
}
17 changes: 17 additions & 0 deletions tests/SecretManagement.Hashicorp.Vault.KV.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BeforeDiscovery {
$s = [io.path]::DirectorySeparatorChar
$ModuleName = ($PSCommandPath).Replace('.Tests.ps1', '').Split($s)[-1]
}

describe "SecretManagement Usage with $ModuleName" {
beforeall {
mock -CommandName Read-Host -MockWith {"yes"}
}
It "Should register the vault 'pester'" {
$VaultParameters = @{ VaultServer = 'http://127.0.0.1:8200'; VaultToken = $(ConvertTo-SecureString -AsPlainText -Force -String 'root'| ConvertFrom-SecureString); VaultAuthType = 'Token'; KVVersion = 'v2'}
{Register-SecretVault -ModuleName SecretManagement.Hashicorp.Vault.KV -Name pester -VaultParameters $VaultParameters} | Should -Not -Throw
}
It "Should fail to unregister the vault 'pester'" {
{Unregister-SecretVault -Name pester -ErrorAction Stop} | Should -Throw
}
}

0 comments on commit bbed87f

Please sign in to comment.