Skip to content

[Project-scoped API tokens] are too big for travis pypi deploy #6338

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

Closed
graingert opened this issue Aug 1, 2019 · 18 comments
Closed

[Project-scoped API tokens] are too big for travis pypi deploy #6338

graingert opened this issue Aug 1, 2019 · 18 comments

Comments

@graingert
Copy link
Contributor

Describe the bug

data too large - consider using travis encrypt-file or travis env set

Expected behavior
travis encrypt "pypi:token-here"
it prints a nice encrypted token

To Reproduce
$ travis encrypt "pypi:token-here"
data too large - consider using travis encrypt-file or travis env set

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2019

Interesting... Worked for me using a account-global token. Haven't tried it with a project-scoped one. Is it longer?

@graingert
Copy link
Contributor Author

Mine was 195 characters

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2019

It looks like Travis CI limitation is 501 byte. You're probably doing something wrong. Are you using --com or --org?

$ dd if=/dev/urandom | LC_CTYPE=X tr -cd "[:alpha:][:digit:]" | head -c 256 | travis encrypt -r xxx/xxx --api-endpoint 'https://api.travis-ci.com/'
Please add the following to your .travis.yml file:

  secure: "VW5SHPo68Mz40zMlDJRwqgh5bsTzItdhDSAsK+Xozb64Z/4GOUJ++iWLFB7eqMA/pS9+FkuwUcBNBxB/DYCJ2jJRb3UxnF3JgBvsgNsi0FQAgvhzz3vKSfWZoTn9c1/jK8Ng1KmqJDkcwjC77EawUo8dbUz19Iw5eyES3803j/Q68luzO1IipZhQLrJRnCV0YhZTnCpoluOoePdv0GG/BU15PVMJIqn3B34fJk6mXrAfrhrjgsp2wt0XAj4e7cQEk80fZsM595mS6qgtLrNP4ZdIA6eSoYuaZ1oeK10wxuOz79wLkEv5LifdZaU5rEmn9grT+35B6Cekkk5rjotPQXgTKGByXWCQywvhYxpQU7zonZr3AeVgVMdFcFnNtxrDbN+dsyR6SwwyEUIBazxZyxN/ITTCHJLAad/1C9MPIY/SzZzNRYkwSbAjh+IxEcANm6Pitvf8UeP6bmII/61ovgPI0t3nxbtA2cnCaYeP6fbfqOBwdYc1ISBqR5w4pR85HBtZM7MI7qq+nME1i3UUG+j0MyixUIB10vOI1XnumxaQ2AqTOIoi3vm/4gDEay+S2YnWq7jMD4xCW6rQ+8b7lZWQhpRoig9rv6yb16oUOZsScCCwOkxbA4k33H2v+PbvBrFlvb8jKALYnaWqFlCU9WB4rIUGCjJ7NZcZ7I0h37U="

Pro Tip: You can add it automatically by running with --add.
$ dd if=/dev/urandom | LC_CTYPE=X tr -cd "[:alpha:][:digit:]" | head -c 502 | travis encrypt -r xxx/xxx --api-endpoint 'https://api.travis-ci.com/'
Outdated CLI version, run `gem install travis`.
data too large - consider using travis encrypt-file or travis env set

