Skip to content
Back to search

pysheeet

MarketplaceWorks with Claude CodeGitHub

Python Cheat Sheet

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/crazyguitar/pysheeet with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/crazyguitar/pysheeet'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/crazyguitar--pysheeet/badge.svg)](/listings/crazyguitar--pysheeet)

HTML

<a href="/listings/crazyguitar--pysheeet"><img src="/api/listings/crazyguitar--pysheeet/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

**As a Claude Code plugin (recommended):**

.. code-block:: bash

# Step 1: Add the marketplace claude plugin marketplace add crazyguitar/pysheeet

# Step 2: Install the plugin claude plugin install pysheeet@pysheeet

**Local testing (single session only):**

.. code-block:: bash

claude --plugin-dir /path/to/pysheeet

**Manual installation (requires cloning the repo):**

.. code-block:: bash

git clone https://github.com/crazyguitar/pysheeet.git mkdir -p ~/.claude/skills cp -r pysheeet/skills/py ~/.claude/skills/py

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 20 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "pysheeet",
  3. "owner": {
  4. "name": "crazyguitar"
  5. },
  6. "plugins": [
  7. {
  8. "name": "pysheeet",
  9. "source": {
  10. "source": "github",
  11. "repo": "crazyguitar/pysheeet"
  12. },
  13. "description": "Comprehensive Python programming reference covering syntax, concurrency, networking, databases, ML/LLM development, and HPC",
  14. "version": "1.0.0",
  15. "author": {
  16. "name": "crazyguitar"
  17. }
  18. }
  19. ]
  20. }
README.rst · README · 242 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. .. raw:: html
  2. <h1 align="center">
  3. <br>
  4. <a href="https://www.pythonsheets.com"><img src="docs/_static/logo.png" alt="pysheeet" width=200"></a>
  5. </h1>
  6. <p align="center">
  7. <a href="https://github.com/crazyguitar/pysheeet/actions">
  8. <img src="https://github.com/crazyguitar/pysheeet/actions/workflows/pythonpackage.yml/badge.svg" alt="Build Status">
  9. </a>
  10. <a href="https://coveralls.io/github/crazyguitar/pysheeet?branch=master">
  11. <img src="https://coveralls.io/repos/github/crazyguitar/pysheeet/badge.svg?branch=master" alt="Coverage">
  12. </a>
  13. <a href="https://raw.githubusercontent.com/crazyguitar/pysheeet/master/LICENSE">
  14. <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License MIT">
  15. </a>
  16. <a href="https://doi.org/10.5281/zenodo.15529042">
  17. <img src="https://zenodo.org/badge/52760178.svg" alt="DOI">
  18. </a>
  19. </p>
  20. Introduction
  21. =============
  22. This project was started to bring together useful Python code snippets that make
  23. coding faster, easier, and more enjoyable. You can explore all the cheat sheets at
  24. `Pysheeet <https://www.pythonsheets.com/>`_. Contributions are always welcome—feel
  25. free to fork the repo and submit a pull request to help it grow!
  26. Plugin
  27. ======
  28. **pysheeet** is available as a Claude Code plugin. Once installed, Claude
  29. automatically uses the cheat sheets to answer Python questions — just ask
  30. naturally and the skill triggers based on context.
  31. Installation
  32. ------------
  33. **As a Claude Code plugin (recommended):**
  34. .. code-block:: bash
  35. # Step 1: Add the marketplace
  36. claude plugin marketplace add crazyguitar/pysheeet
  37. # Step 2: Install the plugin
  38. claude plugin install pysheeet@pysheeet
  39. **Local testing (single session only):**
  40. .. code-block:: bash
  41. claude --plugin-dir /path/to/pysheeet
  42. **Manual installation (requires cloning the repo):**
  43. .. code-block:: bash
  44. git clone https://github.com/crazyguitar/pysheeet.git
  45. mkdir -p ~/.claude/skills
  46. cp -r pysheeet/skills/py ~/.claude/skills/py
  47. Python Interview Cheatsheet
  48. ===========================
  49. Curated Python interview questions indexed by topic — each question links
  50. directly to the section of the cheat sheet that answers it. Use it for quick
  51. review before an interview, or to drill down on a specific area (GIL, asyncio,
  52. decorators, MRO, and more).
  53. - `Python Interview Cheatsheet <docs/notes/interview/index.rst>`_
  54. What's New In Python 3
  55. ======================
  56. This part only provides a quick glance at some important features in Python 3.
  57. If you're interested in all of the most important features, please read the
  58. official document, `What’s New in Python <https://docs.python.org/3/whatsnew/index.html>`_.
  59. - `New in Python3 <docs/notes/python-new-py3.rst>`_
  60. Cheat Sheet
  61. ===========
  62. Core Python fundamentals including data types, functions, classes, and commonly
  63. used patterns for everyday programming tasks.
  64. - `From Scratch <docs/notes/basic/python-basic.rst>`_
  65. - `Future <docs/notes/basic/python-future.rst>`_
  66. - `Typing <docs/notes/basic/python-typing.rst>`_
  67. - `Class <docs/notes/basic/python-object.rst>`_
  68. - `Function <docs/notes/basic/python-func.rst>`_
  69. - `Unicode <docs/notes/basic/python-unicode.rst>`_
  70. - `List <docs/notes/basic/python-list.rst>`_
  71. - `Set <docs/notes/basic/python-set.rst>`_
  72. - `Dictionary <docs/notes/basic/python-dict.rst>`_
  73. - `Heap <docs/notes/basic/python-heap.rst>`_
  74. - `Generator <docs/notes/basic/python-generator.rst>`_
  75. - `Regular expression <docs/notes/basic/python-rexp.rst>`_
  76. System
  77. ======
  78. Date/time handling, file I/O, and operating system interfaces.
  79. - `Datetime <docs/notes/os/python-date.rst>`_ - Timestamps, formatting, parsing, timezones, timedelta
  80. - `Files and I/O <docs/notes/os/python-io.rst>`_ - Reading, writing, pathlib, shutil, tempfile
  81. - `Operating System <docs/notes/os/python-os.rst>`_ - Processes, environment, system calls
  82. Concurrency
  83. ===========
  84. Threading, multiprocessing, and concurrent.futures for parallel execution.
  85. Covers synchronization primitives, process pools, and bypassing the GIL.
  86. - `Threading <docs/notes/concurrency/python-threading.rst>`_ - Threads, locks, semaphores, events, conditions
  87. - `Multiprocessing <docs/notes/concurrency/python-multiprocessing.rst>`_ - Processes, pools, shared memory, IPC
  88. - `concurrent.futures <docs/notes/concurrency/python-futures.rst>`_ - Executors, futures, callbacks
  89. Asyncio
  90. =======
  91. Asynchronous programming with Python's ``asyncio`` module. Covers coroutines,
  92. event loops, tasks, networking, and advanced patterns.
  93. - `A Hitchhiker's Guide to Asynchronous Programming <docs/notes/asyncio/python-asyncio-guide.rst>`_ - Design philosophy and evolution
  94. - `Asyncio Basics <docs/notes/asyncio/python-asyncio-basic.rst>`_ - Coroutines, tasks, gather, timeouts
  95. - `Asyncio Networking <docs/notes/asyncio/python-asyncio-server.rst>`_ - TCP/UDP servers, HTTP, SSL/TLS
  96. - `Asyncio Advanced <docs/notes/asyncio/python-asyncio-advanced.rst>`_ - Synchronization, queues, subprocesses
  97. C/C++ Extensions
  98. ================
  99. Native extensions for performance-critical code. Covers modern pybind11 (used by
  100. PyTorch, TensorFlow), ctypes, cffi, Cython, and the traditional Python C API.
  101. Also includes a guide for Python developers learning modern C++ syntax.
  102. - `ctypes <docs/notes/extension/python-ctypes.rst>`_ - Load shared libraries without compilation
  103. - `Python C API <docs/notes/extension/python-capi.rst>`_ - Traditional C extension reference
  104. - `Modern C/C++ Extensions <docs/notes/extension/python-cext-modern.rst>`_ - pybind11, Cython
  105. - `Learn C++ from Python <docs/notes/extension/cpp-from-python.rst>`_ - Modern C++ for Python developers
  106. Security
  107. ========
  108. Modern cryptographic practices and common security vulnerabilities. Covers
  109. encryption, TLS/SSL, and why legacy patterns are dangerous.
  110. - `Modern Cryptography <docs/notes/security/python-crypto.rst>`_ - AES-GCM, RSA-OAEP, Ed25519, Argon2
  111. - `TLS/SSL and Certificates <docs/notes/security/python-tls.rst>`_ - HTTPS servers, certificate generation
  112. - `Common Vulnerabilities <docs/notes/security/python-vulnerability.rst>`_ - Padding oracle, injection, timing attacks
  113. Network
  114. =======
  115. Low-level network programming with Python sockets. Covers TCP/UDP communication,
  116. server implementations, asynchronous I/O, SSL/TLS encryption, and packet analysis.
  117. - `Socket Basics <docs/notes/network/python-socket.rst>`_
  118. - `Socket Servers <docs/notes/network/python-socket-server.rst>`_
  119. - `Async Socket I/O <docs/notes/network/python-socket-async.rst>`_
  120. - `SSL/TLS Sockets <docs/notes/network/python-socket-ssl.rst>`_
  121. - `Packet Sniffing <docs/notes/network/python-socket-sniffer.rst>`_
  122. - `SSH and Tunnels <docs/notes/network/python-ssh.rst>`_
  123. Database
  124. ========
  125. Database access with SQLAlchemy, Python's most popular ORM. Covers connection
  126. management, raw SQL, object-relational mapping, and common query patterns.
  127. - `SQLAlchemy Basics <docs/notes/database/python-sqlalchemy.rst>`_
  128. - `SQLAlchemy ORM <docs/notes/database/python-sqlalchemy-orm.rst>`_
  129. - `SQLAlchemy Query Recipes <docs/notes/database/python-sqlalchemy-query.rst>`_
  130. LLM
  131. ===
  132. Large Language Models (LLM) training, inference, and optimization. Covers PyTorch
  133. for model development, distributed training across GPUs, and vLLM/SGLang for
  134. high-performance LLM inference and serving.
  135. - `PyTorch <docs/notes/llm/pytorch.rst>`_ - Tensors, autograd, neural networks, training loops
  136. - `Megatron <docs/notes/llm/megatron.rst>`_ - NVIDIA Megatron training/fine-tuning framework with enroot/pyxis
  137. - `LLM Serving <docs/notes/llm/llm-serving.rst>`_ - vLLM and SGLang for production inference with TP/PP/DP/EP
  138. - `LLM Benchmark <docs/notes/llm/llm-bench.rst>`_ - Benchmark suite for measuring serving performance
  139. HPC
  140. ===
  141. High-Performance Computing tools for cluster management and job scheduling.
  142. Covers Slurm workload manager and Ray for distributed computing on GPU clusters.
  143. - `Slurm <docs/notes/hpc/slurm.rst>`_
  144. - `Ray Cluster <docs/notes/hpc/ray.rst>`_
  145. Blog
  146. ====
  147. Supplementary topics covering Python internals, debugging techniques, and
  148. language features that don't fit elsewhere.
  149. - `NCCL Multi-Rail Broadcast with More GPU Ranks <docs/notes/appendix/nccl-ring.rst>`_
  150. - `NVSHMEM Multi-NIC Support with AWS EFA <docs/notes/appendix/nvshmem-multi-nic.rst>`_
  151. - `Is Disaggregated Prefill/Decode a Silver Bullet for LLM Serving? <docs/notes/appendix/disaggregated-prefill-decode.rst>`_
  152. - `Monitoring EFA with NCCL GIN and Nsys <docs/notes/appendix/megatron-efa-monitoring.rst>`_
  153. - `GPU-Initiated Networking for NCCL on AWS <docs/notes/appendix/nccl-gin.rst>`_
  154. - `PEP 572 and the walrus operator <docs/notes/appendix/python-walrus.rst>`_
  155. - `Python Interpreter in GNU Debugger <docs/notes/appendix/python-gdb.rst>`_
  156. PDF Version
  157. ============
  158. `pdf`_
  159. .. _pdf: https://media.readthedocs.org/pdf/pysheeet/latest/pysheeet.pdf
  160. How to run the server
  161. =======================
  162. .. code-block:: bash
  163. $ virtualenv venv
  164. $ . venv/bin/activate
  165. $ pip install -r requirements.txt
  166. $ make
  167. $ python app.py
  168. # URL: localhost:5000
src/security/vulnerability_.py · Bundled script · 256 lines · 4 findings marked
  1. """Tests demonstrating security vulnerabilities and secure alternatives."""
  2. import pytest
  3. import hmac
  4. import secrets
  5. import os
  6. class TestTimingAttack:
  7. """Demonstrate timing attack vulnerability in string comparison."""
  8. def test_insecure_comparison(self):
  9. """Insecure comparison - vulnerable to timing attack."""
  10. secret = b"correct_secret_token"
  11. def insecure_compare(a, b):
  12. """INSECURE: Returns early on mismatch."""
  13. if len(a) != len(b):
  14. return False
  15. for x, y in zip(a, b):
  16. if x != y:
  17. return False
  18. return True
  19. # These comparisons take different amounts of time
  20. assert insecure_compare(secret, secret) == True
  21. assert insecure_compare(secret, b"wrong_secret_token!") == False
  22. assert insecure_compare(secret, b"c") == False
  23. def test_secure_comparison(self):
  24. """Secure comparison using hmac.compare_digest."""
  25. secret = b"correct_secret_token"
  26. # Constant-time comparison - safe from timing attacks
  27. assert hmac.compare_digest(secret, secret) == True
  28. assert hmac.compare_digest(secret, b"wrong_secret_token!") == False
  29. class TestWeakRandom:
  30. """Demonstrate weak vs strong random number generation."""
  31. def test_weak_random(self):
  32. """INSECURE: random module is predictable."""
  33. import random
  34. # Mersenne Twister can be predicted after observing outputs
  35. random.seed(12345)
  36. values = [random.randint(0, 100) for _ in range(10)]
  37. # Same seed produces same sequence - predictable!
  38. random.seed(12345)
  39. values2 = [random.randint(0, 100) for _ in range(10)]
  40. assert values == values2
  41. def test_secure_random(self):
  42. """SECURE: secrets module uses OS entropy."""
  43. # Cryptographically secure random
  44. token1 = secrets.token_hex(16)
  45. token2 = secrets.token_hex(16)
  46. # Each call produces unique, unpredictable value
  47. assert token1 != token2
  48. assert len(token1) == 32
  49. class TestSQLInjection:
  50. """Demonstrate SQL injection vulnerability."""
  51. def test_vulnerable_query_building(self):
  52. """INSECURE: String formatting in SQL."""
  53. def build_query_insecure(username):
  54. # VULNERABLE: User input directly in query
  55. return f"SELECT * FROM users WHERE username = '{username}'"
  56. # Normal input
  57. query = build_query_insecure("alice")
  58. assert query == "SELECT * FROM users WHERE username = 'alice'"
  59. # Malicious input - SQL injection!
  60. malicious = "admin' OR '1'='1"
  61. query = build_query_insecure(malicious)
  62. # This would return ALL users!
  63. assert "OR '1'='1'" in query
  64. def test_parameterized_query(self):
  65. """SECURE: Parameterized queries prevent injection."""
  66. def build_query_secure(username):
  67. # Parameters are escaped by the database driver
  68. return ("SELECT * FROM users WHERE username = ?", (username,))
  69. query, params = build_query_secure("admin' OR '1'='1")
  70. # The malicious input is treated as a literal string
  71. assert params == ("admin' OR '1'='1",)
  72. class TestCommandInjection:
  73. """Demonstrate command injection vulnerability."""
  74. def test_vulnerable_shell_command(self):
  75. """INSECURE: User input in shell command."""
  76. def build_command_insecure(filename):
  77. # VULNERABLE: Shell injection possible
  78. return f"cat {filename}"
  79. # Malicious input
  80. malicious = "file.txt; rm -rf /"
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 109 on GitHub
  81. cmd = build_command_insecure(malicious)
  82. # Would execute: cat file.txt; rm -rf /
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 111 on GitHub
  83. assert "; rm -rf /" in cmd
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 112 on GitHub
  84. def test_secure_command(self):
  85. """SECURE: Use argument list, not shell string."""
  86. import shlex
  87. def build_command_secure(filename):
  88. # Validate and use list of arguments
  89. if not filename.replace(".", "").replace("_", "").isalnum():
  90. raise ValueError("Invalid filename")
  91. return ["cat", filename]
  92. # Malicious input is rejected
  93. with pytest.raises(ValueError):
  94. build_command_secure("file.txt; rm -rf /")
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 126 on GitHub
  95. # Valid input works
  96. cmd = build_command_secure("file.txt")
  97. assert cmd == ["cat", "file.txt"]
  98. class TestPickleVulnerability:
  99. """Demonstrate pickle deserialization vulnerability."""
  100. def test_pickle_code_execution(self):
  101. """INSECURE: Pickle can execute arbitrary code."""
  102. import pickle
  103. class MaliciousPayload:
  104. def __reduce__(self):
  105. # This would execute when unpickled!
  106. # return (os.system, ("echo HACKED",))
  107. # For safety, we just return a harmless function
  108. return (str, ("PAYLOAD_EXECUTED",))
  109. # Attacker creates malicious pickle
  110. malicious_data = pickle.dumps(MaliciousPayload())
  111. # Victim unpickles - code executes!
  112. result = pickle.loads(malicious_data)
  113. assert result == "PAYLOAD_EXECUTED"
  114. def test_safe_json(self):
  115. """SECURE: JSON cannot execute code."""
  116. import json
  117. data = {"user": "alice", "role": "admin"}
  118. serialized = json.dumps(data)
  119. deserialized = json.loads(serialized)
  120. assert deserialized == data
  121. # JSON only supports basic types - no code execution
  122. class TestHardcodedSecrets:
  123. """Demonstrate hardcoded secrets vulnerability."""
  124. def test_environment_variables(self):
  125. """SECURE: Use environment variables for secrets."""
  126. # Set a test secret
  127. os.environ["TEST_API_KEY"] = "secret_key_123"
  128. # Read from environment
  129. api_key = os.environ.get("TEST_API_KEY")
  130. assert api_key == "secret_key_123"
  131. # Clean up
  132. del os.environ["TEST_API_KEY"]
  133. # Missing secret should be handled
  134. missing = os.environ.get("NONEXISTENT_KEY")
  135. assert missing is None
  136. class TestAESModes:
  137. """Demonstrate AES mode vulnerabilities."""
  138. def test_ecb_mode_pattern_leak(self):
  139. """INSECURE: ECB mode leaks patterns in plaintext."""
  140. # ECB encrypts identical blocks to identical ciphertext
  141. # This reveals patterns in the data
  142. # Simulated ECB behavior (without actual crypto)
  143. def fake_ecb_encrypt(blocks):
  144. # Same input block -> same output (pattern leak!)
  145. block_map = {}
  146. result = []
  147. for i, block in enumerate(blocks):
  148. if block not in block_map:
  149. block_map[block] = f"cipher_{i}"
  150. result.append(block_map[block])
  151. return result
  152. # Repeated plaintext blocks
  153. blocks = ["AAAA", "BBBB", "AAAA", "CCCC", "AAAA"]
  154. encrypted = fake_ecb_encrypt(blocks)
  155. # Pattern is visible! Same plaintext -> same ciphertext
  156. assert encrypted[0] == encrypted[2] == encrypted[4]
  157. def test_cbc_needs_authentication(self):
  158. """AES-CBC without authentication is vulnerable."""
  159. # CBC provides confidentiality but not integrity
  160. # Attacker can modify ciphertext without detection
  161. # This enables padding oracle attacks
  162. # AES-GCM provides both confidentiality AND integrity
  163. # Tampering is detected and rejected
  164. pass
  165. class TestPasswordStorage:
  166. """Demonstrate password storage vulnerabilities."""
  167. def test_weak_hash(self):
  168. """INSECURE: MD5/SHA1 for passwords."""
  169. import hashlib
  170. password = "password123"
  171. # INSECURE: Fast hashes are easily brute-forced
  172. md5_hash = hashlib.md5(password.encode()).hexdigest()
  173. sha1_hash = hashlib.sha1(password.encode()).hexdigest()
  174. # These can be cracked in seconds with rainbow tables
  175. assert len(md5_hash) == 32
  176. assert len(sha1_hash) == 40
  177. def test_secure_password_hash(self):
  178. """SECURE: Use slow, salted password hashing."""
  179. # In production, use argon2-cffi or bcrypt
  180. # This is a simplified demonstration
  181. import hashlib
  182. password = "password123"
  183. salt = secrets.token_bytes(16)
  184. # PBKDF2 with high iteration count (still not ideal, use Argon2)
  185. hash_value = hashlib.pbkdf2_hmac(
  186. "sha256", password.encode(), salt, iterations=100000
  187. )
  188. assert len(hash_value) == 32
  189. assert len(salt) == 16

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.