Hub rules-ocaml

rules-ocaml

v3 public Verified

Ocaml

OCaml is a general-purpose, industrial-strength functional programming language with an emphasis on expressiveness and safety. These rules govern type-safe development, module systems, and functional programming patterns.

@sigmashakeinc 2 pulls 6 rules published Apr 8, 2026 synced Nov 22, 2026 sigmashakeinc/rules/rulesets/rules-ocaml →
Severity
3 error 2 warn 1 info
demo.cast
OCaml is a general-purpose, industrial-strength functional programming language with an emphasis on expressiveness and safety. These rules govern type-safe development, module systems, and functional programming patterns.

Rules index

6 governance rules

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

ocaml

ocaml-block-unsafe-patterns warning ask

RISK: Obj.magic performs an unchecked type coercion bypassing OCaml's type system — a mismatch between the actual and asserted types leads to undefined behaviour, corruption of the GC's tag bits, and segfaults (CWE-843). FIX: use a well-typed GADT, variant, or explicit coercion; confine Obj.magic to FFI shims that are verified against C headers.

Rule source requires an active Pro or Enterprise subscription.
ocaml-bytes-unsafe-ops warning log

RISK: Bytes/String.unsafe_get/set skip bounds checking — an off-by-one or attacker-controlled index reads or writes out of bounds, corrupting the heap (CWE-125, CWE-787). FIX: use the safe Bytes.get/set which raise Invalid_argument on out-of-bounds access, and handle the exception explicitly.

Rule source requires an active Pro or Enterprise subscription.
ocaml-force-updated-api info log

INFO: The Pervasives module was renamed to Stdlib in OCaml 4.07 and is available as a deprecated alias only — it may be removed in a future release. FIX: replace 'Pervasives.' with 'Stdlib.' (or omit the module qualifier, as Stdlib is opened by default).

Rule source requires an active Pro or Enterprise subscription.
ocaml-marshal-from-untrusted error block

RISK: Marshal.from_* deserializes arbitrary OCaml values including closures — loading from an untrusted source executes attacker-supplied code when the value is applied (CWE-502). FIX: use JSON (yojson), Sexplib, or Cap'n Proto with explicit schema validation; never unmarshal network or user data.

Rule source requires an active Pro or Enterprise subscription.
ocaml-obj-unsafe-ops error block

RISK: Obj.unsafe_get/set/raw_field/set_tag/truncate operate on GC-managed values without any bounds or type checks — misuse corrupts the OCaml heap and causes non-deterministic crashes or exploitable memory safety violations (CWE-119). FIX: avoid these entirely outside of the OCaml runtime source; use safe array/record accessors.

Rule source requires an active Pro or Enterprise subscription.
ocaml-unix-system error block

RISK: Unix.system passes its argument to /bin/sh — any interpolated variable or user-supplied string enables command injection (CWE-78). FIX: use Unix.create_process or Unix.execve with an explicit argv array and never build command strings from untrusted input.

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
Nov 22, 2026
Hash
8ee2841cf4aa3ac831583c2a92938eb091345a6e1d02f8d050a0a3a9f9a50a7a
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

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

No commit history available.