Skip to content

Revert password changes - #309

Merged
justin-phxm merged 2 commits into
mainfrom
revert-password-changes
Jul 11, 2026
Merged

Revert password changes#309
justin-phxm merged 2 commits into
mainfrom
revert-password-changes

Conversation

@dastine0308

@dastine0308 dastine0308 commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added separate credentials for driver updates, finish-line updates, and snapshot creation.
    • Updated password configuration to support these dedicated credentials.
  • Bug Fixes

    • Driver, finish-line, and snapshot actions now validate against their respective passwords.
    • Invalid passwords continue to provide clear validation errors and prevent unauthorized changes.

@dastine0308
dastine0308 requested a review from a team as a code owner July 11, 2026 22:26
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
helios-telemetry Building Building Preview, Comment Jul 11, 2026 10:26pm

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change replaces shared master-password validation with separate password configuration and checks for driver updates, finish-line updates, and snapshot creation.

Changes

Password validation updates

Layer / File(s) Summary
Password secret configuration
packages/amplify/amplify/backend.ts, packages/server/.env.example
Deployment and example environment configuration now define separate driver, finish-line, and snapshot password variables.
Password validator changes
packages/server/src/utils/validatePassword.ts
Driver validation uses MQTT_PASSWORD, and snapshot validation uses SNAPSHOT_PASSWORD; the shared master-password validator is removed.
Controller password routing
packages/server/src/controllers/...
Driver, finish-line, and snapshot controllers use their corresponding password checks while retaining existing error handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: promatty, alexwhelan12, justin-phxm

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title says the PR reverts password changes, but the diff introduces new password env vars and validation logic instead. Rename it to describe the actual password-separation changes, or revert the code changes if that was the intent.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-password-changes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@justin-phxm
justin-phxm merged commit 385f05b into main Jul 11, 2026
6 of 8 checks passed
@justin-phxm
justin-phxm deleted the revert-password-changes branch July 11, 2026 22:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/server/src/utils/validatePassword.ts (1)

30-43: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Inconsistent env-var reading and error-handling patterns across the two validators.

validateDriverUpdatePassword reads its env var at module load (fail-fast at startup), while validateSnapshotPassword reads at call time (fails on first request). The LapController does a raw process.env comparison with no existence check at all (fail-open if unset). Consider unifying all three into a single pattern — ideally read-at-call-time with an explicit missing-env-var check — to avoid surprising behavior differences.

♻️ Suggested unified pattern
 export function validateDriverUpdatePassword(password: string): boolean {
+  const driverPassword = process.env.DRIVER_NAME_UPDATE_PASSWORD;
+  if (!driverPassword) {
+    throw new Error("DRIVER_NAME_UPDATE_PASSWORD environment variable is not configured");
+  }
-  return password === validPassword;
+  return password === driverPassword;
 }

This aligns validateDriverUpdatePassword with validateSnapshotPassword's read-at-call-time approach and makes the missing-env-var behavior explicit.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/utils/validatePassword.ts` around lines 30 - 43, Unify
password validation to read environment variables at call time and reject
missing configuration explicitly. Update validateDriverUpdatePassword to read
and validate its driver-password env var inside the function, matching
validateSnapshotPassword, and update LapController’s password comparison to use
the same validator or equivalent missing-env-var check; preserve the existing
valid-password comparisons and error behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/server/src/controllers/LapController/LapController.ts`:
- Around line 140-141: Update the password validation in the LapController check
to reject requests when FINISH_LINE_UPDATE_PASSWORD is unset, preventing missing
credentials from passing validation. Replace the logger.error message with a
generic invalid-password message that never includes the supplied password,
matching the behavior of the other controllers.

In `@packages/server/src/controllers/routeControllers/snapshot.controller.ts`:
- Line 85: Update the snapshot controller flow around validateSnapshotPassword
so an unset SNAPSHOT_PASSWORD is validated during application startup, following
the existing validateDriverUpdatePassword pattern, rather than allowing its
configuration error to reach clients. If startup validation is not applicable,
catch that failure and route a generic 500 response without exposing the
missing-secret message.

In `@packages/server/src/utils/validatePassword.ts`:
- Around line 1-4: Update validateDriverUpdatePassword to read the
DRIVER_NAME_UPDATE_PASSWORD environment variable instead of MQTT_PASSWORD, and
change the missing-configuration error message to reference
DRIVER_NAME_UPDATE_PASSWORD so driver update validation uses its dedicated
secret.

---

Nitpick comments:
In `@packages/server/src/utils/validatePassword.ts`:
- Around line 30-43: Unify password validation to read environment variables at
call time and reject missing configuration explicitly. Update
validateDriverUpdatePassword to read and validate its driver-password env var
inside the function, matching validateSnapshotPassword, and update
LapController’s password comparison to use the same validator or equivalent
missing-env-var check; preserve the existing valid-password comparisons and
error behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0c9b62c2-35c8-4099-ae28-3466aae0592c

📥 Commits

Reviewing files that changed from the base of the PR and between c8bc134 and e264863.

📒 Files selected for processing (6)
  • packages/amplify/amplify/backend.ts
  • packages/server/.env.example
  • packages/server/src/controllers/LapController/LapController.ts
  • packages/server/src/controllers/routeControllers/driver.controller.ts
  • packages/server/src/controllers/routeControllers/snapshot.controller.ts
  • packages/server/src/utils/validatePassword.ts

Comment on lines +140 to +141
if (password !== process.env.FINISH_LINE_UPDATE_PASSWORD) {
logger.error("Invalid Password: " + password);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Password is logged in the error message and the env-var check is fail-open.

Two issues on this password check:

  1. CWE-532 — Sensitive data in logs: logger.error("Invalid Password: " + password) logs the raw password value. The other controllers (driver.controller.ts, snapshot.controller.ts) log a generic "Invalid password attempt" message without the value. This is inconsistent and leaks credentials to log files.

  2. Fail-open when FINISH_LINE_UPDATE_PASSWORD is unset: The raw comparison password !== process.env.FINISH_LINE_UPDATE_PASSWORD passes if both sides are undefined (env var not configured + missing password in payload). Unlike validateSnapshotPassword which throws when the env var is missing, this check silently allows access.

🔒 Proposed fix: remove password from log and guard against unset env var
     const { lat, long, password } = newCoordInfo;
-    if (password !== process.env.FINISH_LINE_UPDATE_PASSWORD) {
-      logger.error("Invalid Password: " + password);
+    const finishLinePassword = process.env.FINISH_LINE_UPDATE_PASSWORD;
+    if (!finishLinePassword || password !== finishLinePassword) {
+      logger.error("Invalid password attempt for finish line update");
       return { error: "Invalid Password", invalidFields: ["password"] };
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (password !== process.env.FINISH_LINE_UPDATE_PASSWORD) {
logger.error("Invalid Password: " + password);
if (password !== process.env.FINISH_LINE_UPDATE_PASSWORD) {
logger.error("Invalid Password: " + password);
Suggested change
if (password !== process.env.FINISH_LINE_UPDATE_PASSWORD) {
logger.error("Invalid Password: " + password);
const finishLinePassword = process.env.FINISH_LINE_UPDATE_PASSWORD;
if (!finishLinePassword || password !== finishLinePassword) {
logger.error("Invalid password attempt for finish line update");
return { error: "Invalid Password", invalidFields: ["password"] };
}
🧰 Tools
🪛 ast-grep (0.44.1)

[warning] 140-140: Avoid logging sensitive data
Context: logger.error("Invalid Password: " + password)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/controllers/LapController/LapController.ts` around lines
140 - 141, Update the password validation in the LapController check to reject
requests when FINISH_LINE_UPDATE_PASSWORD is unset, preventing missing
credentials from passing validation. Replace the logger.error message with a
generic invalid-password message that never includes the supplied password,
matching the behavior of the other controllers.

Source: Linters/SAST tools

}

if (!validateMasterPassword(password)) {
if (!validateSnapshotPassword(password)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the asyncHandler implementation and error-handling middleware to verify
# whether raw error messages are sanitized before reaching the client.
rg -nC5 "asyncHandler" --type=ts packages/server/src/
rg -nC5 "error.*handler\|ErrorHandler\|err.*req.*res" --type=ts packages/server/src/ -g '!**/node_modules/**'

Repository: UCSolarCarTeam/Helios-Telemetry

Length of output: 5895


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== errorHandler implementation =="
cat -n packages/server/src/middleware/errorHandler.ts

echo
echo "== snapshot controller around validateSnapshotPassword =="
rg -nC6 "validateSnapshotPassword|createSnapshot|SNAPSHOT_PASSWORD" packages/server/src/controllers/routeControllers/snapshot.controller.ts

echo
echo "== server/app wiring for error middleware =="
rg -nC4 "app.use\\(|errorHandler|asyncHandler|express\\(" packages/server/src -g '!**/node_modules/**'

echo
echo "== startup validation for driver update password =="
rg -nC6 "validateDriverUpdatePassword|DRIVER_UPDATE_PASSWORD|throw new Error" packages/server/src

Repository: UCSolarCarTeam/Helios-Telemetry

Length of output: 23647


Avoid returning the missing-secret error to clients. validateSnapshotPassword() throws when SNAPSHOT_PASSWORD is unset, and errorHandler sends err.message in the JSON response, so the client can see SNAPSHOT_PASSWORD environment variable is not configured. Move this check to startup like validateDriverUpdatePassword() or map it to a generic 500.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/controllers/routeControllers/snapshot.controller.ts` at
line 85, Update the snapshot controller flow around validateSnapshotPassword so
an unset SNAPSHOT_PASSWORD is validated during application startup, following
the existing validateDriverUpdatePassword pattern, rather than allowing its
configuration error to reach clients. If startup validation is not applicable,
catch that failure and route a generic 500 response without exposing the
missing-secret message.

Comment on lines +1 to +4
const validPassword = process.env.MQTT_PASSWORD;

if (!validPassword) {
throw new Error("UI_MASTER_PASSWORD environment variable is not configured");
throw new Error("MQTT_PASSWORD environment variable is not configured");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that DRIVER_NAME_UPDATE_PASSWORD is not referenced anywhere in the application code.
rg -n "DRIVER_NAME_UPDATE_PASSWORD" --type=ts -g '!**/*.env*' -g '!**/backend.ts'
# Also check if MQTT_PASSWORD is referenced beyond MQTT connection setup.
rg -nC3 "MQTT_PASSWORD" --type=ts -g '!**/*.env*' -g '!**/backend.ts'

Repository: UCSolarCarTeam/Helios-Telemetry

Length of output: 169


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== validatePassword.ts ==\n'
git ls-files 'packages/server/src/utils/validatePassword.ts' 'packages/server/src/**' | cat
echo
wc -l packages/server/src/utils/validatePassword.ts 2>/dev/null || true
echo
cat -n packages/server/src/utils/validatePassword.ts 2>/dev/null || true

printf '\n== References to DRIVER_NAME_UPDATE_PASSWORD ==\n'
rg -n -S "DRIVER_NAME_UPDATE_PASSWORD" .

printf '\n== References to MQTT_PASSWORD ==\n'
rg -n -C 3 -S "MQTT_PASSWORD" packages/server/src .

Repository: UCSolarCarTeam/Helios-Telemetry

Length of output: 9672


validateDriverUpdatePassword should read DRIVER_NAME_UPDATE_PASSWORD, not MQTT_PASSWORD. The new secret is wired into deployment, but this validator still gates driver updates on the MQTT broker password, so the two credentials remain coupled. Update the env var and error message here so driver updates use their own secret.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/utils/validatePassword.ts` around lines 1 - 4, Update
validateDriverUpdatePassword to read the DRIVER_NAME_UPDATE_PASSWORD environment
variable instead of MQTT_PASSWORD, and change the missing-configuration error
message to reference DRIVER_NAME_UPDATE_PASSWORD so driver update validation
uses its dedicated secret.

Source: Linters/SAST tools

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