Skip to content

Commit bc84b9a

Browse files
svorclaude
andcommitted
refactor: Use psql parameterized queries for user-setup Job
Replace shell variable interpolation with psql -v variables and heredoc input to prevent SQL injection from user-provided secret values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d440ad1 commit bc84b9a

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ metadata:
8686
categories: Developer Tools
8787
certified: "false"
8888
containerImage: quay.io/eclipse/che-operator:next
89-
createdAt: "2026-06-17T11:32:24Z"
89+
createdAt: "2026-06-17T15:00:32Z"
9090
description: A Kube-native development solution that delivers portable and collaborative
9191
developer workspaces.
9292
features.operators.openshift.io/cnf: "false"
@@ -108,7 +108,7 @@ metadata:
108108
operatorframework.io/arch.amd64: supported
109109
operatorframework.io/arch.arm64: supported
110110
operatorframework.io/os.linux: supported
111-
name: eclipse-che.v7.119.0-1021.next
111+
name: eclipse-che.v7.119.0-1023.next
112112
namespace: placeholder
113113
spec:
114114
apiservicedefinitions: {}
@@ -1166,7 +1166,7 @@ spec:
11661166
name: openvsx
11671167
- image: quay.io/sclorg/postgresql-16-c9s:20260319
11681168
name: openvsx-postgres
1169-
version: 7.119.0-1021.next
1169+
version: 7.119.0-1023.next
11701170
webhookdefinitions:
11711171
- admissionReviewVersions:
11721172
- v1

pkg/deploy/openvsx/server/openvsx_server.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,31 @@ func (r *OpenVSXServerReconciler) syncUserSetupJob(ctx *chetypes.DeployContext)
302302
envFromSecret("OPENVSX_ADMIN_NAME", secretName, "admin-name"),
303303
envFromSecret("OPENVSX_ADMIN_PAT", secretName, "admin-token"),
304304
),
305-
Command: []string{"sh", "-c",
306-
`psql -c "INSERT INTO user_data (id, login_name, role) VALUES (1001, '$OPENVSX_USER_NAME', 'privileged') ON CONFLICT (id) DO NOTHING; INSERT INTO personal_access_token (id, user_data, value, active, created_timestamp, accessed_timestamp, description, notified) VALUES (1001, 1001, '$OPENVSX_USER_PAT', true, current_timestamp, current_timestamp, 'extensions publisher', false) ON CONFLICT (id) DO NOTHING; INSERT INTO user_data (id, login_name, role) VALUES (1002, '$OPENVSX_ADMIN_NAME', 'admin') ON CONFLICT (id) DO NOTHING; INSERT INTO personal_access_token (id, user_data, value, active, created_timestamp, accessed_timestamp, description, notified) VALUES (1002, 1002, '$OPENVSX_ADMIN_PAT', true, current_timestamp, current_timestamp, 'Admin API Token', false) ON CONFLICT (id) DO NOTHING;"`,
305+
Command: []string{"sh", "-c", `
306+
psql \
307+
-v user_name="$OPENVSX_USER_NAME" \
308+
-v user_pat="$OPENVSX_USER_PAT" \
309+
-v admin_name="$OPENVSX_ADMIN_NAME" \
310+
-v admin_pat="$OPENVSX_ADMIN_PAT" \
311+
<<'EOSQL'
312+
INSERT INTO user_data (id, login_name, role)
313+
VALUES (1001, :'user_name', 'privileged')
314+
ON CONFLICT (id) DO NOTHING;
315+
316+
INSERT INTO personal_access_token
317+
(id, user_data, value, active, created_timestamp, accessed_timestamp, description, notified)
318+
VALUES (1001, 1001, :'user_pat', true, current_timestamp, current_timestamp, 'extensions publisher', false)
319+
ON CONFLICT (id) DO NOTHING;
320+
321+
INSERT INTO user_data (id, login_name, role)
322+
VALUES (1002, :'admin_name', 'admin')
323+
ON CONFLICT (id) DO NOTHING;
324+
325+
INSERT INTO personal_access_token
326+
(id, user_data, value, active, created_timestamp, accessed_timestamp, description, notified)
327+
VALUES (1002, 1002, :'admin_pat', true, current_timestamp, current_timestamp, 'Admin API Token', false)
328+
ON CONFLICT (id) DO NOTHING;
329+
EOSQL`,
307330
},
308331
},
309332
},

0 commit comments

Comments
 (0)