← Back to Pull requests

fix(ack): remove temp Docker config dir after crane image check #2158

Merged
Vedant-Agarwal merged 2 files (60 lines) on Sep 24, 2026 22:04 UTC
View on GitHub
Vedant-Agarwal Vedant-Agarwal commented on Jul 02, 2026 06:00 UTC
Author

What

ACKEnvironment._image_exists's crane fallback writes registry credentials into a temp Docker config dir (tempfile.mkdtemp(prefix="crane-docker-config-"), ack.py:726) and sets DOCKER_CONFIG to it — but never removes it. Every image-existence check via crane therefore leaks a credential-bearing directory on disk (a base64 registry auth in config.json), on both the success and exception paths.

Why it's a real bug

The two sibling buildkit paths in the same file already clean up their temp Docker config / build dirs (shutil.rmtree at ack.py:984 and a finally: shutil.rmtree(...) at :1001). Only the crane path omits cleanup — a clear sibling-consistency gap, with a mild security angle (credentials left on disk).

Fix

Track the temp dir and remove it in a finally (mirroring the buildkit paths). String content aside, this just ensures the credential dir is always reclaimed.

Test

Added tests/unit/environments/test_ack.py — forces the crane path with registry auth (mocked subprocess) and asserts the temp DOCKER_CONFIG dir is gone afterward. It fails without the fix (mutation-checked) and passes with it. ruff clean.
<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/2158" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review">
</picture>
</a>
<!-- devin-review-badge-end -->

Diff: 60 lines (+60 / -0) across 2 files Reviewer: KunWuLuan Review duration: 121924m
All Vouch review confidence checks passed
Residual risk 0.11 = Change Risk (0.52) × (1 − Review Confidence (0.79)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 60 lines diff across 2 files
0.52
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.69 · 5 substantive comment(s)
0.69
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
79%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.246
Sensitive Paths sensitive_paths
0.052
Real PR Conversation Timeline
10 items
vercel[bot] vercel[bot] commented on Jul 02, 2026 06:00 UTC
Bot

@Vedant-Agarwal is attempting to deploy a commit to the Harbor Framework Team on Vercel.

A member of the Team first needs to authorize it.

github-actions[bot] github-actions[bot] commented on Jul 02, 2026 06:00 UTC
Bot

Enjoy a better diff viewing experience by clicking one of these URLs:

  • <a href="https://devinreview.com/harbor-framework/harbor/pull/2158" target="_blank" rel="noopener noreferrer">devinreview</a>

  • <a href="https://diffshub.com/harbor-framework/harbor/pull/2158" target="_blank" rel="noopener noreferrer">diffshub</a>

  • <a href="https://linear.review/harbor-framework/harbor/pull/2158" target="_blank" rel="noopener noreferrer">linear</a>
  • devin-ai-integration[bot] devin-ai-integration[bot] commented on Jul 02, 2026 06:02 UTC
    Reviewer

    ✅ Devin Review: No Issues Found

    Devin Review analyzed this PR and found no bugs or issues to report.

    <!-- devin-review-badge-begin -->
    <a href="https://app.devin.ai/review/harbor-framework/harbor/pull/2158" target="_blank">
    <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review">
    </picture>
    </a>
    <!-- devin-review-badge-end -->

    kobe0938 kobe0938 commented on Jul 02, 2026 22:42 UTC
    Contributor

    @KunWuLuan do you want to take a look at this since ack.py is added/used by your team at alibaba? It's fine if it's not legit and not worth merging.

    Vedant-Agarwal Vedant-Agarwal commented on Jul 07, 2026 12:36 UTC
    Author

    The leak is easy to confirm: in the crane fallback of _image_exists, tempfile.mkdtemp(prefix="crane-docker-config-") gets a config.json with registry credentials written into it and is never removed — every image check leaves one behind. The buildkit paths in the same file already shutil.rmtree their temp configs; this PR just adds the same cleanup in a finally, and the unit test asserts the dir is gone after _image_exists returns.

    Vedant-Agarwal Vedant-Agarwal commented on Jul 24, 2026 16:35 UTC
    Author

    @kobe0938 In case it helps unblock this while KunWuLuan is busy: I don't think ACK-specific context is strictly needed to review it. The temp DOCKER_CONFIG dir is created by harbor itself (tempfile.mkdtemp(prefix="crane-docker-config-")) and holds a config.json with registry auth — and the buildkit paths in this same file already shutil.rmtree their temp configs on the same success/failure paths. The PR just applies that existing pattern to the crane fallback, so there's no ACK behavior change, only cleanup of a credential-bearing directory. Branch is conflict-free and checks are green.

    KunWuLuan KunWuLuan commented on Sep 24, 2026 02:50 UTC
    Contributor

    /lgtm

    KunWuLuan KunWuLuan approved these changes on Sep 24, 2026 03:57 UTC
    Approved Reviewer

    Approved these changes.

    kobe0938 kobe0938 approved these changes on Sep 24, 2026 22:04 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    Vedant-Agarwal Vedant-Agarwal
    Labels
    risk: low confidence: 79.4% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.2% (MEDIUM) · Higher = larger blast radius
    52.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 79.4% · Lower = rushed or shallow review
    79.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 10.8% · Safe to merge
    10.8%