mirror of
https://github.com/hashicorp/vault-action.git
synced 2026-07-29 09:53:15 +03:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c2d817b85 | |||
| b477844b5f | |||
| 9f522b8598 | |||
| efab57ede0 | |||
| d523bb05b2 | |||
| 11845b19f6 | |||
| 7a6258bb0b | |||
| a0b66b1cc3 | |||
| c616aba63e | |||
| e3d5714d59 | |||
| 00bce0da9c | |||
| 6853090cd9 | |||
| 45dc5344f1 | |||
| 2fb925f14c | |||
| caba6efd0e |
+26
-1
@@ -1,6 +1,31 @@
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
* Add changes here
|
## 2.8.1 (February 15, 2024)
|
||||||
|
|
||||||
|
Bugs:
|
||||||
|
|
||||||
|
* Revert [GH-509](https://github.com/hashicorp/vault-action/pull/509) which made a backwards incompatible bump of the node runtime from node16 to node20 [GH-527](https://github.com/hashicorp/vault-action/pull/527)
|
||||||
|
|
||||||
|
## 2.8.0 (February 1, 2024)
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
* Add `ignoreNotFound` input (default: false) to prevent the action from failing when a secret does not exist [GH-518](https://github.com/hashicorp/vault-action/pull/518)
|
||||||
|
|
||||||
|
Improvements:
|
||||||
|
|
||||||
|
* bump jsrsasign from 10.8.6 to 11.0.0 [GH-513](https://github.com/hashicorp/vault-action/pull/513)
|
||||||
|
* bump @actions/core from 1.10.0 to 1.10.1 [GH-489](https://github.com/hashicorp/vault-action/pull/489)
|
||||||
|
* bump jest-when from 3.5.2 to 3.6.0 [GH-484](https://github.com/hashicorp/vault-action/pull/484)
|
||||||
|
* bump jest from 29.5.0 to 29.7.0 [GH-490](https://github.com/hashicorp/vault-action/pull/490)
|
||||||
|
* bump @vercel/ncc from 0.36.1 to 0.38.1 [GH-503](https://github.com/hashicorp/vault-action/pull/503)
|
||||||
|
|
||||||
|
## 2.7.5 (January 30, 2024)
|
||||||
|
|
||||||
|
Improvements:
|
||||||
|
|
||||||
|
* Bump node runtime from node16 to node20 [GH-509](https://github.com/hashicorp/vault-action/pull/509)
|
||||||
|
* Bump got from 11.8.5 to 11.8.6 [GH-492](https://github.com/hashicorp/vault-action/pull/492)
|
||||||
|
|
||||||
## 2.7.4 (October 26, 2023)
|
## 2.7.4 (October 26, 2023)
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
A helper action for easily pulling secrets from HashiCorp Vault™.
|
A helper action for easily pulling secrets from HashiCorp Vault™.
|
||||||
|
|
||||||
|
Note: The Vault Github Action is a read-only action, and in general
|
||||||
|
is not meant to modify Vault’s state.
|
||||||
|
|
||||||
<!-- TOC -->
|
<!-- TOC -->
|
||||||
|
|
||||||
- [Vault GitHub Action](#vault-github-action)
|
- [Vault GitHub Action](#vault-github-action)
|
||||||
@@ -22,6 +25,7 @@ A helper action for easily pulling secrets from HashiCorp Vault™.
|
|||||||
- [Userpass](#userpass)
|
- [Userpass](#userpass)
|
||||||
- [Ldap](#ldap)
|
- [Ldap](#ldap)
|
||||||
- [Other Auth Methods](#other-auth-methods)
|
- [Other Auth Methods](#other-auth-methods)
|
||||||
|
- [Custom Path](#custom-path-name)
|
||||||
- [Key Syntax](#key-syntax)
|
- [Key Syntax](#key-syntax)
|
||||||
- [Simple Key](#simple-key)
|
- [Simple Key](#simple-key)
|
||||||
- [Set Output Variable Name](#set-output-variable-name)
|
- [Set Output Variable Name](#set-output-variable-name)
|
||||||
@@ -297,6 +301,20 @@ with:
|
|||||||
If any other method is specified and you provide an `authPayload`, the action will
|
If any other method is specified and you provide an `authPayload`, the action will
|
||||||
attempt to `POST` to `auth/${method}/login` with the provided payload and parse out the client token.
|
attempt to `POST` to `auth/${method}/login` with the provided payload and parse out the client token.
|
||||||
|
|
||||||
|
### Custom Path Name
|
||||||
|
|
||||||
|
Auth methods at custom path names can be configured using the [`path`](#path) parameter
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
with:
|
||||||
|
url: https://vault.mycompany.com:8200
|
||||||
|
caCertificate: ${{ secrets.VAULT_CA_CERT }}
|
||||||
|
path: my-custom-path
|
||||||
|
method: userpass
|
||||||
|
username: ${{ secrets.VAULT_USERNAME }}
|
||||||
|
password: ${{ secrets.VAULT_PASSWORD }}
|
||||||
|
```
|
||||||
|
|
||||||
## Key Syntax
|
## Key Syntax
|
||||||
|
|
||||||
The `secrets` parameter is a set of multiple secret requests separated by the `;` character.
|
The `secrets` parameter is a set of multiple secret requests separated by the `;` character.
|
||||||
@@ -631,6 +649,13 @@ Base64 encoded client key the action uses to authenticate with Vault when mTLS i
|
|||||||
|
|
||||||
When set to true, disables verification of server certificates when testing the action.
|
When set to true, disables verification of server certificates when testing the action.
|
||||||
|
|
||||||
|
### `ignoreNotFound`
|
||||||
|
|
||||||
|
**Type: `string`**\
|
||||||
|
**Default: `false`**
|
||||||
|
|
||||||
|
When set to true, prevents the action from failing when a secret does not exist.
|
||||||
|
|
||||||
## Masking - Hiding Secrets from Logs
|
## Masking - Hiding Secrets from Logs
|
||||||
|
|
||||||
This action uses GitHub Action's built-in masking, so all variables will automatically be masked (aka hidden) if printed to the console or to logs.
|
This action uses GitHub Action's built-in masking, so all variables will automatically be masked (aka hidden) if printed to the console or to logs.
|
||||||
|
|||||||
+5
-1
@@ -1,4 +1,4 @@
|
|||||||
name: 'Vault Secrets'
|
name: 'HashiCorp Vault'
|
||||||
description: 'A Github Action that allows you to consume HashiCorp Vault™ secrets as secure environment variables'
|
description: 'A Github Action that allows you to consume HashiCorp Vault™ secrets as secure environment variables'
|
||||||
inputs:
|
inputs:
|
||||||
url:
|
url:
|
||||||
@@ -89,6 +89,10 @@ inputs:
|
|||||||
secretEncodingType:
|
secretEncodingType:
|
||||||
description: 'The encoding type of the secret to decode. If not specified, the secret will not be decoded. Supported values: base64, hex, utf8'
|
description: 'The encoding type of the secret to decode. If not specified, the secret will not be decoded. Supported values: base64, hex, utf8'
|
||||||
required: false
|
required: false
|
||||||
|
ignoreNotFound:
|
||||||
|
description: 'Whether or not the action should exit successfully if some requested secrets were not found.'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
Vendored
+26
-14
File diff suppressed because one or more lines are too long
@@ -124,12 +124,34 @@ describe('integration', () => {
|
|||||||
.mockReturnValueOnce(secrets);
|
.mockReturnValueOnce(secrets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mockIgnoreNotFound(shouldIgnore) {
|
||||||
|
when(core.getInput)
|
||||||
|
.calledWith('ignoreNotFound', expect.anything())
|
||||||
|
.mockReturnValueOnce(shouldIgnore);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
it('prints a nice error message when secret not found', async () => {
|
it('prints a nice error message when secret not found', async () => {
|
||||||
mockInput(`secret/data/test secret ;
|
mockInput(`secret/data/test secret ;
|
||||||
secret/data/test secret | NAMED_SECRET ;
|
secret/data/test secret | NAMED_SECRET ;
|
||||||
secret/data/notFound kehe | NO_SIR ;`);
|
secret/data/notFound kehe | NO_SIR ;`);
|
||||||
|
|
||||||
expect(exportSecrets()).rejects.toEqual(Error(`Unable to retrieve result for "secret/data/notFound" because it was not found: {"errors":[]}`));
|
await expect(exportSecrets()).rejects.toEqual(Error(`Unable to retrieve result for "secret/data/notFound" because it was not found: {"errors":[]}`));
|
||||||
|
})
|
||||||
|
|
||||||
|
it('does not error when secret not found and ignoreNotFound is true', async () => {
|
||||||
|
mockInput(`secret/data/test secret ;
|
||||||
|
secret/data/test secret | NAMED_SECRET ;
|
||||||
|
secret/data/notFound kehe | NO_SIR ;`);
|
||||||
|
|
||||||
|
mockIgnoreNotFound("true");
|
||||||
|
|
||||||
|
await exportSecrets();
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledTimes(2);
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET');
|
||||||
|
expect(core.exportVariable).toBeCalledWith('NAMED_SECRET', 'SUPERSECRET');
|
||||||
})
|
})
|
||||||
|
|
||||||
it('get simple secret', async () => {
|
it('get simple secret', async () => {
|
||||||
|
|||||||
Generated
+1636
-1352
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -34,18 +34,18 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/hashicorp/vault-action#readme",
|
"homepage": "https://github.com/hashicorp/vault-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"got": "^11.8.5",
|
"got": "^11.8.6",
|
||||||
"jsonata": "^2.0.3",
|
"jsonata": "^2.0.3",
|
||||||
"jsrsasign": "^10.8.6"
|
"jsrsasign": "^11.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@actions/core": ">=1 <2"
|
"@actions/core": ">=1 <2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.1",
|
||||||
"@vercel/ncc": "^0.36.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.7.0",
|
||||||
"jest-when": "^3.5.2",
|
"jest-when": "^3.6.0",
|
||||||
"mock-http-server": "^1.4.5"
|
"mock-http-server": "^1.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -1,6 +1,8 @@
|
|||||||
const jsonata = require("jsonata");
|
const jsonata = require("jsonata");
|
||||||
const { WILDCARD } = require("./constants");
|
const { WILDCARD } = require("./constants");
|
||||||
const { normalizeOutputKey } = require("./utils");
|
const { normalizeOutputKey } = require("./utils");
|
||||||
|
const core = require('@actions/core');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} SecretRequest
|
* @typedef {Object} SecretRequest
|
||||||
* @property {string} path
|
* @property {string} path
|
||||||
@@ -21,7 +23,7 @@ const { normalizeOutputKey } = require("./utils");
|
|||||||
* @param {import('got').Got} client
|
* @param {import('got').Got} client
|
||||||
* @return {Promise<SecretResponse<TRequest>[]>}
|
* @return {Promise<SecretResponse<TRequest>[]>}
|
||||||
*/
|
*/
|
||||||
async function getSecrets(secretRequests, client) {
|
async function getSecrets(secretRequests, client, ignoreNotFound) {
|
||||||
const responseCache = new Map();
|
const responseCache = new Map();
|
||||||
let results = [];
|
let results = [];
|
||||||
|
|
||||||
@@ -42,7 +44,14 @@ async function getSecrets(secretRequests, client) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
const {response} = error;
|
const {response} = error;
|
||||||
if (response?.statusCode === 404) {
|
if (response?.statusCode === 404) {
|
||||||
throw Error(`Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}`)
|
notFoundMsg = `Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}`;
|
||||||
|
const ignoreNotFound = (core.getInput('ignoreNotFound', { required: false }) || 'false').toLowerCase() != 'false';
|
||||||
|
if (ignoreNotFound) {
|
||||||
|
core.error(`✘ ${notFoundMsg}`);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
throw Error(notFoundMsg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user