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

Allow conversion of std::process::Command into a openssh::Command given a openssh::Session. #112

Merged
merged 27 commits into from
Jul 28, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e314422
Add OverSsh trait to allow conversion of std::process::Command into a…
aalekhpatel07 Jan 31, 2023
d9ba8d3
Add a doc comment and example usage.
aalekhpatel07 Jan 31, 2023
dd64633
Add tests for OverSsh's with_session
aalekhpatel07 Jan 31, 2023
9743a5e
Use raw_command and raw_args. Refactor the name to 'over_ssh'.
aalekhpatel07 Jan 31, 2023
0a69ed1
Remove a dangling test import. Use better name for test.
aalekhpatel07 Jan 31, 2023
974cd52
Clean up doc comment.
aalekhpatel07 Jan 31, 2023
cca22b1
Apply suggestions of code review.
aalekhpatel07 Jan 31, 2023
66cecba
Update src/command.rs
aalekhpatel07 Jan 31, 2023
511c62c
Apply more suggestions from the code review.
aalekhpatel07 Jan 31, 2023
d14a4c2
Apply more suggestions from the code review.
aalekhpatel07 Jan 31, 2023
32a8960
Update src/command.rs
aalekhpatel07 Jan 31, 2023
08b77a5
Update src/lib.rs
aalekhpatel07 Jan 31, 2023
5d9a112
Update src/escape.rs
aalekhpatel07 Jan 31, 2023
7d84871
Apply more suggestions. Add a test for non-utf8 chars for escape.
aalekhpatel07 Jan 31, 2023
c4baafd
Slight refactor of escape.
CdnCentreForChildProtection Jan 31, 2023
7e84beb
Run cargo clippy --fix and persist all modifications to escape.rs
CdnCentreForChildProtection Jan 31, 2023
7fcfaf2
Apply rustfmt to command.rs and escape.rs
CdnCentreForChildProtection Jan 31, 2023
13d865a
Lint over_session test
CdnCentreForChildProtection Jan 31, 2023
c4ded38
Update src/escape.rs
aalekhpatel07 Feb 1, 2023
67d0885
Update src/escape.rs
aalekhpatel07 Feb 1, 2023
6970753
Update src/escape.rs
aalekhpatel07 Feb 1, 2023
8207907
Apply more suggestions.
aalekhpatel07 Feb 6, 2023
10687fb
Rustfmt fix.
aalekhpatel07 Feb 6, 2023
020366a
Fix a doctest for overssh.
aalekhpatel07 Feb 11, 2023
6842e5a
Add a test for overssh that requires escaping the argument passed to …
aalekhpatel07 Feb 11, 2023
e09d2fd
Update overssh require-escaping-arguments test to contain a space.
aalekhpatel07 Feb 11, 2023
f30d34e
Apply rustfmt to tests/openssh.rs
aalekhpatel07 Feb 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run cargo clippy --fix and persist all modifications to escape.rs
Signed-off-by: Aalekh Patel <aalekh@protectchildren.ca>
  • Loading branch information
CdnCentreForChildProtection authored and NobodyXu committed Jul 28, 2023
commit 7e84bebfa56f6237f56f5b54d98520e8e17a6c9e
7 changes: 2 additions & 5 deletions src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use std::{


fn whitelisted(byte: u8) -> bool {
match byte {
b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' | b'_' | b'=' | b'/' | b',' | b'.' | b'+' => true,
_ => false,
}
matches!(byte, b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' | b'_' | b'=' | b'/' | b',' | b'.' | b'+')
}

/// Escape characters that may have special meaning in a shell, including spaces.
Expand All @@ -27,7 +24,7 @@ fn whitelisted(byte: u8) -> bool {
///
/// [`shell-escape::unix::escape`]: https://docs.rs/shell-escape/latest/src/shell_escape/lib.rs.html#101
///
pub fn escape(s: &OsStr) -> Cow<'_, OsStr> {
pub(crate) fn escape(s: &OsStr) -> Cow<'_, OsStr> {
let as_bytes = s.as_bytes();
let all_whitelisted = as_bytes.iter().copied().all(whitelisted);

Expand Down