* Check if a string looks like a valid secret ID (not a raw secret value)
(secretId: string)
| 522 | * Check if a string looks like a valid secret ID (not a raw secret value) |
| 523 | */ |
| 524 | function isValidSecretId(secretId: string): boolean { |
| 525 | // Secret IDs should be reasonable-length identifiers, not raw secret values |
| 526 | |
| 527 | // 1. Explicitly allow UUIDs (common format for internal IDs) |
| 528 | const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; |
| 529 | if (uuidPattern.test(secretId)) { |
| 530 | return true; |
| 531 | } |
| 532 | |
| 533 | // 2. Reject common patterns that suggest raw API keys or secrets |
| 534 | const suspiciousPatterns = [ |
| 535 | /^AIza[A-Za-z0-9_-]{35}$/, // Google API keys |
| 536 | /^sk-[A-Za-z0-9]{48}$/, // Stripe keys |
| 537 | /^ghp_[A-Za-z0-9]{36}$/, // GitHub PATs |
| 538 | /^xoxb-[0-9]+-[0-9]+-[A-Za-z0-9]{24}$/, // Slack bot tokens |
| 539 | /^[A-Za-z0-9]{32,}$/, // Generic long alphanumeric strings (no dashes/underscores) |
| 540 | ]; |
| 541 | |
| 542 | // If it matches suspicious patterns, it's probably a raw secret |
| 543 | if (suspiciousPatterns.some((pattern) => pattern.test(secretId))) { |
| 544 | return false; |
| 545 | } |
| 546 | |
| 547 | // Valid secret names should be reasonable length. |
| 548 | // We allow names with dashes/underscores even if long, as they are likely identifiers. |
| 549 | return secretId.length >= 1 && secretId.length <= 100; |
| 550 | } |
| 551 | |
| 552 | function resolveActionPortSnapshot(action: WorkflowAction, component: any): ActionPortSnapshot { |
| 553 | let inputs: ComponentPortMetadata[] = []; |
no outgoing calls
no test coverage detected