-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PM-15934] Add agent-forwarding detection and git signing detection parsers #12371
Open
quexten
wants to merge
16
commits into
main
Choose a base branch
from
km/forwarding-and-signing-parsers
base: main
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
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
53f2b6d
Add agent-forwarding detection and git signing detection parsers
quexten 761c28c
Cleanup
quexten 4236ae9
Pin russh version
quexten 088a72b
Merge branch 'main' into km/forwarding-and-signing-parsers
quexten 29ccb47
Run cargo fmt
quexten 684862d
Merge branch 'km/forwarding-and-signing-parsers' of github.com:bitwarโฆ
quexten a530f91
Fix build
quexten d4796d1
Update apps/desktop/desktop_native/core/src/ssh_agent/mod.rs
quexten f5472df
Pass through entire namespace
quexten 4c78e3b
Move to bytes crate
quexten fac5e38
Merge branch 'main' into km/forwarding-and-signing-parsers
quexten e456a91
Fix clippy errors
quexten 6413645
Fix clippy warning
quexten 7956ff5
Run cargo fmt
quexten 9053721
Fix build
quexten 18e50de
Merge branch 'main' into km/forwarding-and-signing-parsers
quexten 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
41 changes: 41 additions & 0 deletions
41
apps/desktop/desktop_native/core/src/ssh_agent/request_parser.rs
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,41 @@ | ||
use bytes::{Buf, Bytes}; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct SshSigRequest { | ||
pub namespace: String, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct SignRequest {} | ||
|
||
#[derive(Debug)] | ||
pub(crate) enum SshAgentSignRequest { | ||
SshSigRequest(SshSigRequest), | ||
SignRequest(SignRequest), | ||
} | ||
|
||
pub(crate) fn parse_request(data: &[u8]) -> Result<SshAgentSignRequest, anyhow::Error> { | ||
let mut data = Bytes::copy_from_slice(data); | ||
let magic_header = "SSHSIG"; | ||
let header = data.split_to(magic_header.len()); | ||
|
||
// sshsig; based on https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.sshsig | ||
if header == magic_header.as_bytes() { | ||
let _version = data.get_u32(); | ||
|
||
// read until null byte | ||
let namespace = data | ||
.into_iter() | ||
.take_while(|&x| x != 0) | ||
.collect::<Vec<u8>>(); | ||
let namespace = | ||
String::from_utf8(namespace).map_err(|_| anyhow::anyhow!("Invalid namespace"))?; | ||
|
||
Ok(SshAgentSignRequest::SshSigRequest(SshSigRequest { | ||
namespace, | ||
})) | ||
} else { | ||
// regular sign request | ||
Ok(SshAgentSignRequest::SignRequest(SignRequest {})) | ||
} | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Nice! Looks better as a separate struct this way, at least we don't get
arg0
,arg1
,arg2
parameters.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.
Hehe, yeah. Meant to do it sometime either-way, but in this case clippy complained.