Js/Yaml: add getFile() predicate

This commit is contained in:
Arthur Baars
2023-04-11 16:01:44 +01:00
parent 3c4bd5b6a7
commit 83cd55cb29
4 changed files with 6 additions and 3 deletions

View File

@@ -32,7 +32,7 @@ module Actions {
string getName() { result = this.lookup("name").(YamlString).getValue() }
/** Gets the name of the workflow file. */
string getFileName() { result = this.getLocation().getFile().getBaseName() }
string getFileName() { result = this.getFile().getBaseName() }
/** Gets the `on:` in this workflow. */
On getOn() { result = this.lookup("on") }

View File

@@ -15,7 +15,7 @@ private module ServerLess {
* `codeURI` defaults to the empty string if no explicit value is set in the configuration.
*/
private predicate hasServerlessHandler(File ymlFile, string handler, string codeUri) {
exists(YamlMapping resource | ymlFile = resource.getLocation().getFile() |
exists(YamlMapping resource | ymlFile = resource.getFile() |
// There exists at least "AWS::Serverless::Function" and "Aliyun::Serverless::Function"
resource.lookup("Type").(YamlScalar).getValue().regexpMatch(".*::Serverless::Function") and
exists(YamlMapping properties | properties = resource.lookup("Properties") |

View File

@@ -62,7 +62,7 @@ module ESLint {
/** An `.eslintrc.yaml` file. */
private class EslintrcYaml extends Configuration instanceof YamlMapping {
EslintrcYaml() {
exists(string n | n = this.getFile().getBaseName() |
exists(string n | n = getFile().getBaseName() |
n = ".eslintrc.yaml" or n = ".eslintrc.yml" or n = ".eslintrc"
)
}