GH-500 domain - 14% of the exam

Configure and use Code Security

Configure and use Code Security is 14% of the GH-500 exam. These are the objectives it covers, each with practice questions, with every answer explained.

The domain in numbers

42
Practice questions
4
Objectives
22
Medium
20
Hard

Where people go wrong

  • Separating analyses by anything except category

    The wrong answers try to keep two result sets apart with something other than the upload category: staggering the schedules, giving each upload a different commit SHA, or setting different severity thresholds. Code scanning identifies an analysis by tool, ref and category, so two uploads under the default category for the same commit replace each other, and the earlier set's open alerts are marked fixed. A distinct category per tool, language or build configuration keeps every result set, and its dismissals, separate.

    See it in a sample question
  • Keeping the automatic build where a custom build is needed

    The wrong answers keep an automatic build where the project needs its own. They suggest default setup with secrets, a pre-build step before init, rerunning autobuild, or build-mode none. Default setup and autobuild guess the build sequence and cannot be taught a bespoke CMake script or custom Gradle tasks, and none skips tracing, so compiled sources can be missed. Advanced setup with build-mode manual, plus the team's own commands between the init and analyse steps, lets CodeQL trace the real compilation.

    See it in a sample question
  • Confusing fail-fast, max-parallel and concurrency

    The wrong answers apply the wrong workflow control to an isolation or cancellation requirement. Fail-fast set to false stops one failing matrix job cancelling its siblings, but it cannot cancel earlier runs. Max-parallel only limits how many matrix jobs run at once, and setting it to one makes them run in sequence. Continue-on-error hides a failure rather than isolating it. Superseded runs on the same branch are cancelled by a concurrency group keyed on workflow and ref with cancel-in-progress true.

    See it in a sample question
  • Gating on alert level instead of security severity

    The wrong answers gate or rank alerts on the SARIF level, error, warning or note, instead of security severity. The level records how a query reports a result and says nothing about how dangerous the weakness is, so gating on error can block low-danger findings. Pull request thresholds act on security severity: critical, high, medium or low. For uploaded third-party results, a numeric security-severity property on each rule supplies it; precision metadata and a default level do not.

    See it in a sample question
  • Closing an alert without fixing the data flow

    The wrong answers close an alert, or commit a suggestion, without removing the data flow the alert traces. Dismissing as false positive or won't fix, an inline suppression, a try-catch around the sink, and a renamed variable all leave tainted input reaching the sink. An autofix suggestion is an editable starting point for a real result. The fix goes between source and sink, extended to every branch the data flow view shows, and false positive is reserved for a flow that cannot occur.

    See it in a sample question

Objectives in this domain

What to study

The official documents this domain's practice questions cite most.

Sample questions from this domain

Free sampleConfigure and use Code Securitymedium

A monorepo is analysed by two scanners: CodeQL for application code and a separate infrastructure-as-code scanner. Both upload SARIF for the same commit, but the second upload appears to overwrite the first so only one tool's alerts remain visible. What SARIF upload practice keeps both sets of results as distinct, co-existing code scanning alerts?

  • AGive each tool's upload a distinct category value so code scanning tracks the two analyses separately for that commit and ref. Correct
  • BUpload both SARIF files in a single combined run so code scanning merges the two tools into one result set.
  • CSchedule the two scanners on different days so their uploads never target the same commit and cannot collide.
  • DSet a unique runAutomationDetails id on each tool's check run so the Security tab keeps them on separate pages.
Use a distinct SARIF category per tool so multiple analyses for the same commit and ref are tracked and displayed separately. Code scanning treats an analysis as the tuple of tool, ref, and category. When two tools share the same effective category, a fresh upload from one is interpreted as updating the same analysis and supersedes the other. Supplying a unique category for each scanner lets code scanning keep the analyses independent so both tools' alerts remain on the same commit.

Why A is correct: Code scanning identifies an analysis by the combination of tool, ref, and the category supplied at upload. Assigning each scanner a unique category means a new upload only refreshes the matching analysis, so both tools' alerts persist side by side instead of one overwriting the other.

Why B is wrong: Combining unrelated tools into one upload does not preserve their separation and is not how code scanning distinguishes analyses. It is tempting as a way to keep everything together, but without distinct categories one analysis still replaces the other.

Why C is wrong: Staggering schedules avoids same-commit uploads but defeats the goal of having both tools' current results on the latest commit. It is a workaround that sacrifices coverage rather than the supported way to keep concurrent analyses distinct.

Why D is wrong: While SARIF does carry automation details, code scanning keys analyses on the upload category rather than on a hand-set check run page, and the example wrongly ties this to check runs. Relying on a check run id instead of a category does not stop one analysis replacing another.

Free sampleConfigure and use Code Securityhard

A repository contains a Go service and a C++ component, the latter built with a bespoke CMake script that needs three environment variables and a vendored toolchain to compile. The security lead enables code scanning default setup and the Go analysis succeeds, but the C++ analysis fails because the automatic build step cannot reproduce the custom compilation. They want CodeQL to keep analysing both languages with the least ongoing maintenance once a custom build is involved. What is the correct way to proceed?

  • ASwitch to advanced setup, which commits a CodeQL workflow file you can edit to run the custom CMake build before the analyse step, while still letting CodeQL scan the Go code automatically. Correct
  • BKeep default setup and add the missing environment variables and toolchain path to the repository secrets, since default setup reads repository secrets when it runs its automatic build for compiled languages.
  • CRemain on default setup but exclude C++ from the scanned languages, because default setup only supports interpreted languages such as Go and cannot analyse any compiled language at all.
  • DKeep default setup and raise a separate scheduled workflow that runs the CMake build and then calls the CodeQL command line interface directly to overwrite the default setup results for C++.
Choose advanced setup over default setup when a compiled language needs a custom build sequence that the automatic build cannot reproduce. Default setup runs a managed CodeQL analysis with an automatic build that you cannot customise, so a compiled language requiring a bespoke build will fail there. Advanced setup commits an editable codeql-action workflow where you can insert the exact build commands between the init and analyse steps, which is the supported mechanism for non-standard compilation while other languages are still analysed automatically.

Why A is correct: Advanced setup generates an editable codeql-action workflow where you can place the exact CMake commands between the init and analyse steps for the compiled language, while a language that needs no manual build is still picked up automatically. This is the supported route once a compiled language needs a custom build sequence that default setup cannot reproduce.

Why B is wrong: Default setup runs a managed analysis that does not expose an editable build sequence, so it cannot invoke the bespoke CMake script regardless of which secrets exist. Secrets do not teach the automatic build how to drive a vendored toolchain, so the C++ build would keep failing.

Why C is wrong: Default setup does support several compiled languages by attempting an automatic build, so the claim that it cannot analyse any compiled language is false. Dropping C++ would also abandon coverage of the component that most needs scanning, which is the opposite of the goal.

Why D is wrong: Running a parallel command line analysis alongside default setup duplicates configuration and creates two competing sources of results for the same language, which is fragile and high maintenance. The supported way to inject a custom build is the editable advanced setup workflow, not a bolt-on scheduled job.

Free sampleConfigure and use Code Securityhard

A monorepo holds JavaScript, Python, and Java code, and the security team wants each language analysed by CodeQL as an independent job so a build failure in one language does not block the others and the jobs can run in parallel. They are editing the advanced setup workflow, which uses a matrix over a single variable named language and a default branch policy that fails the whole workflow if any job fails. Which workflow change best delivers parallel, independent per-language analysis?

strategy:
  matrix:
    language: [ 'javascript', 'python', 'java' ]
  • AReplace the matrix with a single job that passes languages as a comma-separated list to the init step, because one job analysing all three languages together is what allows them to run in parallel.
  • BKeep the matrix and add max-parallel set to 1 under strategy, which lets the runner isolate each language so a failure in one does not affect the others.
  • CKeep the matrix and add fail-fast set to false under strategy, so a failure analysing one language does not cancel the still-running jobs for the other languages. Correct
  • DKeep the matrix and add continue-on-error set to true to each analyse step, so the workflow reports success even when a language build fails and never blocks the others.
Use a CodeQL language matrix with fail-fast disabled to analyse each language in an independent, parallel job. A strategy matrix over the language variable creates one parallel job per language, which is how CodeQL achieves per-language analysis. Disabling fail-fast prevents a single failing job from cancelling the others, giving true independence, whereas a single combined job removes parallelism, max-parallel one serialises the jobs, and continue-on-error merely hides failures instead of isolating them.

Why A is wrong: Collapsing three languages into one job removes the parallelism a matrix provides and ties their fates together, so a build failure for one language would still stop the analysis of the others. It moves away from the independence the team asked for.

Why B is wrong: Setting max-parallel to one forces the language jobs to run one after another rather than in parallel, which directly contradicts the requirement for parallel analysis. It also does nothing to stop fail-fast cancelling later jobs.

Why C is correct: A matrix already spawns one parallel job per language value, and setting fail-fast to false stops a single failing job from cancelling its siblings, so each language is analysed independently. This is the standard tuning for resilient per-language CodeQL matrix runs.

Why D is wrong: continue-on-error masks a genuine analysis failure by marking the step successful, which hides broken coverage rather than isolating jobs cleanly. The correct lever for keeping sibling matrix jobs running is fail-fast, not pretending a failed step passed.

Free sampleConfigure and use Code Securitymedium

A repository protects its default branch with a required code scanning check. The team configures the check so that only alerts at or above a chosen security severity block a pull request from merging, while lower-severity findings are surfaced but do not stop the merge. A new alert is reported with a security severity of "high". Given a threshold set to fail the check on high or critical findings, what happens to a pull request introducing this alert?

  • AThe pull request merges and the alert is recorded only after merge, because severity affects reporting but never the merge decision of a required check.
  • BThe merge is blocked only if the alert is additionally classified as an error rather than a warning, regardless of its security severity rating.
  • CThe check passes with a warning annotation, because high severity is below the default blocking level and only critical findings fail the check.
  • DThe required code scanning check fails and blocks the merge, because the high-severity alert meets the configured threshold for failing the pull request. Correct
Predict that a required code scanning check with a security severity threshold fails the pull request when an alert meets or exceeds that threshold. Code scanning lets a repository set the security severity level at which the pull request check fails, and require that check on the default branch. When an alert's security severity meets or exceeds the configured threshold, the check fails and a required check blocks the merge. A high-severity finding under a high-or-critical threshold therefore blocks the pull request, independent of the alert's SARIF warning-or-error level.

Why A is wrong: Severity does influence the check outcome when a threshold is configured, so this is incorrect. It is tempting if one assumes checks are purely informational, but a required check tied to a severity threshold can block the merge.

Why B is wrong: This conflates the SARIF alert level with the security severity used by the pull request threshold. The configured failure condition here is based on security severity, so a high-severity finding triggers the failure independent of its warning-or-error level.

Why C is wrong: The threshold in the scenario is set to fail on high or critical, so high is not below the blocking level here. Assuming only critical findings ever block ignores that the failure severity is configurable.

Why D is correct: Code scanning pull request checks can be configured with a security severity threshold, and an alert at or above that threshold causes the check to fail. A "high" finding meets a "high or critical" threshold, so the required check fails and the merge is blocked until the alert is addressed.

Free sampleConfigure and use Code Securitymedium

A code scanning alert raised by CodeQL offers a suggested fix generated by autofix. A developer reviews the suggestion and sees that it adds input validation that looks plausible but does not account for one of the code paths in the affected function. They want to act on the autofix appropriately without introducing a regression. What is the correct way to handle the autofix suggestion?

  • ACommit the autofix exactly as proposed, because an accepted autofix is automatically verified by re-running the CodeQL query before it is allowed to merge.
  • BDismiss the alert as a false positive, since autofix proposing a change confirms the finding can be auto-resolved without code changes.
  • CEdit the autofix suggestion before committing, extending the validation to cover the missed code path so the remediation is complete. Correct
  • DReject the autofix and disable autofix for the repository, because a partial suggestion proves the feature is unreliable for this language.
Treat an autofix suggestion as an editable, reviewable proposal that the developer must validate and may adjust before committing, not an auto-applied guarantee. Autofix for code scanning generates a suggested code change for an alert, but the developer reviews it and can accept, edit, or reject it. The fix is the human reviewer's responsibility, so when a suggestion misses a code path the right action is to extend it before committing, not to commit it blindly, dismiss the real finding, or disable the feature entirely.

Why A is wrong: Autofix does not gate the commit behind an automatic re-analysis that guarantees correctness, and accepting it unreviewed can ship an incomplete change. The claim of automatic verification before merge is tempting but overstates what autofix provides.

Why B is wrong: An autofix suggestion does not make a finding a false positive; it is a proposed remediation for a real result. Dismissing as false positive misrepresents a genuine vulnerability and leaves the insecure code in place.

Why C is correct: Autofix produces a suggested change that the developer can accept, edit, or reject, and it remains the reviewer's responsibility to confirm it is correct. Editing the suggestion to cover the missed path delivers a complete fix while still using the autofix as a starting point.

Why D is wrong: One incomplete suggestion is not grounds to disable the feature, and rejecting outright discards a useful starting point the developer could refine. Disabling autofix removes assistance from every future alert over a single editable case.

Other domains in this exam

See also the GH-500 cert hub, the study guide, and the cheat sheet.

Examworthy is not affiliated with or endorsed by GitHub. Original, blueprint-aligned practice material only.