Repository navigation
test: add sample code for pr-agent review #1
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,20 @@ | ||||||||||||||||||||
| // Missing await on async call | ||||||||||||||||||||
| async function fetchUser(id: string) { | ||||||||||||||||||||
| const result = fetch(`https://api.example.com/users/${id}`); | ||||||||||||||||||||
| return result; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Hardcoded secret | ||||||||||||||||||||
| const API_KEY = "sk-prod-abc123supersecretkey"; | ||||||||||||||||||||
|
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. 🟠 Security · high — Hardcoded secret API key A secret API key is committed in source code, exposing credentials that could be abused to access the production service. This constitutes a credential leakage risk.
Suggested change
Confidence 95% |
||||||||||||||||||||
|
|
||||||||||||||||||||
| // SQL injection risk | ||||||||||||||||||||
| function getUser(db: any, userId: string) { | ||||||||||||||||||||
| return db.query("SELECT * FROM users WHERE id = " + userId); | ||||||||||||||||||||
|
Comment on lines
+11
to
+12
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. 🟠 Security · high — SQL injection via string concatenation The getUser function builds a SQL query by concatenating userId directly, allowing an attacker to inject arbitrary SQL. This can lead to data leakage or modification.
Suggested change
Confidence 96% |
||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Empty catch | ||||||||||||||||||||
| async function riskyOp() { | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| await fetchUser("123"); | ||||||||||||||||||||
| } catch (e) {} | ||||||||||||||||||||
|
Comment on lines
+15
to
+19
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. 🔵 Bug · low — Empty catch block swallows errors The catch block catches exceptions from riskyOp but does nothing, silently ignoring failures. This makes debugging difficult and can hide runtime errors.
Suggested change
Confidence 85% |
||||||||||||||||||||
| } | ||||||||||||||||||||
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.
🟡 Bug · medium — Missing await on async fetch call
The function fetchUser is declared async but calls fetch without awaiting, so it returns a Promise instead of the resolved response. Callers expecting a resolved value may get an unexpected Promise, leading to runtime errors.
Confidence 90%