Hub rules-numpy

rules-numpy

v3 public Verified

Numpy

NumPy is a fundamental library for scientific computing in Python, providing support for large, multi-dimensional arrays and matrices. These rules govern high-performance numerical operations, memory management, and data manipulation.

@sigmashakeinc 2 pulls 5 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-numpy →
Severity
1 error 4 warn 0 info
demo.cast
NumPy is a fundamental library for scientific computing in Python, providing support for large, multi-dimensional arrays and matrices. These rules govern high-performance numerical operations, memory management, and data manipulation.

Rules index

5 governance rules

Indexed from the repository's .rules files, grouped by technology. Expand any rule to read the raw source.

numpy

numpy-block-unsafe-patterns error block

RISK: np.load(allow_pickle=True) deserializes arbitrary Python objects from the file, enabling remote code execution if the .npy file comes from an untrusted source (CWE-502, analogous to pickle exploits). FIX: use allow_pickle=False (the default since NumPy 1.16.3) and store structured data as .npz (compressed arrays) or .csv/.json for human-readable formats.

Rule source requires an active Pro or Enterprise subscription.
numpy-force-updated-api warning log

RISK: np.matrix is deprecated since NumPy 1.15 and slated for removal — it wraps ndarray with different broadcast semantics that silently change the result of * (matrix multiply vs element-wise). FIX: replace with np.ndarray (np.array) and the @ operator for matrix multiplication.

Rule source requires an active Pro or Enterprise subscription.
numpy-frompyfunc-arbitrary-callable warning log

RISK: np.frompyfunc(eval, ...) vectorizes the Python eval function over array elements — passing an array of untrusted strings causes code execution on every element (CWE-94). FIX: never pass eval/exec/compile to frompyfunc; use np.vectorize with a safe parsing function.

Rule source requires an active Pro or Enterprise subscription.
numpy-index-fromstring-exec warning log

RISK: constructing string arrays from np.fromstring/frombuffer and later evaluating them (e.g., with eval or ast.literal_eval in a loop) creates a code-execution surface if the data is user-controlled. FIX: validate input data against an expected schema and use structured array dtypes instead of raw string buffers.

Rule source requires an active Pro or Enterprise subscription.
numpy-unsafe-dtype-object warning log

RISK: dtype=object arrays store arbitrary Python objects — serializing them with pickle (np.save/joblib) is equivalent to raw pickle and enables deserialization RCE when loaded from untrusted sources (CWE-502). FIX: use a concrete numeric dtype (float64, int32) and ensure object arrays are never persisted or loaded from external data without schema validation.

Rule source requires an active Pro or Enterprise subscription.

Version metadata

Published metadata

The hash-locked record of this published ruleset. When source contents change, the maintainer resyncs and the version bumps.

Version
v3
Published
Apr 8, 2026
Source commits
0
Synced
Oct 11, 2026
Hash
3c9a6318dbb0ecec27a9cd8fcbb2da6ea80b7b13827865dfe78ef4bb9025c500
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

Latest commits touching rulesets/rules-numpy/.sigmashake/rules in sigmashakeinc/rules/rulesets/rules-numpy. The published version only bumps when a maintainer resyncs.

No commit history available.