-
Notifications
You must be signed in to change notification settings - Fork 1
Proper escaping for generated encrypted password hashes #20
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
Conversation
WalkthroughThe script responsible for finalizing images now escapes dollar signs in the root password hash before inserting it into the shadow file. It also changes the Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tools/finalize-nakamochi.sh (2)
274-275
: Properly escape and substitute test-image root hash
Escaping\$
withsed 's/\$/\\\$/g'
and switching thesed
delimiter to|
prevents misinterpretation of$
or/
in the hashed password. This change ensures the fixed"nakamochi"
password is safely injected into/etc/shadow
.You could eliminate the extra
sed
call by using Bash parameter expansion to escape$
, for example:crypted_root_pass="$(mkpasswd "$root_pass")" # Escape all $ characters in-place crypted_root_pass="${crypted_root_pass//\$/\\\$}"
282-283
: Properly escape and substitute production-image root hash
The same escaping logic and|
delimiter are applied to the random 13-character password, ensuring that slashes or dollar signs in the generated hash don’t break thesed
substitution.Similarly, capture the raw hash then escape via parameter expansion to avoid spawning
sed
twice:raw_hash="$(mkpasswd "$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 13)")" crypted_root_pass="${raw_hash//\$/\\\$}"
Summary by CodeRabbit