diff --git a/shared/yaml/codeql/yaml/Yaml.qll b/shared/yaml/codeql/yaml/Yaml.qll index 153ff5979c8..f0d9424ca53 100644 --- a/shared/yaml/codeql/yaml/Yaml.qll +++ b/shared/yaml/codeql/yaml/Yaml.qll @@ -134,6 +134,23 @@ signature module InputSig { */ string getMessage(); } + + /** + * A base class for comments. + * + * Typically `@yaml_comment`. + */ + class CommentBase extends LocatableBase { + /** + * Gets the text of this comment, not including delimiters. + */ + string getText(); + + /** + * Gets a textual representation of this comment. + */ + string toString(); + } } /** Provides a class hierarchy for working with YAML files. */ @@ -607,6 +624,26 @@ module Make { string toString() { result = super.getMessage() } } + /** + * A YAML comment. + * + * Example: + * + * ``` + * # here is a comment + * ``` + */ + class YamlComment instanceof Input::CommentBase { + /** Gets the `Location` of this comment. */ + Input::Location getLocation() { result = super.getLocation() } + + /** Gets the text of this comment, not including delimiters. */ + string getText() { result = super.getText() } + + /** Gets a textual representation of this comment. */ + string toString() { result = super.toString() } + } + /** * A YAML node that may contain sub-nodes that can be identified by a name. * I.e. a mapping, sequence, or scalar.