Skip to content

Commit 69214f9

Browse files
fix: use chmod 755 instead of 777 for downloaded helm binary and folder (#278)
World-writable permissions allow other processes on shared runners to replace the helm binary or inject files between download and execution. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
1 parent 9dad99f commit 69214f9

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎src/run.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ describe('run.ts', () => {
288288
expect(toolCache.downloadTool).toHaveBeenCalledWith(
289289
'https://test.tld/helm-v4.0.0-windows-amd64.zip'
290290
)
291-
expect(fs.chmodSync).toHaveBeenCalledWith('pathToTool', '777')
291+
expect(fs.chmodSync).toHaveBeenCalledWith('pathToTool', '755')
292292
expect(toolCache.extractZip).toHaveBeenCalledWith('pathToTool')
293293
expect(fs.chmodSync).toHaveBeenCalledWith(
294294
path.join('pathToCachedDir', 'helm.exe'),
295-
'777'
295+
'755'
296296
)
297297
})
298298

@@ -335,7 +335,7 @@ describe('run.ts', () => {
335335
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1')
336336
expect(fs.chmodSync).toHaveBeenCalledWith(
337337
path.join('pathToCachedDir', 'helm.exe'),
338-
'777'
338+
'755'
339339
)
340340
})
341341

@@ -362,7 +362,7 @@ describe('run.ts', () => {
362362
expect(toolCache.downloadTool).toHaveBeenCalledWith(
363363
'https://test.tld/helm-v3.2.1-windows-amd64.zip'
364364
)
365-
expect(fs.chmodSync).toHaveBeenCalledWith('pathToTool', '777')
365+
expect(fs.chmodSync).toHaveBeenCalledWith('pathToTool', '755')
366366
expect(toolCache.extractZip).toHaveBeenCalledWith('pathToTool')
367367
})
368368
})

‎src/run.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export async function downloadHelm(
105105
)
106106
}
107107

108-
fs.chmodSync(helmDownloadPath, '777')
108+
fs.chmodSync(helmDownloadPath, '755')
109109
const extractedPath =
110110
getPlatform() === 'windows'
111111
? await toolCache.extractZip(helmDownloadPath)
@@ -125,12 +125,12 @@ export async function downloadHelm(
125125
)
126126
}
127127

128-
fs.chmodSync(helmpath, '777')
128+
fs.chmodSync(helmpath, '755')
129129
return helmpath
130130
}
131131

132132
export function findHelm(rootFolder: string): string {
133-
fs.chmodSync(rootFolder, '777')
133+
fs.chmodSync(rootFolder, '755')
134134
let filelist: string[] = []
135135
walkSync(rootFolder, filelist, helmToolName + getExecutableExtension())
136136
if (!filelist || filelist.length == 0) {

0 commit comments

Comments
 (0)