Skip to content

Commit eac9685

Browse files
Disallow 'SELECT *' statements in scala code (#8867)
### URL of deployed dev instance (used for testing): - https://___.webknossos.xyz ### Steps to test: - Nothing CI should be enough - See run with `SELECT *` in the code https://github.com/scalableminds/webknossos/actions/runs/17131927788/job/48598210705 - See run without `SELECT *` in the code https://github.com/scalableminds/webknossos/actions/runs/17131985178/job/48598399466 ### Issues: - fixes [#8820](#8820) ------ (Please delete unneeded items, merge only when none are left open) - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`)
1 parent de553c2 commit eac9685

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

.github/workflows/build_test_deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ jobs:
9999
run: tools/postgres/dbtool.js check-evolutions-schema
100100
- name: Assert that all migrations are mentioned in one migration guide and that they have a reversion counterpart.
101101
run: tools/assert-complete-migrations.sh
102+
- name: Assert no 'SELECT *' are present in scala files
103+
run: tools/assert-no-select-asterisk-present.sh
104+
102105

103106
- name: Lint backend code and check formatting
104107
run: sbt ";scapegoat; scalafmtCheck; util/scalafmtCheck; webknossosTracingstore/scalafmtCheck; webknossosDatastore/scalafmtCheck"

app/models/organization/CreditTransaction.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ class CreditTransactionDAO @Inject()(conf: WkConf,
264264

265265
private def revokeExpiredCreditsForOrganizationQuery(organizationId: ObjectId): DBIO[List[CreditTransaction]] =
266266
for {
267-
transactionsWithExpiredCredits <- q"""SELECT *
268-
FROM webknossos.credit_transactions
267+
transactionsWithExpiredCredits <- q"""SELECT $columns
268+
FROM $existingCollectionName
269269
WHERE _organization = $organizationId
270270
AND expiration_date <= NOW()
271271
AND credit_state = ${CreditState.Pending}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Start directory, default to current
5+
START_DIR="${1:-.}"
6+
7+
# Search recursively for *.scala and detect "SELECT *"
8+
echo "🔍 Checking for forbidden 'SELECT *' in Scala files under $START_DIR..."
9+
10+
violations=$(grep -ri --include="*.scala" --exclude-dir="test" "select[[:space:]]*\*" "$START_DIR" || true)
11+
12+
if [[ -n "$violations" ]]; then
13+
echo "❌ Found forbidden 'SELECT *' usage:"
14+
echo "$violations"
15+
exit 1
16+
else
17+
echo "✅ No 'SELECT *' found."
18+
fi

unreleased_changes/8867.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Changed
2+
- Remove left over occurrence of `SELECT *` statement in backend. Added assertions to CI to ensure that the `SELECT *` statement is not used in the backend.

0 commit comments

Comments
 (0)