Repository navigation
Test: Suggested Changes V3 #2
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||||
| const sqlite3 = require('sqlite3').verbose(); | ||||||||
| const db = new sqlite3.Database(':memory:'); | ||||||||
|
|
||||||||
| function getUser(id) { | ||||||||
| const query = "SELECT * FROM users WHERE id = " + id; | ||||||||
| db.get(query, (err, row) => { | ||||||||
| if (err) console.error(err); | ||||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQL Injection VulnerabilitySeverity: CRITICAL | Confidence: 100% Why: The Suggested Fix:
Suggested change
|
||||||||
| console.log(row); | ||||||||
| }); | ||||||||
|
Comment on lines
+4
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "vulnerable-test.js" -type fRepository: Ashutosh0x/gemini-code-review-bot Length of output: 210 🏁 Script executed: cd . && git ls-files | grep -E "(vulnerable|test)" | head -20Repository: Ashutosh0x/gemini-code-review-bot Length of output: 109 🏁 Script executed: cat -n vulnerable-test.jsRepository: Ashutosh0x/gemini-code-review-bot Length of output: 504 🌐 Web query:
💡 Result: In Node.js, SQLite parameterized queries work by putting placeholders in your SQL, then binding values separately (array/object), so values are never string-interpolated into the SQL.
|
||||||||
| } | ||||||||
|
|
||||||||
| const userId = "1 OR 1=1"; | ||||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Demonstration of SQL InjectionSeverity: CRITICAL | Confidence: 100% Why: The Suggested Fix:
Suggested change
|
||||||||
| getUser(userId); | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,6 @@ | ||||||||||||||||||||||||||||||
| function getUser(id) { | ||||||||||||||||||||||||||||||
| // TODO: Fix injection | ||||||||||||||||||||||||||||||
| const query = `SELECT * FROM users WHERE id = ${id}`; | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P0: SQL Injection Vulnerability: The Use parameterized queries with placeholders instead of string interpolation. With sqlite3, use Prompt for AI agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQL Injection VulnerabilitySeverity: CRITICAL | Confidence: 100% Why: The Suggested Fix:
Suggested change
|
||||||||||||||||||||||||||||||
| return query; | ||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "vulnerable.js" -type fRepository: Ashutosh0x/gemini-code-review-bot Length of output: 92 🏁 Script executed: cat -n ./vulnerable.jsRepository: Ashutosh0x/gemini-code-review-bot Length of output: 281 🏁 Script executed: rg "getUser" -B 2 -A 2Repository: Ashutosh0x/gemini-code-review-bot Length of output: 695 🏁 Script executed: cat -n ./vulnerable-test.jsRepository: Ashutosh0x/gemini-code-review-bot Length of output: 504 🏁 Script executed: rg "require.*vulnerable" -A 3Repository: Ashutosh0x/gemini-code-review-bot Length of output: 59 🏁 Script executed: find . -type f \( -name "*.js" -o -name "*.json" \) | head -20Repository: Ashutosh0x/gemini-code-review-bot Length of output: 254 🏁 Script executed: grep -r "vulnerable" . --include="*.js" --include="*.json"Repository: Ashutosh0x/gemini-code-review-bot Length of output: 59 🏁 Script executed: cat -n ./vulnerable.jsRepository: Ashutosh0x/gemini-code-review-bot Length of output: 281 Block SQL injection by parameterizing the query. Line 3 interpolates 🔒 Proposed fix function getUser(id) {
// TODO: Fix injection
- const query = `SELECT * FROM users WHERE id = ${id}`;
- return query;
+ return {
+ sql: 'SELECT * FROM users WHERE id = ?',
+ params: [id],
+ };
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQL Injection VulnerabilitySeverity: CRITICAL | Confidence: 100% Why: The Suggested Fix:
Suggested change
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| module.exports = { getUser }; | ||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P0: SQL Injection Vulnerability: Building SQL queries via string concatenation allows attackers to inject malicious SQL. Use parameterized queries with placeholders instead.
Prompt for AI agents