codeql-action: CodeQL analyze error with exit code 2: running specific queries using a query suite

Hi CodeQL team,

I found this error occur just about a week ago. I don’t change anything in the codebase (because I set this workflow to run on master branch and master branch the last update is a week ago).

Right now this error is raised when my CodeQL run when the schedule time arrive

Error: Error running analysis for go: Error: The process '/opt/hostedtoolcache/CodeQL/0.0.0-20210308/x64/codeql/codeql' failed with exit code 2
CodeQLAnalysisError: Error running analysis for go: Error: The process '/opt/hostedtoolcache/CodeQL/0.0.0-20210308/x64/codeql/codeql' failed with exit code 2
    at runQueries (/home/runner/work/_actions/github/codeql-action/v1/lib/analyze.js:113:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  name: 'CodeQLAnalysisError',
  queriesStatusReport: {
    analyze_builtin_queries_go_duration_ms: 92593,
    analyze_failure_language: 'go'
  }
}

I still have no idea why does this happens. If you need any additional information, feel free to provide me what you want. Thank you guys in advance.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

Exactly the information I needed, thank you @ArielSAdamsNASA. Try the following in your jpl.qls query suite file:

# Start with all the queries in the codeql/cpp-queries pack.
- queries: .
  from: codeql/cpp-queries
# Restrict to only the queries with the following ID patterns.
- include:
    id:
      # Regular expression matching all query IDs that start with `cpp/jpl-c/`
      # This covers all queries in the `JPL_C` directory,
      # but matching on query ID is more stable.
      - /cpp/jpl-c/*/
      # Specific JSF queries, identified by query ID.
      - cpp/jsf/av-rule-153
      - cpp/jsf/av-rule-168
      - cpp/jsf/av-rule-202
      - cpp/jsf/av-rule-165
      - cpp/jsf/av-rule-173

Each query’s ID can be found in the query metadata section at the top of the query file, starting with @id.

To help you with future query suite writing:

@ArielSAdamsNASA thanks for asking. Could you please try changing your jpl.qls file to

- queries: JPL_C
  from: codeql/cpp-queries

The name expected in the from field is the name of the query pack, which is defined in https://github.com/github/codeql/blob/main/cpp/ql/src/qlpack.yml. codeql-cpp should also work in place of codeql/cpp-queries, much like the examples earlier in this thread. That is the old name, and CodeQL handles both.