Skip to content

CodeQL's default configuration generator is inconsistent with CodeQL's internal language detectors #21787

@emeralddcw

Description

@emeralddcw

Description of the issue

I've been running CodeQL on an internal repo with the default CodeQL config. That repo contains a python script without a .py extension. The default CodeQL config correctly detects that the repository contains python code, so it ran the CodeQL python analyzer. The CodeQL python analyzer incorrectly detected that there was no python code present in the project, so it emitted an error:

Encountered a fatal error while running "/opt/hostedtoolcache/CodeQL/2.25.3/x64/codeql/codeql database finalize --finalize-dataset --threads=2 --ram=6914 /home/runner/work/_temp/codeql_databases/python". Exit code was 32 and last log line was: CodeQL detected code written in GitHub Actions, but not any written in Python. Confirm that there is some source code for Python in the project. For more information, review our troubleshooting guide at https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build . See the logs for more details.

The github/codeql-action/init@v4 action notes that it activated the python analyzer, but does not explain why. Through guess-and-check, I found that adding a .py extension to the python script got the analyzer to run.

Suggestions for improvement

  1. Use a single set of filtering rules in the CodeQL init stage and CodeQL analyze stage. As a user of the default CodeQL config, it is surprising to see that CodeQL (the GitHub action) determined this project has python code and CodeQL (the python analyzer) determine this project does not have python code.
  2. Make it possible to see why an analyzer was activated so that visitors of the linked troubleshooting page know which flow is applicable to them. For example, make it possible to see a list of the files that the analyzer determined were python files.

Probably related

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions