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

Change modsecurity directories #2660

Merged
merged 1 commit into from
Jun 20, 2018

Conversation

aledbf
Copy link
Member

@aledbf aledbf commented Jun 17, 2018

What this PR does / why we need it:

Running as user prevents the start of modsecurity. Changing directories to fix this issue.

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 17, 2018
@codecov-io
Copy link

Codecov Report

Merging #2660 into master will increase coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2660      +/-   ##
=========================================
+ Coverage   40.84%   40.9%   +0.05%     
=========================================
  Files          72      72              
  Lines        5073    5073              
=========================================
+ Hits         2072    2075       +3     
+ Misses       2718    2716       -2     
+ Partials      283     282       -1
Impacted Files Coverage Δ
cmd/nginx/main.go 24.81% <0%> (+2.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 857c3b0...2510c13. Read the comment docs.

@@ -37,6 +37,13 @@ RUN setcap cap_net_bind_service=+ep /usr/sbin/nginx \
RUN mkdir -p /etc/ingress-controller/ssl /etc/ingress-controller/auth \
&& chown -R www-data.www-data /etc/nginx /etc/ingress-controller

RUN mkdir -p /tmp/modsecurity/audit /tmp/modsecurity/upload \
Copy link
Contributor

@antoineco antoineco Jun 17, 2018

Choose a reason for hiding this comment

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

As this seems to be a recurring problem and probably not the last time permissions have to be adjusted, I'd be in favor of declaring an array of all directories used by the controller and applying ownership in one go. This mix and match of chown and file sed'ing feels suboptimal and prone to errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree but we have a problem, some or most of the directories are located in the parent image or even worse in configuration files with some defaults. I don't see an easy way to tackle this.

Copy link
Contributor

@antoineco antoineco Jun 20, 2018

Choose a reason for hiding this comment

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

I persist in thinking defining an array in the Dockerfile instead of changing configs in place would be a good attempt at documenting what directories nginx/controller write to, at least.

Either that or move everything under /tmp.

None of these are ideal, but it would at least be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

&& sed -i 's|/var/log/modsec_audit.log|/tmp/modsec_audit.log|g' /etc/nginx/modsecurity/modsecurity.conf \
&& sed -i 's|/opt/modsecurity/var/log/debug.log|/tmp/debug.log|g' /etc/nginx/modsecurity/modsecurity.conf \
&& sed -i 's|/opt/modsecurity/var/upload|/tmp/modsecurity/upload|g' /etc/nginx/modsecurity/modsecurity.conf \
&& sed -i 's|/opt/modsecurity/var/audit|/tmp/modsecurity/audit|g' /etc/nginx/modsecurity/modsecurity.conf
Copy link
Member

Choose a reason for hiding this comment

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

Are these temporary files by definition (I have never used modsecurity)? If not can we create the modsecurity dedicated folder in user's home directory?

Copy link
Member Author

Choose a reason for hiding this comment

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

All this directories are temporal

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 20, 2018
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 20, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 20, 2018
@antoineco
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 20, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, antoineco

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot merged commit fe9a5ae into kubernetes:master Jun 20, 2018
@aledbf aledbf deleted the fix-modesecurity branch June 21, 2018 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants