From 77231cb1be056f5df0ba29955566b1784ea3fa05 Mon Sep 17 00:00:00 2001 From: nain-F49FF806 <126972030+nain-F49FF806@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:43:21 +0200 Subject: [PATCH] Fix: Remove dependency on unmaintained `atty` (#10) atty is unmaintained for a while. and github dependabot says there is a detected vulnerability in it. So let's use new IsTerminal trait from stdlib instead --- Cargo.lock | 1 - Cargo.toml | 1 - src/main.rs | 5 +++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a25dadd..aecc6f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -777,7 +777,6 @@ name = "pbcli" version = "2.3.1" dependencies = [ "aes-gcm", - "atty", "base64", "bs58", "clap", diff --git a/Cargo.toml b/Cargo.toml index 6506455..b3e92d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,6 @@ crypto-mac = "0.11.1" hmac = "0.11.0" sha2 = "0.9.8" url = { version = "2.2.2", features = ["serde"] } -atty = "0.2.14" rand_chacha = "0.3.1" dialoguer = "0.9.0" data-url = "0.1.1" diff --git a/src/main.rs b/src/main.rs index 3012017..6b5da02 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,10 +6,11 @@ use pbcli::opts::Opts; use pbcli::privatebin::DecryptedPaste; use pbcli::util::check_filesize; use serde_json::Value; +use std::io::IsTerminal; use std::io::{Read, Write}; fn get_stdin() -> std::io::Result { - if atty::is(atty::Stream::Stdin) { + if std::io::stdin().is_terminal() { return Ok("".into()); } let mut buffer = String::new(); @@ -43,7 +44,7 @@ fn handle_get(opts: &Opts) -> PbResult<()> { match paste.decrypt(key) { Ok(c) => content = c, Err(err) => { - if !atty::is(atty::Stream::Stdin) { + if !std::io::stdin().is_terminal() { return Err(err); }