FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Python: Add model for `unicodedata.iter_graphemes` by tausbn · Pull Request #22732 · github/codeql · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) .py  (1) .yml  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added taint-flow modeling for `unicodedata.iter_graphemes`, introduced in Python 3.15.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ extensions:
- ["traceback.StackSummary", "Member[from_list]", "Argument[0,a_list:]", "ReturnValue", "taint"]
# See https://docs.python.org/3/library/typing.html#typing.cast
- ["typing", "Member[cast]", "Argument[1,val:]", "ReturnValue", "value"]
# See https://docs.python.org/3/library/unicodedata.html#unicodedata.iter_graphemes
- ["unicodedata", "Member[iter_graphemes]", "Argument[0]", "ReturnValue", "taint"]
# See https://docs.python.org/3/library/urllib.parse.html#urllib.parse.parse_qs
- ["urllib", "Member[parse].Member[parse_qs]", "Argument[0,qs:]", "ReturnValue", "taint"]
# See https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import unicodedata
from unicodedata import iter_graphemes as graphemes


def string_iteration():
for character in TAINTED_STRING:
ensure_tainted(character) # $ tainted


def grapheme_iteration():
iterator = unicodedata.iter_graphemes(TAINTED_STRING)
ensure_tainted(iterator) # $ tainted
for grapheme in iterator:
ensure_tainted(grapheme) # $ tainted
ensure_tainted(str(grapheme)) # $ tainted
ensure_not_tainted(grapheme.start, grapheme.end)


def next_grapheme():
grapheme = next(unicodedata.iter_graphemes(TAINTED_STRING))
ensure_tainted(str(grapheme)) # $ tainted


def bounded_iteration():
for grapheme in unicodedata.iter_graphemes(TAINTED_STRING, 1, 10):
ensure_tainted(str(grapheme)) # $ tainted


def aliases():
ensure_tainted(str(next(graphemes(TAINTED_STRING)))) # $ tainted
split = unicodedata.iter_graphemes
ensure_tainted(str(next(split(TAINTED_STRING)))) # $ tainted


def callback():
iterator = next(map(unicodedata.iter_graphemes, [TAINTED_STRING]))
ensure_tainted(str(next(iterator))) # $ tainted


def clean_inputs():
start, end = 0, 10
taint(start, end)
iterator = unicodedata.iter_graphemes("a\u0301bc", start, end)
ensure_not_tainted(iterator)
for grapheme in iterator:
ensure_not_tainted(str(grapheme))
ensure_not_tainted(str(next(graphemes("clean"))))


def shadowed_function():
def iter_graphemes(unistr):
return iter(["clean"])

ensure_not_tainted(str(next(iter_graphemes(TAINTED_STRING))))
Loading

Back | FazBrowse Home | New Git URL