@@ -1896,6 +1896,41 @@ describe("storage", () => {
18961896 ) . toThrow ( / e s c a p e s b a c k u p d i r e c t o r y / i) ;
18971897 } ) ;
18981898
1899+ it ( "rejects symlinked backup roots during restore path validation" , async ( ) => {
1900+ const canonicalBackupRoot = join ( testWorkDir , "canonical-backups" ) ;
1901+ const linkedBackupRoot = join ( testWorkDir , "linked-backups" ) ;
1902+ const backupPath = join ( canonicalBackupRoot , "linked-root.json" ) ;
1903+ await fs . mkdir ( canonicalBackupRoot , { recursive : true } ) ;
1904+ await fs . writeFile (
1905+ backupPath ,
1906+ JSON . stringify ( {
1907+ version : 3 ,
1908+ activeIndex : 0 ,
1909+ accounts : [
1910+ {
1911+ accountId : "linked-root" ,
1912+ refreshToken : "ref-linked-root" ,
1913+ addedAt : 1 ,
1914+ lastUsed : 1 ,
1915+ } ,
1916+ ] ,
1917+ } ) ,
1918+ "utf-8" ,
1919+ ) ;
1920+ await fs . symlink (
1921+ resolve ( canonicalBackupRoot ) ,
1922+ linkedBackupRoot ,
1923+ process . platform === "win32" ? "junction" : "dir" ,
1924+ ) ;
1925+
1926+ expect ( ( ) =>
1927+ assertNamedBackupRestorePath (
1928+ join ( linkedBackupRoot , "linked-root.json" ) ,
1929+ linkedBackupRoot ,
1930+ ) ,
1931+ ) . toThrow ( / e s c a p e s b a c k u p d i r e c t o r y / i) ;
1932+ } ) ;
1933+
18991934 it ( "rejects named backup listings whose resolved paths escape the backups directory" , async ( ) => {
19001935 const backupRoot = join ( dirname ( testStoragePath ) , "backups" ) ;
19011936 const originalReaddir = fs . readdir . bind ( fs ) ;
@@ -2252,7 +2287,9 @@ describe("storage", () => {
22522287 expect ( listedBackups ) . toEqual (
22532288 expect . arrayContaining ( [
22542289 expect . objectContaining ( {
2255- name : "chunk-boundary-08" ,
2290+ name : `chunk-boundary-${ String (
2291+ NAMED_BACKUP_LIST_CONCURRENCY ,
2292+ ) . padStart ( 2 , "0" ) } `,
22562293 valid : true ,
22572294 } ) ,
22582295 ] ) ,
0 commit comments