-
Notifications
You must be signed in to change notification settings - Fork 163
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 steps to read and write TOML file #272
Conversation
@rsandell, hello! Can you review this PR, please? 🙏 |
} | ||
|
||
try (InputStream is = f.read()) { | ||
toml = mapper.readValue(IOUtils.toString(is, StandardCharsets.UTF_8), Object.class); |
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.
I am not familiar with TOML, but the yaml read step has extra configuration in place to avoid mapping to complex objects for security reasons, for example to avoid loading a class with a vulnerable static initializer that could be utilized by a nefarious user. Is that a precaution that can be taken here as well?
The mapping to Object.class
was reminding me of it and made me nervous :)
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 took some time to get back to work on this pull request 😄
Thanks for review. I have understood the idea of CVE-2022-1471 vulnerability (I hope you mentioned exactly this problem)
TOML format is much easier than YAML. TOML operates with simple data structures which have already defined in the code. It is similar to SafeConstructor in SnakeYAML
. So, no extra classes can be initialized during parsing
com.fasterxml.jackson.dataformat.toml
package very small and simple, it delegates all work on tomlj
and com.fasterxml.jackson.databind.ObjectMapper
. This package extends ObjectMapper
class with custom input/output decorators. Before mapping on the given structure (Object.class
in this case, no one will be able to change the mapping class), it converts TOML to JSON (because TOML is just a map) and after that jackson packages work with the data as if it were a json file
Could you update https://github.com/jenkinsci/pipeline-utility-steps-plugin/blob/master/docs/STEPS.md as well please? |
5beea35
to
5084406
Compare
5084406
to
3a461bb
Compare
@rsandell, thank you! I've updated |
Thank you! |
Add steps to work with TOML files/text. We are going to use these new steps to work with BuildKit configuration files in own pipeline/shared library. The realization is similar to JSON steps.
I chose
com.fasterxml.jackson.dataformat.jackson-dataformat-toml
, because this library implements the latest version of TOML specification (v1.0.0) and was recommended by official WIKI.Testing done
Test cases are similar to JSON realization.
Submitter checklist