Skip to content

Deduplicate enclave audit setup and cleanup Docker assertions - #11963

Merged
lpcox merged 3 commits into
mainfrom
copilot/duplicate-code-fix
Nov 22, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/duplicate-code-fix

Conversation

@lpcox

@lpcox lpcox commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Enclave audit fixtures and rootless cleanup Docker assertions were duplicated across three test files, creating opportunities for coverage drift.

  • Shared setup: Add setupEnclaveAuditFixture(dir) to create the enclave root and return the audit directory.
  • Shared assertions: Add expectPreserveCleanupDockerRun(mock, options) for mount translation, image selection, pull policy, and repair command checks.
  • Coverage: Retain existing assertions and add an alternate mount-prefix, registry, and tag case. Production code remains unchanged.
const auditDir = setupEnclaveAuditFixture(getDir());
preserveIptablesAudit(getDir(), auditDir);

@lpcox lpcox changed the title [WIP] Refactor duplicate code in audit-preservation test setup Deduplicate enclave audit setup and cleanup Docker assertions Nov 22, 2026
@lpcox
lpcox marked this pull request as ready for review November 22, 2026 22:39
Copilot AI adaptive review requested due to automatic review settings November 22, 2026 22:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active critical and moderate findings remain: an unused variable causes ESLint to fail, and a test expectation mishandles supported path-prefix normalization.

2 open issues
What changed in this PR

This PR centralizes duplicated enclave audit fixture setup and rootless Docker permission-repair assertions across related tests while adding coverage for alternate mount prefixes, registries, and image tags.

Changes:

  • Added shared helpers for enclave audit fixtures and cleanup Docker assertions.
  • Updated diagnostics and artifact-preservation tests to use the shared helpers.
  • Added parameterized coverage for alternate Docker mount prefixes and image references.
File Description
src/​test-helpers/​docker-test-fixtures.test-utils.ts Adds shared enclave audit fixture and Docker invocation assertion helpers.
src/​docker-manager-diagnostics.test.ts Replaces duplicated enclave audit setup with the shared fixture helper.
src/​artifact-preservation-errors.test.ts Uses the shared cleanup Docker assertion helper for error-path coverage.
src/​artifact-permissions.test.ts Parameterizes rootless repair tests and adds alternate registry, tag, and mount-prefix coverage.

Review effort: Lite (adaptive)

Comment on lines 275 to +276
const enclaveRoot = resolveEnclavePaths(getDir()).root;
fs.mkdirSync(enclaveRoot, { recursive: true });
const auditDir = path.join(getDir(), 'audit');
fs.mkdirSync(auditDir);
const auditDir = setupEnclaveAuditFixture(getDir());
'--entrypoint',
'sh',
'-v',
`${path.join(dockerHostPathPrefix, path.resolve(auditDir))}:/fix:rw`,
@lpcox

lpcox commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in 5cb3108. The enclaveRoot variable is used by cleanup, so it remains. Targeted tests and lint could not run because dependencies were unavailable; direct prefix checks passed.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox
lpcox merged commit 51610b3 into main Nov 22, 2026
39 of 41 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-fix branch November 22, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Duplicate Code] Enclave audit-preservation test setup and docker-run assertions repeated across three test files

3 participants