Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible tasks should set explicit file permissions #1342

Open
mboersma opened this issue Nov 13, 2023 · 5 comments
Open

Ansible tasks should set explicit file permissions #1342

mboersma opened this issue Nov 13, 2023 · 5 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@mboersma
Copy link
Contributor

What steps did you take and what happened:

Run make -C images/capi lint and notice that the project is ignoring a few linter warnings of the type risky-file-permissions: File permissions unset or incorrect. See here for details.

Fixing this usually involves setting an appropriate Linux permission on a resource. This is generally 0755 for directories and 0644 for files, but each case needs to be looked at individually.

There are also cases where files are being deleted (which shouldn't require permissions to be explicit), but the linter can't tell that since the state: field is being populated from a loop variable. That can be refactored so state: absent is hard-coded.

What did you expect to happen:

The linter shouldn't report any of this type of warning.

Anything else you would like to add:

Here's one way to fix it:

cd images/capi
rm .ansible-lint-ignore  # so the linter reports existing issues
ansible-lint --tags=risky-file-permissions ansible
# Edit the code flagged in each of the "risky-file-permissions" warnings
# and re-run the above command until the warnings are gone. Then,
make lint-ignore
git add .
git commit -m "Ansible shell commands set explicit file permissions"

/kind bug

@mboersma mboersma added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Nov 13, 2023
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 13, 2023
@uroy-personal
Copy link
Contributor

/assign

@uroy-personal
Copy link
Contributor

Hi @mboersma ,
I am interested to work on it. I will reach out if I need more info.
Thanks,

@jongwooo
Copy link
Member

/assign

@jongwooo
Copy link
Member

I'll work on this once #1404 is merged.

@jongwooo
Copy link
Member

cd images/capi
rm .ansible-lint-ignore  # so the linter reports existing issues
ansible-lint --tags=risky-file-permissions ansible
# Edit the code flagged in each of the "risky-file-permissions" warnings
# and re-run the above command until the warnings are gone. Then,
make lint-ignore

Hi @mboersma,
I ran the command, but all files remained unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants