OWASP / OWASP/SecurityShepherd

Refactor Getter.java and Setter.java into DAO pattern

Open
#815 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.5k
Forks
515
Avg merge
3h 46m
Merged PRs (30d)
1

Description

Context

Getter.java (2847 lines, 52+ methods) and Setter.java (1567 lines, 28+ methods) are monolithic data access classes that handle all database operations. This makes them hard to maintain, test, and review.

Proposal

Refactor into a DAO (Data Access Object) pattern, splitting by domain:

  • UserDao — auth, user creation, password management, role updates
  • ModuleDao — module retrieval, status, scoring, cheat sheets
  • ClassDao — class management, scoreboards
  • SessionDao — CSRF tokens, session management helpers
  • SettingsDao — platform configuration (registration, feedback, scoreboard settings)

Each DAO would:

  • Use try-with-resources for all connections (no leak risk)
  • Be independently testable
  • Have a clear, focused responsibility

Prerequisites

  • Connection leak fixes (part of #800) should be done first — fixing leaks on the current structure, then refactoring
  • Should not change any business logic, only code organization

Benefits

  • Smaller, reviewable files
  • Easier to add tests per domain
  • Clear ownership of database operations
  • Reduces merge conflicts when multiple contributors work on different features

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Getter.java and Setter.java to inventory their database operations by the proposed domains. Complete the connection leak fixes from #800 first, then split the operations into UserDao, ModuleDao, ClassDao, SessionDao, and SettingsDao. Done means focused, independently testable DAOs using try-with-resources without changing business logic.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, database
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.