caldera
caldera copied to clipboard
Pipe characters dropped from Fact during Parsing
Describe the bug
A fact that contains a quoted string with a pipe character will drop all text following the pipe character during parsing. For example, if your ability is:
echo #{my.caldera.fact}
and your fact value pair is my.caldera.fact = 'before|after'
When you execute the ability, the output is:
echo 'before
The expected output is:
echo 'before|after'
Our (@d3vco) best guess is that this is an issue with the yaml parser library. To Reproduce Steps to reproduce the behavior: factbug_yml.zip - zip file with test ability and fact source
- Add attached ability into 'caldera/data/ability/test/' directory (82dc***.yml)
- Add attached fact source into 'caldera/data/sources/' directory (c4de***.yml)
- Execute ability (test print fact) with the quoted fact value
Expected behavior I expect pipe characters to be translated from the fact source into the ability especially when quoted.
Screenshots
If applicable, add screenshots to help explain your problem.
Add the potential link
Reviewing the command in manual mode Notice how everything after the pipe character (including the pipe) is dropped.
Desktop (please complete the following information):
- OS: Ubuntu 22.04.3 LTS Linux - VM
- Browser: Firefox
- Version: Caldera 4.2.0
Additional context Add any other context about the problem here.
Looks like your first issue -- we aim to respond to issues as quickly as possible. In the meantime, check out our documentation here: http://caldera.readthedocs.io/
So I was too quick to blame yaml
.
The bug occurs in operations.html
. Each fact is concatenated with its name like so: ${factName}|${fact.value}
. Later, to recover the value, this string is split on the |
character, which would also split any pipe characters in the value (or name for that matter). I think using the limit parameter of the split
function would solve your issue, but that doesn't account for pipe characters in the name (as they would occur before the pipe that we actually want to split on).
We encountered this issue in the past and I ended up using a hacky fix - using |SEPARATORVALUE|
in place of the joining |
. I think a better way of doing it might be prepending the length of the factName to the concatenated values, so "hello":"world" might become 5:helloworld, then using split with a limit of one to retrieve the key's length
Fixed for v5 - https://github.com/mitre/magma/pull/41
as patched for v5, closing. reopen if issue persists.