nasa / CTF

This is a new repository for a new tool to be added to the cFS ecosystem called cFS Test Framework (CTF).
27 stars 6 forks source link

resolve_function not handling all possible types of params #45

Closed snoyes closed 1 year ago

snoyes commented 2 years ago

https://github.com/nasa/CTF/blob/982311047cc2417ecdeaebed97ab8d967f40411d/lib/readers/json_script_reader.py#L143-L144

Parameters can be a list, yet:

https://github.com/nasa/CTF/blob/982311047cc2417ecdeaebed97ab8d967f40411d/lib/readers/json_script_reader.py#L246

params is handled only if it is a dict; a list here would raise an AttributeError as it has no keys.

It's also possible that a function expects no parameters, in which case functions[name]["varlist"] might be an empty list and command["params"] be None. That will get past line 246, but then

https://github.com/nasa/CTF/blob/982311047cc2417ecdeaebed97ab8d967f40411d/lib/readers/json_script_reader.py#L253-L256

will raise the AttributeError. Also, this section of code seems to be pointless: for each key in command["params"], if the key is in varlist, then set it back to its own value. I don't think that changes anything.

blueoceanwater commented 1 year ago

Thank you for reporting the issue and for contributing the code fix. We do not have a legal process in place to accept coding contributions from our end-users at this time. Hence, we will implement our own fix for it and will make it available for CTF v1.7 release. But please continue to report issues to help us improve the tool for everyone.