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: Insecure randomness #144

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Conversation

dinxsh
Copy link
Owner

@dinxsh dinxsh commented Dec 18, 2024

Fixes https://github.com/dinxsh/sanity/security/code-scanning/1

To fix the problem, we need to replace the use of Math.random() with a cryptographically secure random number generator. In Node.js, we can use the crypto module's randomInt function to generate a secure random integer. This will ensure that the verification code is not easily predictable.

  1. Import the crypto module in the app/api/sign-up/route.ts file.
  2. Replace the Math.random() based code with crypto.randomInt to generate the verification code.

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

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

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
beta-sanity ❌ Failed (Inspect) Dec 18, 2024 9:05pm
sanity ❌ Failed (Inspect) Dec 18, 2024 9:05pm

Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@dinxsh dinxsh marked this pull request as ready for review December 18, 2024 20:41
@dinxsh dinxsh merged commit 2d3e8c3 into master Dec 18, 2024
7 of 9 checks passed
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.

1 participant