Custom CodeQL query in Azure DevOps in yaml pipeline gives error: No queries defined for javascript

I want to run custom codeql queries for Advanced Security in Azure DevOps (this is a feature that is now available in Azure DevOps not only GitHub). The built in default queries like security-and-quality works fine. I run them as batch at night.

But I am now building a new separate pipeline that will also run at night as a batch. With it I want to run a few custom queries looking for specific not wanted pattern in this rather large JavaScript git repository.

All of this is stored and run in Azure DevOps Services. I have started with a simple find all ToDo codeql query to get thing going. But I get this error, that I cant find in the documentation or Troubleshooting code scanning faq , or see anyone else have had before:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>/opt/hostedtoolcache/CodeQL/2.17.2/x64/codeql/codeql database init --codescanning-config=/home/vsts/work/1/s/.azuredevops/customcodeql/customconfig.yaml --db-cluster /home/vsts/work/_temp/advancedsecurity.codeql/d --source-root=/home/vsts/work/1/s --language=javascript --calculate-baseline
A fatal error occurred: No queries defined for javascript
##[warning] Error running the 'database init' CodeQL command for javascript (2)
##[error]Error running the 'database init' CodeQL command for javascript (2)
====================================================================================================
Analyzing CodeQL execution results.
CodeQL analysis finished with exit code 2.
</code>
<code>/opt/hostedtoolcache/CodeQL/2.17.2/x64/codeql/codeql database init --codescanning-config=/home/vsts/work/1/s/.azuredevops/customcodeql/customconfig.yaml --db-cluster /home/vsts/work/_temp/advancedsecurity.codeql/d --source-root=/home/vsts/work/1/s --language=javascript --calculate-baseline A fatal error occurred: No queries defined for javascript ##[warning] Error running the 'database init' CodeQL command for javascript (2) ##[error]Error running the 'database init' CodeQL command for javascript (2) ==================================================================================================== Analyzing CodeQL execution results. CodeQL analysis finished with exit code 2. </code>
/opt/hostedtoolcache/CodeQL/2.17.2/x64/codeql/codeql database init --codescanning-config=/home/vsts/work/1/s/.azuredevops/customcodeql/customconfig.yaml --db-cluster /home/vsts/work/_temp/advancedsecurity.codeql/d --source-root=/home/vsts/work/1/s --language=javascript --calculate-baseline
A fatal error occurred: No queries defined for javascript
##[warning] Error running the 'database init' CodeQL command for javascript (2)
##[error]Error running the 'database init' CodeQL command for javascript (2)

====================================================================================================
Analyzing CodeQL execution results.
CodeQL analysis finished with exit code 2.

I have a yaml pipeline with the tasks
AdvancedSecurity-Codeql-Init@1 , AdvancedSecurity-Codeql-Autobuild@1 and AdvancedSecurity-Codeql-Analyze@1 .
The task AdvancedSecurity-Codeql-Init@1 points to a codeqlconfig yaml file and in this file I point to a simple todo codeql query. This is afaik how it has to be done according to the documentation I have read eg: Analysis with custom queries .

I once wrote the wrong path the codeql query. Then I got the error message: A fatal error occurred: ./azuredevops/customcodeql/todos.ql is not a .ql file, .qls file, a directory, or a query pack specification.
I corrected the path (added . infront so it became ./.azuredevops….) and no longer got the cant find file type of error, so I assume it finds the file now.

But now I get this other error: “No queries defined for javascript” so assume that it finds my todos.ql but it does not work anyway.

Here are the three files that I use:

Here is the todo.ql taken from the examples :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>/**
* @id js/javascript/todocomment
* @name TODO_comments
* @description Finds comments containing the word TODO
* @kind problem
* @problem.severity recommendation
* @tags comment
* TODO
*/
import javascript
from Comment c
where c.getText().regexpMatch("(?si).*\bTODO\b.*")
select c
</code>
<code>/** * @id js/javascript/todocomment * @name TODO_comments * @description Finds comments containing the word TODO * @kind problem * @problem.severity recommendation * @tags comment * TODO */ import javascript from Comment c where c.getText().regexpMatch("(?si).*\bTODO\b.*") select c </code>
/**
 * @id js/javascript/todocomment
 * @name TODO_comments
 * @description Finds comments containing the word TODO
 * @kind problem
 * @problem.severity recommendation
 * @tags comment
 *       TODO
 */
import javascript

from Comment c
where c.getText().regexpMatch("(?si).*\bTODO\b.*")
select c

Here is the codeql customconfig.yaml :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>name: "Run custom queries"
disable-default-queries: true
queries:
- name: TODO_comments
uses: ./.azuredevops/customcodeql/todos.ql
paths:
- src
paths-ignore:
- '**/node_modules'
- '**/*.test.js'
query-filters:
- include:
kind: problem
</code>
<code>name: "Run custom queries" disable-default-queries: true queries: - name: TODO_comments uses: ./.azuredevops/customcodeql/todos.ql paths: - src paths-ignore: - '**/node_modules' - '**/*.test.js' query-filters: - include: kind: problem </code>
name: "Run custom queries"
disable-default-queries: true
queries:
  - name: TODO_comments
      uses: ./.azuredevops/customcodeql/todos.ql
paths:
  - src 
paths-ignore: 
  - '**/node_modules'
  - '**/*.test.js'
query-filters:
 - include:
    kind: problem

Here is part of the yaml pipeline that is run in Azure DevOps as a batch job.
Ehe error occur on the task AdvancedSecurity-Codeql-Init@1 version 1.1.262 after about 7 seconds

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>- stage: Analyze_Custom_CQL
jobs:
- job: Analyze
steps:
- task: AdvancedSecurity-Codeql-Init@1
inputs:
languages: 'javascript'
loglevel: '3'
configfilepath: '$(build.sourcesDirectory)/.azuredevops/customcodeql/customconfig.yaml'
- task: AdvancedSecurity-Codeql-Autobuild@1
displayName: 'Advanced Security Autobuild'
- task: AdvancedSecurity-Codeql-Analyze@1
</code>
<code>- stage: Analyze_Custom_CQL jobs: - job: Analyze steps: - task: AdvancedSecurity-Codeql-Init@1 inputs: languages: 'javascript' loglevel: '3' configfilepath: '$(build.sourcesDirectory)/.azuredevops/customcodeql/customconfig.yaml' - task: AdvancedSecurity-Codeql-Autobuild@1 displayName: 'Advanced Security Autobuild' - task: AdvancedSecurity-Codeql-Analyze@1 </code>
- stage: Analyze_Custom_CQL
  jobs:
  - job: Analyze
    steps:
    - task: AdvancedSecurity-Codeql-Init@1
      inputs:
        languages: 'javascript'
        loglevel: '3'
        configfilepath: '$(build.sourcesDirectory)/.azuredevops/customcodeql/customconfig.yaml'

    - task: AdvancedSecurity-Codeql-Autobuild@1
      displayName: 'Advanced Security Autobuild'

    - task: AdvancedSecurity-Codeql-Analyze@1   

Am I missing something in the todos.ql, metadata or something ? I have changes the filter and include in the customconfig.yaml. Tried with or without them.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật