MCPcopy Create free account
hub / github.com/getsentry/sentry / _record_input_call

Method _record_input_call

tools/flake8_plugin.py:1033–1054  ·  view source on GitHub ↗

A `.get()` read, or the whole dict handed to something else.

(self, node: ast.Call)

Source from the content-addressed store, hash-verified

1031 return True
1032
1033 def _record_input_call(self, node: ast.Call) -> None:
1034 """A `.get()` read, or the whole dict handed to something else."""
1035 ctx = self._input_stack[-1]
1036 func = node.func
1037 if isinstance(func, ast.Attribute) and func.attr in _READ_METHODS:
1038 source = ctx.source_of(func.value)
1039 if source is not None and node.args:
1040 ctx.record_read(node.args[0], source, node.lineno, node.col_offset)
1041 # On anything but the request this is an ordinary lookup, and
1042 # `options.get("k", request.GET)` passes a default, not the dict.
1043 return
1044 # Only a serializer's data= is the target shape. `my_func(data=...)`
1045 # hands the dict over exactly as a positional argument would.
1046 if _looks_like_a_class(func) and any(kw.arg == "data" for kw in node.keywords):
1047 return
1048 for argument in [*node.args, *(keyword.value for keyword in node.keywords)]:
1049 source = ctx.source_of(argument)
1050 if source is not None:
1051 name = _name_of(func).rsplit(".", 1)[-1]
1052 if name not in _CONTAINER_OPS:
1053 ctx.hand_offs.append((node.lineno, node.col_offset, name, source))
1054 return
1055
1056 def _record_validator(self, node: ast.Call) -> None:
1057 """A serializer built from the query string or the request body."""

Callers 1

visit_CallMethod · 0.95

Calls 5

_looks_like_a_classFunction · 0.85
_name_ofFunction · 0.85
source_ofMethod · 0.80
record_readMethod · 0.80
appendMethod · 0.65

Tested by

no test coverage detected