Skip to content

Commit 11525ee

Browse files
bettercleverLuD1161
authored andcommitted
fix the secrets loader component issue
Signed-off-by: betterclever <[email protected]>
1 parent 2672705 commit 11525ee

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

backend/src/dsl/validator.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,22 +420,30 @@ function validateEntryPointConfiguration(
420420
*/
421421
function isValidSecretId(secretId: string): boolean {
422422
// Secret IDs should be reasonable-length identifiers, not raw secret values
423-
// Reject common patterns that suggest raw API keys or secrets
423+
424+
// 1. Explicitly allow UUIDs (common format for internal IDs)
425+
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
426+
if (uuidPattern.test(secretId)) {
427+
return true;
428+
}
429+
430+
// 2. Reject common patterns that suggest raw API keys or secrets
424431
const suspiciousPatterns = [
425432
/^AIza[A-Za-z0-9_-]{35}$/, // Google API keys
426433
/^sk-[A-Za-z0-9]{48}$/, // Stripe keys
427-
/^[A-Za-z0-9]{32,}$/, // Generic long alphanumeric strings
428434
/^ghp_[A-Za-z0-9]{36}$/, // GitHub PATs
429435
/^xoxb-[0-9]+-[0-9]+-[A-Za-z0-9]{24}$/, // Slack bot tokens
436+
/^[A-Za-z0-9]{32,}$/, // Generic long alphanumeric strings (no dashes/underscores)
430437
];
431438

432439
// If it matches suspicious patterns, it's probably a raw secret
433440
if (suspiciousPatterns.some((pattern) => pattern.test(secretId))) {
434441
return false;
435442
}
436443

437-
// Valid secret IDs should be reasonable length and not look like raw secrets
438-
return secretId.length >= 3 && secretId.length <= 100 && !/[A-Za-z0-9_-]{30,}/.test(secretId);
444+
// Valid secret names should be reasonable length.
445+
// We allow names with dashes/underscores even if long, as they are likely identifiers.
446+
return secretId.length >= 1 && secretId.length <= 100;
439447
}
440448

441449
function resolveActionPortSnapshot(

docs/components/core.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Fetches secrets from the ShipSec-managed secret store.
102102

103103
| Parameter | Type | Description |
104104
|-----------|------|-------------|
105-
| `secretId` | Secret | Secret name or UUID |
105+
| `secretName` | Secret | Secret name or UUID |
106106
| `version` | Number | Optional version pin |
107107
| `outputFormat` | Select | `raw` or `json` |
108108

frontend/src/components/workflow/ParameterField.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export function ParameterField({
154154
}
155155
if (
156156
typeof currentValue === 'string' &&
157-
secrets.some((secret) => secret.id === currentValue)
157+
secrets.some((secret) => secret.id === currentValue || secret.name === currentValue)
158158
) {
159159
return 'select'
160160
}
@@ -183,11 +183,11 @@ export function ParameterField({
183183
if (
184184
secretMode === 'select' &&
185185
(typeof currentValue !== 'string' ||
186-
!secrets.some((secret) => secret.id === currentValue))
186+
!secrets.some((secret) => secret.id === currentValue || secret.name === currentValue))
187187
) {
188188
const firstSecret = secrets[0]
189189
if (firstSecret) {
190-
onChange(firstSecret.id)
190+
onChange(firstSecret.name)
191191
}
192192
}
193193
}, [parameter.type, secretMode, secrets, currentValue, onChange, isReceivingInput])
@@ -518,12 +518,14 @@ export function ParameterField({
518518

519519
case 'secret': {
520520
const hasSecrets = secrets.length > 0
521-
const selectedSecretId =
522-
typeof currentValue === 'string' && secrets.some((secret) => secret.id === currentValue)
523-
? currentValue
524-
: ''
521+
const activeSecret = secrets.find(
522+
(s) => s.id === currentValue || s.name === currentValue
523+
)
524+
525+
const selectedSecretKey = activeSecret?.name ?? ''
526+
525527
const manualValue =
526-
typeof currentValue === 'string' && !secrets.some((secret) => secret.id === currentValue)
528+
typeof currentValue === 'string' && !activeSecret
527529
? currentValue
528530
: ''
529531
const disableForGithubConnection =
@@ -547,14 +549,14 @@ export function ParameterField({
547549
return
548550
}
549551
const existing =
550-
secrets.find((secret) => secret.id === selectedSecretId) ?? secrets[0]
552+
secrets.find((s) => s.id === currentValue || s.name === currentValue) ?? secrets[0]
551553
setSecretMode('select')
552-
updateSecretValue(existing?.id ?? undefined)
554+
updateSecretValue(existing?.name ?? undefined)
553555
return
554556
}
555557

556558
setSecretMode('manual')
557-
if (selectedSecretId) {
559+
if (selectedSecretKey) {
558560
updateSecretValue(undefined)
559561
}
560562
}
@@ -626,7 +628,7 @@ export function ParameterField({
626628

627629
{secretMode === 'select' && hasSecrets && (
628630
<select
629-
value={selectedSecretId}
631+
value={selectedSecretKey}
630632
onChange={(e) => {
631633
const nextValue = e.target.value
632634
updateSecretValue(nextValue === '' ? undefined : nextValue)
@@ -636,7 +638,7 @@ export function ParameterField({
636638
>
637639
<option value="">Select a secret…</option>
638640
{secrets.map((secret) => (
639-
<option key={secret.id} value={secret.id}>
641+
<option key={secret.id} value={secret.name}>
640642
{secret.name}
641643
</option>
642644
))}
@@ -661,9 +663,9 @@ export function ParameterField({
661663
/>
662664
)}
663665

664-
{secretMode === 'select' && selectedSecretId && (
666+
{secretMode === 'select' && activeSecret && (
665667
<p className="text-xs text-muted-foreground">
666-
ID: <span className="font-mono">{selectedSecretId}</span>
668+
Reference: <span className="font-mono">{activeSecret.name}</span> (ID: {activeSecret.id.substring(0, 8)}...)
667669
</p>
668670
)}
669671

worker/src/components/core/secret-fetch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const inputSchema = z.object({
1010
secretId: z
1111
.string()
1212
.min(1, 'Secret identifier is required')
13-
.describe('Secret name or UUID from the ShipSec secret store'),
13+
.describe('Name or UUID of the secret in the ShipSec store'),
1414
version: z
1515
.number()
1616
.int()
@@ -91,10 +91,10 @@ const definition: ComponentDefinition<Input, Output> = {
9191
parameters: [
9292
{
9393
id: 'secretId',
94-
label: 'Secret ID',
94+
label: 'Secret Name',
9595
type: 'secret',
9696
required: true,
97-
description: 'Secret name or UUID from the platform store.',
97+
description: 'Name or UUID of the secret from the platform store.',
9898
},
9999
{
100100
id: 'version',

0 commit comments

Comments
 (0)