-
Notifications
You must be signed in to change notification settings - Fork 15
test: add --allow-host-ports validation tests #1221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -403,6 +403,25 @@ export function validateSkipPullWithBuildLocal( | |||||
| return { valid: true }; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Validates that --allow-host-ports is only used with --enable-host-access | ||||||
| * @param allowHostPorts - The --allow-host-ports value (undefined if not provided) | ||||||
| * @param enableHostAccess - Whether --enable-host-access flag was provided | ||||||
| * @returns FlagValidationResult with validation status and error message | ||||||
| */ | ||||||
| export function validateAllowHostPorts( | ||||||
| allowHostPorts: string | undefined, | ||||||
| enableHostAccess: boolean | undefined | ||||||
| ): FlagValidationResult { | ||||||
| if (allowHostPorts && !enableHostAccess) { | ||||||
| return { | ||||||
| valid: false, | ||||||
| error: '--allow-host-ports requires --enable-host-access to be set', | ||||||
| }; | ||||||
| } | ||||||
| return { valid: true }; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Parses and validates DNS servers from a comma-separated string | ||||||
| * @param input - Comma-separated DNS server string (e.g., "8.8.8.8,1.1.1.1") | ||||||
|
|
@@ -1110,9 +1129,10 @@ program | |||||
| logger.warn(' This may expose sensitive credentials if logs or configs are shared'); | ||||||
| } | ||||||
|
|
||||||
| // Warn if --allow-host-ports is used without --enable-host-access | ||||||
| if (config.allowHostPorts && !config.enableHostAccess) { | ||||||
| logger.error('❌ --allow-host-ports requires --enable-host-access to be set'); | ||||||
| // Validate --allow-host-ports requires --enable-host-access | ||||||
| const hostPortsValidation = validateAllowHostPorts(config.allowHostPorts, config.enableHostAccess); | ||||||
| if (!hostPortsValidation.valid) { | ||||||
| logger.error(`❌ ${hostPortsValidation.error}`); | ||||||
|
||||||
| logger.error(`❌ ${hostPortsValidation.error}`); | |
| logger.error(`❌ ${hostPortsValidation.error ?? 'Invalid --allow-host-ports configuration'}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateAllowHostPortsuses a truthy check (if (allowHostPorts && ...)). If the flag is provided as an empty string (e.g.--allow-host-ports ""), this bypasses validation even though the option was explicitly set. Consider checkingallowHostPorts !== undefined(and optionallyallowHostPorts.trim() !== '') instead of relying on truthiness so the constraint is enforced consistently.