Skip to content

fix: use 0644 permissions for runtime data files in .func/#3867

Open
Ankitsinghsisodya wants to merge 1 commit into
knative:mainfrom
Ankitsinghsisodya:fix/runtime-file-permissions
Open

fix: use 0644 permissions for runtime data files in .func/#3867
Ankitsinghsisodya wants to merge 1 commit into
knative:mainfrom
Ankitsinghsisodya:fix/runtime-file-permissions

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

Problem

.func/built-image and .func/built-hash were written using os.ModePerm
(0777), which sets the execute bit on plain data files and is inconsistent
with the rest of the codebase.

The pkg/config package already writes ~/.func/config.yaml with explicit
0600 permissions and has a dedicated test enforcing this. The runtime data
directory had no such discipline.

Changes

  • pkg/functions/function.go:577BuiltHash file now written with 0644
  • pkg/functions/function.go:833BuiltImage file now written with 0644

client.go:1277 (MkdirAll for the .func/ directory) is intentionally
unchanged — using os.ModePerm with MkdirAll is standard Go practice for
directories; the umask produces the correct 0755 result.

Why 0644 and not 0600

These files contain build metadata (image references, content hashes), not
credentials. They do not need to be private to the owner. 0644 gives the
owner read/write and others read-only, with no execute bits — appropriate for
data files.

Testing

  • make test passes with no changes to existing tests

Changed file permission mode from os.ModePerm to 0644 for files written in the Stamp and WriteRuntimeBuiltImage functions to ensure proper access control.
Copilot AI review requested due to automatic review settings May 30, 2026 09:56
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 30, 2026 09:56
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 30, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ankitsinghsisodya
Once this PR has been reviewed and has the lgtm label, please assign dsimansk for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added size/XS 🤖 PR changes 0-9 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 30, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 30, 2026

Hi @Ankitsinghsisodya. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR tightens the permissions used when writing function build metadata files, avoiding overly permissive file modes.

Changes:

  • Change os.WriteFile permissions from os.ModePerm (0777) to 0644 when writing the built hash.
  • Change os.WriteFile permissions from os.ModePerm (0777) to 0644 when writing the built image reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/functions/function.go

// Write out the hash
if err = os.WriteFile(filepath.Join(f.Root, RunDataDir, BuiltHash), []byte(hash), os.ModePerm); err != nil {
if err = os.WriteFile(filepath.Join(f.Root, RunDataDir, BuiltHash), []byte(hash), 0644); err != nil {
Comment thread pkg/functions/function.go
}

return os.WriteFile(path, []byte(f.Build.Image), os.ModePerm)
return os.WriteFile(path, []byte(f.Build.Image), 0644)
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 52.45%. Comparing base (5b32fef) to head (f1e0bc4).

Files with missing lines Patch % Lines
pkg/functions/function.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3867      +/-   ##
==========================================
- Coverage   53.40%   52.45%   -0.96%     
==========================================
  Files         200      200              
  Lines       23413    23413              
==========================================
- Hits        12504    12281     -223     
- Misses       9659     9889     +230     
+ Partials     1250     1243       -7     
Flag Coverage Δ
e2e 21.74% <50.00%> (-11.94%) ⬇️
e2e go 29.59% <50.00%> (ø)
e2e node 25.88% <50.00%> (ø)
e2e python 29.92% <50.00%> (ø)
e2e quarkus 25.99% <50.00%> (ø)
e2e rust 25.46% <50.00%> (ø)
e2e springboot 24.12% <50.00%> (ø)
e2e typescript 25.98% <50.00%> (ø)
e2e-config-ci 26.82% <50.00%> (ø)
integration 15.76% <50.00%> (-0.02%) ⬇️
unit macos-14 42.23% <50.00%> (ø)
unit macos-latest 42.23% <50.00%> (ø)
unit ubuntu-24.04-arm 42.52% <50.00%> (ø)
unit ubuntu-latest 43.09% <50.00%> (ø)
unit windows-latest 42.30% <50.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test 🤖 Needs an org member to approve testing size/XS 🤖 PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants