Skip to content

GH-500 · Domain 4: Configure and use Code Security (formerly Code Scanning with CodeQL) · 13% of the exam

Task 4.4: Optimize and automate Code Security operations

Configuration files and repository properties that tune analysis, and diagnosing slow, failed or incomplete scans.

Study it

  • Tuning analysis and troubleshooting failed or slow scans

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the GitHub documentation page that proves it.

Question 1 · choose 1

An organization sets the github-codeql-config-file repository property to a shared configuration that adds path exclusions. Most repositories use default setup with threat models chosen in the UI; one repository uses advanced setup with its own config-file input in the workflow. Which configuration does each use?

  1. ADefault setup repositories use only the shared file, which discards the threat models chosen in the UI
  2. BThe advanced setup repository uses the shared file, which overrides its workflow input
  3. CDefault setup merges the file with its UI settings, and the advanced workflow keeps its own file
  4. DThe property applies only to advanced setup, so default setup repositories ignore the shared file
Show the answer and why
  • ADefault setup repositories use only the shared file, which discards the threat models chosen in the UI

    Incorrect

    The file is merged with the UI selections, which are kept.

  • BThe advanced setup repository uses the shared file, which overrides its workflow input

    Incorrect

    An explicit config-file input takes precedence over the property.

  • CDefault setup merges the file with its UI settings, and the advanced workflow keeps its own file

    Correct

    That is how the property combines with each setup type.

  • DThe property applies only to advanced setup, so default setup repositories ignore the shared file

    Incorrect

    The property applies to both setup types.

The github-codeql-config-file property points to a local or remote configuration file. For default setup it is merged with the automatically generated configuration, keeping UI choices such as threat models and model packs. It also applies to advanced setup, unless the workflow sets an explicit config-file input for codeql-action/init, which then takes precedence.

Question 2 · choose 2

An advanced setup workflow for a Java project, with build-mode: manual, fails with "No source code was seen during the build". The job runs mvn package as its first step, then codeql-action/init, then codeql-action/analyze, and Maven reuses outputs from a build cache restored at the start. Which two changes address the cause? (Choose TWO.)

  1. AMove the build so that it runs between the init and analyze steps
  2. BMake sure a full compilation happens instead of a cached one
  3. CAdd the java-kotlin language a second time in the init step
  4. DRaise the runner's memory so that the extractor can finish
  5. EReplace the analyze step with the upload-sarif action
Show the answer and why
  • AMove the build so that it runs between the init and analyze steps

    Correct

    CodeQL must observe the compiler, which happens only between init and analyze.

  • BMake sure a full compilation happens instead of a cached one

    Correct

    CodeQL needs a complete build to watch; cached components aren't seen.

  • CAdd the java-kotlin language a second time in the init step

    Incorrect

    Listing a language twice doesn't change what CodeQL observes.

  • DRaise the runner's memory so that the extractor can finish

    Incorrect

    Memory isn't the problem; the compiler ran when CodeQL wasn't watching.

  • EReplace the analyze step with the upload-sarif action

    Incorrect

    Without analysis there are no results to upload.

For compiled languages built with autobuild or manual mode, CodeQL monitors the compiler. If the code is compiled outside the init and analyze steps, if parts of the build are cached so no real compilation happens (common with Gradle or Bazel), or if it is built in another container, CodeQL sees no source code. The build must run between init and analyze, and fully.

Question 3 · choose 1

How can a team download the CodeQL database built in an Actions workflow to inspect which files were extracted?

  1. AAdd a SECURITY.md file
  2. BEnable Copilot Autofix
  3. CSet debug: true on codeql-action/init
  4. DExport an SBOM
Show the answer and why
  • AAdd a SECURITY.md file

    Incorrect

    That is a security policy.

  • BEnable Copilot Autofix

    Incorrect

    Autofix suggests fixes.

  • CSet debug: true on codeql-action/init

    Correct

    The database is then uploaded as an Actions artifact.

  • DExport an SBOM

    Incorrect

    SBOMs list dependencies.

Setting debug: true on the init step of the CodeQL workflow uploads the database as an Actions artifact. It includes src.zip, a copy of the source files CodeQL scanned, which you can compare with the repository.

Question 4 · choose 1

Which CodeQL configuration keyword excludes one noisy query from analysis?

  1. Apaths-ignore
  2. Bquery-filters
  3. Cthreat-models
  4. Dexclude-queries
Show the answer and why
  • Apaths-ignore

    Incorrect

    That excludes files, not queries.

  • Bquery-filters

    Correct

    query-filters excludes queries.

  • Cthreat-models

    Incorrect

    That changes sources of tainted data.

  • Dexclude-queries

    Incorrect

    The CodeQL configuration has no such keyword.

In advanced setup, the query-filters keyword in the CodeQL configuration excludes one or more queries from analysis, for example a single rule that dominates the results.

Question 5 · choose 1

A repository with Java and Kotlin code uses default setup with build mode none. The CodeQL run warns that Kotlin files "could not be processed without a build". What explains the warning?

  1. ACodeQL doesn't support Kotlin
  2. BThe runner ran out of disk space during extraction
  3. CThe Kotlin code needs a newer CodeQL version than default setup uses
  4. DWithout a build, Kotlin files are left out of the CodeQL database
Show the answer and why
  • ACodeQL doesn't support Kotlin

    Incorrect

    Kotlin is supported; it is analyzed with Java as java-kotlin.

  • BThe runner ran out of disk space during extraction

    Incorrect

    A lack of disk space produces an "Out of disk" error, not this warning.

  • CThe Kotlin code needs a newer CodeQL version than default setup uses

    Incorrect

    Default setup always uses the latest version of the CodeQL action.

  • DWithout a build, Kotlin files are left out of the CodeQL database

    Correct

    Build mode none covers Java, but Kotlin files are excluded unless the code is built.

CodeQL can create a database for Java without building the code, but Kotlin files are excluded unless the code is built, so the warning appears when build mode none is used for a repository with both Java and Kotlin files. To include Kotlin, disable and re-enable default setup once the Kotlin code is on the default branch, so that it uses automatic build detection, or use advanced setup with autobuild or manual build steps.

Question 6 · choose 1

Improved incremental analysis fails on a repository because of its higher hardware needs. Which change turns it off?

  1. AThe github-codeql-disable-overlay property set to true
  2. BThe security-extended suite instead of the default suite
  3. CA lower memory limit for the runner
  4. Dbuild-mode: none in the init step
Show the answer and why
  • AThe github-codeql-disable-overlay property set to true

    Correct

    Setting it to true disables improved incremental analysis.

  • BThe security-extended suite instead of the default suite

    Incorrect

    A larger suite adds work; it doesn't turn incremental analysis off.

  • CA lower memory limit for the runner

    Incorrect

    Less memory makes failures more likely.

  • Dbuild-mode: none in the init step

    Incorrect

    Build mode changes how the database is created, not incremental analysis.

You can disable improved incremental analysis by setting the github-codeql-disable-overlay repository property to true, which may help when that analysis fails because of increased hardware requirements.

Practise domain 4 →Practise all domains →