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

[steps] [ENG-14503] Don't wrap b64-encoded values on Linux #491

Conversation

radoslawkrzemien
Copy link
Contributor

Why

Linux systems add line wraps to b64 encoded values after 76 characters by default. We don't want that

How

If set-env is executed on a Linux system base64 command is called with -w 0 option. It's not present in other systems therefore in other case base64 is called with no options

Test Plan

Automated tests pass
Tested manually both for ios and android

When using set-env command base64-encode the value of the env var before saving to a file

See: https://linear.app/expo/issue/ENG-14503/base64-encode-env-vars-in-custom-builds
Linux systems add line wraps to b64 encoded values after 76 characters by default. We don't want that

See: https://linear.app/expo/issue/ENG-14503/base64-encode-env-vars-in-custom-builds
Linux systems add line wraps to b64 encoded values after 76 characters by default. We don't want that

See: https://linear.app/expo/issue/ENG-14503/base64-encode-env-vars-in-custom-builds
Copy link

linear bot commented Jan 13, 2025

Comment on lines +23 to +27
if [[ "$OSTYPE" == "linux"* ]]; then
echo -n "$VALUE" | base64 -w 0 > $__EXPO_STEPS_ENVS_DIR/$NAME
else
echo -n "$VALUE" | base64 > $__EXPO_STEPS_ENVS_DIR/$NAME
fi
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
if [[ "$OSTYPE" == "linux"* ]]; then
echo -n "$VALUE" | base64 -w 0 > $__EXPO_STEPS_ENVS_DIR/$NAME
else
echo -n "$VALUE" | base64 > $__EXPO_STEPS_ENVS_DIR/$NAME
fi
echo -n "$VALUE" | base64 -w 0 > $__EXPO_STEPS_ENVS_DIR/$NAME

-w [number] works in macOS (even though --help doesn't mention it). Can you confirm it works in Linux too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can confirm it doesn't work on macOS, got an error trying to run it on my machine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

radoslawkrzemien@MacBook-Pro-9 ~ % echo czescstaszekawsumiedobrze | base64 -w 0
base64: invalid option -- w
Usage:	base64 [-Ddh] [-b num] [-i in_file] [-o out_file]
  -b, --break    break encoded string into num character lines
  -Dd, --decode   decodes input
  -h, --help     display this message
  -i, --input    input file (default: "-" for stdin)
  -o, --output   output file (default: "-" for stdout)

Copy link
Contributor

Choose a reason for hiding this comment

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

Fascinating! On my computer it doesn't do that!

> echo czescradekcotamuciebie | base64 -w 0
Y3plc2NyYWRla2NvdGFtdWNpZWJpZQo=
> echo czescradekcotamuciebie | base64 -w 6
Y3plc2
NyYWRl
a2NvdG
FtdWNp
ZWJpZQ
o=

I guess then it's ok to do it like you're doing it. Thanks for confirming!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder what is the cause of that. Guess it's better to be safe than sorry at least for now

@radoslawkrzemien radoslawkrzemien merged commit 3212222 into main Jan 14, 2025
5 checks passed
@radoslawkrzemien radoslawkrzemien deleted the @radoslawkrzemien/ENG-14503_base64_encode_envs_in_custom_builds branch January 14, 2025 10:22
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

Successfully merging this pull request may close these issues.

2 participants