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

API request logging improvements #3180

Merged
merged 3 commits into from
Aug 2, 2018

Conversation

jeefy
Copy link
Member

@jeefy jeefy commented Jul 27, 2018

Hey all!

This directly addresses #3174, #3012, and potentially others.

I created a list of addresses that may potentially have sensitive information that should not be logged. Instead it will only log { contents hidden }.

However, in some cases (like debugging and development) you still want to see what's being passed along. So I added a new CLI argument to the dashboard called --api-log-level with three options: INFO,DEBUG,NONE

The default setting is INFO, which will log everything but sensitive URLs.
NONE will turn off all request/response logging.
DEBUG will log everything including the contents of sensitive URLs.

I added tests for all this, and also updated TestFormatRequestLog to handle more diverse test cases.

Thanks!

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 27, 2018
@jeefy
Copy link
Member Author

jeefy commented Jul 28, 2018

/retest

@codecov
Copy link

codecov bot commented Jul 28, 2018

Codecov Report

Merging #3180 into master will increase coverage by 0.06%.
The diff coverage is 65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3180      +/-   ##
==========================================
+ Coverage   54.52%   54.58%   +0.06%     
==========================================
  Files         565      565              
  Lines       12397    12415      +18     
==========================================
+ Hits         6759     6777      +18     
- Misses       5376     5377       +1     
+ Partials      262      261       -1
Impacted Files Coverage Δ
src/app/backend/handler/filter.go 44.21% <65%> (+13.04%) ⬆️

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 6ed35fc...29841d5. Read the comment docs.

Copy link
Member

@maciaszczykm maciaszczykm left a comment

Choose a reason for hiding this comment

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

Few minor comments to the code, I will test it later. Thanks for taking care of it :)

@maciaszczykm maciaszczykm self-assigned this Jul 31, 2018
@@ -76,6 +83,19 @@ func formatRequestLog(request *restful.Request) string {
}
}

// Is DEBUG level logging enabled?
if args.Holder.GetAPILogLevel() != "DEBUG" {
// Great now let's filter out any content from sensitive URLs
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest is to export it to another method. You can also use map instead of slice to get rid of the loop:

_, isSensitive := sensitiveUrls[key]

You can put struct{} as a value to save space.

Please remember to use camelCase and switch likes of sensitive_urls to sensitiveUrls.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed and pushed to c820847 -- Thoughts?

If that looks good, I can squash before the merge.

Copy link
Member Author

@jeefy jeefy left a comment

Choose a reason for hiding this comment

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

Updated in commit c820847

@@ -76,6 +83,19 @@ func formatRequestLog(request *restful.Request) string {
}
}

// Is DEBUG level logging enabled?
if args.Holder.GetAPILogLevel() != "DEBUG" {
// Great now let's filter out any content from sensitive URLs
Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed and pushed to c820847 -- Thoughts?

If that looks good, I can squash before the merge.

@maciaszczykm
Copy link
Member

maciaszczykm commented Aug 2, 2018

/lgtm

It seems to work, but I think it should be possible to use this flag also when running gulp serve (take a look at build/serve.js and build/conf.js files). Besides that, please update https://github.com/kubernetes/dashboard/wiki/Dashboard-arguments. You can do this in separate pull request.

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jeefy, maciaszczykm

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 2, 2018
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants