Skip to content

Commit 89271bb

Browse files
committed
Python: Add support for YAML comments.
1 parent 142685d commit 89271bb

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

python/ql/lib/semmle/python/Yaml.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ private module YamlSig implements LibYaml::InputSig {
4545
class ParseErrorBase extends LocatableBase, @yaml_error {
4646
string getMessage() { yaml_errors(this, result) }
4747
}
48+
49+
class CommentBase extends LocatableBase, @yaml_comment {
50+
string getText() { yaml_comments(this, result, _) }
51+
52+
override string toString() { yaml_comments(this, _, result) }
53+
}
4854
}
4955

5056
import LibYaml::Make<YamlSig>

python/ql/lib/semmlecode.python.dbscheme

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,17 @@ yaml_scalars (unique int scalar: @yaml_scalar_node ref,
280280
int style: int ref,
281281
string value: string ref);
282282

283+
yaml_comments (unique int id: @yaml_comment,
284+
string text: string ref,
285+
string tostring: string ref);
286+
283287
yaml_errors (unique int id: @yaml_error,
284288
string message: string ref);
285289

286290
yaml_locations(unique int locatable: @yaml_locatable ref,
287291
int location: @location_default ref);
288292

289-
@yaml_locatable = @yaml_node | @yaml_error;
293+
@yaml_locatable = @yaml_node | @yaml_error | @yaml_comment;
290294

291295
/*- Python dbscheme -*/
292296

0 commit comments

Comments
 (0)