Skip to content

Commit ae2c5cf

Browse files
authored
Avoiding infinite loop for invalid files in rest spec parser (elastic#128335) (elastic#128339)
1 parent d3da5f5 commit ae2c5cf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApiParser.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public class ClientYamlSuiteRestApiParser {
3434
public ClientYamlSuiteRestApi parse(String location, XContentParser parser) throws IOException {
3535

3636
while (parser.nextToken() != XContentParser.Token.FIELD_NAME) {
37+
if (parser.currentToken() == null) {
38+
throw new ParsingException(
39+
parser.getTokenLocation(),
40+
"Invalid rest spec file found at [" + location + "]. No API name found in file"
41+
);
42+
}
3743
// move to first field name
3844
}
3945

0 commit comments

Comments
 (0)