-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add new lense for Teleport service #814
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the teleport.yaml file is a straight-forward Yaml file.
As you noticed, the existing Yaml lens handles only a small subset of Yaml.
This lens attempts to at least handle 2 levels of mappings (also known as hashes or dictionaries), plus sequences (ordered lists)
Unfortunately, although the lens passes the tests supplied, it does not achieve its desired goals.
For example, taking a sample from the test_teleport.aug comments as a teleport.yaml file:
teleport:
nodename: nodename
auth_servers:
- host:port
Gives the following output from augtool:
> augtool print /files/etc/teleport.yaml
/files/etc/teleport.yaml
/files/etc/teleport.yaml/teleport
/files/etc/teleport.yaml/teleport/nodename = "nodename"
/files/etc/teleport.yaml/auth_servers
Notice that the value "host:port" is missing from the output
Also, the lens fails a basic test where a single key-value is created
> augtool
augtool> print /files/etc/teleport.yaml
augtool> set /files/etc/teleport.yaml/teleport/nodename 'nodename'
augtool> save
error: Failed to execute command
saving failed (run 'errors' for details)
augtool>
Also note that, at the current version, Augeas does not handle recursion within a lens definition.
This lense only for read, not for update/create values. We need reading this configuration file without updating them. Because we are use osquery and osquery parses configuration files with augeas, we wrote this lense for this goal.. For update this configuration files must be used specific playbooks with corporate templates. |
I can see how this may be useful for osquery, and that it solves a particular problem related to your setup Augeas does provide for users to create their own custom lenses, and these can be read automatically by augeas by setting the environment variable For example:
The environment variable The allows users to have custom special-purpose lenses which will not be overwritten by a package update. In this case, I would suggest that this is a better solution, until a more complete Yaml lens is developed. |
@georgehansper thank you! I am trying write a complete Yaml parser. True, it won't be easy. So, all lenses must work with the SET request? |
I think it is important to keep in mind that Augeas is actually a file editor. It is intended to be able to make changes to config files, both by changing existing values and adding additional content. By and large, the existing lenses achieve this. Although Augeas is somewhat "aware" of the syntax of the file, it is not designed to be a config checker or linter. Lenses convert the file's native syntax into a "tree" representation. The set command operates on the tree, and more often than not, the set command will succeed, even if it makes the resulting tree "invalid" for the underlying lens. So to answer your question, it's not the "set" function that must succeed, it is the subsequent "save" command. A good criteria for success here would be the following should succeed:
The original config file should be re-created, and be syntactically correct. |
Hello @georgehansper ! Thanks for the clarification. I am updated lense for read a simple/classic yaml files. These file name is like simplevars/simplelines lenses. My parser works with simple 'key: value' params, indented 'key: value', sequence and comments. In test file I am add multiple config format. I tested with your criteria:
So, YAML format is not simple for parse all available type of key:values . For example, a pyyaml project - big project for analyze yaml files. Although my work covers a small percentage of possible scripts for writing the YAML format, nevertheless it is most often found in the configuration files of many services. And these can be useful to many people. I'm waiting for a review. Thank you. |
Thanks for having a go at this. Writing lenses is tricky at the best of times, and I have to admit that it is not something I have done much of to date. In step 6 of your test, the indentation is lost on the values of This means that after a "save", the resulting file would become corrupted. I can see that you have made use of the existing Util and Rx modules. Unfortunately, this is why the indentation is lost during the save operation. The definition of Util.indent is:
Note the arg "". This tells Augeas: "when creating a new entry, put an empty string at this location." So Util.indent is part of the problem I think we can do better than this, by telling Augeas to insert some spaces. I have been experimenting with the following code, which shows some promise:
Using the following test-data:
It loads as expected, and if I run the following commands:
It successfully saves the file with It is by no means a full Yaml parser, but it is certainly an improvement |
Hi!
This lense read teleport configuration file https://goteleport.com/ .
The existing yaml lens does not work correctly with this type of configuration file, so we wrote a separate parser for a specific service.