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

Make directory enforcer more lenient and add flag #2716

Merged
merged 12 commits into from Nov 27, 2019

Conversation

simster7
Copy link
Member

@simster7 simster7 commented Nov 13, 2019

Fixes: #2715 and updates change in #2452. Adds a new argo-cd-cm flag (helm.directoryEnforcerLevel) to set Directory Enforcer level. Supported values are:

  • Strict: only allows access to files within the directory containing Chart.yaml
  • Repo (default): allows access to files within the entire repo

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Optional. My organization is added to the README.
  • I've signed the CLA and my build is green (troubleshooting builds).

util/security/path_traversal.go Outdated Show resolved Hide resolved
util/security/path_traversal_test.go Outdated Show resolved Hide resolved
util/settings/settings.go Outdated Show resolved Hide resolved
util/settings/settings.go Outdated Show resolved Hide resolved
@simster7
Copy link
Member Author

@jannfis @wecger @adamjohnson01 If possible, could you guys download and build this branch and see if the fix works as you would expect? The default behavior is to permit all files within a repo.

@codecov
Copy link

codecov bot commented Nov 13, 2019

Codecov Report

Merging #2716 into master will increase coverage by 0.04%.
The diff coverage is 86.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2716      +/-   ##
==========================================
+ Coverage   38.38%   38.42%   +0.04%     
==========================================
  Files         156      156              
  Lines       17292    17310      +18     
  Branches      203      203              
==========================================
+ Hits         6638     6652      +14     
- Misses       9831     9833       +2     
- Partials      823      825       +2
Impacted Files Coverage Δ
util/settings/settings.go 30.89% <100%> (+0.25%) ⬆️
util/security/path_traversal.go 81.48% <100%> (+10.89%) ⬆️
util/helm/cmd.go 40.56% <100%> (-2.42%) ⬇️
reposerver/repository/repository.go 59.88% <75%> (-0.08%) ⬇️

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 257c276...80a5ac2. Read the comment docs.

@simster7 simster7 marked this pull request as ready for review November 15, 2019 16:36
@simster7
Copy link
Member Author

@jannfis @wecger @adamjohnson01 If possible, could you guys download and build this branch and see if the fix works as you would expect? The default behavior is to permit all files within a repo.

@jannfis @wecger @adamjohnson01 Hope you guys don't mind if I try you one more time :)

@jannfis
Copy link
Member

jannfis commented Nov 15, 2019

Sorry for the late reply @simster7 and also thanks for the quick PR - unfortunately, We didn't find the time to build from that branch yet, as we're pretty busy with other topics. I'll see if I find time over the weekend to test it out and let you know any feedback.

@simster7
Copy link
Member Author

@alexec This could potentially need to be backported.

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Still not built & tested, but reviewed the change. I just have some minor comments, please check.

pkg/apis/application/v1alpha1/types.go Outdated Show resolved Hide resolved
reposerver/repository/repository.go Outdated Show resolved Hide resolved
util/settings/settings.go Show resolved Hide resolved
util/settings/settings.go Show resolved Hide resolved
util/settings/settings.go Outdated Show resolved Hide resolved
@alexec
Copy link
Contributor

alexec commented Nov 15, 2019

IMHO for app where repo type is Git (as opposed to Helm) you should be able to read any file within the repo. No need for options.

@simster7
Copy link
Member Author

@alexec Sure, I can remove the option functionality. Since it's already implemented though, we could leave it in? Doesn't seem like it would hurt

@alexec
Copy link
Contributor

alexec commented Nov 15, 2019

I'd prefer to not have extra code to maintain TBH.

@simster7
Copy link
Member Author

@alexec Removed the enforcer level option

@alexec alexec self-assigned this Nov 21, 2019
util/helm/cmd.go Outdated Show resolved Hide resolved
util/settings/settings.go Show resolved Hide resolved
util/helm/cmd_test.go Outdated Show resolved Hide resolved
if appHelm.Values != "" {
file, err := ioutil.TempFile(appPath, "values-*.yaml")
file, err := ioutil.TempFile("", "values-*.yaml")
Copy link
Member Author

Choose a reason for hiding this comment

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

Ditto

util/helm/cmd.go Outdated Show resolved Hide resolved
reposerver/repository/repository.go Outdated Show resolved Hide resolved
@simster7 simster7 requested a review from alexec November 26, 2019 23:03
@simster7
Copy link
Member Author

@alexec Ready for another look

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

Looks good so far. Can we allow URLs please?

reposerver/repository/repository.go Outdated Show resolved Hide resolved
reposerver/repository/repository_test.go Show resolved Hide resolved
@alexec
Copy link
Contributor

alexec commented Nov 27, 2019

Please dismiss and re-request review when ready - so it appears in my notifications.

@simster7 simster7 requested a review from alexec November 27, 2019 00:13
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

LGTM

@alexec alexec added this to the v1.3 milestone Nov 27, 2019
@alexec alexec added S bug Something isn't working labels Nov 27, 2019
@wecger
Copy link
Contributor

wecger commented Nov 27, 2019

built, deployed and tested this branch on our env. Using value files from outside the chart folder, but inside the repo worked fine for me :)

@simster7 simster7 merged commit c8ae89f into argoproj:master Nov 27, 2019
alexec pushed a commit that referenced this pull request Nov 27, 2019
* Make directory enforcer more lenient and add flag

* Fixes

* Lint fixes

* Lint fixes

* Fixed test

* Minor

* Removed enforcer option

* Move directory traversal check higher up

* Go fmt

* Allow URLs

* Added test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Helm value files outside of chart path
5 participants