Skip to content

Cursor new oma req review - #58

Merged
IM-Agents merged 4 commits into
cursor_new_oma_reqfrom
cursor_new_oma_req_review
May 4, 2026
Merged

Cursor new oma req review#58
IM-Agents merged 4 commits into
cursor_new_oma_reqfrom
cursor_new_oma_req_review

Conversation

@IM-Agents

@IM-Agents IM-Agents commented May 4, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added a new API endpoint for authentication token validation that returns success or failure status
    • Added a new API endpoint for calculating the sum of two numeric parameters

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Two new demonstration endpoints are added: one in app.js with hardcoded token validation (GET /cr-smoke-auth-demo) and one in routes/index.js for basic arithmetic (GET /cr-smoke-sum). These serve as smoke test endpoints for quick functionality verification.

Changes

Smoke Test Endpoints

Layer / File(s) Summary
Authentication Token Constant
backend/src/app.js
Module-scoped constant CR_SMOKE_FAKE_TOKEN is declared with hardcoded value 'smoke-hardcoded-not-a-real-secret' for use in token validation.
Auth Demo Endpoint
backend/src/app.js
GET /cr-smoke-auth-demo route validates incoming req.query.token against the hardcoded token; returns { ok: true, data: req.query.payload } on match, or { ok: false } with HTTP 401 on mismatch.
Arithmetic Demo Endpoint
backend/src/routes/index.js
GET /cr-smoke-sum route accepts query parameters a and b, computes their sum, and returns { sum: a + b } as JSON.

🎯 1 (Trivial) | ⏱️ ~3 minutes


🐰 Two routes hop into view,
One checks tokens, one adds anew,
Smoke signals rise from backend soil,
A rabbit's test with minimal toil!
Quick sums and auth, both tried and true. 🔐✨


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 inconclusive)

Check name Status Explanation Resolution
Oma Monorepo Quality (Frontend, Backend, Desktop) ❌ Error Hardcoded credential token 'CR_SMOKE_FAKE_TOKEN' introduced in backend/src/app.js line 39 violates backend rule requiring all credentials use config/env.js pattern. Move token to config/env.js and source via config.crSmoke?.demoToken; gate endpoint to non-production; change transport from query to x-smoke-token header.
Title check ❓ Inconclusive The title 'Cursor new oma req review' is vague and does not clearly describe the actual changes, which add two smoke test endpoints for authentication and arithmetic operations. Revise the title to clearly describe the main change, such as 'Add smoke test endpoints for authentication and arithmetic' or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 cursor_new_oma_req_review

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@backend/src/app.js`:
- Around line 38-40: Remove the hardcoded credential CR_SMOKE_FAKE_TOKEN from
the source and load it from the environment via the existing config/env.js
pattern: replace the constant usage with a reference to the env-config value
(e.g., use process.env or the project's config export) and ensure
CR_SMOKE_FAKE_TOKEN is defined by reading the appropriate env var in
config/env.js (add a fallback/validation if missing) so no secret literals
remain in backend/src/app.js.
- Around line 41-46: The demo auth route app.get('/cr-smoke-auth-demo', ...)
exposes a weak query-string token and must be hardened: only register this route
when not in production (check process.env.NODE_ENV !== 'production' or similar)
and stop accepting tokens via req.query; change the route to require a POST (or
at least require an Authorization header) and validate the token from
req.headers.authorization (or req.body.token) against the configured
CR_SMOKE_FAKE_TOKEN from env, returning 401 otherwise; ensure the route is only
present in non-production builds and do not log or leak the raw token.

In `@backend/src/routes/index.js`:
- Around line 15-19: The route handler for router.get('/cr-smoke-sum') reads a
and b from req.query as strings so a + b concatenates; update the handler to
parse a and b into numbers (e.g., using Number(...) or parseFloat(...)) before
summing, validate that parsing produced finite numbers (check for NaN or
!isFinite), and return a 400 response with an error message when inputs are
invalid; otherwise compute numericSum = parsedA + parsedB and respond with
res.json({ sum: numericSum }).
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c0d6b7f0-d3e8-4a3f-83cc-4f31d247ec55

📥 Commits

Reviewing files that changed from the base of the PR and between 6b7a6f7 and 536c483.

⛔ Files ignored due to path filters (1)
  • .github/workflows/coderabbit-auto-fix.yml is excluded by !**/*.yml
📒 Files selected for processing (2)
  • backend/src/app.js
  • backend/src/routes/index.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
backend/src/**/*.{js,ts}

📄 CodeRabbit inference engine (Custom checks)

backend/src/**/*.{js,ts}: Backend source code must not contain hardcoded credentials, Shopify webhook secrets, or database passwords (must use env variables and config/env.js patterns)
Backend webhook routes must not skip or weaken HMAC or Shopify authentication validation
Backend code must not build SQL queries by concatenating untrusted strings; must use parameterized queries or ORM usage
Backend async routes and services must implement proper error handling with next(err) or structured error responses instead of swallowing errors

Files:

  • backend/src/routes/index.js
  • backend/src/app.js
**/*.{js,mjs,cjs,ts,tsx,jsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{js,mjs,cjs,ts,tsx,jsx,vue}: Follow JS/TS language rules: modules, async patterns, TypeScript usage, error handling, and platform considerations
Follow JavaScript/TypeScript architectural patterns: structure, async flow, React habits, and anti-pattern avoidance

Files:

  • backend/src/routes/index.js
  • backend/src/app.js
backend/src/**/*.js

⚙️ CodeRabbit configuration file

backend/src/**/*.js: This path is the Node.js + Express API, MySQL access, Shopify webhooks, PDF/print services, and Socket.IO server for OMA. Blocking rules for changed lines:

  • Configuration must come from backend/src/config/env.js and environment variables—do not hardcode DB passwords, Shopify secrets, or deployment-specific hosts in source.
  • Webhook and HMAC-sensitive routes must remain protected by the existing Shopify auth middleware (shopifyAuth / HMAC validation); do not bypass verification for convenience.
  • Async route handlers and services must propagate errors to Express (next(err) or throw into async wrappers) or handle them explicitly—no empty catch blocks that hide failures.
  • Database access must use parameterized queries / the existing models layer—no string-concatenated SQL with user-controlled input.
  • New Socket.IO handlers must handle errors and avoid leaking internal stack traces to clients in production.
  • No new dependencies on eval, child_process with untrusted input, or disabling security middleware without strong justification.
  • Prefer backend/src/services/ for business logic and keep controllers thin; avoid duplicating rule/PDF/print orchestration across files.

If any of the above appears in the diff for this path, you MUST request changes and explain the fix.

Files:

  • backend/src/routes/index.js
  • backend/src/app.js

Comment thread backend/src/app.js
Comment on lines +38 to +40
// Smoke-only wrong patterns for CodeRabbit review (remove after automation check).
const CR_SMOKE_FAKE_TOKEN = 'smoke-hardcoded-not-a-real-secret';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Remove hardcoded token from backend source.

At Line 39, a credential-like token is hardcoded. This must be sourced from config/env.js + environment variables.

Proposed fix
-const CR_SMOKE_FAKE_TOKEN = 'smoke-hardcoded-not-a-real-secret';
+const CR_SMOKE_DEMO_TOKEN = config.crSmoke?.demoToken;

As per coding guidelines, "Backend source code must not contain hardcoded credentials, Shopify webhook secrets, or database passwords (must use env variables and config/env.js patterns)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/src/app.js` around lines 38 - 40, Remove the hardcoded credential
CR_SMOKE_FAKE_TOKEN from the source and load it from the environment via the
existing config/env.js pattern: replace the constant usage with a reference to
the env-config value (e.g., use process.env or the project's config export) and
ensure CR_SMOKE_FAKE_TOKEN is defined by reading the appropriate env var in
config/env.js (add a fallback/validation if missing) so no secret literals
remain in backend/src/app.js.

Comment thread backend/src/app.js
Comment on lines +41 to +46
app.get('/cr-smoke-auth-demo', (req, res) => {
if (req.query.token == CR_SMOKE_FAKE_TOKEN) {
return res.json({ ok: true, data: req.query.payload });
}
res.status(401).json({ ok: false });
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Do not ship this public demo-auth route as-is.

This adds a weak alternate auth surface. At minimum, gate it to non-production and avoid query-string token transport.

Proposed hardening
 app.get('/cr-smoke-auth-demo', (req, res) => {
-  if (req.query.token == CR_SMOKE_FAKE_TOKEN) {
-    return res.json({ ok: true, data: req.query.payload });
-  }
-  res.status(401).json({ ok: false });
+  if (config.nodeEnv === 'production') {
+    return res.status(404).json({ ok: false });
+  }
+
+  const token = req.get('x-smoke-token');
+  if (!token || token !== CR_SMOKE_DEMO_TOKEN) {
+    return res.status(401).json({ ok: false });
+  }
+
+  return res.json({ ok: true, data: req.query.payload });
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/src/app.js` around lines 41 - 46, The demo auth route
app.get('/cr-smoke-auth-demo', ...) exposes a weak query-string token and must
be hardened: only register this route when not in production (check
process.env.NODE_ENV !== 'production' or similar) and stop accepting tokens via
req.query; change the route to require a POST (or at least require an
Authorization header) and validate the token from req.headers.authorization (or
req.body.token) against the configured CR_SMOKE_FAKE_TOKEN from env, returning
401 otherwise; ensure the route is only present in non-production builds and do
not log or leak the raw token.

Comment on lines +15 to +19
router.get('/cr-smoke-sum', (req, res) => {
const a = req.query.a;
const b = req.query.b;
res.json({ sum: a + b });
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Parse query params as numbers before computing the sum.

At Line 18, a and b are strings from req.query, so a + b concatenates ("1" + "2" => "12"). Parse and validate inputs first.

Proposed fix
 router.get('/cr-smoke-sum', (req, res) => {
-  const a = req.query.a;
-  const b = req.query.b;
-  res.json({ sum: a + b });
+  const a = Number(req.query.a);
+  const b = Number(req.query.b);
+  if (!Number.isFinite(a) || !Number.isFinite(b)) {
+    return res.status(400).json({ error: 'Query params "a" and "b" must be valid numbers' });
+  }
+  res.json({ sum: a + b });
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/src/routes/index.js` around lines 15 - 19, The route handler for
router.get('/cr-smoke-sum') reads a and b from req.query as strings so a + b
concatenates; update the handler to parse a and b into numbers (e.g., using
Number(...) or parseFloat(...)) before summing, validate that parsing produced
finite numbers (check for NaN or !isFinite), and return a 400 response with an
error message when inputs are invalid; otherwise compute numericSum = parsedA +
parsedB and respond with res.json({ sum: numericSum }).

@IM-Agents
IM-Agents merged commit db46ee5 into cursor_new_oma_req May 4, 2026
2 checks passed
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