Skip to content

Prune at configured disk limits and support paths with spaces - #1231

Merged
mmguero merged 3 commits into
cisagov:contributor-prsfrom
sylvesterkaczmarek:fix/prune-threshold-and-spaced-paths-20261013
Oct 13, 2026
Merged

mmguero merged 3 commits into
cisagov:contributor-prsfrom
sylvesterkaczmarek:fix/prune-threshold-and-spaced-paths-20261013

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Problem

shared/bin/prune_files.sh documents that pruning begins at or above the
configured disk-usage percentage or path-size threshold and stops only after
usage drops below both limits. The implementation uses strict greater-than
comparisons, so exact-boundary usage never triggers cleanup or can stop early.

The script also expands the -p prune path without quoting it when changing
directories. A valid capture or log directory containing spaces fails with
a path error instead of being pruned.

Fix

  • Quote the path passed to pushd so directories with whitespace are accepted.
  • Use inclusive comparisons both to trigger cleanup and to decide whether
    further pruning is needed.
  • Keep the existing age order, filesystem boundaries, spool exclusions,
    and independent percent/size threshold selection unchanged.

Tests

Four sandboxed integration tests exercise the real shell script with mock
disk-usage and file-listing tools. Files are only created and deleted inside
temporary directories. The cases cover paths containing spaces, usage exactly
equal to the percent threshold, size exactly equal to the GB threshold,
and no cleanup below the threshold.

The original upstream script fails three cases and passes the below-threshold
control. With the fix, all four cases pass.

  • Bash syntax validation, Python test compilation, Ruff correctness lint and
    git diff --check passed.
  • No live capture files, production volumes, or files outside the test sandbox
    were touched.

@mmguero
mmguero changed the base branch from main to contributor-prs October 13, 2026 15:55
@mmguero mmguero self-assigned this Oct 13, 2026
@mmguero mmguero added beats Relating to Malcolm's use of Beats iso relating to the ISO-installed environment for Malcolm and/or Hedgehog labels Oct 13, 2026
@mmguero mmguero added this to the v26.10.0 milestone Oct 13, 2026
@mmguero mmguero added this to Malcolm Oct 13, 2026
@mmguero
mmguero merged commit 9be38ed into cisagov:contributor-prs Oct 13, 2026
@github-project-automation github-project-automation Bot moved this from Review to Done in Malcolm Oct 13, 2026
@mmguero mmguero mentioned this pull request Oct 29, 2026
@mmguero mmguero moved this from Done to Released in Malcolm Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beats Relating to Malcolm's use of Beats iso relating to the ISO-installed environment for Malcolm and/or Hedgehog

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

2 participants