Commit Graph

43 Commits

Author SHA1 Message Date
Mark Nevill
14846fb743 all: rewrite the lexer to consume the entire input first
Previously we used the buffruneio package to buffer input. However,
the error handling was not good, and we would often panic when parsing
inputs.

SSH config files are generally not large, on the order of kilobytes or
megabytes, and it's fine to just read the entire thing into memory and
then parse from there. This also simplifies the parser significantly
and lets us remove a dependency and several defer calls.

Add a test that panicked with the old version and then modify the code
to ensure the test no longer panics.

Thanks to Mark Nevill (@devnev) for the initial error report and
failing test case.

Fixes #10.
Fixes #24.
2019-07-24 10:52:01 -10:00
Kevin Burke
2e50c44127 all: fix lint issues
staticcheck updated, and it requires inline fixes as well as dropping
support for 1.9 and 1.10.
2019-06-29 21:04:20 -07:00
Kevin Burke
f648cfb84b all: use ints instead of uints
Files are small and these are cheap enough that we should be more
worried about overflow errors than the space cost.
2019-06-29 20:37:49 -07:00
Kevin Burke
81db2a7582 0.5 2018-08-30 14:53:28 -06:00
Kevin Burke
b64c0219b6 Add Go 1.11 to build matrix 2018-08-30 14:47:24 -06:00
Kevin Burke
555f37af0a Correctly parse files without trailing newline
If the file did not have a newline character as the last character,
parseKV() would panic with an NPE. Handle the parser changes better.

Fixes #21.
2018-08-30 14:46:27 -06:00
Kevin Burke
82cf3f9264 Remove 1.7 and 1.8 from build matrix
They don't work with megacheck anymore. The source code and tests will
probably still pass, however.
2018-07-11 09:47:46 -07:00
Kevin Burke
4fcc689bee Use kevinburke/bump_version instead of Shyp/bump_version 2018-04-22 12:34:03 -07:00
Wayne Ashley Berry
6c3af74fa5 Run tests with the race detector
At some point recently this was fixed (maybe investigate more and
figure out how/why this has been resolved?)

Add Go 1.10 to Travis CI.
2018-04-02 20:41:57 -07:00
Kevin Burke
b8c871d977 run tests before releasing a new version 2018-03-17 10:56:17 -07:00
Kevin Burke
9fc7bb800b 0.4 2018-03-17 10:55:31 -07:00
Eugene Terentev
fe204ef364 Fix DOS line endings parsing
Previously we would fail to lex lines ending with CRLF properly.
2018-03-17 10:50:38 -07:00
Kevin Burke
0ff8514904 0.3 2018-01-27 11:48:58 -08:00
Kevin Burke
fc20c60f74 Add AUTHORS file 2018-01-27 11:48:38 -08:00
Sergey Lukjanov
c665f6f442 Fix potential index out of range error
I had some extra spaces and junk in my ssh config and it was causing
this part of the code to fail with an out of range error.
2018-01-27 11:46:18 -08:00
Kevin Burke
802051befe Implement encoding.TextMarshaler interface 2017-10-13 14:14:58 -07:00
Kevin Burke
db49ba357d Use better dependencies in Makefile 2017-08-22 10:15:53 -07:00
Kevin Burke
4ec3da02a7 add Default example 2017-05-26 11:07:48 -07:00
Kevin Burke
fc8c332031 fix example 2017-05-26 11:06:09 -07:00
Kevin Burke
2b54512628 switch staticcheck for megacheck and fix things it complains about 2017-05-26 10:01:24 -07:00
Kevin Burke
6dcd4cf595 update README and add more examples 2017-05-25 22:05:04 -07:00
Kevin Burke
873a8ad95f add errata 2017-05-25 08:22:23 -07:00
Kevin Burke
8b24c0d360 improve the documentation 2017-05-25 08:16:57 -07:00
Kevin Burke
b365efcd38 add a release target 2017-05-25 08:11:58 -07:00
Kevin Burke
fa48d7ff1c 0.2 2017-05-25 08:11:05 -07:00
Kevin Burke
4a3c8dfaf0 add a version constant 2017-05-25 08:11:01 -07:00
Kevin Burke
e05b90745b more doc tweaks 2017-05-25 08:09:30 -07:00
Kevin Burke
7897293c53 Cleanup for public release
- Test Include string representation

- Add docs and examples
2017-05-25 08:00:10 -07:00
Kevin Burke
3fad3c64da Add more documentation and correctness fix 2017-05-24 22:10:17 -07:00
Kevin Burke
1c4ddb97d7 use Default() and validate() 2017-05-24 21:30:13 -07:00
Kevin Burke
c20644453d add Default() and start of a validate() function 2017-05-24 10:11:10 -07:00
Kevin Burke
54fabb9a37 Implement Include directive
It's tricky because it involves recursive filesystem parsing, depth
checking and glob matching. But figured it out.

Fixes #4.
2017-05-23 20:09:31 -07:00
Kevin Burke
ad36f0d71a Implement negative match
Fixes #3.
2017-04-23 16:39:17 -07:00
Kevin Burke
3918a52bb7 Add a LICENSE 2017-04-23 12:13:57 -07:00
Kevin Burke
01f73642b5 Add more documentation 2017-04-23 12:10:47 -07:00
Kevin Burke
251b79e492 install staticcheck on host 2017-04-23 11:59:34 -07:00
Kevin Burke
bc2824eae3 tweak readme again 2017-04-23 11:47:51 -07:00
Kevin Burke
67c39ca6b4 Implement Get and wildcard match
Lots of changes and new API's here.

Fixes #7.
2017-04-23 11:42:22 -07:00
Kevin Burke
c40e54d2bf fix tests 2017-04-21 20:39:44 -07:00
Kevin Burke
8075e819ad tweak interface 2017-04-18 10:57:51 -07:00
Kevin Burke
c07ebbe98d add very basic README 2017-04-17 11:24:14 -07:00
Kevin Burke
ab5641d3b9 Add Travis 2017-04-17 11:16:04 -07:00
Kevin Burke
29f594a81c Add alpha SSH config parser
The error handling is nonexistent and there's no easy way to get
data out. But we can parse a SSH config file into a Go struct, and
roundtrip that struct back to a file that looks (roughly) the same.
2017-04-17 11:08:10 -07:00