Skip to content

fix(utils): fail closed in site-scope checks when siteBaseUrl is missing#1766

Open
dhavkuma wants to merge 2 commits into
mainfrom
worktree-url-helpers-scope-fix-tests
Open

fix(utils): fail closed in site-scope checks when siteBaseUrl is missing#1766
dhavkuma wants to merge 2 commits into
mainfrom
worktree-url-helpers-scope-fix-tests

Conversation

@dhavkuma

@dhavkuma dhavkuma commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • isWithinSiteScope and isPathPatternWithinSiteScope returned true when siteBaseUrl was missing/empty, treating every URL or pattern as in-scope by default.
  • Changed both to fail closed (false) instead, consistent with isPathPatternWithinSiteScope's existing fail-closed behavior for patterns it can't verify as scoped.
  • Updated the existing unit tests that asserted the old fail-open behavior (isWithinSiteScope, isPathPatternWithinSiteScope, filterBySiteScope).

Test plan

  • npm test -w packages/spacecat-shared-utils — 1254 passing, 100% coverage on url-helpers.js
  • npm run lint -w packages/spacecat-shared-utils — clean

🤖 Generated with Claude Code

isWithinSiteScope and isPathPatternWithinSiteScope returned true when
siteBaseUrl was falsy, treating URLs/patterns as in-scope by default.
Fail closed instead, consistent with isPathPatternWithinSiteScope's
existing fail-closed behavior for unverifiable regex patterns.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dhavkuma dhavkuma requested a review from MysticatBot July 2, 2026 12:10
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@MysticatBot MysticatBot 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.

Hey @dhavkuma,

Verdict: Approve - clean security hardening, no issues found.
Complexity: TRIVIAL - 2-line behavior flip, 2 files.
Changes: Switches site-scope check functions from fail-open to fail-closed when siteBaseUrl is missing (2 files).

Non-blocking (1): minor issues and suggestions
  • suggestion: Add an explicit undefined assertion to the isWithinSiteScope null/empty test case (the falsy guard already handles it, but pinning the case prevents a future refactor from regressing it) - packages/spacecat-shared-utils/test/url-helpers.test.js:1256

Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 1m 21s | Cost: $2.27 | Commit: cdf39f617c55c747265fcf0fb69186f71bc46ff8
If this code review was useful, please react with 👍. Otherwise, react with 👎.

@MysticatBot MysticatBot added ai-reviewed Reviewed by AI complexity:trivial AI-assessed PR complexity: TRIVIAL labels Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed Reviewed by AI complexity:trivial AI-assessed PR complexity: TRIVIAL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants