@@ -19,6 +19,19 @@ describe("security audit rosterless configs", () => {
1919 return { stateDir, workspaceDir } ;
2020 }
2121
22+ function makeEscapingWorkspace ( rootDir : string , workspaceDir : string ) {
23+ const externalSkillDir = path . join ( rootDir , `external-${ path . basename ( workspaceDir ) } ` ) ;
24+ const skillsDir = path . join ( workspaceDir , "skills" ) ;
25+ fs . mkdirSync ( externalSkillDir , { recursive : true } ) ;
26+ fs . mkdirSync ( skillsDir , { recursive : true } ) ;
27+ fs . writeFileSync ( path . join ( externalSkillDir , "SKILL.md" ) , "# external\n" ) ;
28+ fs . symlinkSync (
29+ externalSkillDir ,
30+ path . join ( skillsDir , "escape" ) ,
31+ process . platform === "win32" ? "junction" : "dir" ,
32+ ) ;
33+ }
34+
2235 it ( "uses the explicit audit workspace without resolving a missing roster default" , async ( ) => {
2336 const { stateDir, workspaceDir } = makeAuditPaths ( "rosterless" ) ;
2437
@@ -35,6 +48,30 @@ describe("security audit rosterless configs", () => {
3548 ) . resolves . toEqual ( expect . objectContaining ( { findings : expect . any ( Array ) } ) ) ;
3649 } ) ;
3750
51+ it ( "keeps the implicit main workspace for a rosterless compatibility config" , async ( ) => {
52+ const rootDir = tempDirs . make ( "openclaw-audit-rosterless-default-" ) ;
53+ const stateDir = path . join ( rootDir , "state" ) ;
54+ const workspaceDir = path . join ( rootDir , ".openclaw" , "workspace" ) ;
55+ fs . mkdirSync ( stateDir , { recursive : true } ) ;
56+ makeEscapingWorkspace ( rootDir , workspaceDir ) ;
57+
58+ const report = await runSecurityAuditCore ( {
59+ config : { } ,
60+ stateDir,
61+ configPath : path . join ( stateDir , "openclaw.json" ) ,
62+ env : { HOME : rootDir } ,
63+ includeFilesystem : true ,
64+ includeChannelSecurity : false ,
65+ } ) ;
66+
67+ expect ( report . findings ) . toContainEqual (
68+ expect . objectContaining ( {
69+ checkId : "skills.workspace.symlink_escape" ,
70+ detail : expect . stringContaining ( `workspace=${ workspaceDir } ` ) ,
71+ } ) ,
72+ ) ;
73+ } ) ;
74+
3875 it ( "distinguishes an authored empty roster from an absent pre-roster source" , async ( ) => {
3976 const { stateDir, workspaceDir } = makeAuditPaths ( "authored-empty-roster" ) ;
4077 const config = { agents : { entries : { main : { default : true } } } } as never ;
@@ -151,4 +188,42 @@ describe("security audit rosterless configs", () => {
151188 } ) ,
152189 ) ;
153190 } ) ;
191+
192+ it ( "scans every explicit fleet workspace without fabricating a legacy default workspace" , async ( ) => {
193+ const rootDir = tempDirs . make ( "openclaw-audit-explicit-workspaces-" ) ;
194+ const stateDir = path . join ( rootDir , "state" ) ;
195+ const unusedDefaultsWorkspace = path . join ( rootDir , "unused-defaults" ) ;
196+ const alphaWorkspace = path . join ( rootDir , "alpha" ) ;
197+ const betaWorkspace = path . join ( rootDir , "beta" ) ;
198+ fs . mkdirSync ( stateDir , { recursive : true } ) ;
199+
200+ for ( const workspaceDir of [ unusedDefaultsWorkspace , alphaWorkspace , betaWorkspace ] ) {
201+ makeEscapingWorkspace ( rootDir , workspaceDir ) ;
202+ }
203+
204+ const report = await runSecurityAuditCore ( {
205+ config : {
206+ agents : {
207+ ownership : "explicit" ,
208+ defaults : { workspace : unusedDefaultsWorkspace } ,
209+ entries : {
210+ alpha : { workspace : alphaWorkspace } ,
211+ beta : { workspace : betaWorkspace } ,
212+ } ,
213+ } ,
214+ } as never ,
215+ stateDir,
216+ configPath : path . join ( stateDir , "openclaw.json" ) ,
217+ env : { HOME : rootDir } ,
218+ includeFilesystem : true ,
219+ includeChannelSecurity : false ,
220+ } ) ;
221+
222+ const finding = report . findings . find (
223+ ( candidate ) => candidate . checkId === "skills.workspace.symlink_escape" ,
224+ ) ;
225+ expect ( finding ?. detail ) . toContain ( `workspace=${ alphaWorkspace } ` ) ;
226+ expect ( finding ?. detail ) . toContain ( `workspace=${ betaWorkspace } ` ) ;
227+ expect ( finding ?. detail ) . not . toContain ( `workspace=${ unusedDefaultsWorkspace } ` ) ;
228+ } ) ;
154229} ) ;
0 commit comments