@@ -422,6 +422,23 @@ export function validateAllowHostPorts(
422422 return { valid : true } ;
423423}
424424
425+ /**
426+ * Parses and validates a Docker memory limit string.
427+ * Valid formats: positive integer followed by b, k, m, or g (e.g., "2g", "512m", "4g").
428+ */
429+ export function parseMemoryLimit ( input : string ) : { value: string ; error ? : undefined } | { value ?: undefined ; error : string } {
430+ const pattern = / ^ ( \d + ) ( [ b k m g ] ) $ / i;
431+ const match = input . match ( pattern ) ;
432+ if ( ! match ) {
433+ return { error : `Invalid --memory-limit value "${ input } ". Expected format: <number><unit> (e.g., 2g, 512m, 4g)` } ;
434+ }
435+ const num = parseInt ( match [ 1 ] , 10 ) ;
436+ if ( num <= 0 ) {
437+ return { error : `Invalid --memory-limit value "${ input } ". Memory limit must be a positive number.` } ;
438+ }
439+ return { value : input . toLowerCase ( ) } ;
440+ }
441+
425442/**
426443 * Parses and validates DNS servers from a comma-separated string
427444 * @param input - Comma-separated DNS server string (e.g., "8.8.8.8,1.1.1.1")
@@ -780,6 +797,11 @@ program
780797 '--container-workdir <dir>' ,
781798 'Working directory inside the container (should match GITHUB_WORKSPACE for path consistency)'
782799 )
800+ . option (
801+ '--memory-limit <limit>' ,
802+ 'Memory limit for the agent container (e.g., 1g, 2g, 4g, 512m). Default: 2g' ,
803+ '2g'
804+ )
783805 . option (
784806 '--dns-servers <servers>' ,
785807 'Comma-separated list of trusted DNS servers. DNS traffic is ONLY allowed to these servers (default: 8.8.8.8,8.8.4.4)' ,
@@ -1067,6 +1089,13 @@ program
10671089 logger . warn ( '⚠️ SSL Bump intercepts HTTPS traffic. Only use for trusted workloads.' ) ;
10681090 }
10691091
1092+ // Validate memory limit
1093+ const memoryLimit = parseMemoryLimit ( options . memoryLimit ) ;
1094+ if ( memoryLimit . error ) {
1095+ logger . error ( memoryLimit . error ) ;
1096+ process . exit ( 1 ) ;
1097+ }
1098+
10701099 // Validate agent image option
10711100 const agentImageResult = processAgentImageOption ( options . agentImage , options . buildLocal ) ;
10721101 if ( agentImageResult . error ) {
@@ -1096,6 +1125,7 @@ program
10961125 volumeMounts,
10971126 containerWorkDir : options . containerWorkdir ,
10981127 dnsServers,
1128+ memoryLimit : memoryLimit . value ,
10991129 proxyLogsDir : options . proxyLogsDir ,
11001130 enableHostAccess : options . enableHostAccess ,
11011131 allowHostPorts : options . allowHostPorts ,
0 commit comments