GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #1198 from github/michaelrfairhurst/optimise-conta… · github/codeql-coding-standards@1246af9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • change_notes
    • 2026-09-16-improve-iterator-access-check-performance.md
  • cpp/common/src/codingstandards/cpp/standardlibrary
    • STLContainers.qll
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎change_notes/2026-09-16-improve-iterator-access-check-performance.md‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- All queries using `Iterators.qll` or `STLContainers.qll`:
2+
- The means of detecting iterator and container accesses has been optimized to improve performance by avoiding construction of the full transitive closure of local taint paths.
Collapse file

‎cpp/common/src/codingstandards/cpp/standardlibrary/STLContainers.qll‎

Copy file name to clipboardExpand all lines: cpp/common/src/codingstandards/cpp/standardlibrary/STLContainers.qll
+26-16Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,30 @@ abstract class ContainerAccess extends VariableAccess {
312312
abstract Variable getOwningContainer();
313313
}
314314

315-
pragma[noinline, nomagic]
316-
private predicate localTaint(DataFlow::Node n1, DataFlow::Node n2) {
317-
TaintTracking::localTaint(n1, n2)
315+
pragma[nomagic]
316+
private predicate containerTaintSource(FunctionCall fc, DataFlow::Node n1) {
317+
n1 = DataFlow::exprNode(fc) and
318+
exists(STLContainer c |
319+
fc = c.getACallToAFunction() and
320+
// There are a few cases where the value is tainted
321+
// but no actual link to the underlying container is established.
322+
// For example, calling Vector<int>.size() returns an int but the
323+
// resulting variable doesn't depend on the underlying container
324+
// anymore.
325+
(
326+
fc.getTarget().getType() instanceof ReferenceType or
327+
fc.getTarget().getType() instanceof PointerType or
328+
fc.getTarget().getType() instanceof IteratorType
329+
)
330+
)
331+
}
332+
333+
pragma[nomagic]
334+
private predicate containerTaint(FunctionCall fc, DataFlow::Node n2) {
335+
exists(DataFlow::Node n1 |
336+
containerTaintSource(fc, n1) and
337+
TaintTracking::localTaint(n1, n2)
338+
)
318339
}
319340

320341
/**
@@ -326,19 +347,8 @@ class ContainerPointerOrReferenceAccess extends ContainerAccess {
326347
Variable owningContainer;
327348

328349
ContainerPointerOrReferenceAccess() {
329-
exists(STLContainer c, FunctionCall fc |
330-
fc = c.getACallToAFunction() and
331-
// There are a few cases where the value is tainted
332-
// but no actual link to the underlying container is established.
333-
// For example, calling Vector<int>.size() returns an int but the
334-
// resulting variable doesn't depend on the underlying container
335-
// anymore.
336-
(
337-
fc.getTarget().getType() instanceof ReferenceType or
338-
fc.getTarget().getType() instanceof PointerType or
339-
fc.getTarget().getType() instanceof IteratorType
340-
) and
341-
localTaint(DataFlow::exprNode(fc), DataFlow::exprNode(this)) and
350+
exists(FunctionCall fc |
351+
containerTaint(fc, DataFlow::exprNode(this)) and
342352
(getUnderlyingType() instanceof ReferenceType or getUnderlyingType() instanceof PointerType) and
343353
fc.getQualifier().(VariableAccess).getTarget() = owningContainer and
344354
// Exclude cases where we see taint into the owning container

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.