Skip to content

Commit 83cd55c

Browse files
committed
Js/Yaml: add getFile() predicate
1 parent 3c4bd5b commit 83cd55c

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

javascript/ql/lib/semmle/javascript/Actions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module Actions {
3232
string getName() { result = this.lookup("name").(YamlString).getValue() }
3333

3434
/** Gets the name of the workflow file. */
35-
string getFileName() { result = this.getLocation().getFile().getBaseName() }
35+
string getFileName() { result = this.getFile().getBaseName() }
3636

3737
/** Gets the `on:` in this workflow. */
3838
On getOn() { result = this.lookup("on") }

javascript/ql/lib/semmle/javascript/frameworks/ServerLess.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private module ServerLess {
1515
* `codeURI` defaults to the empty string if no explicit value is set in the configuration.
1616
*/
1717
private predicate hasServerlessHandler(File ymlFile, string handler, string codeUri) {
18-
exists(YamlMapping resource | ymlFile = resource.getLocation().getFile() |
18+
exists(YamlMapping resource | ymlFile = resource.getFile() |
1919
// There exists at least "AWS::Serverless::Function" and "Aliyun::Serverless::Function"
2020
resource.lookup("Type").(YamlScalar).getValue().regexpMatch(".*::Serverless::Function") and
2121
exists(YamlMapping properties | properties = resource.lookup("Properties") |

javascript/ql/lib/semmle/javascript/linters/ESLint.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module ESLint {
6262
/** An `.eslintrc.yaml` file. */
6363
private class EslintrcYaml extends Configuration instanceof YamlMapping {
6464
EslintrcYaml() {
65-
exists(string n | n = this.getFile().getBaseName() |
65+
exists(string n | n = getFile().getBaseName() |
6666
n = ".eslintrc.yaml" or n = ".eslintrc.yml" or n = ".eslintrc"
6767
)
6868
}

shared/yaml/codeql/yaml/Yaml.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ module Make<InputSig Input> {
150150
* ```
151151
*/
152152
class YamlNode instanceof Input::NodeBase {
153+
/** Gets the file this node comes from. */
154+
Input::File getFile() { result = this.getLocation().getFile() }
155+
153156
/**
154157
* Gets the `Location` of this node.
155158
*/

0 commit comments

Comments
 (0)