MSBA-361 · Lesson 3 of 12 · 18 min
Reading code scanning alerts
▶ Video coming soon A video version of this lesson is on the way.
By the third Thursday, every group at Skerry had alerts and most had opinions about them. Teodric Nnaji-Lund from the commerce group arrived with a printout of one alert from the checkout service and a single question written across the top: is this real? Seraphine said that was exactly the right question, and that the alert page was designed to answer it, if you knew how to read it.
This lesson walks through a code scanning alert from top to bottom, then covers the life of an alert from detection to closure, and the triage habits that keep a large backlog manageable.
The parts of an alert
Every code scanning alert has the same structure, whether it came from CodeQL or a third-party tool.
| Part | What it tells you |
|---|---|
| Title and rule | Which query or rule fired, for example a CodeQL query for database queries built from user-controlled sources |
| Tool | Which analysis produced it: CodeQL, or the name of a third-party tool |
| Severity and security severity | How serious the finding is as an error, warning or note, and for security rules whether it is critical, high, medium or low |
| Tags | Classification such as security, correctness and the CWE identifiers |
| Location | The file and lines where the problem is reported, with the code shown |
| Show paths | For data flow alerts, each step from source to sink |
| Rule help | An explanation of the problem, how to fix it, examples and references |
| Affected branches | Which branches currently contain the alert |
| Timeline | When it was first detected, in which commit, and every state change since |
Following the path
Teodric's alert was a data flow alert for cross-site scripting in the checkout service's order confirmation page. The location pointed at a line that wrote a value into the page. On its own, the line looked harmless. The show paths view told the rest of the story: the value began as a query parameter carrying a gift message, passed through three functions in two files, was stored briefly on the order object and was then inserted into the page without escaping.
Reading a path well means asking three questions at each step. Could an attacker control this value? Does anything on this step make it safe for the sink at the end? Is the path actually reachable when the application runs? In Teodric's case the answers were yes, no and yes. The gift message could contain anything a shopper typed, nothing escaped it, and the confirmation page was shown to every shopper. The alert was real.
Some paths fail the third question. CodeQL sometimes finds paths through code that is only reachable in tests, behind a feature flag that is permanently off, or through an unusual combination of configuration that cannot occur in production. Those are candidates for dismissal, with a note saying why, but only after someone has checked.
Severity and security severity together
Freya's team agreed a simple reading of the two severity fields for Skerry.
| Security severity | Skerry response target on production code | Merge behavior after lesson 11's ruleset |
|---|---|---|
| Critical | Fix within 7 days | Blocks merge |
| High | Fix within 30 days | Blocks merge |
| Medium | Fix within 90 days or in a campaign | Warns |
| Low | Fix when the code is next changed | Warns |
| None (quality rules: error, warning, note) | Team discretion | Does not block |
Response targets like these are the organization's decision, not something GitHub sets. GitHub provides the classification and the tools to filter and enforce; the security team decides what each level means for its own risk.
The life of an alert
An alert is created when an analysis first reports a problem on a branch that GitHub tracks. From then on it moves through a small set of states.
| State | How it happens | Notes |
|---|---|---|
| Open | An analysis reports the problem | Shown in lists and counted in metrics |
| Fixed | A later analysis of the same branch and category no longer reports it | Closed automatically; nobody clicks fixed |
| Dismissed: false positive | A person decides the alert is wrong | Should include a comment saying why |
| Dismissed: won't fix | A person accepts the risk or the code is being retired | Should name who accepted the risk |
| Dismissed: used in tests | The code is test-only | Better handled by excluding test paths where possible |
| Reopened | A person reopens a dismissed alert, or a fixed problem reappears | Keeps the alert's history |
The point that surprises new users most is that fixed is automatic. Code scanning closes an alert as fixed only when a new analysis of the same branch and category no longer reports it. Developers do not mark alerts as fixed by hand. If a developer merges a change that ought to fix an alert and the alert stays open, either the analysis has not run yet, or the change did not remove the path CodeQL found.
Dismissal, by contrast, is a human decision. It should be rare and explained. GitHub records who dismissed the alert, when, with which reason and comment, and the timeline keeps that record even if the alert is later reopened. Ottoline Brisbane-Teale, Skerry's internal audit lead, had already said that the January 2027 audit would sample dismissed alerts and expect a comment on every one.
Who can dismiss
By default, people with write access to a repository can dismiss its code scanning alerts. In organizations that want more control, GitHub supports delegated alert dismissal for code scanning: developers request a dismissal with a reason, and a designated reviewer, usually from the security team, approves or rejects it. Skerry turned this on through the Stores restricted configuration for skerry-stores, where alerts in payment terminal code needed a second opinion before anyone dismissed them. Lesson 9 covers the roles involved.
Branches, pull requests and categories
Alerts are tracked per branch. An alert on the default branch is the one that counts in most metrics. A pull request shows alerts that the change introduces compared with its base branch; when the pull request is merged and the default branch is analyzed again, those alerts either appear on the default branch or, if they were fixed before merging, never do.
Each analysis also has a category. Results from different categories are tracked separately, so the checkout monorepo's three analyses (front end, order services and pricing) each manage their own alerts. If a team changes a workflow so that the category changes, old alerts may remain open under the old category and look stale. The fix is to keep categories stable, or to delete the old analysis from the code scanning settings once the new one is running.
Filtering a large list
The alert list for a repository, and security overview across many, supports filters that make thousands of alerts workable. Seraphine showed the filters her team used every day.
| Filter | Example | Use |
|---|---|---|
| State | is:open | Hide fixed and dismissed alerts |
| Tool | tool:CodeQL | Separate CodeQL from third-party results |
| Severity | severity:critical,high | Start with the most serious |
| Rule | rule:js/xss | Find every instance of one pattern |
| Branch | branch:main | Focus on the default branch |
| Tag | tag:security | Exclude quality-only findings |
| Application code only | The filter that hides alerts in test, generated and documentation code | Cut noise from code that does not ship |
| Autofix available | The filter for alerts with a suggested fix | Find quick wins |
Filtering by rule is the habit that turns a backlog into a plan. Of the commerce group's 1,180 open alerts, 410 came from just four rules. Fixing a rule's pattern once, for example by adding a shared escaping helper, and then applying it everywhere, is far quicker than handling alerts one by one. Lesson 7 shows how security campaigns build on exactly this idea.
A triage routine
The team settled on a routine for each repository's first pass.
| Step | Action | Outcome |
|---|---|---|
| 1 | Filter to open security alerts in application code on the default branch | The list that matters |
| 2 | Sort by security severity and group by rule | Patterns, not individual alerts |
| 3 | Read one alert per rule fully, including the path | Decide whether the rule is finding real problems here |
| 4 | If real, fix one instance and apply the pattern to the rest | Efficient remediation |
| 5 | If not real, dismiss with a comment, and consider excluding the path or tuning the query | Less noise next time |
| 6 | Assign remaining alerts to owners with a due date | Accountability |
Code scanning alerts can be assigned to a person with write access, which shows ownership on the alert and appears in filters and the API. Skerry used assignment for anything not fixed within a week of triage, so that security overview could show who owned what.
Worked problem
Is this alert real?
A high security severity alert reports a path traversal in an inventory export job: a file name from a message queue is joined to a directory and opened. The path view shows the source is a queue message. The team says the queue is internal, so the alert is a false positive. What should the reviewer check before agreeing?
Show solution
- Who can publish to the queue: only trusted services, or any service in the network?
- Whether the file name is validated anywhere on the path, for example against an allow list.
- Whether the job runs with access to sensitive directories.
- If publishers are not tightly controlled or validation is missing, treat the alert as real.
Answer: An internal source is not automatically trusted. Unless publishing to the queue is restricted and the name is validated, fix the alert with validation rather than dismissing it.
Teodric fixed his cross-site scripting alert by escaping the gift message with the framework's standard output encoding rather than building the HTML by hand. The next pull request scan reported nothing on that path, and after merge the default branch analysis closed the alert as fixed. He brought the second printout, showing the closed alert, to the following week's session.
Writing a dismissal comment someone can use
A dismissal without a comment saves a minute today and costs an hour in six months, when an auditor or a new team member asks why a serious alert was closed. Skerry's guidance asked for three things in every dismissal comment for high and critical alerts: what makes the alert not a problem, where that is enforced, and what would make the decision wrong.
| Weak comment | Useful comment |
|---|---|
| Not exploitable | The id parameter is converted to an integer by the route definition before this query runs; if the route changes to accept strings, reopen |
| Test code | File is under tests and builds only into the test target; the test fixture deliberately uses unsafe input |
| Fixed elsewhere | Input is validated by the gateway allow list for this path; see the gateway configuration; this service is not reachable directly |
The third part of the comment, what would make the decision wrong, was the one developers found hardest and auditors found most valuable. It turns a dismissal into a small, testable claim. When Ottoline sampled dismissals in her November review, she could check the claim against the current code, and two of the dismissals she sampled no longer held because the code had changed. Both alerts were reopened and fixed.
An alert closed as fixed can also reopen on its own. If a later commit reintroduces the same problem at the same location, code scanning matches it to the original alert and reopens it, which keeps the history together. A developer who sees a reopened alert should read its history before acting, because the earlier fix or dismissal often explains what changed.
Common mistakes
MistakeJudging an alert by the highlighted line alone.
InsteadOpen the path view and check each step from source to sink.
MistakeTrying to mark an alert as fixed.
InsteadFix the code; the next analysis closes the alert automatically.
MistakeDismissing alerts without a comment.
InsteadRecord the reason, the evidence and who accepted any risk.
MistakeTreating internal sources as trusted by default.
InsteadCheck who can control the data and whether it is validated.
MistakeChanging an analysis category without cleaning up.
InsteadKeep categories stable, or delete the old analysis once the new one runs.
Summary and key terms
- An alert page shows the rule, tool, severities, tags, location, data flow path, rule help, branches and timeline.
- For data flow alerts, check each step for attacker control, sanitization and reachability.
- Alerts are open, fixed, dismissed or reopened; fixed is set automatically by a later analysis.
- Dismissal is a recorded human decision with a reason and should always carry a comment.
- Delegated alert dismissal lets security reviewers approve dismissals.
- Alerts are tracked per branch and per analysis category.
- Filtering by severity, rule and application code turns a large backlog into patterns that can be fixed together.
- Show paths
- The view of a data flow alert that lists each step from source to sink.
- Dismissed
- An alert state set by a person, with a reason such as false positive, won't fix or used in tests.
- Fixed
- An alert state set automatically when a later analysis no longer reports the problem.
- Delegated alert dismissal
- A setting that requires dismissal requests to be approved by designated reviewers.
- Affected branches
- The branches on which an alert is currently present.
- Alert assignee
- A person with write access assigned to own an alert.
- Rule help
- The explanation, guidance and examples attached to the rule that produced an alert.
Practice problems
Work each problem on paper first, then reveal the answer to check.
A developer merged a fix but the alert is still open an hour later. Name two possible reasons.
Show answer
The default branch analysis has not run yet, or the change did not remove the path the query found.
Which dismissal reason fits code that only runs in automated tests?
Show answer
Used in tests, though excluding test paths from analysis is often better.
Why filter by rule during triage?
Show answer
Repeated alerts from one rule can usually be fixed with one pattern applied everywhere.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.