Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
T
trespass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Neuser
trespass
Commits
de10fa7b
Commit
de10fa7b
authored
5 months ago
by
Sebastian Neuser
Browse files
Options
Downloads
Patches
Plain Diff
fix(lint): Follow remaining clippy suggestions
parent
3933fcb2
No related branches found
No related tags found
1 merge request
!2
CI pipeline
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/cli.rs
+1
-1
1 addition, 1 deletion
src/cli.rs
src/daemon.rs
+1
-1
1 addition, 1 deletion
src/daemon.rs
src/recipient.rs
+3
-3
3 additions, 3 deletions
src/recipient.rs
src/repository.rs
+6
-6
6 additions, 6 deletions
src/repository.rs
src/secret.rs
+9
-9
9 additions, 9 deletions
src/secret.rs
with
20 additions
and
20 deletions
src/cli.rs
+
1
−
1
View file @
de10fa7b
...
...
@@ -283,7 +283,7 @@ pub fn interpret(command: &Command, cached_keys: &mut Vec<recipient::SshKeypair>
}
}
pub
fn
interpret_input
(
input
:
&
S
tr
ing
,
cached_keys
:
&
mut
Vec
<
recipient
::
SshKeypair
>
)
->
Vec
<
String
>
{
pub
fn
interpret_input
(
input
:
&
s
tr
,
cached_keys
:
&
mut
Vec
<
recipient
::
SshKeypair
>
)
->
Vec
<
String
>
{
let
mut
tokens
:
Vec
<
String
>
=
split
(
input
)
.unwrap
();
tokens
.insert
(
0
,
String
::
from
(
"trespass"
));
...
...
This diff is collapsed.
Click to expand it.
src/daemon.rs
+
1
−
1
View file @
de10fa7b
...
...
@@ -16,7 +16,7 @@ fn handle_client(mut stream: UnixStream, cached_keys: &mut Vec<SshKeypair>) -> R
stream
.read_to_string
(
&
mut
incoming
)
?
;
println!
(
"Executing {}"
,
incoming
);
for
line
in
incoming
.lines
()
{
for
output
in
cli
::
interpret_input
(
&
line
.to_owned
()
,
cached_keys
)
{
for
output
in
cli
::
interpret_input
(
line
,
cached_keys
)
{
stream
.write_all
(
format!
(
"{}
\n
"
,
output
)
.as_bytes
())
?
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/recipient.rs
+
3
−
3
View file @
de10fa7b
...
...
@@ -27,7 +27,7 @@ pub struct SshKeypair {
}
impl
SshKeypair
{
pub
fn
from
(
key
:
&
S
tr
ing
)
->
Self
{
pub
fn
from
(
key
:
&
s
tr
)
->
Self
{
let
mut
tokens
=
key
.split
(
' '
);
let
mut
result
=
SshKeypair
{
name
:
None
,
...
...
@@ -82,7 +82,7 @@ fn list_recipients(path: &PathBuf, verbose: bool) -> Result<Vec<SshKeypair>> {
}
pub
fn
add
(
path
:
&
PathBuf
,
pubkey
:
&
S
tr
ing
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
pub
fn
add
(
path
:
&
PathBuf
,
pubkey
:
&
s
tr
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
Vec
<
String
>>
{
let
mut
results
=
vec!
[];
let
new_key
=
SshKeypair
::
from
(
pubkey
);
...
...
@@ -124,7 +124,7 @@ pub fn print(path: &PathBuf) -> Result<Vec<String>> {
return
Ok
(
list_recipients
(
path
,
true
)
?
.iter
()
.map
(|
key
|
format!
(
"{}"
,
key
))
.collect
())
}
pub
fn
remove
(
path
:
&
PathBuf
,
pubkey
:
&
S
tr
ing
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
pub
fn
remove
(
path
:
&
PathBuf
,
pubkey
:
&
s
tr
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
Vec
<
String
>>
{
let
mut
results
=
vec!
[];
let
obsolete_key
=
SshKeypair
::
from
(
pubkey
);
...
...
This diff is collapsed.
Click to expand it.
src/repository.rs
+
6
−
6
View file @
de10fa7b
use
std
::
process
::
Command
;
use
std
::
path
::
PathBuf
;
use
std
::
path
::
{
Path
,
PathBuf
}
;
use
anyhow
::{
Result
,
anyhow
};
use
gix
::
progress
::
Discard
;
...
...
@@ -22,8 +22,8 @@ fn execute_command(args: &Vec<&str>, repo: Option<&PathBuf>) -> Result<Vec<Strin
return
Ok
(
output
.lines
()
.map
(
String
::
from
)
.collect
());
}
fn
resolve_submodule_path
(
path
:
&
Path
Buf
)
->
Result
<
(
String
,
PathBuf
)
>
{
let
mut
file_path
=
path
.
clone
();
fn
resolve_submodule_path
(
path
:
&
Path
)
->
Result
<
(
String
,
PathBuf
)
>
{
let
mut
file_path
=
path
.
to_path_buf
();
let
mut
repo_path
=
root_path
();
if
let
Some
(
submodules
)
=
gix
::
open
(
root_path
())
?
.submodules
()
?
{
for
submodule
in
submodules
{
...
...
@@ -57,7 +57,7 @@ fn update_submodule(path: PathBuf) -> Result<()> {
// Public API
//
pub
fn
add
(
path
:
&
Path
Buf
,
url
:
&
String
)
->
Result
<
Vec
<
String
>>
{
pub
fn
add
(
path
:
&
Path
,
url
:
&
String
)
->
Result
<
Vec
<
String
>>
{
let
mut
output
=
vec!
[];
// This appears to be unsupported - maybe check if it works later or implement it there:
// output.append(&mut execute_command(vec!["submodule", "add", url, path.to_str().unwrap()])?);
...
...
@@ -111,7 +111,7 @@ pub fn path(path: &PathBuf) -> PathBuf {
root_path
()
.join
(
path
)
}
pub
fn
relative_path
(
path
:
&
Path
Buf
)
->
PathBuf
{
pub
fn
relative_path
(
path
:
&
Path
)
->
PathBuf
{
return
path
.strip_prefix
(
root_path
())
.unwrap
()
.to_path_buf
();
}
...
...
@@ -136,7 +136,7 @@ pub fn sync() -> Result<Vec<String>> {
Ok
(
output
)
}
pub
fn
update_file
(
path
:
&
Path
Buf
,
message
:
String
)
->
Result
<
Vec
<
String
>>
{
pub
fn
update_file
(
path
:
&
Path
,
message
:
String
)
->
Result
<
Vec
<
String
>>
{
let
(
file_path
,
repo_path
)
=
resolve_submodule_path
(
path
)
?
;
execute_command
(
&
vec!
[
"stage"
,
&
file_path
],
Some
(
&
repo_path
))
?
;
execute_command
(
&
vec!
[
"commit"
,
"-m"
,
message
.as_str
()],
Some
(
&
repo_path
))
?
;
...
...
This diff is collapsed.
Click to expand it.
src/secret.rs
+
9
−
9
View file @
de10fa7b
use
std
::
env
::
var
;
use
std
::
fs
::{
File
,
read
,
create_dir_all
,
read_to_string
,
write
};
use
std
::
io
::{
BufReader
,
Read
,
Seek
,
SeekFrom
,
Write
};
use
std
::
path
::
PathBuf
;
use
std
::
path
::
{
Path
,
PathBuf
}
;
use
std
::
process
::
Command
;
use
std
::
str
::
FromStr
;
use
std
::
thread
::
spawn
;
...
...
@@ -58,8 +58,8 @@ fn copy_to_clipboard(target: LinuxClipboardKind, secret: String) -> Result<()> {
Ok
(())
}
fn
decrypt
(
path
:
&
Path
Buf
,
identities
:
&
Vec
<
impl
Identity
>
)
->
Result
<
String
>
{
let
encrypted
=
read
(
repository
::
path
(
path
))
?
;
fn
decrypt
(
path
:
&
Path
,
identities
:
&
[
impl
Identity
]
)
->
Result
<
String
>
{
let
encrypted
=
read
(
repository
::
path
(
&
path
.to_path_buf
()
))
?
;
let
decryptor
=
match
Decryptor
::
new
(
&
encrypted
[
..
])
?
{
Decryptor
::
Recipients
(
d
)
=>
d
,
_
=>
unreachable!
(),
...
...
@@ -90,7 +90,7 @@ fn encrypt(path: &PathBuf, secret: &String, recipient_keys: &Vec<SshKeypair>, ms
Ok
(())
}
fn
fill_in_recipients
(
path
:
&
Path
Buf
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
()
>
{
fn
fill_in_recipients
(
path
:
&
Path
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
()
>
{
for
rcpt
in
list_recipients
(
path
)
?
{
let
found
=
cached_keys
.iter
()
.find
(|
key
|
rcpt
.algorithm
==
key
.algorithm
&&
rcpt
.pubkey
==
key
.pubkey
...
...
@@ -102,7 +102,7 @@ fn fill_in_recipients(path: &PathBuf, cached_keys: &mut Vec<SshKeypair>) -> Resu
Ok
(())
}
fn
get_ssh_identities
(
recipients
:
&
mut
Vec
<
SshKeypair
>
,
limit
:
usize
)
->
Result
<
Vec
<
impl
Identity
>>
{
fn
get_ssh_identities
(
recipients
:
&
mut
[
SshKeypair
]
,
limit
:
usize
)
->
Result
<
Vec
<
impl
Identity
>>
{
let
mut
identities
=
vec!
[];
let
pattern
=
config
::
get
()
.ssh_path
()
.join
(
"id_ed25519*.pub"
);
for
candidate
in
glob
(
pattern
.to_str
()
.unwrap
())
.expect
(
"Could not find SSH keys"
)
{
...
...
@@ -146,12 +146,12 @@ fn get_ssh_identities(recipients: &mut Vec<SshKeypair>, limit: usize) -> Result<
Ok
(
identities
)
}
fn
list_recipients
(
path
:
&
Path
Buf
)
->
Result
<
Vec
<
SshKeypair
>>
{
fn
list_recipients
(
path
:
&
Path
)
->
Result
<
Vec
<
SshKeypair
>>
{
let
collection
=
path
.parent
()
.unwrap
()
.to_path_buf
();
recipient
::
list
(
&
collection
)
}
fn
load
(
path
:
&
Path
Buf
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
String
>
{
fn
load
(
path
:
&
Path
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
String
>
{
let
num
=
if
cached_keys
.is_empty
()
{
1
}
else
{
0
};
fill_in_recipients
(
path
,
cached_keys
)
?
;
let
identities
=
get_ssh_identities
(
cached_keys
,
num
)
?
;
...
...
@@ -224,7 +224,7 @@ pub fn add(path: &PathBuf,
Ok
(
vec!
[])
}
pub
fn
clip
(
path
:
&
Path
Buf
,
both
:
&
bool
,
part
:
&
Option
<
String
>
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
pub
fn
clip
(
path
:
&
Path
,
both
:
&
bool
,
part
:
&
Option
<
String
>
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
Vec
<
String
>>
{
let
mut
feedback
=
vec!
[];
let
mut
secret
=
load
(
path
,
cached_keys
)
?
;
...
...
@@ -331,7 +331,7 @@ pub fn reencrypt(path: &PathBuf, recipients: Vec<SshKeypair>, cached_keys: &mut
Ok
(())
}
pub
fn
show
(
path
:
&
Path
Buf
,
clip
:
&
bool
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
Vec
<
String
>>
{
pub
fn
show
(
path
:
&
Path
,
clip
:
&
bool
,
cached_keys
:
&
mut
Vec
<
SshKeypair
>
)
->
Result
<
Vec
<
String
>>
{
let
secret
=
load
(
path
,
cached_keys
)
?
;
if
*
clip
{
copy_to_clipboard
(
LinuxClipboardKind
::
Clipboard
,
secret
.clone
())
?
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment