Skip to content

Commit 3702dc8

Browse files
Update cmd/ctrlc/root/sync/salesforce/common/util.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 5eed7cf commit 3702dc8

File tree

1 file changed

+13
-3
lines changed
  • cmd/ctrlc/root/sync/salesforce/common

1 file changed

+13
-3
lines changed

cmd/ctrlc/root/sync/salesforce/common/util.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,19 @@ func buildSOQL(objectName string, fields []string, whereClause string, lastId st
121121
if whereClause != "" {
122122
conditions = append(conditions, whereClause)
123123
}
124-
if lastId != "" {
125-
conditions = append(conditions, fmt.Sprintf("Id > '%s'", lastId))
126-
}
124+
if lastId != "" {
125+
// Reject anything that isn’t exactly 15 or 18 alphanumeric chars
126+
if len(lastId) != 15 && len(lastId) != 18 {
127+
return "", fmt.Errorf("invalid Salesforce ID: %q", lastId)
128+
}
129+
for i := range lastId {
130+
c := lastId[i]
131+
if !((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
132+
return "", fmt.Errorf("invalid Salesforce ID: %q", lastId)
133+
}
134+
}
135+
conditions = append(conditions, fmt.Sprintf("Id > '%s'", lastId))
136+
}
127137
if len(conditions) > 0 {
128138
query += " WHERE " + strings.Join(conditions, " AND ")
129139
}

0 commit comments

Comments
 (0)