- Adds reporting the line with the bad key position
that makes the config invalid.
- Fixes a few tests with trailing braces which were
being handled as keys and ignored before.
Signed-off-by: Waldemar Quevedo <wally@nats.io>
This makes configuration files that are empty, or read and processed
by the parser but with no detected values now return an error.
Signed-off-by: Waldemar Quevedo <wally@nats.io>
If a configuration variable starts with numbers and has a character
that such as K/k/G/g/etc.. it would assume that it was a number
(expressed in Kb, Gb, etc..).
This PR checks that if the special characters are not the suffix,
that is, the variable does not end after those characters, then
the parsing will treat the whole thing as a string.
Resolves#3431
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
- Add Go 1.17
- Fix go fmt from Go 1.17 (build directives)
- Download version of misspell and staticcheck instead of doing
"go get" since current staticcheck would be broken without go.mod
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
* [fixed] timeout in configuration lexer found by oss-fuzz
Peek followed by next resulted in an infinite loop when eof was not
checked.
I looked for all instances of this pattern and return an error when eof is not already checked or skip was used.
Signed-off-by: Matthias Hanel <mh@synadia.com>
Changed account lookup and validation failures to be more understandable by users.
Changed limits to be -1 for unlimited to match jwt pkg.
The limits changed exposed problems with options holding real objects causing issues with reload tests under race mode.
Longer term this code should be reworked such that options only hold config data, not real structs, etc.
Signed-off-by: Derek Collison <derek@nats.io>
The configuration format from the server is almost already a superset
of JSON with exception of two cases:
1) trailing commas from values at the top level (although they are
supported inside of maps)
2) initial and final brackets on the top level section.
This change relaxes the two cases above to just skip those tokens so
that the config syntax can also support valid JSON objects for
configuring the server which might be helpful when generating it
programmatically.
This involves evaluating and interpolating \-escaped sequences
in double-quoted and undelimited strings.
Added tests on various edge-conditions, as well as ruling out bare
strings like '\true' as a bool.
This allows blocked scoped variables to be set and retrieved as values using the $ prefix.
e.g. foo = 22; bar = $foo
Also supports env variables being used as variables and will properly parse to the correct type.