You can add a fix key to rules to tell Semgrep how to automatically fix your findings! This can involve more advanced operations as well, such as replacing one captured metavariable with another.
fix