Skip to content

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

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
Ankitsinghsisodya:fix/runtime-file-permissions
Jun 11, 2026
Merged

fix: use 0644 permissions for runtime data files in .func/#3867
knative-prow[bot] merged 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 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

knative-prow Bot commented May 30, 2026

Copy link
Copy Markdown

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 53.39%. Comparing base (5b32fef) to head (f1e0bc4).
⚠️ Report is 16 commits behind head on main.

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%   53.39%   -0.02%     
==========================================
  Files         200      200              
  Lines       23413    23413              
==========================================
- Hits        12504    12501       -3     
- Misses       9659     9661       +2     
- Partials     1250     1251       +1     
Flag Coverage Δ
e2e 33.67% <50.00%> (ø)
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 Harness.
📢 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.

@matejvasek

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Jun 11, 2026
@knative-prow

knative-prow Bot commented Jun 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ankitsinghsisodya, matejvasek

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

The pull request process is described 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 the approved 🤖 PR has been approved by an approver from all required OWNERS files. label Jun 11, 2026
@matejvasek

Copy link
Copy Markdown
Contributor

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test 🤖 Needs an org member to approve testing labels Jun 11, 2026
@knative-prow knative-prow Bot merged commit be8b24d into knative:main Jun 11, 2026
69 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. size/XS 🤖 PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants