Skip to content

Bound the project search parameters instead of concatenating them - #9

Merged
vagisha merged 1 commit into
masterfrom
project-search-bind-parameters
Sep 12, 2026
Merged

vagisha merged 1 commit into
masterfrom
project-search-bind-parameters

Conversation

@vagisha

@vagisha vagisha commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Project search built its WHERE clause by string concatenation, so a search word with an
    apostrophe closed the string literal
    • Searching for Parkinson's threw a syntax error on the live site, and the error page
      returned the query fragment
    • Reachable by any logged-in user, not only administrators
  • Search words, project types and both date constraints now use bind parameters
  • The ten columns a search word is matched against are now one array and one helper,
    rather than being written out twice
  • SearchProjectsAction and SortProjectSearchAction now require the administrators group
    • The link is on the ADMIN menu, but neither action checked

Test plan

  • Parkinson's returns 3 projects, O'KEEFE returns none, neither errors
  • HDL restricted to Billed Projects returns 16, matching the database
  • HDL diabetes returns 3 billed and 5 supported, so words are ANDed
  • 310 matches on project ID
  • Recent Submissions lists a project inside the one-month window and not one outside it
  • As a non-administrator, submitting the search is refused
  • Search still works as an administrator

Co-Authored-By: Claude noreply@anthropic.com

* ProjectsSearcher built its WHERE clause by string concatenation, so a search word
  containing an apostrophe closed the literal.  Searching for Parkinson's threw a
  syntax error on the live site, and the error page returned the query fragment
* Search words, project types and both dates now go through bind parameters
* The ten columns a search word is matched against were written out twice.  They are
  now one array and one tokenConstraint helper
* setEndDate built its date without separators, giving 2026911 rather than 2026-9-11.
  Nothing calls it, so nothing was broken, but the hand-built string is gone
* SearchProjectsAction and SortProjectSearchAction now require the administrators
  group.  The link is on the ADMIN menu but neither action checked, so any logged-in
  user could reach the search by posting to it directly

Co-Authored-By: Claude <noreply@anthropic.com>

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

🟢 Approval recommended

The parameter ordering, query construction, date handling, and authorization checks are consistent and complete.

Pull request overview

Secures administrative project search by parameterizing SQL inputs and enforcing administrator access.

Changes:

  • Binds project types, search tokens, IDs, and date constraints.
  • Consolidates token matching across searchable columns.
  • Adds administrator checks to search and sorting actions.
File summaries
File Description
ProjectsSearcher.java Replaces SQL concatenation with bind parameters.
SearchProjectsAction.java Restricts searches to administrators.
SortProjectSearchAction.java Restricts result sorting to administrators.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vagisha
vagisha merged commit 4580bfe into master Sep 12, 2026
1 check 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