-
Notifications
You must be signed in to change notification settings - Fork 311
HPCC-35978 Handle invalid vault definitions #21149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kenrowland
wants to merge
4
commits into
hpcc-systems:candidate-10.2.x
Choose a base branch
from
kenrowland:HPCC-35978
base: candidate-10.2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1038,7 +1038,7 @@ | |
| }, | ||
| "kind": { | ||
| "type": "string", | ||
| "enum": ["kv-v2", "kv-v1"] | ||
| "enum": ["kv-v2", "kv-v1", "akeyless"] | ||
| }, | ||
| "type": { | ||
| "description": "The vault provider type (e.g. 'akeyless' or kv backend)", | ||
|
|
@@ -1114,6 +1114,7 @@ | |
| "required": ["type"] | ||
| }, | ||
| "then": { | ||
| "required": ["accessId"], | ||
| "oneOf": [ | ||
| { | ||
| "required": ["accessKey"], | ||
|
|
@@ -1123,7 +1124,47 @@ | |
| "required": ["client-secret"], | ||
| "not": { "required": ["accessKey"] } | ||
| } | ||
| ] | ||
| ], | ||
| "properties": { | ||
| "kind": { "enum": ["akeyless"] } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "if": { | ||
| "properties": { | ||
| "kind": { "const": "akeyless" } | ||
| }, | ||
| "required": ["kind"] | ||
| }, | ||
| "then": { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to cause backward compatibility issues with deployments that do not have the value set - when it was previously optional. |
||
| "required": ["accessId"], | ||
| "oneOf": [ | ||
| { | ||
| "required": ["accessKey"], | ||
| "not": { "required": ["client-secret"] } | ||
| }, | ||
| { | ||
| "required": ["client-secret"], | ||
| "not": { "required": ["accessKey"] } | ||
| } | ||
| ], | ||
| "properties": { | ||
| "type": { "enum": ["akeyless"] } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "if": { | ||
| "properties": { | ||
| "type": { "enum": ["kv-v1", "kv-v2"] } | ||
| }, | ||
| "required": ["type"] | ||
| }, | ||
| "then": { | ||
| "properties": { | ||
| "kind": { "enum": ["kv-v1", "kv-v2"] } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ################################################################################ | ||
| # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ################################################################################ | ||
| --> | ||
|
|
||
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
|
||
| <xsl:template name="validateLdapVaultReferences"> | ||
| <xsl:for-each select="/Environment/Software/LDAPServerProcess"> | ||
| <xsl:variable name="ldapServerName" select="@name"/> | ||
| <xsl:variable name="ldapAdminVaultId" select="normalize-space(@ldapAdminVaultId)"/> | ||
| <xsl:variable name="hpccAdminVaultId" select="normalize-space(@hpccAdminVaultId)"/> | ||
|
|
||
| <xsl:if test="$ldapAdminVaultId != '' and not(/Environment/Software/vaults/authn[@name=$ldapAdminVaultId])"> | ||
| <xsl:message terminate="yes">LDAPServerProcess '<xsl:value-of select="$ldapServerName"/>' references ldapAdminVaultId '<xsl:value-of select="$ldapAdminVaultId"/>' which does not match any /Environment/Software/vaults/authn/@name.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <xsl:if test="$hpccAdminVaultId != '' and not(/Environment/Software/vaults/authn[@name=$hpccAdminVaultId])"> | ||
| <xsl:message terminate="yes">LDAPServerProcess '<xsl:value-of select="$ldapServerName"/>' references hpccAdminVaultId '<xsl:value-of select="$hpccAdminVaultId"/>' which does not match any /Environment/Software/vaults/authn/@name.</xsl:message> | ||
| </xsl:if> | ||
| </xsl:for-each> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template name="validateVaultTypeKind"> | ||
| <xsl:for-each select="/Environment/Software/vaults/*"> | ||
| <xsl:variable name="vaultName" select="@name"/> | ||
| <xsl:variable name="vaultType" select="translate(normalize-space(@type), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/> | ||
| <xsl:variable name="vaultKind" select="translate(normalize-space(@kind), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/> | ||
| <xsl:variable name="isAkeyless" select="$vaultType='akeyless' or ($vaultType='' and $vaultKind='akeyless')"/> | ||
|
|
||
| <xsl:if test="$vaultType='' and $vaultKind=''"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' is invalid: either type or kind must be specified.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <xsl:if test="normalize-space(@url) = ''"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' is missing required attribute url.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <xsl:if test="$vaultType != '' and not($vaultType='akeyless' or $vaultType='hashicorp' or $vaultType='kv-v1' or $vaultType='kv-v2')"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' has invalid type '<xsl:value-of select="@type"/>'. Allowed values are: akeyless, hashicorp, kv-v1, kv-v2.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <!-- Match runtime behavior in jsecrets.cpp: only akeyless is a distinct provider; any other/non-empty type is treated as hashicorp-like. --> | ||
| <xsl:if test="$vaultType='akeyless' and $vaultKind != '' and $vaultKind != 'akeyless'"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' has invalid type/kind combination: type='<xsl:value-of select="@type"/>' kind='<xsl:value-of select="@kind"/>'.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <xsl:if test="$vaultType != '' and $vaultType != 'akeyless' and $vaultKind = 'akeyless'"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' has invalid type/kind combination: type='<xsl:value-of select="@type"/>' kind='<xsl:value-of select="@kind"/>'.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <xsl:if test="$isAkeyless and normalize-space(@accessId) = ''"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' is missing required akeyless attribute accessId.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <xsl:if test="$isAkeyless and normalize-space(@accessKey) = '' and normalize-space(@client-secret) = ''"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' must specify one of akeyless attributes accessKey or client-secret.</xsl:message> | ||
| </xsl:if> | ||
|
|
||
| <xsl:if test="$isAkeyless and normalize-space(@accessKey) != '' and normalize-space(@client-secret) != ''"> | ||
| <xsl:message terminate="yes">Vault '<xsl:value-of select="$vaultName"/>' cannot specify both akeyless attributes accessKey and client-secret.</xsl:message> | ||
| </xsl:if> | ||
| </xsl:for-each> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template name="copyVaultsConfig"> | ||
| <xsl:call-template name="validateVaultTypeKind"/> | ||
| <xsl:if test="/Environment/Software/vaults"> | ||
| <vaults> | ||
| <xsl:copy-of select="/Environment/Software/vaults/@*"/> | ||
| <xsl:for-each select="/Environment/Software/vaults/*"> | ||
| <xsl:copy> | ||
| <xsl:copy-of select="@*"/> | ||
| <xsl:copy-of select="node()"/> | ||
| </xsl:copy> | ||
| </xsl:for-each> | ||
| </vaults> | ||
| </xsl:if> | ||
| </xsl:template> | ||
|
|
||
| </xsl:stylesheet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Invalid: Akeyless vault with both accessKey and client-secret (oneOf violation) | ||
| vaults: | ||
| ecl: | ||
| - name: my-akeyless-vault | ||
| url: https://api.akeyless.io | ||
| type: akeyless | ||
| accessId: my-access-id | ||
| accessKey: my-access-key-value | ||
| client-secret: my-k8s-secret-name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Invalid: Akeyless vault with unsupported accessType (only "access_key" allowed) | ||
| vaults: | ||
| ecl: | ||
| - name: my-akeyless-vault | ||
| url: https://api.akeyless.io | ||
| type: akeyless | ||
| accessId: my-access-id | ||
| accessKey: my-access-key-value | ||
| accessType: invalid_type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Invalid: Akeyless vault missing required accessId | ||
| vaults: | ||
| ecl: | ||
| - name: my-akeyless-vault | ||
| url: https://api.akeyless.io | ||
| type: akeyless | ||
| accessKey: my-access-key-value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Invalid: Akeyless vault with neither accessKey nor client-secret (oneOf violation) | ||
| vaults: | ||
| ecl: | ||
| - name: my-akeyless-vault | ||
| url: https://api.akeyless.io | ||
| type: akeyless | ||
| accessId: my-access-id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Valid: Akeyless vault with accessKey | ||
| vaults: | ||
| ecl: | ||
| - name: my-akeyless-vault | ||
| url: https://api.akeyless.io | ||
| type: akeyless | ||
| accessId: my-access-id | ||
| accessKey: my-access-key-value | ||
| accessType: access_key | ||
| # Valid: Akeyless vault using client-secret instead | ||
| eclUser: | ||
| - name: my-akeyless-ecl-user-vault | ||
| url: https://api.akeyless.io | ||
| kind: akeyless | ||
| accessId: another-access-id | ||
| client-secret: my-k8s-secret-for-key |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have two enumerations that now contain identical values? It is too late, but the names should have been chosen more carefully. Can type be deleted, and just rely on type?