mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 08:36:45 +00:00
Merge pull request #9 from actions/nikola-jokic/user-volume-mounts-path
User volume mount restriction to the work directory mounts if path is absolute
This commit is contained in:
@@ -34,11 +34,38 @@ describe('Prepare job', () => {
|
||||
prepareJob(prepareJobData.args, prepareJobOutputFilePath)
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
/*
|
||||
|
||||
it('should generate output file in JSON format', async () => {
|
||||
|
||||
await prepareJob(prepareJobData.args, prepareJobOutputFilePath)
|
||||
const content = fs.readFileSync(prepareJobOutputFilePath)
|
||||
expect(() => JSON.parse(content.toString())).not.toThrow()
|
||||
}) */
|
||||
})
|
||||
|
||||
it('should prepare job with absolute path for userVolumeMount', async () => {
|
||||
prepareJobData.args.container.userMountVolumes.forEach(v => {
|
||||
if (!path.isAbsolute(v.sourceVolumePath)) {
|
||||
v.sourceVolumePath = path.join(
|
||||
process.env.GITHUB_WORKSPACE as string,
|
||||
v.sourceVolumePath
|
||||
)
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
prepareJob(prepareJobData.args, prepareJobOutputFilePath)
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
|
||||
it('should throw an exception if the user volume mount is absolute path outside of GITHUB_WORKSPACE', async () => {
|
||||
prepareJobData.args.container.userMountVolumes.forEach(v => {
|
||||
if (!path.isAbsolute(v.sourceVolumePath)) {
|
||||
v.sourceVolumePath = path.join(
|
||||
'/path/outside/of/github-workspace',
|
||||
v.sourceVolumePath
|
||||
)
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
prepareJob(prepareJobData.args, prepareJobOutputFilePath)
|
||||
).rejects.toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user