usnistgov/oscal-cli

Partial line output on STDOUT output of profile resolution

nikitawootten-nist opened this issue · 3 comments

Describe the bug

The CLI does not properly terminate the output of profile resolution with a new line.

Who is the bug affecting?

Users that pass profile resolution to another program with pipes

What is affected by this bug?

Profile resolution

When does this occur?

When the user runs profile resolution without an output argument

How do we replicate the issue?

oscal-cli profile resolve profile.json | jq
parse error: Invalid numeric literal at line 1, column 10
                                                         write /dev/stdout: broken pipe

Expected behavior (i.e. solution)

Other Comments

As an aside, why does profile resolution allow for STDOUT output, but convert commands do not?

The CLI does not properly terminate the output of profile resolution with a new line.

Thanks for this report. We can look into this!

As an aside, why does profile resolution allow for STDOUT output, but convert commands do not?

That is a good question, I am not sure there was an explicit rationale there. @david-waltermire-nist?

There was some improper handling of stream closure and flushing. This was fixed in usnistgov/metaschema-java#176.

Once PR #155 is merged, this should be fixed.

The convert commands do allow for STDOUT as of oscal-cli v0.3.3.

This works now.

$ oscal-cli --version
oscal-cli 0.3.4-SNAPSHOT built at 2023-07-06 15:21 from branch develop (6dfcb19) at https://github.com/usnistgov/oscal-cli
liboscal-java  built at 2023-07-06 13:18 from branch develop (64ecdd7) at https://github.com/usnistgov/liboscal-java
oscal  built at 2023-07-06 13:18 from branch develop (8a57d69) at https://github.com/usnistgov/OSCAL.git
metaschema-java 0.11.0-SNAPSHOT built at 2023-07-05T19:21:56+0000 from branch develop (0eda1b5) at https://github.com/usnistgov/metaschema-java
metaschema v0.9.0 built at 2023-07-05T19:21:56+0000 from branch develop (a36f579) at https://github.com/usnistgov/metaschema
$ oscal-cli profile resolve nist.gov/SP800-53/rev5/json/NIST_SP-800-53_rev5_LOW-baseline_profile.json --to=json | jq .catalog.metadata.title
"NIST Special Publication 800-53 Revision 5 LOW IMPACT BASELINE"
$ echo $?
0