Skip to content

installed_key membership probe silently reverses on a non-object .plugins shape (to_entries doesn't error on an array) #762

Closed

Description

@fdaviddpt

Filed while curating trap.d/660.promo-installed-key-array-plugins-shape.md, an independent
oss:auditor finding on PR #661, ranked non-blocking (latent unless installed_plugins.json's
writer ever emits .plugins as a non-object). Still present at HEAD,
scripts/session-start-hook.sh:1494:

_iprobe=$($JQ -r 'if (.version // empty) == "2" then (["#ok"] + ((.plugins // {}) | to_entries | map(.key))) | .[] else empty end' "$installed_file" 2>/dev/null)

The old per-candidate query (.plugins[$k] // empty | length) errored (jq exit 5, "Cannot index
array with string") if .plugins were a JSON array rather than an object; that error was caught
by a >/dev/null 2>&1 guard and treated as "cannot tell", suppressing the promo -- a deliberate
#574 decision. to_entries is defined for arrays too (index keys "0", "1", ...), so it does
NOT error on an array shape: a real installed_key like supertool@dpt-plugins never matches an
index string, so the membership check now reads "not installed" instead of "cannot tell" -- the
promo fires in exactly the situation the old code was written to suppress it in.

Confirmed live in a standalone repro: both jq calls run directly against a shimmed
installed_plugins.json with "plugins": ["x", "y"] -- old path suppresses, new path fires. Not
established whether installed_plugins.json's real writer can ever emit .plugins as a
non-object under schema version "2" -- if never, this is latent.

Candidate fix: validate .plugins is an object before to_entries, or catch a non-object
explicitly and fall back to cannot-tell, mirroring the old per-key behaviour.

[AI-generated]

Activity

  1. added
    priority:low
    filed-by-loop
    lane-other
    on Sep 25, 2026
  2. added
    lane-capture
    and removed
    lane-other
    on Sep 26, 2026
  3. self-assigned this
    on Sep 26, 2026
  4. added a commit that references this issue on Sep 26, 2026
  5. removed their assignment
    on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    filed-by-looplane-capturepriority:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions