vault icon indicating copy to clipboard operation
vault copied to clipboard

Vault OpenAPI is incorrect for new PKI secrets engine endpoints

Open maxb opened this issue 1 year ago • 2 comments

Describe the bug The Vault OpenAPI generator relies on reverse-engineering path regexps to correctly generate the OpenAPI document.

Several regexps used in the new (circa 1.11) PKI secrets engine are now too complicated for the OpenAPI generator to handle correctly.

To Reproduce

  1. Mount a PKI secrets engine
  2. Examine the generated OpenAPI
  3. Observe these clearly incorrect paths:
/pki//delta
/pki//delta/pem
/pki//der
/pki//json
/pki//pem
/pki/internal|exported
/pki/{issuer_ref}/crl/pem|/der|/delta/pem
/pki/{issuer_ref}/der|/pem

Expected behavior The Vault OpenAPI generator should generate a document which accurately describes the Vault API.

In order to achieve this, it may well be helpful to define a strict subset of regexp syntax which can be used in Vault path regexps.

maxb avatar Dec 19 '22 22:12 maxb

These are the regexes that are currently being misinterpreted:

`crl(/pem|/delta(/pem)?)?`    # pathFetchCRL
"issuer/" + framework.GenericNameRegex(issuerRefParam) + "(/der|/pem|/json)?"    # pathGetIssuer
"issuer/" + framework.GenericNameRegex(issuerRefParam) + "/crl(/pem|/der|/delta(/pem|/der)?)?"    # pathGetIssuerCRL
"keys/generate/(internal|exported|kms)"    # pathGenerateKey

maxb avatar Dec 19 '22 22:12 maxb

Further investigation shows that the following regexes are also being misinterpreted - they just result in paths which are less obviously wrong than the other group:

"issuers/import/(cert|bundle)"    # pathImportIssuer
`cert/(crl|delta-crl)`    # pathFetchCRLViaCertPath

maxb avatar Dec 20 '22 00:12 maxb