Skip to content

Add config flag for GDPR compliance. Remove last octet from ips in request-logs accordingly.#1585

Merged
aashah merged 1 commit intocloudfoundry:masterfrom
FloThinksPi-Forks:flo-marc-gdpr
Apr 9, 2020
Merged

Add config flag for GDPR compliance. Remove last octet from ips in request-logs accordingly.#1585
aashah merged 1 commit intocloudfoundry:masterfrom
FloThinksPi-Forks:flo-marc-gdpr

Conversation

@FloThinksPi
Copy link
Copy Markdown
Member

@FloThinksPi FloThinksPi commented Mar 25, 2020

A short explanation of the proposed change:

IP Adresses now get their last octet cut of and replaced by 0 if the
new config option logging.gdpr_compliant is true. E.g 192.168.1.80
will be logged as 192.168.1.0 which provides sufficent anonymization
to comply with european data protection regulations.

If the flag is false or not present, CC will have the old behaviour
which means logging the full ips.

This flag can also be used in other places that one may find needs
adoptions to comply to EU GDPR.

An explanation of the use cases your change solves

It provides a way to comply to the european data protection regulations.
All EU Customers of Pivotal that save their logs would benefit from this change.
The IP is specifically called as Personal information: https://gdpr.eu/recital-30-online-identifiers-for-profiling-and-identification/
So either one has to:

  • Not save it at all
  • Request formal approval from all users for saving their ips
  • Anonymise the IP so it can not be tracked down to an individual

This change enables customers to use the third option as the first ones are not practicable.

Links to any other associated PRs

Followup of: #1575
Issue: #1568
Slack discussion: https://cloudfoundry.slack.com/archives/C07C04W4Q/p1584635872138900

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the master branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests
    Could not get CATS to run(having no bosh-lite atm). Would be thankful if some pivot can run it against one of you bosh-lites.

@cf-gitbot
Copy link
Copy Markdown

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/171974450

The labels on this github issue will be updated when the story is started.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Mar 25, 2020

CLA Check
The committers are authorized under a signed CLA.

Comment thread config/cloud_controller.yml Outdated
Comment thread middleware/request_logs.rb Outdated
request = ActionDispatch::Request.new(env)

# Remove last octet of ip if EU GDPR compliance is needed
ip = VCAP::CloudController::Config.config.get(:logging, :gdpr_compliant) ? request.ip.split('.')[0...-1].join('.') + '.0' : request.ip
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like it'll only work with ipv4 - maybe worth looking into a gem that also supports ipv6 to do this as many folks are probably anonymizing IP addresses in ruby for gdpr compliance. (I found https://github.com/ankane/ip_anonymizer after a brief search)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would probably also favor this construct over a ternary:

ip = if VCAP::CloudController::Config.config.get(:logging, :gdpr_compliant)
         <redact ip>
      else
        <unredacted-ip>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@selzoc Thank you for the hint. We changed the implementation quite a bit to allow for v6 adresses. We ditched third party libs to not introduce new dependencies as the task is quite simple to adress with the stdlib of ruby. Also using you recommendation for the variable assignment : ).

If we find we need this in other parts of the CC we will think of pulling the code to anonymize the ip out, somwhere else to make it reusable. For now i think we are good keeping it in request_logs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still think it would be clearer to pull it out into a function. But yeah I guess no need for a gem!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@selzoc as i am still not that familiar with the codebase, where would such a function be placed in the coding ? Maybe lib/utils ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I just meant extracting lines 15-24 into a function within the same class, just to clean up the call function a bit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done : )

IP Adresses now get their last octet cut of and replaced by 0 if the
new config option logging.gdpr_compliant is true. E.g 192.168.1.80
will be logged as 192.168.1.0 which provides sufficent anonymization
to comply with european data protection regulations.

If the flag is false or not present, CC will have the old behaviour
which means logging the full ips.

Signed-off-by: Marc Misoch <47423110+MMisoch@users.noreply.github.com>

Add unittest for ip anonymization in request logs

Signed-off-by: Marc Misoch <47423110+MMisoch@users.noreply.github.com>

Fix rubocop issues for request_logs(_specs).rb

Signed-off-by: Marc Misoch <47423110+MMisoch@users.noreply.github.com>

Make ip anonymization ipv6 capable and use stdlib to validate adresses

We ditched any additional libary as the stdlib is sufficient and we dont
want to introduce new dependencies as this is for now just needed once.

Signed-off-by: Marc Misoch <47423110+MMisoch@users.noreply.github.com>

Add more test for ipv6 behaviour and print ipv6 canonicaly by default

Signed-off-by: Marc Misoch <47423110+MMisoch@users.noreply.github.com>

Renamed config flag to anonymize_ips to reflect correct behaviour

Signed-off-by: Marc Misoch <47423110+MMisoch@users.noreply.github.com>

Pull out anonymize ip logic in own function

Signed-off-by: Marc Misoch <47423110+MMisoch@users.noreply.github.com>
@FloThinksPi
Copy link
Copy Markdown
Member Author

@selzoc can you review again, also squashed all changes into one commit so history is more clean once merged.

Copy link
Copy Markdown
Member

@selzoc selzoc left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@aashah aashah merged commit 15db3e3 into cloudfoundry:master Apr 9, 2020
@aashah
Copy link
Copy Markdown
Contributor

aashah commented Apr 9, 2020

Thanks for the PR!

aashah pushed a commit that referenced this pull request Apr 17, 2020
This reverts commit 39952cf, reversing
changes made to c3b2d6d.
aashah pushed a commit that referenced this pull request Apr 20, 2020
This reverts commit 39952cf, reversing
changes made to c3b2d6d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants