Skip to content

fix: resolve issue #42 — Fix WEIGHT_PER_POINT constant value#1

Open
echobt wants to merge 1 commit intomainfrom
fix/bounty-issue-42
Open

fix: resolve issue #42 — Fix WEIGHT_PER_POINT constant value#1
echobt wants to merge 1 commit intomainfrom
fix/bounty-issue-42

Conversation

@echobt
Copy link
Copy Markdown

@echobt echobt commented Feb 24, 2026

Fix for Issue PlatformNetwork#42

Issue: Fix WEIGHT_PER_POINT constant value

Automated Fixes Applied

  • src/scoring.rs: replaced "const WEIGHT_PER_POINT: f64 = 0.02;..." with "const WEIGHT_PER_POINT: f64 = 0.025;..."

Files Analyzed

  • src/scoring.rs — 1 suggestion(s)
    • Replace identified text from issue analysis (line 8)

Patch File

A detailed patch file has been generated at output/patches/issue-42.patch


Generated by bounty-challenge worker

Summary by CodeRabbit

  • Updates
    • Adjusted scoring calculation parameters to refine accuracy of score computations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db46240 and 0265bcb.

📒 Files selected for processing (1)
  • src/scoring.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/scoring.rs

📝 Walkthrough

Walkthrough

A single public constant WEIGHT_PER_POINT in src/scoring.rs has been updated from 0.02 to 0.025, adjusting the scaling factor used in downstream scoring calculations without any functional or API changes.

Changes

Cohort / File(s) Summary
Scoring Constant Update
src/scoring.rs
Public constant WEIGHT_PER_POINT value updated from 0.02 to 0.025, affecting the weight scaling calculation across all scoring operations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A fraction small, from 0.02 to more,
The weight per point now holds 0.025's score,
Through scoring flows it gently flows,
A careful tweak that precision shows! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: updating the WEIGHT_PER_POINT constant value, and references the associated issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/bounty-issue-42

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 and usage tips.

@echobt echobt force-pushed the fix/bounty-issue-42 branch from db46240 to 0265bcb Compare February 24, 2026 12:00
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@src/git-manager.ts`:
- Around line 36-49: The commitAndPush function currently interpolates the
user-supplied message into a shell string (exec(`git commit -m
"${message...}"`)) which risks command injection; replace the shell-invoking
exec calls that include user input with a safe child process call that accepts
an argument array (e.g., use execFileSync or spawnSync) so the commit message is
passed as an argument rather than embedded in a shell string, update the git
commit invocation in commitAndPush to call git with args ["commit","-m",
message] and likewise ensure any other exec calls that take untrusted input are
invoked with argument arrays, and preserve the existing error handling (catching
push failures) while logging failures appropriately.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 201157b and db46240.

📒 Files selected for processing (3)
  • src/git-manager.ts
  • src/scoring.rs
  • src/worker.ts

Comment thread src/git-manager.ts Outdated
Comment on lines 36 to 49
export function commitAndPush(repoPath: string, branchName: string, message: string): void {
exec("git add -A", repoPath);
const status = exec("git status --porcelain", repoPath);
if (!status) {
return;
}

try {
execGit(`git checkout ${branchName}`);

for (const file of files) {
execGit(`git add -- "${file}"`);
}

execGit(`git commit -m "${message.replace(/"/g, '\\"')}"`);
} catch (error) {
const msg = error instanceof Error ? error.message : String(error);
throw new Error(
`Failed to commit changes on branch '${branchName}': ${msg}`
);
}
}

export function pushBranch(branchName: string): void {
const token = getGHToken();
const originUrl = getOriginUrl();

exec(`git commit -m "${message.replace(/"/g, '\\"')}"`, repoPath);
try {
execGit(`git checkout ${branchName}`);

const authenticatedUrl = originUrl.replace(
/https:\/\/(.*@)?github\.com/,
`https://${token}@github.com`
);
execGit(`git remote set-url origin ${authenticatedUrl}`);

try {
execGit(`git push -u origin ${branchName}`);
} finally {
execGit(`git remote set-url origin ${originUrl}`);
}
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to push branch '${branchName}': ${message}`);
exec(`git push origin ${branchName} --force`, repoPath);
} catch {
// push may fail without remote configured; log but don't throw
console.error(`Warning: git push to origin/${branchName} failed. Commit is local only.`);
}
}
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

Avoid shell interpolation of commit messages (command injection risk).

Line 42 interpolates message into a shell command. Issue titles can contain $() or backticks, which the shell expands even inside double quotes, enabling command injection. Prefer execFileSync/spawnSync with argument arrays.

🛡️ Proposed fix (use execFileSync for git commands with user input)
-import { execSync } from "child_process";
+import { execSync, execFileSync } from "child_process";

 function exec(cmd: string, cwd: string): string {
   return execSync(cmd, { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
 }
+
+function execGit(args: string[], cwd: string): string {
+  return execFileSync("git", args, { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
+}
@@
-  exec(`git commit -m "${message.replace(/"/g, '\\"')}"`, repoPath);
+  execGit(["commit", "-m", message], repoPath);
   try {
-    exec(`git push origin ${branchName} --force`, repoPath);
+    execGit(["push", "origin", branchName, "--force"], repoPath);
   } catch {
#!/bin/bash
# Verify where commitAndPush is called and how the message is built.
rg -n "commitAndPush\\(" -S
rg -n "commitMessage|spec\\.title|issue_number" -S src
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/git-manager.ts` around lines 36 - 49, The commitAndPush function
currently interpolates the user-supplied message into a shell string (exec(`git
commit -m "${message...}"`)) which risks command injection; replace the
shell-invoking exec calls that include user input with a safe child process call
that accepts an argument array (e.g., use execFileSync or spawnSync) so the
commit message is passed as an argument rather than embedded in a shell string,
update the git commit invocation in commitAndPush to call git with args
["commit","-m", message] and likewise ensure any other exec calls that take
untrusted input are invoked with argument arrays, and preserve the existing
error handling (catching push failures) while logging failures appropriately.

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.

1 participant