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

UNOMI-858: Fix CodeQL Java Error + Fix code scanning alert no. 11: Insecure randomness #701

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

jsinovassin
Copy link
Contributor

@jsinovassin jsinovassin commented Oct 14, 2024

https://issues.apache.org/jira/browse/UNOMI-858
Specify the Java version to use in the CodeQL workflow

Fixes https://github.com/apache/unomi/security/code-scanning/11

To fix the problem, we need to replace the use of Math.random() with a cryptographically secure random number generator. In the browser environment, crypto.getRandomValues is the recommended method. This function generates cryptographically secure random values, which can be used to replace the insecure Math.random().

  • Replace the Math.random() call with crypto.getRandomValues.
  • Ensure the generated random values are used correctly to maintain the UUID format.
  • Update the generateUUID function in the samples/tweet-button-plugin/src/main/webapp/index.html file.

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

jsinovassin and others added 3 commits October 14, 2024 10:25
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@jsinovassin jsinovassin marked this pull request as ready for review October 14, 2024 13:16
@jsinovassin jsinovassin changed the title Fix code scanning alert no. 11: Insecure randomness Fix CodeQL Java Error + Fix code scanning alert no. 11: Insecure randomness Oct 14, 2024
@jsinovassin jsinovassin changed the title Fix CodeQL Java Error + Fix code scanning alert no. 11: Insecure randomness UNOMI-858: Fix CodeQL Java Error + Fix code scanning alert no. 11: Insecure randomness Oct 14, 2024
@jsinovassin jsinovassin merged commit 694d671 into master Oct 14, 2024
5 checks passed
@jsinovassin jsinovassin deleted the alert-autofix-11 branch October 14, 2024 14:44
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.

3 participants