$ dd if=/dev/urandom | LC_CTYPE=X tr -cd "[:alpha:][:digit:]" | head -c 501 | travis encrypt -r xxx/xxx --api-endpoint 'https://api.travis-ci.com/'
Outdated CLI version, run `gem install travis`.
Please add the following to your .travis.yml file:

  secure: "t7P2dCpHE7x7nknQvUxGVSC5WFjTzDu2vnd59I26cG7jszeyEeE4J9sJctgwkHq5GGyiE24tZqsrfW4Nf6n3oS/S/KQRJb8zS3fSwnSlXDyrIDeH319/5i2qxolTZsXFKVkhNi9pzaAHCmFV2Id/VqjgFO9DegpuChObckJ8LGGhrAb7snRSwCtBAuAV0yE2sUsyhqwkKiglY4GSV/W+lswR+hxdkDlaqgA/uODSNWIMaFeuAUTwtLR1owpDyai5J9xTEk06PvYIWvOHvnu5Mcdck8rcNWyjUJiPGQEw2cFklH0JDuDSeAHULc/K3c0LMvXdN5HtPJMphuAH/7PKy4BOgIGIa40C9Hu4q1Tx9Y0jImOVUgywvWThFUBobxTsWLo0IFjRTe6wRfKR2/nzprnUiwQ1ouasynpF8/PDsuPczIm8kAUv+S9NM+7mLR+BFEg98f37wcxwYAM+nDqU8WkJjGxczoQybF0Xx1KW4QrFH7CrJfiQ4Urd7b6EQF58L5fD24T2SgIIA84r0bF0DWLUKvHMJifW8vRDPlThKXev3xwGti02EpUcnYATrWVOd5oJs1PBfirjp0zFRIE8GAjnBoVTQlAnG8JFYlvzJp+DdlB4NXY16VcIcyJ6kcWRUFDBKttJlmY7NnWxNuGQZ60kg11YjRGfhEju17KW6oQ="

Pro Tip: You can add it automatically by running with --add.

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2019

Workaround:

It's not very well advertised but you can actually use PYPI_PASSWORD env var.
DPL tool supports it as a fallback, see: https://github.com/travis-ci/dpl/blob/1077ce6/lib/dpl/provider/pypi.rb#L12.
You can set it as a secret var (which I think supports data of size up to 4096 bytes) on the Settings page of your repo @ travis-ci.com.

@brainwane
Copy link
Contributor

Not sure whether we should consider this a documentation issue to address in travis-ci/docs-travis-ci-com#2452 & #6211 or a thing we can/should address on the Warehouse side. @woodruffw ?

@graingert
Copy link
Contributor Author

I'm using the travis snap if that helps anyone repeat?

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2019

@graingert I'm not sure what's packaged into that snap and don't have it myself :(
Did you notice any weird special chars in your token?

@woodruffw
Copy link
Member

Hmm -- this probably falls under documentation, since we're already using the more compact ("V2") text serialization format for Macaroons. We could probably squish it further by using a binary format for caveats instead of JSON, but it'll still be a relatively long token.

I agree with @webknjaz that there might be something additional going on here: 195 characters is long, but well below the actual Travis CI limit.

@graingert
Copy link
Contributor Author

No nothing weird, just the :

@brainwane
Copy link
Contributor

brainwane commented Aug 1, 2019

@graingert Could I ask you to contact Travis CI support or their bug tracker and ask what they find, in case there's something else going on here?

@graingert
Copy link
Contributor Author

I suspect this is a unique problem to me. I'm using travis set env now

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2019

@graingert I believe it's not safe to use that.

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2019

@graingert heads up: the issue seems to be a duplicate of #6287

@jaraco
Copy link
Contributor

jaraco commented Sep 21, 2019

This problem isn't unique to you. I've encountered it in a couple of projects myself. It seems some projects in Travis have a 128-byte key while others a 512-byte key (and maybe others with another length). The only recommended solution seems to be "don't use encrypted values in config".

@jaraco
Copy link
Contributor

jaraco commented Sep 21, 2019

the issue seems to be a duplicate of #6287

I don't see how this is a duplicate of that issue. That issue discussed the escaping of values (@token and pypi:), both of which were changed to avoid those issues.

This issue is about how Travis config refuses to encrypt the value for certain projects, which was reported upstream in travis-ci/travis.rb#221, but the recommendation is to avoid using that feature.

@jaraco
Copy link
Contributor

jaraco commented Sep 21, 2019

Although #6355 is a duplicate of this issue, the conversation is continuing there.

@webknjaz
Copy link
Member

Well, it seemed to have the same roots back when I suggested that it's a duplicate ;)

@ssbarnea
Copy link

To be honest the pypi token looks like a joke made in order to test who would choke trying to use it. Its unresonable length breaks even the newer v3 travis deploy api, as documentd at https://docs.travis-ci.com/user/deployment-v2/providers/pypi/

Any attempt to encrypt that huge token would give you a data too large - consider using travis encrypt-file or travis env set

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

No branches or pull requests

6 participants