open-nomad/website/content
Luiz Aoqui ac90c6f008 acl: fix parsing of policies with blocks w/o label
An ACL policy with a block without label generates unexpected results.
For example, a policy such as this:

```
namespace {
  policy = "read"
}
```

Is applied to a namespace called `policy` instead of the documented
behaviour of applying it to the `default` namespace.

This happens because of the way HCL1 decodes blocks. Since it doesn't
know if a block is expected to have a label it applies the `key` tag to
the content of the block and, in the example above, the first key is
`policy`, so it sets that as the `namespace` block label.

Since this happens internally in the HCL decoder it's not possible to
detect the problem externally.

Fixing the problem inside the decoder is challenging because the JSON
and HCL parsers generate different ASTs that makes impossible to
differentiate between a JSON tree from an invalid HCL tree within the
decoder.

The fix in this commit consists of manually parsing the policy after
decoding to clear labels that were not set in the file. This allows the
validation rules to consistently catch and return any errors, no matter
if the policy is an invalid HCL or JSON.
2023-07-18 12:09:37 -04:00
..
api-docs node pools: apply node pool scheduler configuration (#17598) 2023-06-21 20:31:50 -04:00
docs acl: fix parsing of policies with blocks w/o label 2023-07-18 12:09:37 -04:00
intro docs: Migrate link formats (#15779) 2023-01-25 09:31:14 -08:00
partials node pools: implement CLI for node pool jobs command (#17432) 2023-06-06 15:02:26 -04:00
plugins backport of commit 25a062650f38b682733fe51d886188a8d0504844 (#17922) 2023-07-12 10:17:45 -05:00
tools backport of commit b75f9bd459700112cb31a329dc54ddeba46d749e (#17942) 2023-07-13 17:26:01 -05:00
security.mdx Upgrade global styles (#10936) 2021-08-20 11:53:12 -04:00