-
Notifications
You must be signed in to change notification settings - Fork 0
fix(operations): harden maintainer readiness evidence output #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { | ||
| existsSync, | ||
| mkdtempSync, | ||
| mkdirSync, | ||
| readFileSync, | ||
| rmSync, | ||
| symlinkSync, | ||
| writeFileSync, | ||
| } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { afterAll, afterEach, describe, expect, it } from "vitest"; | ||
| import { main } from "../scripts/maintainer-app-readiness.mjs"; | ||
|
|
||
| const originalEnvironment = { ...process.env }; | ||
| const originalExitCode = process.exitCode; | ||
| const directories: string[] = []; | ||
|
|
||
| function temporaryDirectory(): string { | ||
| const directory = mkdtempSync(join(tmpdir(), "noema-maintainer-output-safety-")); | ||
| directories.push(directory); | ||
| return directory; | ||
| } | ||
|
|
||
| function configureCollectionFailure(reportPath: string): void { | ||
| process.env.GITHUB_REPOSITORY = "ContextualWisdomLab/not-noema"; | ||
| process.env.NOEMA_MAINTAINER_READINESS_PATH = reportPath; | ||
| delete process.env.GITHUB_OUTPUT; | ||
| delete process.env.GITHUB_STEP_SUMMARY; | ||
| } | ||
|
|
||
| function restoreProcessState(): void { | ||
| for (const key of Object.keys(process.env)) { | ||
| if (!(key in originalEnvironment)) delete process.env[key]; | ||
| } | ||
| Object.assign(process.env, originalEnvironment); | ||
| process.exitCode = originalExitCode; | ||
| } | ||
|
|
||
| afterEach(() => restoreProcessState()); | ||
|
|
||
| afterAll(() => { | ||
| restoreProcessState(); | ||
| for (const directory of directories) rmSync(directory, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| describe("maintainer App readiness output path integrity", () => { | ||
| it("refuses a pre-existing symbolic-link report leaf without modifying its target", () => { | ||
| const directory = temporaryDirectory(); | ||
| const targetPath = join(directory, "target.json"); | ||
| const reportPath = join(directory, "report.json"); | ||
| writeFileSync(targetPath, "sentinel\n", "utf8"); | ||
| symlinkSync(targetPath, reportPath); | ||
| configureCollectionFailure(reportPath); | ||
|
|
||
| expect(() => main()).toThrow(/output path|symbolic link|regular file/i); | ||
| expect(readFileSync(targetPath, "utf8")).toBe("sentinel\n"); | ||
| }); | ||
|
|
||
| it("refuses a symbolic-link report parent without creating evidence through it", () => { | ||
| const directory = temporaryDirectory(); | ||
| const realParent = join(directory, "real-parent"); | ||
| const linkedParent = join(directory, "linked-parent"); | ||
| const reportPath = join(linkedParent, "report.json"); | ||
| mkdirSync(realParent); | ||
| symlinkSync(realParent, linkedParent, "dir"); | ||
| configureCollectionFailure(reportPath); | ||
|
|
||
| expect(() => main()).toThrow(/output parent|symbolic link|real directory/i); | ||
| expect(existsSync(join(realParent, "report.json"))).toBe(false); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Parent validation rejects symlinked ancestors up to root
writeReportvalidates every existing parent up to the filesystem root before writing (assertAcquisitionPrivatePathParentsat scripts/lib/acquisition-private-output.mjs:78-87). Missing dirs are tolerated, so recursive mkdir still works. On macOStmpdir()resolves under/var, a symlink to/private/var, which this walk would reject. CI is Linux so no regression here, only relevant to local runs.Was this helpful? React with 👍 or 👎 to provide feedback.