-
-
Notifications
You must be signed in to change notification settings - Fork 1
✨ Combustion & Appraisals #5
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
Conversation
…-based implementation
| def update | ||
| respond_to do |format| | ||
| if site.update_attributes(site_params) | ||
| if site.update(site_params) |
Check failure
Code scanning / CodeQL
Insecure Mass Assignment Critical
this remote flow source
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix the problem, we need to explicitly specify which keys are permitted within the properties hash. This can be done by listing the allowed keys in the permit method. This change should be made in the site_params method in the app/controllers/masq/sites_controller.rb file.
- Identify the keys that are allowed within the
propertieshash. - Update the
site_paramsmethod to explicitly permit only those keys.
-
Copy modified line R57
| @@ -56,3 +56,3 @@ | ||
| def site_params | ||
| params.require(:site).permit(:persona_id, :url, properties: {}) | ||
| params.require(:site).permit(:persona_id, :url, properties: [:key1, :key2, :key3]) | ||
| end |
|
|
||
| # Encrypts some data with the salt. | ||
| def encrypt(password, salt) | ||
| Digest::SHA1.hexdigest("--#{salt}--#{password}--") |
Check failure
Code scanning / CodeQL
Use of a broken or weak cryptographic hashing algorithm on sensitive data High
Sensitive data (password)
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix the problem, we need to replace the use of the weak SHA-1 hashing algorithm with a stronger, more secure algorithm suitable for password hashing. One of the best options for password hashing is the Argon2 algorithm, which is designed to be computationally expensive and includes a per-password salt by default.
To implement the fix, we will:
- Replace the
encryptmethod to use Argon2 for hashing passwords. - Add the necessary import for the
argon2gem. - Ensure that the
authenticatemethod verifies the password using Argon2.
-
Copy modified line R1 -
Copy modified line R74 -
Copy modified line R83 -
Copy modified line R85
| @@ -1,2 +1,2 @@ | ||
| require "digest/sha1" | ||
| require "argon2" | ||
|
|
||
| @@ -73,3 +73,3 @@ | ||
| if !a.nil? && a.active? && a.enabled | ||
| if a.authenticated?(password) || (Masq::Engine.config.masq["trust_basic_auth"] && basic_auth_used) | ||
| if Argon2::Password.verify_password(password, a.encrypted_password) || (Masq::Engine.config.masq["trust_basic_auth"] && basic_auth_used) | ||
| a.last_authenticated_at = Time.now.utc | ||
| @@ -82,5 +82,5 @@ | ||
|
|
||
| # Encrypts some data with the salt. | ||
| # Encrypts some data with Argon2. | ||
| def encrypt(password, salt) | ||
| Digest::SHA1.hexdigest("--#{salt}--#{password}--") | ||
| Argon2::Password.create(password) | ||
| end |
-
Copy modified lines R51-R52
| @@ -50 +50,3 @@ | ||
| gem "rails", "~> 8.0", ">= 8.0.2" | ||
|
|
||
| gem "argon2", "2.3.2" |
| Package | Version | Security advisories |
| argon2 (rubygems) | 2.3.2 | None |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5 +/- ##
=======================================
Coverage ? 88.33%
=======================================
Files ? 28
Lines ? 917
Branches ? 290
=======================================
Hits ? 810
Misses ? 107
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Attempt to keep Rails 5.2 and 6.0 support