add general check for yaml on rcl_yaml_param_parser#809
add general check for yaml on rcl_yaml_param_parser#809jacobperron merged 14 commits intoros2:masterfrom
Conversation
| /// Validate a name whether it is a valid namespace | ||
| /// | ||
| static rcutils_ret_t | ||
| __validate_namespace(const char * name) |
There was a problem hiding this comment.
why it should not be dependent on rmw? could you elaborate a little bit? I think it would be better to use rmw to validate the namespace instead of having redundant code else where.
I found that using rmw_validate_namespace has some limitations because there are some extra rules, such as "/**" (maybe more in the future), need to be parsed.
you mean ros2/rclcpp#1265?
There was a problem hiding this comment.
Thanks for your questions, @fujitatomoya
why it should not be dependent on rmw?
"/**" is a special rule at rclcpp, it is invalid checked by rmw_validate_namespace.
If using rmw_validate_namespace, we need to add more extra checking for these special rules inside __validate_namespace, which seems not a requirement of this issue.
maybe more in the future
you mean ros2/rclcpp#1265?
Yes.
There was a problem hiding this comment.
Though this solves the reported issue, I think we should do a more general check if the node namespace (and node name) are valid. I would do this using rmw_validate_namespace and rmw_validate_node_name, and handle the special cases for wildcards * and **.
I suggest implementing this function as follows:
- Make a copy of the name to validate
- Substitute substrings
*and**with arbitrary valid strings (e.g.WILDCARD) - Pass the modified name to
rmw_validate_namespace
By using the rmw functions we are consistent with what it means to be a valid name.
What do you think?
There was a problem hiding this comment.
I suggest implementing this function as follows
Thanks for your suggestion. I'll update it later.
jacobperron
left a comment
There was a problem hiding this comment.
I think we should also validate the node name. If you don't want to add it to this PR, we do it in a follow-up.
| /// Validate a name whether it is a valid namespace | ||
| /// | ||
| static rcutils_ret_t | ||
| __validate_namespace(const char * name) |
There was a problem hiding this comment.
Though this solves the reported issue, I think we should do a more general check if the node namespace (and node name) are valid. I would do this using rmw_validate_namespace and rmw_validate_node_name, and handle the special cases for wildcards * and **.
I suggest implementing this function as follows:
- Make a copy of the name to validate
- Substitute substrings
*and**with arbitrary valid strings (e.g.WILDCARD) - Pass the modified name to
rmw_validate_namespace
By using the rmw functions we are consistent with what it means to be a valid name.
What do you think?
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
This reverts commit b847544. Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
This reverts commit 52bb028. Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
1c5ac73 to
682d4db
Compare
|
After rebasing from BTW: I didn't add some extra rules which are not merged (such as ros2/rclcpp#1265) in this PR |
jacobperron
left a comment
There was a problem hiding this comment.
LGTM.
Could you also add a test for the /** case? Thanks!
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
I have added the test and added additional rules for wildcards based on ros2/design#303. |
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
…partial matches Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
|
The |
|
@ros-pull-request-builder retest this please |
jacobperron
left a comment
There was a problem hiding this comment.
I'm not sure about the cppcheck failure on macOS or the Windows build failure 🤔
rcl_yaml_param_parser/src/parse.c
Outdated
| /// \return RCUTILS_RET_ERROR if an unspecified error occurred. | ||
| RCL_YAML_PARAM_PARSER_LOCAL | ||
| rcutils_ret_t | ||
| __validate_namespace(const char * namespace); |
There was a problem hiding this comment.
I think we should use a single underscore. Double underscores are reserved identifiers.
| __validate_namespace(const char * namespace); | |
| _validate_namespace(const char * namespace); |
Same for other functions names below.
There was a problem hiding this comment.
That's good to know.
the version of |
Co-authored-by: Jacob Perron <jacob@openrobotics.org> Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
jacobperron
left a comment
There was a problem hiding this comment.
LGTM, thanks for iterating!
Fixes #301
Signed-off-by: Chen Lihui Lihui.Chen@sony.com
Updated: Besides fixing to not allow '//' in node name, adding the general check and some special rules about wildcards(including some new rules on ros2/design#303)