MCPcopy Create free account
hub / github.com/ShipSecAI/studio / validateSecretParameters

Function validateSecretParameters

backend/src/dsl/validator.ts:197–251  ·  view source on GitHub ↗

* Validate secret parameter references

(
  action: WorkflowAction,
  component: any,
  errors: ValidationError[],
  warnings: ValidationError[],
)

Source from the content-addressed store, hash-verified

195 * Validate secret parameter references
196 */
197function validateSecretParameters(
198 action: WorkflowAction,
199 component: any,
200 errors: ValidationError[],
201 warnings: ValidationError[],
202) {
203 const secretParams =
204 componentRegistry
205 .getMetadata(action.componentId)
206 ?.parameters?.filter((p) => p.type === 'secret') ?? [];
207
208 for (const secretParam of secretParams) {
209 const paramValue = action.params?.[secretParam.id];
210
211 const isRequired = secretParam.required !== false;
212
213 if (!paramValue) {
214 if (!isRequired) {
215 continue;
216 }
217 errors.push({
218 node: action.ref,
219 field: secretParam.id,
220 message: `Required secret parameter '${secretParam.label}' is missing`,
221 severity: 'error',
222 suggestion: 'Configure this parameter in the node configuration panel',
223 });
224 } else if (typeof paramValue === 'string' && !isValidSecretId(paramValue)) {
225 // Check if it looks like a direct API key/value instead of a secret reference
226 if (
227 paramValue.length > 20 &&
228 (paramValue.startsWith('AIza') ||
229 paramValue.startsWith('sk-') ||
230 /[A-Za-z0-9_-]{20,}/.test(paramValue))
231 ) {
232 errors.push({
233 node: action.ref,
234 field: secretParam.id,
235 message: `Invalid secret reference: '${paramValue.substring(0, 10)}...' appears to be a direct API key value`,
236 severity: 'error',
237 suggestion:
238 'Store your API key in the secrets manager and reference it by name instead of using the raw value',
239 });
240 } else {
241 warnings.push({
242 node: action.ref,
243 field: secretParam.id,
244 message: `Secret reference '${paramValue}' may not exist or may be malformed`,
245 severity: 'warning',
246 suggestion: 'Verify the secret exists in the secrets manager',
247 });
248 }
249 }
250 }
251}
252
253/**
254 * Validate input mappings between nodes

Callers 1

validateWorkflowGraphFunction · 0.85

Calls 3

isValidSecretIdFunction · 0.85
getMetadataMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected