Skip to content

Commit 030e314

Browse files
lpcoxCopilot
andcommitted
fix: unexport internal helpers from ssl-bump and host-iptables
- Remove export from mountSslTmpfs (ssl-bump.ts) — only used internally - Remove export from getDockerBridgeGateway (host-iptables.ts) — only used internally - Move _resetIpv6State behind __testing namespace — removes direct export of test-only mutable state reset from security-critical module Closes #2524 Closes #2531 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 00734f9 commit 030e314

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/host-iptables.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ensureFirewallNetwork, setupHostIptables, cleanupHostIptables, cleanupFirewallNetwork, _resetIpv6State, HostAccessConfig, isValidPortSpec } from './host-iptables';
1+
import { ensureFirewallNetwork, setupHostIptables, cleanupHostIptables, cleanupFirewallNetwork, __testing, HostAccessConfig, isValidPortSpec } from './host-iptables';
22
import execa from 'execa';
33

44
// Mock execa
@@ -24,7 +24,7 @@ jest.mock('./logger', () => ({
2424
describe('host-iptables', () => {
2525
beforeEach(() => {
2626
jest.clearAllMocks();
27-
_resetIpv6State();
27+
__testing._resetIpv6State();
2828
});
2929

3030
describe('ensureFirewallNetwork', () => {

src/host-iptables.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ let ipv6DisabledViaSysctl = false;
5656
/**
5757
* Resets internal IPv6 state (for testing only).
5858
*/
59-
export function _resetIpv6State(): void {
59+
function _resetIpv6State(): void {
6060
ip6tablesAvailableCache = null;
6161
ipv6DisabledViaSysctl = false;
6262
}
6363

64+
// Exposed for testing only — not part of public API
65+
export const __testing = { _resetIpv6State };
66+
6467
/**
6568
* Gets the bridge interface name for the firewall network
6669
*/
@@ -85,7 +88,7 @@ async function getNetworkBridgeName(): Promise<string | null> {
8588
* Gets the Docker default bridge gateway IP (e.g., 172.17.0.1).
8689
* This is the IP that host.docker.internal resolves to inside containers.
8790
*/
88-
export async function getDockerBridgeGateway(): Promise<string | null> {
91+
async function getDockerBridgeGateway(): Promise<string | null> {
8992
try {
9093
const { stdout } = await execa('docker', [
9194
'network', 'inspect', 'bridge',

src/ssl-bump.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface CaFiles {
5252
* @param sslDir - Directory path to mount tmpfs on
5353
* @returns true if tmpfs was mounted, false if fallback to disk
5454
*/
55-
export async function mountSslTmpfs(sslDir: string): Promise<boolean> {
55+
async function mountSslTmpfs(sslDir: string): Promise<boolean> {
5656
try {
5757
// Mount tmpfs with restrictive options (4MB is more than enough for SSL keys)
5858
await execa('mount', [

0 commit comments

Comments
 (0)