Skip to content

Commit

Permalink
chore(deps): Replace atty with is-terminal
Browse files Browse the repository at this point in the history
`atty` seems to be unmaintained and vulnerable to GHSA-g98v-hv3f-hcfr.
I followed `clap`'s lead and replaced with `is-termianl`
(clap-rs/clap#4249).

Signed-off-by: Jesse Szwedko <jesse.szwedko@datadoghq.com>
  • Loading branch information
jszwedko committed Oct 27, 2023
1 parent c23efce commit f27a475
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ mlua = { version = "0.9.1", default-features = false, features = ["lua54", "send
windows-service = "0.6.0"

[target.'cfg(unix)'.dependencies]
atty = { version = "0.2.14", default-features = false }
is-terminal = { version = "0.4", default-features = false }
nix = { version = "0.26.2", default-features = false, features = ["socket", "signal"] }

[build-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,10 @@ pub enum Color {

impl Color {
pub fn use_color(&self) -> bool {
use is_terminal::IsTerminal;
match self {
#[cfg(unix)]
Color::Auto => atty::is(atty::Stream::Stdout),
Color::Auto => std::io::stdout().is_terminal(),
#[cfg(windows)]
Color::Auto => false, // ANSI colors are not supported by cmd.exe
Color::Always => true,
Expand Down
5 changes: 4 additions & 1 deletion src/test_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ pub fn next_addr_v6() -> SocketAddr {

pub fn trace_init() {
#[cfg(unix)]
let color = atty::is(atty::Stream::Stdout);
let color = {
use is_terminal::IsTerminal;
std::io::stdout().is_terminal()
};
// Windows: ANSI colors are not supported by cmd.exe
// Color is false for everything except unix.
#[cfg(not(unix))]
Expand Down
2 changes: 1 addition & 1 deletion vdev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false

[dependencies]
anyhow = "1.0.75"
atty = "0.2.14"
is-terminal = { version = "0.4" }
cached = "0.46.0"
chrono = { version = "0.4.31", default-features = false, features = ["serde", "clock"] }
clap = { version = "4.4.7", features = ["derive"] }
Expand Down
3 changes: 2 additions & 1 deletion vdev/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use std::process::{Command, Output};
use std::{collections::BTreeMap, fmt::Debug, fs, io::ErrorKind, path::Path};

use anyhow::{Context as _, Result};
use is_terminal::IsTerminal;
use once_cell::sync::Lazy;
use serde::Deserialize;
use serde_json::Value;

pub static IS_A_TTY: Lazy<bool> = Lazy::new(|| atty::is(atty::Stream::Stdout));
pub static IS_A_TTY: Lazy<bool> = Lazy::new(|| std::io::stdout().is_terminal());

#[derive(Deserialize)]
pub struct CargoTomlPackage {
Expand Down

0 comments on commit f27a475

Please sign in to comment.