-
Notifications
You must be signed in to change notification settings - Fork 169
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
640 triaging issue #642
Open
alessandro-fazzi
wants to merge
2
commits into
rewrite_for_6.0
Choose a base branch
from
640_triageing_issue
base: rewrite_for_6.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
640 triaging issue #642
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
global: | ||
sql_adapter: "wpcli" | ||
local: | ||
wordpress_path: "~/dev/sites/your_site" | ||
remote: | ||
vhost: "http://secrets.example.com" | ||
wordpress_path: "/var/www/your_site" | ||
database: | ||
name: "database_name" | ||
user: "user" | ||
password: "R4ndom#+Str1nG" | ||
host: "remote_database_host" | ||
ssh: | ||
user: "user" | ||
password: "ssh_password" | ||
host: "ssh_host" | ||
port: 30000 | ||
ftp: | ||
user: "user" | ||
password: "ftp_password" | ||
host: "ftp_host" | ||
foo: | ||
vhost: "https://foo.bar" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Where is the code that creates this commandline normally? The escaping may happen when the commandline is constructed.
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.
Disclaimer: I'm not a ruby programmer. I may say things that are wrong, because I misunderstood the code.
found it:here
(the same is happening a few lines down and here)
So there does happen shellescaping of the password for the commandline, not just for the regex to filter secrets.
So the regex used for substituting secrets should search for shellescaped secrects!
Another potential issue:
Shellwords.escape() escapes for the bourne shell, but you are using system(), which calls whatever the users current shell is. So it might break for unusual shells.
Additionally, system() is difficult to use safely and correctly, when the passed argument is constructed dynamically from user input.
I recommend using fork() followed by exec(), in the second or third form in the documentation, i.e. pass an array of strings.
That way you don't need to worry about string escaping! You just pass an array of the used arguments.
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.
No problem; you'd be welcome anyway :)
This seems a good catch to me! But it seems more an endemic problem the fact we're logging escaped commands more than thinking about searching for escaped secrets. I have to tinker a bit on this.
Why do you say
system
will call «whatever the user's current shell is»? In my knowledge system calls, in any form, should use the standard shell; which means, in *nix systems,/bin/sh
. Would you mind to point me where you found that information? TIAIf your point is that it's difficult to use
system
due to the occurring shell expansion, keep in mind that the method has the same overloaded signature asexec
. If that was not your point then I'm not catching it, sorry.Instead I'm not prone to introduce threaded patterns (
fork
) because I've not enough knowledge to control them and sincerly I do not take what benefit it should bring on the table here. But I'm not interested in preventing a discussion about that if I am missing something you consider important :)Thanks for the effort; I'll be on this as soon as I'll have a chunk of spare time
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.
The system() documentation refers to exec(), which uses /bin/sh by default, but only after looking the environment variable
RUBYSHELL
.(So I was wrong/unclear, but am right now :))
I did not notice that one could use system() without a subshell. So, one could just change to use system() with each argument separately passed.
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.
Thanks for the patience and feedback.
I've never used that signature of
#system
, but my feeling is that it could be more functional and more straight to read/write.I'll deepen on it a bit and will try to bring out something useful. For sure I won't target the 5.x version BTW.
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.
If you want to do this in sometime, don't just forget it, because the stale bot closed the issue.