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

Try #3: Support encrypted DNS txt records #1828

Merged
merged 1 commit into from
May 9, 2023

Conversation

vsychov
Copy link
Contributor

@vsychov vsychov commented Oct 20, 2020

Hi guys,

I found few pull request about txt records encryption (#1314, #1115, #1538), that have conflicts now, or not merged.
This PR have latest PR (#1538) with resolved conflicts, hope it will help you to review and merge it.

Fixes #1825
Fixes #854

Checklist

  • Unit tests updated
  • End user documentation updated

@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 Oct 20, 2020
@vsychov
Copy link
Contributor Author

vsychov commented Oct 20, 2020

/assign @njuettner

@vsychov
Copy link
Contributor Author

vsychov commented Oct 20, 2020

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 20, 2020
Copy link
Contributor

@Raffo Raffo left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @vsychov . I did a first pass at reviewing, but error handling and a few other things are a bit off and far from a good enough quality. I would suggest, if you are open to that, that you start refactoring the code following the guidelines that I gave.
In a nutshell:

  • error handling according to go guidelines (no valid values when error, don't hide errors, etc.)
  • comments that are useful to generate godocs
  • use American English for all code.

Once a refactor is done I will proceed with a code review.

endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
endpoint/crypto.go Outdated Show resolved Hide resolved
@vsychov
Copy link
Contributor Author

vsychov commented Oct 22, 2020

@Raffo, I made some code refactoring, fixed error handling, and crypto functions logic little bit, do you have any other comments?

@vsychov vsychov requested a review from Raffo October 22, 2020 15:00
@vsychov
Copy link
Contributor Author

vsychov commented Nov 6, 2020

Hi @Raffo , is all good, or something more changes needed for merge it?

@marcgascon
Copy link

Anything missing in this PR beside conflicts? I am really interested in this new feature. 😄

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 14, 2020
@vsychov
Copy link
Contributor Author

vsychov commented Mar 2, 2021

I fixed conflicts with master, do It need more changes for be merged, @Raffo?

@njuettner njuettner assigned Raffo and unassigned njuettner Mar 3, 2021
Copy link
Contributor

@Raffo Raffo left a comment

Choose a reason for hiding this comment

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

@vsychov There are still many changes to be done, please check again that all errors are handled, comments are correct and that we do not mask possible errors. Generally speaking we also don't want to log and return err.


// EncryptText gzip input data and encrypts it using the supplied AES key
func EncryptText(text string, aesKey []byte) (string, error) {
block, _ := aes.NewCipher(aesKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a unhandled error here, please handle it.

data := []byte(text)
data, err = compressData(data)
if err != nil {
log.Debugf("Failed to compress data based on the text %#v. Got error %#v.", text, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to log and return the error. If you need to add a message, please wrap the error.

Comment on lines 44 to 45
data := []byte(text)
data, err = compressData(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
data := []byte(text)
data, err = compressData(data)
data, err = compressData([]byte(text))

return string(plaindata), nil
}

// Decompress gzip compressed data
Copy link
Contributor

Choose a reason for hiding this comment

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

code comment is wrong

Suggested change
// Decompress gzip compressed data
// decompressData gzip compressed data

return b.Bytes(), nil
}

// Compress data by gzip, for minify data stored in registry
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Compress data by gzip, for minify data stored in registry
// compressData data by gzip, for minify data stored in registry

}
return NewLabelsFromStringPlain(labelText)
}

// Serialize transforms endpoints labels into a external-dns recognizable format string
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Serialize transforms endpoints labels into a external-dns recognizable format string
// SerializePlain transforms endpoints labels into a external-dns recognizable format string

endpoint/labels.go Show resolved Hide resolved
Comment on lines 130 to 149
if err != nil {
log.Debugf("Failed to encrypt the text %#v using the encryption key %#v. Got error %#v.", text, aesKey, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This error is masked. This function should probably return an error.

Choose a reason for hiding this comment

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

@Raffo there is a little to do with this mr
@vsychov do you have working fork with txt encryption feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shcherbak, yes, I'm using this feature in a production with the Cloudflare provider since the moment of the PR creation. If you want I can publish a working Docker image for your convenience.

Choose a reason for hiding this comment

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

@vsychov this is amazing, thank you
but i think will wait for official chart and image
nicely done, respect

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 3, 2021
@vsychov
Copy link
Contributor Author

vsychov commented Mar 3, 2021

@Raffo, fixed

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 6, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 27, 2021
@Mattie112
Copy link

@Raffo Sorry for tagging you but it seems you need to approve this change. Is there any way you can look into this? We would like to use the txt-registry but don't want to expose any more information to the outside world.

@SCLogo
Copy link

SCLogo commented Jul 8, 2021

Any reason why this PR not merged yet? It is a very good new feature to not leak any data about your cluster

@SCLogo
Copy link

SCLogo commented Jul 13, 2021

@Raffo @njuettner Can we help in anything to merge this PR ? It fixes a huge security leak I think. Thanks

@SCLogo
Copy link

SCLogo commented Jul 27, 2021

@vsychov could you please change request change to review request? maybe this is the only issue here.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 25, 2021
@Mattie112
Copy link

We still very much want this feature and it is already a PR, so please /remove-lifecycle stale ?

@vsychov
Copy link
Contributor Author

vsychov commented Oct 25, 2021

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 25, 2023
@szuecs
Copy link
Contributor

szuecs commented Apr 26, 2023

Please don't merge remote master but fetch master and rebase your branch on top of master.
I saw this in my email and inbox maybe you already fixed it.
Thanks

@vsychov vsychov closed this Apr 28, 2023
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 28, 2023
vsychov added a commit to vsychov/external-dns that referenced this pull request Apr 28, 2023
Signed-off-by: Viacheslav Sychov <viacheslav.sychov@gmail.com>
@vsychov vsychov mentioned this pull request Apr 28, 2023
@vsychov vsychov reopened this Apr 28, 2023
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 28, 2023
Signed-off-by: Viacheslav Sychov <viacheslav.sychov@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 28, 2023
@vsychov
Copy link
Contributor Author

vsychov commented Apr 28, 2023

Please don't merge remote master but fetch master and rebase your branch on top of master. I saw this in my email and inbox maybe you already fixed it. Thanks

@szuecs, I combined all commits into one and then rebased it onto the master branch. Previously, this was nearly impossible due to numerous conflicts in each commit.

Hope now it's ok to merge?

@szuecs
Copy link
Contributor

szuecs commented May 8, 2023

@vsychov I wait for @Raffo to review. From my side lgtm

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 8, 2023
@shcherbak
Copy link

shcherbak commented May 9, 2023

is there any reason why this PR not merged yet? @Raffo

@Raffo
Copy link
Contributor

Raffo commented May 9, 2023

Sorry I am really on life support with time. I can't review this. @szuecs please feel free to merge this if you think it's good.

@szuecs
Copy link
Contributor

szuecs commented May 9, 2023

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: szuecs, vsychov

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 May 9, 2023
@k8s-ci-robot k8s-ci-robot merged commit f56e2f6 into kubernetes-sigs:master May 9, 2023
@szuecs
Copy link
Contributor

szuecs commented May 9, 2023

@vsychov thanks for your work and answers. Wow we just merged a PR from 2020, great to see that such old PRs are finally merged and improving the tool for everyone.

@shcherbak
Copy link

@Raffo please take care of yourself

@shcherbak
Copy link

shcherbak commented May 10, 2023

@szuecs nicely done! It is time for pushing new tag, isn't it? :) Or talking seriously, when new release is planned?

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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

TXT registry records encryption Encrypt TXT records