Back to the course
Test yourself

Secure CI/CD with GitLab

Final exam · 34 questions · answers explained as you pick
GitLab CI fundamentals
9 questions
01A job in stage test failed. Two jobs in the later stage deploy have no needs. What happens to them?
Correct — Stages run in order, and a failed stage stops the stages after it.
Incorrect — Containers do not change stage order.
Incorrect — The pipeline ends as failed; a retry starts the rest again.
Incorrect — They do not run at all.
02Why does a job that ran pip install not help the next job?
Incorrect — Nothing is deleted from the next container. It never had them.
Correct — It also gets a cleaned checkout. Jobs share only what you pass on as artifacts or cache.
Incorrect — pip knows nothing about branches.
Incorrect — GitLab does not inspect packages.
03A job is pending for an hour with no runner assigned. The runners are online. What is the first thing to compare?
Incorrect — The script has not run yet.
Incorrect — Repository size does not keep a job pending.
Correct — A runner must have every tag the job asks for.
Incorrect — Stage count does not decide which runner takes a job.
04A runner's concurrent setting is 1. Two jobs in one stage take 8 seconds each. About how long does the stage take?
Incorrect — They overlap only if runners have free slots.
Incorrect — Jobs do not split work between them.
Incorrect — There is no lock. They simply queue.
Correct — The lab showed slow-b starting after slow-a ended.
05Which workflow:rules entry stops a branch pipeline while a merge request is open for that branch?
Correct — The merge request pipeline covers that commit instead.
Incorrect — That would allow branch pipelines, not stop them.
Incorrect — That concerns tag pipelines, not duplicates.
Incorrect — That depends on files, not on open merge requests.
06A job has rules: - changes: [docs/**/*]. A developer pushes a new branch that changes only src/. Does it run?
Incorrect — That holds on later pushes, not the first.
Correct — GitLab treats every file as changed on the first push of a branch.
Incorrect — Protection does not affect changes.
Incorrect — changes works in branch and merge request pipelines too.
07A JUnit report and a coverage folder are both artifacts of a job without when. The tests fail. What does GitLab keep?
Incorrect — Plain artifacts default to on_success.
Incorrect — Reports are uploaded on failure too.
Correct — Reports are collected whatever the result.
Incorrect — It is the other way round.
08A job reuses a cache keyed on requirements.txt. What must stay true when the cache is empty?
Incorrect — An empty cache is never an error.
Incorrect — Artifacts are for guaranteed hand-offs, not cache misses.
Incorrect — Cache contents do not depend on protection.
Correct — A cache is a hint, and it can always be missing.
09A project includes shared CI from ref: main of another project. What is the risk?
Correct — Pin includes to a protected tag or a commit SHA.
Incorrect — Includes are fetched for every new pipeline.
Incorrect — Includes apply on every branch.
Incorrect — They run as jobs of this project, with its variables.
9 questions · explanations appear as you answer
Securing the pipeline
11 questions
01A Developer pushes a branch whose .gitlab-ci.yml prints $(echo "$TOKEN" | rev). TOKEN is masked and unprotected. What appears in the log?
Incorrect — The runner does not detect transformations.
Correct — Masking replaces only the exact value.
Incorrect — Unprotected variables reach every branch.
Incorrect — Jobs receive the real value.
02An outside contributor opens a merge request from a fork. With default settings, where does its pipeline run?
Incorrect — That needs a parent member to run it there.
Incorrect — Fork pipelines run in the fork without approval.
Correct — The parent's variables are not involved.
Incorrect — Pipelines always run on runners.
03A Maintainer runs a fork merge request's pipeline in the parent project. What must they read first?
Incorrect — Commit messages do not run.
Incorrect — The title does not run either.
Incorrect — There is no such sandbox.
Correct — That covers .gitlab-ci.yml and its includes. That code runs with the parent's variables and runners.
04PROD_TOKEN is protected. Which pipelines receive it?
Correct — The lab printed length 0 on a feature branch and 21 on main.
Incorrect — Protection follows the ref, not who started the pipeline.
Incorrect — Their ref is refs/merge-requests/..., which is not protected.
Incorrect — Job settings do not decide which variables arrive.
05Release jobs run on tags. Why protect the v* tag pattern?
Incorrect — GitLab does not delete tags.
Correct — A tag can point at any commit, so the release jobs could run on any of them.
Incorrect — Protection has no effect on speed.
Incorrect — Unprotected tags can be pushed by Developers. That is the problem.
06A runner has access_level: ref_protected. A feature branch job matches its tags. What happens?
Incorrect — A protected runner does not take it at all.
Incorrect — It waits rather than failing.
Correct — This one serves only protected refs. The lab job stayed pending until an untrusted runner appeared.
Incorrect — There is no runner approval step.
07A shared runner mounts the host's Docker socket into jobs. What can a job do?
Incorrect — The Docker API can start containers, including privileged ones.
Incorrect — It reaches every container.
Incorrect — Mounting it read-only does not limit the API calls.
Correct — That includes root on the host. The lab job read GitLab's root password through the socket.
08What does allowed_images in a runner's config do?
Correct — The runner refused docker:29-cli as a disallowed image.
Incorrect — It only matches names.
Incorrect — Allowed images run any script.
Incorrect — It does not change image references.
09A team stores a cloud key as a masked variable that is not hidden. They assume nobody can copy it. Who actually can?
Incorrect — Masking only rewrites logs.
Correct — Maintainers can read it in the settings and API, as the lab's API call showed.
Incorrect — Project Maintainers can read it too.
Incorrect — That would be the protected setting.
10A job logs in to OpenBao with an ID token. The role binds project_path, ref_type and ref_protected. Why can a Developer not get in from a branch?
Incorrect — OpenBao sees claims, not GitLab roles.
Incorrect — They can. Their claims just do not match.
Correct — GitLab signs that value into the branch job's token. The claim comes from GitLab, so the job cannot change it.
Incorrect — Branch tokens last as long as others.
11Project A's job clones private project B with CI_JOB_TOKEN and gets 403. What fixes it the intended way?
Incorrect — That bypasses the control with a long-lived secret.
Incorrect — That exposes B to everyone.
Incorrect — That gives every job on the runner access to B.
Correct — B decides which projects' jobs may access it.
11 questions · explanations appear as you answer
Scanning in the pipeline
7 questions
01On the Free tier, GitLab's SAST job finds a high-severity issue. What happens to the pipeline by default?
Correct — A gate job of your own has to fail on the report. Blocking on findings needs security policies, an Ultimate feature.
Incorrect — The analyzer job succeeds when the scan completes.
Incorrect — There is no such pause on the Free tier.
Incorrect — Nothing closes merge requests.
02A token is committed and removed in the next commit. Why is that not enough?
Incorrect — Force-pushing does not reach existing clones or forks.
Correct — It stays in the repository's history and every clone, so rotate it. A historic scan found it again in the lab.
Incorrect — Default scans look at new commits.
Incorrect — GitLab does not block projects for secrets.
03Why cache Trivy's vulnerability database between pipelines?
Incorrect — It downloads the database when none is cached.
Incorrect — A cache does not change results.
Correct — It also depends on the network. The cache only saves time; the job still works without it.
Incorrect — Trivy checks its database itself.
04A team scans its image once at build time. A month later a new CVE affects the same image. What does the original scan tell them?
Incorrect — It passed against an older database.
Incorrect — The scan cannot know that.
Incorrect — The scan does not say anything about rebuilding.
Correct — Images need rescanning. A scan is a snapshot of what was known then.
05ZAP's baseline scan runs against an app started as a job service. What kind of testing is it?
Correct — It looks at things such as headers and cookies. The baseline crawls and inspects; it does not attack.
Incorrect — That is SAST.
Incorrect — That is an active scan.
Incorrect — That is dependency scanning.
06Why give scanner jobs pinned image digests instead of tags like :latest?
Incorrect — Speed does not depend on the reference.
Correct — The scanner's behaviour is fixed until then. A moving tag can change results, or the tool itself, without review.
Incorrect — They run from either.
Incorrect — They hide nothing.
07A scanner reports 40 findings, mostly in a base image you cannot change today. What is a sensible gate?
Incorrect — It would block every pipeline until the base image changes.
Incorrect — Without a gate, findings pile up unnoticed.
Correct — Gate on critical findings with a fix available. A gate nobody can pass gets switched off.
Incorrect — Hiding results is not a gate.
7 questions · explanations appear as you answer
Releases and delivery
7 questions
01Why store a Cosign private key as a protected file variable?
Incorrect — They are stored like other variables.
Incorrect — It can read other forms too.
Incorrect — Variables do not expire.
Correct — Protection keeps it from unprotected refs. The job also gets a path, not the key text.
02A Developer's branch job runs cosign sign-blob --key "$COSIGN_KEY". The key is a protected variable. What happens?
Correct — The branch pipeline receives no protected variables. The lab job had an empty COSIGN_KEY.
Incorrect — The image is not the protection.
Incorrect — GitLab does not inspect scripts.
Incorrect — Not with your key. At most Cosign tries keyless signing, which never verifies against your public key.
03Who can still obtain a signing key held in protected project variables?
Incorrect — Only hidden variables are unreadable after saving.
Correct — They can also cut tags. A KMS reached with an ID token narrows that further.
Incorrect — Branch pipelines do not receive it.
Incorrect — Artifacts carry signatures, not keys.
04Where should customers get the public key used to verify releases?
Incorrect — Whoever swaps the file can swap the key too.
Incorrect — Logs are not a trusted distribution channel.
Correct — It must not be changeable along with the download. A key next to the file is as weak as a checksum next to it.
Incorrect — Public is not the same as authentic.
05What does resource_group: production do for a deploy job?
Incorrect — That would be protected environments.
Incorrect — Runners are chosen by tags.
Incorrect — It only orders jobs.
Correct — A second job waits for the resource.
06How do you roll back a deployment that GitLab tracks in an environment?
Correct — It deploys that commit again and records a new deployment.
Incorrect — Deleting the record does not change what runs.
Incorrect — That works eventually, but it is not the quick rollback.
Incorrect — Runners do not keep deployments.
07A Developer cannot merge into protected main. Can they start the manual deploy-production job in a main pipeline?
Incorrect — Manual jobs on protected branches follow the branch's merge rights.
Correct — Starting a manual job needs permission to merge into its branch. On the Free tier, protected branches already limit who presses play.
Incorrect — It orders jobs and checks no roles.
Incorrect — Environments are created by deployments.
7 questions · explanations appear as you answer