Skip to content

Commit f2c1e1a

Browse files
Copilotpelikhan
andauthored
Secure cached jobs API data
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 8e7ba1c commit f2c1e1a

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

pkg/cli/logs_github_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func fetchJobDetailsWithCounts(ctx context.Context, runID int64, outputDir strin
9696

9797
if outputDir != "" {
9898
responsePath := filepath.Join(outputDir, jobsAPIResponseFileName)
99-
if err := os.WriteFile(responsePath, output, constants.FilePermPublic); err != nil {
99+
if err := os.WriteFile(responsePath, output, constants.FilePermSensitive); err != nil {
100100
return nil, 0, fmt.Errorf("failed to cache jobs API response: %w", err)
101101
}
102102
logsGitHubAPILog.Printf("Cached jobs API response: path=%s", responsePath)

pkg/cli/logs_github_api_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ func TestFetchJobDetailsWithCountsIncludesSteps(t *testing.T) {
264264
require.NoError(t, err)
265265
assert.Contains(t, string(cachedResponse), `"total_count":1`)
266266
assert.Contains(t, string(cachedResponse), `"runner_name":"GitHub Actions 1"`)
267+
cachedInfo, err := os.Stat(filepath.Join(outputDir, jobsAPIResponseFileName))
268+
require.NoError(t, err)
269+
assert.Equal(t, os.FileMode(0o600), cachedInfo.Mode().Perm())
267270
}
268271

269272
// TestFetchJobDetailsWithCountsNullConclusion verifies that jobs and steps with null conclusions

0 commit comments

Comments
 (0)