Skip to content

Potential fix for code scanning alert no. 3: Incomplete URL substring sanitization#24

Draft
SafetyMP wants to merge 2 commits into
mainfrom
alert-autofix-3
Draft

Potential fix for code scanning alert no. 3: Incomplete URL substring sanitization#24
SafetyMP wants to merge 2 commits into
mainfrom
alert-autofix-3

Conversation

@SafetyMP

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/SafetyMP/Autonomous-EHS-Management/security/code-scanning/3

Use parsed URL hostname matching with proper domain-boundary validation instead of raw includes.
Best fix (without changing intended functionality):

  • Parse once with new URL(targetUrl).
  • Use hostname (not host) to avoid port influence.
  • Normalize to lowercase and strip any trailing dot.
  • Classify by checking whether hostname is exactly an allowed domain or a subdomain of it using host === domain || host.endsWith("." + domain).

In src/lib/operationalWebhook/channelAdapters.ts, update detectNotificationChannel (lines 26–41 region) to:

  • Replace all host.includes(...) checks.
  • Add a small local helper matchesDomain inside the function for clarity and reuse.

No new imports or external dependencies are needed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
autonomous-ehs-management Ready Ready Preview, Comment May 31, 2026 1:48pm

@SafetyMP

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented May 31, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved and pushed in commit dfd79e8.

@SafetyMP

SafetyMP commented Jun 1, 2026

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

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