Parse a single match criteria node and insert into the provided criteria map. Example criteria node: "user alice,bob" or "address *.*.0.1" Inserts the criterion as a key with an array value into the `criteria_map`.
(criteria_node: tree_sitter::Node, input: &str, input_bytes: &[u8], criteria_map: &mut Map<String, Value>)
| 119 | /// Example criteria node: "user alice,bob" or "address *.*.0.1" |
| 120 | /// Inserts the criterion as a key with an array value into the `criteria_map`. |
| 121 | fn parse_match_criteria(criteria_node: tree_sitter::Node, input: &str, input_bytes: &[u8], criteria_map: &mut Map<String, Value>) -> Result<(), SshdConfigError> { |
| 122 | if let Some(key_node) = criteria_node.child_by_field_name("keyword") { |
| 123 | let Ok(key_text) = key_node.utf8_text(input_bytes) else { |
| 124 | return Err(SshdConfigError::ParserError(t!("parser.failedToParseNode", input = input).to_string())); |
| 125 | }; |
| 126 | let key = key_text.to_string(); |
| 127 | |
| 128 | let values: Value; |
| 129 | if let Some(value_node) = criteria_node.child_by_field_name("argument") { |
| 130 | // Match criteria are always treated as arrays (comma-separated), so we override |
| 131 | // the keyword_info to force multi-arg behavior |
| 132 | let mut keyword_info = KeywordInfo::from_keyword(&key); |
| 133 | // Force comma separator and multi-arg for match criteria |
| 134 | keyword_info.separator = ValueSeparator::Comma; |
| 135 | values = parse_arguments_node_as_array(value_node, input, input_bytes, &keyword_info)?; |
| 136 | } |
| 137 | else { |
| 138 | return Err(SshdConfigError::ParserError(t!("parser.missingValueInCriteria", input = input).to_string())); |
| 139 | } |
| 140 | |
| 141 | criteria_map.insert(key.to_lowercase(), values); |
| 142 | Ok(()) |
| 143 | } else { |
| 144 | Err(SshdConfigError::ParserError(t!("parser.missingKeyInCriteria", input = input).to_string())) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /// Parse a keyword node and optionally insert it into a map. |
| 149 | /// If `target_map` is provided, the keyword will be inserted into that map with repeatability handling. |
nothing calls this directly
no test coverage detected