Skip to content
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

Proposal: Policy validator for Vault #2851

Open
petems opened this issue Jun 13, 2017 · 4 comments
Open

Proposal: Policy validator for Vault #2851

petems opened this issue Jun 13, 2017 · 4 comments
Labels
community-sentiment Tracking high-profile issues from the community core/policy enhancement
Milestone

Comments

@petems
Copy link
Contributor

petems commented Jun 13, 2017

This is a proposal of a CLI helper to validate policies written in HCL or JSON for Vault.

It seems to make sense to copy how this works for Nomad or Terraform:

The vault validate command is used to validate the syntax of policy files. Vault performs a syntax check on all the policy files in the directory, and will display an error if any of the files doesn't validate.
This command does not check formatting (e.g. tabs vs spaces, newlines, comments etc.).
The following can be reported:
invalid HCL syntax (e.g. missing trailing quote or equal sign)
invalid HCL references (e.g. variable name or attribute which doesn't exist)
same policy declared multiple times

@jefferai jefferai added this to the not-scheduled milestone Jun 14, 2017
@avoidik
Copy link
Contributor

avoidik commented Jul 6, 2018

when you're applying your policy it is being validated, and exit code returned by vault, what if you delete this policy on success and raise the valid flag to true, otherwise to false.

@ncabatoff
Copy link
Collaborator

I wonder if hclfmt would do the trick here?

@heatherezell heatherezell added the community-sentiment Tracking high-profile issues from the community label Jan 18, 2022
@maxb
Copy link
Contributor

maxb commented Feb 20, 2022

The vault policy fmt formatting tool actually also includes lots of validation.

A current workaround I'm using is to just make a copy of a policy file, and run the formatter.

A very easy way to close this would be to make a version of the existing command which just stopped short of writing back the formatted content.

I wonder if hclfmt would do the trick here?

That's for HCL version 2, whereas Vault is stuck on HCL version 1 - mainly, AFAICS, because the documented syntax for defining control groups is invalid according to a HCL version 2 parser.

Also, hclfmt only validates the core HCL syntax - vault policy fmt goes beyond that to detect Vault ACL policy specific issues, e.g. invalid capability names.

@HenriBlacksmith
Copy link

It would be nice to allow vault policy fmt to take a folder or multiple files as an input.

Not sure if I should create a separate issue here though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-sentiment Tracking high-profile issues from the community core/policy enhancement
Projects
None yet
Development

No branches or pull requests

10 participants