Skip to content
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

Fix code scanning alert no. 1: Use of Kernel.open or IO.read or similar sinks with a non-constant value #233

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

davidar
Copy link
Contributor

@davidar davidar commented Jan 3, 2025

Fixes https://github.com/compute-toys/compute.toys/security/code-scanning/1

To fix the problem, we should replace the use of URI.open with a safer alternative that does not call Kernel.open internally. Specifically, we can use Net::HTTP.get to fetch the image data from the URL. This approach avoids the security risks associated with Kernel.open.

We need to:

  1. Replace the URI.open(image_url).read call with Net::HTTP.get(URI.parse(image_url)).
  2. Ensure that the net/http library is required at the beginning of the file.

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

…imilar sinks with a non-constant value

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

cloudflare-workers-and-pages bot commented Jan 3, 2025

Deploying compute-toys with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6b89829
Status: ✅  Deploy successful!
Preview URL: https://41feb0bc.compute-toys.pages.dev
Branch Preview URL: https://alert-autofix-1.compute-toys.pages.dev

View logs

Copy link

github-actions bot commented Jan 3, 2025

Screenshot from BrowserStack

URL: https://41feb0bc.compute-toys.pages.dev/new
Device: Samsung Galaxy Tab S10 Plus (landscape)
OS: Android 14.0
Browser: Android Browser
Created: 2025-01-03 08:20:14 UTC

Screenshot

@davidar davidar marked this pull request as ready for review January 3, 2025 08:24
@davidar davidar merged commit 43b7004 into master Jan 3, 2025
6 checks passed
@davidar davidar deleted the alert-autofix-1 branch January 3, 2025 08:25
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.

1 participant