Skip to content

Validate build output permalinks#63

Open
samdark wants to merge 1 commit into
masterfrom
validate-entry-permalink-output-paths
Open

Validate build output permalinks#63
samdark wants to merge 1 commit into
masterfrom
validate-entry-permalink-output-paths

Conversation

@samdark

@samdark samdark commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

  • reject unsafe permalink path segments before writing output files
  • fail builds that define duplicate permalinks before parallel workers can overwrite each other
  • document front matter permalink path constraints

Tests

  • make test -- --filter BuildCommandTest
  • make psalm
  • make test

Copilot AI review requested due to automatic review settings June 13, 2026 08:46
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@samdark, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 38 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f799b832-9c12-4e44-957f-9063c155ab42

📥 Commits

Reviewing files that changed from the base of the PR and between 315ad8d and 73e7514.

📒 Files selected for processing (3)
  • docs/content.md
  • src/Console/BuildCommand.php
  • tests/Unit/Console/BuildCommandTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch validate-entry-permalink-output-paths

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens build-time permalink handling to prevent unsafe output paths and to detect permalink collisions early, reducing the chance of parallel writers overwriting the same output file. It also adds tests and documents the permalink constraints.

Changes:

  • Add build-time detection of duplicate permalinks and fail the build when duplicates exist.
  • Validate permalink path segments before computing output file paths (rejecting unsafe segments like . / ..).
  • Add unit tests for duplicate permalinks and unsafe permalink segments; document permalink constraints in the content docs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/Unit/Console/BuildCommandTest.php Adds regression tests for duplicate permalinks and unsafe permalink segments causing build failure.
src/Console/BuildCommand.php Implements duplicate-permalink detection and output path validation for permalinks.
docs/content.md Documents new permalink constraints in front matter docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1249 to +1260
private function duplicatePermalinks(array $fileToPermalink): array
{
$sourcesByPermalink = [];
foreach ($fileToPermalink as $source => $permalink) {
$sourcesByPermalink[$permalink][] = $source;
}

return array_filter(
$sourcesByPermalink,
static fn (array $sources): bool => count($sources) > 1,
);
}
Comment on lines +400 to +401
$duplicatePermalinks = $this->duplicatePermalinks($fileToPermalink);
if ($duplicatePermalinks !== []) {
Comment on lines +1277 to +1282
$segments = explode('/', trim($permalink, '/'));
foreach ($segments as $segment) {
if ($segment === '' || $segment === '.' || $segment === '..') {
throw new RuntimeException(sprintf('Permalink "%s" contains an unsafe path segment.', $permalink));
}
}
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.

2 participants