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

Incorrectly decoding data #26

Open
Robin481 opened this issue May 3, 2022 · 1 comment
Open

Incorrectly decoding data #26

Robin481 opened this issue May 3, 2022 · 1 comment

Comments

@Robin481
Copy link
Member

Robin481 commented May 3, 2022

We haven't pinned down the reason 100% but it seems that the ccli can come to a point when syncing secrets that it tries to Base64-decode non-Base64 encoded strings.

This method:

def decoded_data(data)
    return {} unless data

    data.transform_values do |value|
      Base64.strict_decode64(value)
    rescue ArgumentError
      value
    end
end

is probably the biggest culprit as normally a non Base64 encoded String will just throw an error and return its value but in my case a non-Base64 encoded string was recognized as Base64, was therefore decoded and broke everything.

I have an example string for this case that I can share when needed.

@TheWalkingLeek
Copy link
Member

Kind of confused why we're disecting the whole yml here: https://github.com/puzzle/ccli/blob/8ea35525c9/lib/serializers/ose_secret_serializer.rb#L9
We should just be able to do OSESecret.new(Psych.load(yaml)['metadata']['name'], yaml)
We're saving the whole yml to cryptopus anyways, so digging around in the yml and decoding stuff just seems.. unnecessary.
This would also mean that we don't have to encrypt anything anymore after pulling from cryptopus: https://github.com/puzzle/ccli/blob/8ea35525c9/lib/serializers/ose_secret_serializer.rb#L30
I'm not saying this fixes the issue. But it just feels so weird that I'm hoping that we can either actually identify or by chance kill the bug in the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants