Skip to content

fix(inspect): Docker discovery bugs - broken find, N+1 perf, OOM risk, wrong size units #102

@CodeMonkeyCybersecurity

Description

Summary

Multiple bugs and performance issues in pkg/inspect/docker.go:

  1. P0 Bug: discoverComposeFiles() passes 2>/dev/null as a literal argument to find (via exec.Command, which doesn't interpret shell redirections). Also, -type f is ungrouped and only applies to the last -name pattern.
  2. P0 Perf: discoverContainers() runs N+1 shell commands (1 docker ps + N docker inspect). On 50 containers, this is ~15s of unnecessary latency.
  3. P1 Security: os.ReadFile on discovered compose files has no size limit - a symlink to a multi-GB file causes OOM.
  4. P1 Correctness: parseHumanSize uses binary multipliers (1024) but Docker uses SI/decimal (1000). 1GB returns 1073741824 instead of 1000000000.
  5. P1 Style: Emoji characters in log messages despite commit 9cd58733 removing them.

Root Cause

  • exec.Command API misunderstanding (shell syntax in non-shell context)
  • No batching strategy for Docker CLI calls
  • Missing input validation on file reads
  • Incorrect unit conversion assumption
  • Incomplete emoji sweep

Fix

See PR for implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions