Skip to content

Commit 8b43363

Browse files
authored
chore(deps): Replace atty with is-terminal (#18966)
`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>
1 parent 3b85b48 commit 8b43363

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ mlua = { version = "0.9.1", default-features = false, features = ["lua54", "send
340340
windows-service = "0.6.0"
341341

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

346346
[build-dependencies]

src/cli.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,10 @@ pub enum Color {
331331

332332
impl Color {
333333
pub fn use_color(&self) -> bool {
334+
use is_terminal::IsTerminal;
334335
match self {
335336
#[cfg(unix)]
336-
Color::Auto => atty::is(atty::Stream::Stdout),
337+
Color::Auto => std::io::stdout().is_terminal(),
337338
#[cfg(windows)]
338339
Color::Auto => false, // ANSI colors are not supported by cmd.exe
339340
Color::Always => true,

src/test_util/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ pub fn next_addr_v6() -> SocketAddr {
122122

123123
pub fn trace_init() {
124124
#[cfg(unix)]
125-
let color = atty::is(atty::Stream::Stdout);
125+
let color = {
126+
use is_terminal::IsTerminal;
127+
std::io::stdout().is_terminal()
128+
};
126129
// Windows: ANSI colors are not supported by cmd.exe
127130
// Color is false for everything except unix.
128131
#[cfg(not(unix))]

vdev/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ publish = false
99

1010
[dependencies]
1111
anyhow = "1.0.75"
12-
atty = "0.2.14"
12+
is-terminal = { version = "0.4" }
1313
cached = "0.46.0"
1414
chrono = { version = "0.4.31", default-features = false, features = ["serde", "clock"] }
1515
clap = { version = "4.4.7", features = ["derive"] }

vdev/src/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ use std::process::{Command, Output};
33
use std::{collections::BTreeMap, fmt::Debug, fs, io::ErrorKind, path::Path};
44

55
use anyhow::{Context as _, Result};
6+
use is_terminal::IsTerminal;
67
use once_cell::sync::Lazy;
78
use serde::Deserialize;
89
use serde_json::Value;
910

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

1213
#[derive(Deserialize)]
1314
pub struct CargoTomlPackage {

0 commit comments

Comments
 (0)