github / github/codeql

cpp: how to use macro argument as dataflow sink

Offen
#21,824 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

I would like to do something like this:
```codeql
predicate isSink(DataFlow::Node sink) {
exists(MacroInvocation m |
sink.asExpr() = m.getArgument(0)
and m.getTarget().getName() = "my_cool_macro"
)
}
```
But `getArgument` is not defined, and `getExpandedArgument` returns a string. Doing `sink.asExpr().toString() = m.getExpandedArgument(0)` returns zero matches.

How do I use macros in dataflow?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the CodeQL predicate in the issue and read the mentioned MacroInvocation, getArgument, and getExpandedArgument entry points. Determine how macro arguments can be represented as dataflow nodes, or whether this is unsupported, and document a working example or the limitation so the question has a definitive answer.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
security
Issue-Typ
Dokumentation
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.