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

fix: update cos-tool permissions to adhere to cis hardening rules #231

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lucabello
Copy link
Contributor

@lucabello lucabello commented Jan 13, 2025

Issue

Closes #208.

Solution

Fix the cos-tool permissions according to the linked issue (removing the write permission from others).

Warning

I had to bump the cos_agent library because of a linting error which was auto-fixed by tox -e fmt.

We change the cos-tool permissions with path.chmod(0o777) in multiple places:

  • lib/charms/loki_k8s/v1/loki_push_api.py
  • lib/charms/prometheus_k8s/v1/prometheus_remote_write.py
  • lib/charms/grafana_k8s/v0/grafana_dashboard.py
  • lib/charms/prometheus_k8s/v0/prometheus_scrape.py

We need three PRs in Prometheus, Loki and Grafana to fix those libraries:

I manually changed the library files, packed the charm, and tested with the juju ssh grafana-agent/X -- sudo find / -xdev -type f -perm -002 command, and no file with too many permissions is returned anymore.

Testing Instructions

charmcraft pack
juju deploy ./(grafana-agent-charm)
juju deploy zookeeper --base ubuntu@22.04
juju relate grafana-agent zookeeper

# wait for it to settle

# Look for files with too many permissions (see issue)
# Make sure this returns nothing
juju ssh grafana-agent/X -- sudo find / -xdev -type f -perm -002

@lucabello lucabello requested a review from a team as a code owner January 13, 2025 13:55
@lucabello
Copy link
Contributor Author

I will un-draft this as soon as the 3 linked PRs are merged.

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

Successfully merging this pull request may close these issues.

CIS hardening rule 6.1.9 "Ensure no world writable files exist" fails because of permission issue
1 participant