Skip to content

refactor: extract parseUrlPatterns from ssl-bump.ts into domain-patterns.ts#4946

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactor-extract-parse-url-patterns
Jun 14, 2026
Merged

refactor: extract parseUrlPatterns from ssl-bump.ts into domain-patterns.ts#4946
lpcox merged 3 commits into
mainfrom
copilot/refactor-extract-parse-url-patterns

Conversation

Copilot AI commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

parseUrlPatterns (URL glob→regex conversion) had no dependency on SSL primitives yet lived in ssl-bump.ts, alongside CA/key-material management. This moves it to domain-patterns.ts where its siblings (wildcardToRegex, parseDomainWithProtocol, validateDomainOrPattern) already live.

Changes

  • src/ssl-bump.ts — remove parseUrlPatterns and URL_CHAR_PATTERN; module is now SSL key-material only
  • src/domain-patterns.ts — add parseUrlPatterns + URL_CHAR_PATTERN at end of file
  • src/config-writer.ts — split import: parseUrlPatterns from ./domain-patterns, SSL functions remain from ./ssl-bump
  • src/ssl-bump.test.ts — remove parseUrlPatterns describe block and unused constant
  • src/domain-patterns.test.ts — add parseUrlPatterns to imports and test suite
  • src/config-writer.test.ts — move parseUrlPatterns mock from ./ssl-bump to a new jest.mock('./domain-patterns'); update all jest.requireMock call sites accordingly

