Skip to content

Parameterize survey database writes - #72

Merged
mageroni merged 3 commits into
mainfrom
agentic-autofix/fix-code-scanning-alerts
Nov 12, 2026
Merged

mageroni merged 3 commits into
mainfrom
agentic-autofix/fix-code-scanning-alerts

Conversation

@github-agentic-autofix

@github-agentic-autofix github-agentic-autofix AI commented Nov 12, 2026 •

Copy link
Copy Markdown

Survey issue bodies and comments were interpolated into SQL statements, creating an injection risk in both INSERT and UPDATE operations.

  • Parameterized writes: Bind submitted values and issue IDs with mssql.Request.input; use an allowlist for column names.
  • Regression coverage: Check that SQL syntax in submitted comments remains parameter data for both write paths.
request.input("value0", submittedValue);
await request.query("INSERT INTO SurveyResults ([comment]) VALUES (@value0)");

Co-authored-by: mageroni <107436170+mageroni@users.noreply.github.com>
@github-agentic-autofix github-agentic-autofix AI changed the title [WIP] Fix code scanning alerts in repository Parameterize survey database writes Nov 12, 2026
GitHub Agentic Autofix finished work on behalf of mageroni November 12, 2026 16:07
@github-agentic-autofix
github-agentic-autofix AI marked this pull request as ready for review November 12, 2026 16:07
Copilot AI adaptive review requested due to automatic review settings November 12, 2026 16:07

Copilot AI 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.

🟡 Changes recommended

Hard-coded parameter placeholders make the tests brittle to column reordering and leave the INSERT column-to-value mapping unverified.

1 open issue
What changed in this PR

This PR reduces SQL injection risk in survey database writes by replacing interpolated values with bound parameters.

Changes:

  • Parameterize INSERT and UPDATE values and issue IDs, using an allowlist for column names.
  • Add regression tests confirming SQL-like comments remain parameter data in both write paths.
File Description
test/​index.test.js Extend database mocks and test parameterized survey inserts and updates.
index.js Add the column allowlist and bind survey write parameters through mssql.Request.

Review effort: Max (auto)

Comment thread test/index.test.js Resolved
Refactor query validation to extract comment parameter and check format.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mageroni
mageroni merged commit dc96327 into main Nov 12, 2026
6 of 7 checks passed
@mageroni
mageroni deleted the agentic-autofix/fix-code-scanning-alerts branch November 12, 2026 16:22
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.

3 participants