Interview Prep/Python for DevOps/Automation scripting & CLI design

A security review flags that your tool uses `pickle` to cache API responses on disk. What do you change?

IntermediateScenarioAutomation scripting & CLI design
Answer

Situation read → pickle.load on a file someone else can write is arbitrary code execution.

What I'd do →

  1. Switch the cache to JSON (or sqlite3), which is data-only.
  2. Store it in a user-owned directory with 0600 permissions (platformdirs.user_cache_dir).
  3. Add expiry metadata so stale data is not trusted forever.

Why → JSON cannot execute code on load; pickle can.

Interview tip → Know the rule: never unpickle data you did not produce in a location only you can write.

All Python for DevOps questions Roadmap: Python for automation

More on Automation scripting & CLI design