Copilot AI changed the title [WIP] Refactor extract parseUrlPatterns into domain-patterns refactor: extract parseUrlPatterns from ssl-bump.ts into domain-patterns.ts Jun 14, 2026
Copilot finished work on behalf of lpcox June 14, 2026 17:07
Copilot AI requested a review from lpcox June 14, 2026 17:07
@lpcox lpcox marked this pull request as ready for review June 14, 2026 17:09
Copilot AI review requested due to automatic review settings June 14, 2026 17:09
@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 96.60% 96.64% 📈 +0.04%
Statements 96.47% 96.51% 📈 +0.04%
Functions 98.80% 98.80% ➡️ +0.00%
Branches 91.18% 91.21% 📈 +0.03%
📁 Per-file Coverage Changes (4 files)
File Lines (Before → After) Statements (Before → After)
src/ssl-bump.ts 94.7% → 94.0% (-0.64%) 94.0% → 93.3% (-0.70%)
src/config-writer.ts 85.3% → 85.5% (+0.19%) 85.3% → 85.5% (+0.19%)
src/domain-patterns.ts 97.6% → 97.9% (+0.30%) 97.7% → 98.0% (+0.28%)
src/workdir-setup.ts 92.6% → 94.4% (+1.85%) 92.6% → 94.4% (+1.85%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

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.

Pull request overview

Refactors URL glob→regex parsing (parseUrlPatterns) out of src/ssl-bump.ts into src/domain-patterns.ts so SSL key-material logic and domain/URL pattern utilities are separated, with call sites and tests updated accordingly.

Changes:

  • Moved parseUrlPatterns (and URL_CHAR_PATTERN) from ssl-bump.ts into domain-patterns.ts.
  • Updated config-writer.ts to import parseUrlPatterns from domain-patterns.ts while keeping SSL primitives in ssl-bump.ts.
  • Relocated and updated unit tests/mocks to reflect the new module boundary.
Show a summary per file
File Description
src/ssl-bump.ts Removes URL pattern parsing utilities to keep module focused on SSL key-material management.
src/domain-patterns.ts Adds parseUrlPatterns alongside other domain/pattern utilities.
src/config-writer.ts Updates imports to pull URL parsing from domain-patterns.ts.
src/ssl-bump.test.ts Removes the parseUrlPatterns test suite from SSL bump tests.
src/domain-patterns.test.ts Adds parseUrlPatterns tests to the domain/pattern test suite.
src/config-writer.test.ts Updates mocks to mock parseUrlPatterns from ./domain-patterns instead of ./ssl-bump.

Copilot's findings

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment on lines +492 to +509
// Pattern constant for the safer URL character class (matches the implementation)
const URL_CHAR_PATTERN = '[^\\s]*';

describe('parseUrlPatterns', () => {
it('should escape regex special characters except wildcards', () => {
const patterns = parseUrlPatterns(['https://github.com/user']);
expect(patterns).toEqual(['^https://github\\.com/user$']);
});

it('should convert * wildcard to safe regex pattern', () => {
const patterns = parseUrlPatterns(['https://github.com/myorg/*']);
expect(patterns).toEqual([`^https://github\\.com/myorg/${URL_CHAR_PATTERN}`]);
});

it('should handle multiple wildcards', () => {
const patterns = parseUrlPatterns(['https://api-*.example.com/*']);
expect(patterns).toEqual([`^https://api-${URL_CHAR_PATTERN}\\.example\\.com/${URL_CHAR_PATTERN}`]);
});
Comment thread src/domain-patterns.ts
Comment on lines +369 to +381
// Preserve existing .* patterns by using a placeholder before escaping
const WILDCARD_PLACEHOLDER = '\x00WILDCARD\x00';
p = p.replace(/\.\*/g, WILDCARD_PLACEHOLDER);

// Escape regex special characters except *
p = p.replace(/[.+?^${}()|[\]\\]/g, '\\$&');

// Convert * wildcards to safe pattern (prevents ReDoS)
p = p.replace(/\*/g, URL_CHAR_PATTERN);

// Restore preserved patterns from placeholder
p = p.replace(new RegExp(WILDCARD_PLACEHOLDER, 'g'), URL_CHAR_PATTERN);

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

@Copilot @lpcox Smoke Test Results:

• GitHub API connectivity: ✅
• github.com connectivity: ✅
• File write/read test: ✅
• BYOK inference path: ✅

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra

Overall: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Hostname wildcards (e.g., api-* in https://api-*.example.com/path) now
use [^\s/]* instead of [^\s]*, preventing them from matching '/' and
crossing into the path portion. Path wildcards continue to use [^\s]*.

This prevents a security issue where https://api-*.example.com/* could
match https://api-evil.attacker.com/.example.com/anything.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx 1/1 passed ✅ PASS
Node.js execa 1/1 passed ✅ PASS
Node.js p-limit 1/1 passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #4946 ·

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results — FAIL

Test Result
GitHub MCP connectivity ✅ (PR list fetched)
GitHub.com HTTP connectivity ❌ pre-step data unavailable (template vars not expanded)
File write/read ❌ pre-step data unavailable (template vars not expanded)

PR: refactor: extract parseUrlPatterns from ssl-bump.ts into domain-patterns.ts
Author: @Copilot | Assignees: @lpcox, @Copilot

Overall: FAIL — pre-step outputs (SMOKE_HTTP_CODE, SMOKE_FILE_CONTENT, SMOKE_FILE_PATH) were not populated.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅ PASS

Test Results:

  • ✅ GitHub MCP connectivity (verified PRs fetched)
  • ✅ github.com HTTP 200 (DNS & network access working)
  • ✅ File write/read (filesystem access confirmed)
  • ✅ BYOK inference (currently executing in direct BYOK mode via api-proxy → api.githubcopilot.com)

Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY via api-proxy sidecar)

cc: @lpcox

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

Merged PRs:

  • Refactor OpenAI BYOK base URL parsing to reuse shared proxy URL normalization
  • refactor(api-proxy): split proxy-request.js into http-client.js and body-handler.js

✅ GitHub browser check
✅ File write/read
✅ Discussion lookup/comment target
npm ci && npm run build

Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.16.0 v22.22.3
Go go1.22.12 go1.22.12

Overall: ❌ Tests did not pass — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING ❌ No response (timeout)
PostgreSQL pg_isready no response
PostgreSQL SELECT 1 ❌ No response (timeout)

Overall: FAILhost.docker.internal resolves to 172.17.0.1 but ports 6379 and 5432 are not reachable.

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot PAT Auth — Results

Test Status
GitHub MCP connectivity
GitHub.com HTTP ❓ (template var unresolved)
File write/read ❓ (template var unresolved)

Overall: FAIL — pre-step outputs (SMOKE_HTTP_CODE, SMOKE_FILE_PATH, SMOKE_FILE_CONTENT) were not substituted; workflow template expansion did not occur.

Auth mode: PAT (COPILOT_GITHUB_TOKEN)
PR author: @Copilot | Assignees: @lpcox @Copilot

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results: Gemini Engine Validation

  • GitHub MCP Testing: ❌ (Tools not found)
  • GitHub.com Connectivity: ❌ (Status 000/35: SSL error)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox @Copilot

  • ✅ Refactor OpenAI BYOK base URL parsing to reuse shared proxy URL normalization
  • ✅ GitHub.com connectivity
  • ✅ File I/O
  • ✅ BYOK inference

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)

Overall: PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@lpcox lpcox merged commit 177500c into main Jun 14, 2026
110 of 133 checks passed
@lpcox lpcox deleted the copilot/refactor-extract-parse-url-patterns branch June 14, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants