Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ jobs:
run: |
which cargo-tarpaulin || cargo install cargo-tarpaulin
cargo tarpaulin

- name: Check licenses
run: |
which cargo-deny || cargo install cargo-deny
cargo deny check licenses
18 changes: 18 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[licenses]
allow = [
"Apache-2.0",
"MIT",
"MPL-2.0",
"BSD-3-Clause",
"Unicode-3.0",
]

[licenses.private]
ignore = true

[bans]
multiple-versions = "warn"

[sources]
unknown-registry = "warn"
unknown-git = "warn"
7 changes: 7 additions & 0 deletions githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -xeuo pipefail

if [ -n "$GIT_GLOBAL_HOOKS_PATH" -a -x "$GIT_GLOBAL_HOOKS_PATH/pre-commit" ]; then
$GIT_GLOBAL_HOOKS_PATH/pre-commit
fi
9 changes: 9 additions & 0 deletions githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -xeuo pipefail

input="$(cat)"

if [ -n "$GIT_GLOBAL_HOOKS_PATH" -a -x "$GIT_GLOBAL_HOOKS_PATH/pre-push" ]; then
echo -n "$input" | $GIT_GLOBAL_HOOKS_PATH/pre-push
fi
7 changes: 7 additions & 0 deletions githooks/pre-rebase
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -xeuo pipefail

if [ -n "$GIT_GLOBAL_HOOKS_PATH" -a -x "$GIT_GLOBAL_HOOKS_PATH/pre-rebase" ]; then
$GIT_GLOBAL_HOOKS_PATH/pre-rebase
fi
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ pkgs.mkShell {
buildInputs = with pkgs; [
rustup
python3
podman
];
shellHook = ''
git config set core.hooksPath githooks

rustup default stable
rustup component add rust-src
'';
Expand Down
7 changes: 2 additions & 5 deletions src/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use aes::cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit, block_padding::Pkcs7};
use rtoolbox::safe_vec::SafeVec;
use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit};

type Aes256CbcEnc = cbc::Encryptor<aes::Aes256>;
type Aes256CbcDec = cbc::Decryptor<aes::Aes256>;

pub fn encrypt(data: &[u8], key: &[u8], iv: &[u8]) -> Result<Vec<u8>, ()> {
Ok(
Aes256CbcEnc::new(key.into(), iv.into())
.encrypt_padded_vec_mut::<Pkcs7>(data)
)
Ok(Aes256CbcEnc::new(key.into(), iv.into()).encrypt_padded_vec_mut::<Pkcs7>(data))
}

pub fn decrypt(data: &[u8], key: &[u8], iv: &[u8]) -> Result<SafeVec, ()> {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/add.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::clip::{copy_to_clipboard, paste_keys};
use crate::password;
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::password;
use std::ops::Deref;

pub fn callback_exec(
Expand Down
4 changes: 2 additions & 2 deletions src/commands/change.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::clip;
use crate::ffi;
use crate::list;
use crate::password;
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::list;
use crate::password;

pub fn callback_exec(
matches: &clap::ArgMatches,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/delete.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::list;
use crate::password;
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::list;
use crate::password;

pub fn callback_exec(
matches: &clap::ArgMatches,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/generate.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::clip::{copy_to_clipboard, paste_keys};
use crate::generate::{check_password_len, PasswordSpec};
use crate::password;
use crate::generate::{PasswordSpec, check_password_len};
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::password;

use std::ops::Deref;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/get.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::clip;

use crate::io::CliInputOutput;
use crate::list;
use crate::password;
use crate::io::CliInputOutput;

pub fn callback_exec(
matches: &clap::ArgMatches,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::list;
use crate::password;
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::list;
use crate::password;

pub fn callback_exec(
_matches: &clap::ArgMatches,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/regenerate.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::clip;
use crate::ffi;
use crate::generate::{check_password_len, PasswordSpec};
use crate::list;
use crate::password;
use crate::generate::{PasswordSpec, check_password_len};
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::list;
use crate::password;

pub fn callback_exec(
matches: &clap::ArgMatches,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/rename.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::ffi;
use crate::list;
use crate::password;
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::list;
use crate::password;

pub fn callback_exec(
matches: &clap::ArgMatches,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/set_master_password.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::password;
use crate::io::CliInputOutput;
use crate::io::OutputType;
use crate::password;
use std::ops::Deref;

pub fn callback_exec(
Expand Down
7 changes: 1 addition & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ fn main() {

std::process::exit(rooster::main_with_args(
args_refs.as_slice(),
&mut RegularInputOutput::new(
stdin.lock(),
stdout.lock(),
stderr.lock(),
false,
),
&mut RegularInputOutput::new(stdin.lock(), stdout.lock(), stderr.lock(), false),
&rooster_file_path,
));
}
24 changes: 15 additions & 9 deletions src/quale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// https://crates.io/crates/quale
// It has been modified here to support Windows.

use std::{env, ffi, path, fs};
use std::{env, ffi, fs, path};

pub fn which<S: AsRef<ffi::OsStr>>(name: S) -> Option<path::PathBuf> {
let name: &ffi::OsStr = name.as_ref();
Expand Down Expand Up @@ -39,14 +39,19 @@ pub fn which<S: AsRef<ffi::OsStr>>(name: S) -> Option<path::PathBuf> {
#[cfg(windows)]
mod windows {
use std::fs;
use std::os::windows::ffi::OsStrExt;
use std::ptr::null_mut;
use windows::core::PCWSTR;
use windows::Win32::System::WindowsProgramming::{SCS_32BIT_BINARY, SCS_64BIT_BINARY, SCS_DOS_BINARY, SCS_OS216_BINARY, SCS_PIF_BINARY, SCS_POSIX_BINARY, SCS_WOW_BINARY};
use windows::Win32::Storage::FileSystem::GetBinaryTypeW;
use std::os::windows::ffi::OsStrExt;
use windows::Win32::System::WindowsProgramming::{
SCS_32BIT_BINARY, SCS_64BIT_BINARY, SCS_DOS_BINARY, SCS_OS216_BINARY, SCS_PIF_BINARY,
SCS_POSIX_BINARY, SCS_WOW_BINARY,
};
use windows::core::PCWSTR;

pub fn is_executable(file: &fs::DirEntry) -> bool {
let windows_str = file.path().as_os_str()
let windows_str = file
.path()
.as_os_str()
.encode_wide()
.chain(std::iter::once(0))
.collect::<Vec<u16>>();
Expand All @@ -67,17 +72,18 @@ mod windows {
}

match binary_type {
SCS_32BIT_BINARY | SCS_64BIT_BINARY | SCS_DOS_BINARY | SCS_OS216_BINARY | SCS_PIF_BINARY | SCS_POSIX_BINARY | SCS_WOW_BINARY => true,
_ => false
SCS_32BIT_BINARY | SCS_64BIT_BINARY | SCS_DOS_BINARY | SCS_OS216_BINARY
| SCS_PIF_BINARY | SCS_POSIX_BINARY | SCS_WOW_BINARY => true,
_ => false,
}
}
}

#[cfg(unix)]
mod unix {
use std::os::unix::fs::PermissionsExt;
use std::fs;
use std::ffi;
use std::fs;
use std::os::unix::fs::PermissionsExt;

pub fn is_executable(file: &fs::DirEntry) -> bool {
// Don't use `file.metadata()` directly since it doesn't follow symlinks.
Expand Down
2 changes: 1 addition & 1 deletion tests/test-commands-add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn test_command_add() {
let result = main_with_args(
&["rooster", "add", "-s", "Youtube", "yt@example.com"],
&mut inout,
&rooster_file
&rooster_file,
);
assert_eq!(0, result);

Expand Down
Loading