Documentation Index
Fetch the complete documentation index at: https://docs.semgrep.dev/llms.txt
Use this file to discover all available pages before exploring further.
pandas.DataFrame(...).index.set_value(...) against the above code, Semgrep would normally match test1 but not test2. It does not match test2 because there are intermediate assignments, and Semgrep does not know that ix is equals to df.index or that df is equals to pandas.DataFrame(x). If we wanted Semgrep to match such code, we had to be explicit about it.
Symbolic propagation is a generalization of constant propagation that addresses this limitation. It enables Semgrep to perform matching modulo variable assignments. Thus, Semgrep is then able to match both test1 and test2 with the same simple pattern. This feature needs to be enabled explicitly via rule options: by setting symbolic_propagation: true.
Limitations of symbolic propagation
Currently, symbolic propagation does not cross branching boundaries, such asif clauses or loops. Consider the following Python code, adapted from the example shown above:
symbolic_propagation: true is used, Semgrep does not match test2, because the assignment of df to pandas.DataFrame(x) is not propagated over the conditional to the final two lines.