~/talk

Writing Python Codemods for Fun and Profit

Talkat Conf42 Python 2024 · on Thursday, 2024-02-29· [python]
slides:none on file

Open-source codemodder installs via pip and runs over a Python repo, applying about 40–50 ready codemods and custom plugins. It consumes SARIF or invokes semgrep rules, transforms code with libCST, and emits a machine-readable codeTF report. Built fixes include replacing unsafe PyYAML loaders, switching to defusedxml, adding missing imports, converting file operations to context managers, and parameterizing SQL; it can add dependencies to pyproject/requirements and integrates with a free Pixiebot GitHub app and CLI for automated PRs.

AI-written summary · about

  1. 0:00intro
  2. 0:20preamble
  3. 1:24https://github.com/pixee/codemodder-python
  4. 1:55there is a problem
  5. 3:42security tools
  6. 6:03we need to fix and harden codes
  7. 7:57code + modification
  8. 10:19codemodder philosophy
  9. 12:01leverage open-source tools
  10. 12:52process results from other tools
  11. 13:43invoke open-source tools
  12. 14:54codemods tell a story
  13. 15:53how can i use it?
  14. 16:44what does it do?
  15. 18:04what can we fix?
  16. 18:32replace unsafe pyyaml loader
  17. 19:29use defusedxml for parsing xml
  18. 21:06automatically close resources
  19. 22:05parametrize sql queries
  20. 22:57use generator expressions
  21. 24:09codemodder architecture
  22. 26:27codemod metadata
  23. 28:07dependency management
  24. 30:11let's write a codemod
  25. 30:57codemod plugin template
  26. 38:41make the easy things easy
  27. 39:59make the hard things possible
  28. 41:47looking ahead
  29. 44:16we want your feedback!
  30. 44:50pixeebot app
  31. 46:06about pixee
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.