@@ -842,6 +842,39 @@ describe('cli', () => {
842842 expect ( result . valid ) . toBe ( false ) ;
843843 expect ( result . error ) . toContain ( 'Invalid base image' ) ;
844844 } ) ;
845+
846+ it ( 'should reject ubuntu with only major version' , ( ) => {
847+ const result = validateAgentBaseImage ( 'ubuntu:22' ) ;
848+ expect ( result . valid ) . toBe ( false ) ;
849+ expect ( result . error ) . toContain ( 'Invalid base image' ) ;
850+ } ) ;
851+
852+ it ( 'should reject catthehacker with wrong prefix' , ( ) => {
853+ const result = validateAgentBaseImage ( 'ghcr.io/catthehacker/ubuntu:minimal-22.04' ) ;
854+ expect ( result . valid ) . toBe ( false ) ;
855+ expect ( result . error ) . toContain ( 'Invalid base image' ) ;
856+ } ) ;
857+
858+ it ( 'should reject malformed SHA256 digest (too short)' , ( ) => {
859+ const result = validateAgentBaseImage ( 'ubuntu:22.04@sha256:abc123' ) ;
860+ expect ( result . valid ) . toBe ( false ) ;
861+ expect ( result . error ) . toContain ( 'Invalid base image' ) ;
862+ } ) ;
863+
864+ it ( 'should reject image with path traversal attempt' , ( ) => {
865+ const result = validateAgentBaseImage ( '../ubuntu:22.04' ) ;
866+ expect ( result . valid ) . toBe ( false ) ;
867+ expect ( result . error ) . toContain ( 'Invalid base image' ) ;
868+ } ) ;
869+
870+ it ( 'should provide helpful error message with allowed options' , ( ) => {
871+ const result = validateAgentBaseImage ( 'invalid:image' ) ;
872+ expect ( result . valid ) . toBe ( false ) ;
873+ expect ( result . error ) . toContain ( 'ubuntu:XX.XX' ) ;
874+ expect ( result . error ) . toContain ( 'ghcr.io/catthehacker/ubuntu:runner-XX.XX' ) ;
875+ expect ( result . error ) . toContain ( 'ghcr.io/catthehacker/ubuntu:full-XX.XX' ) ;
876+ expect ( result . error ) . toContain ( '@sha256:' ) ;
877+ } ) ;
845878 } ) ;
846879 } ) ;
847880} ) ;
0 commit comments