Skip to content
Open
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
2 changes: 1 addition & 1 deletion fact/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fact"
version = "0.3.0-dev"
edition = "2021"
edition = "2024"

license.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion fact/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{path::PathBuf, process::Command};

use anyhow::{bail, Context};
use anyhow::{Context, bail};

fn main() -> anyhow::Result<()> {
println!("cargo::rerun-if-changed=../.git/HEAD");
Expand Down
2 changes: 1 addition & 1 deletion fact/src/bpf/checks.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Context;
use aya::{programs::Lsm, Btf};
use aya::{Btf, programs::Lsm};
use log::debug;

pub(super) struct Checks {
Expand Down
12 changes: 6 additions & 6 deletions fact/src/bpf/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{io, path::PathBuf};

use anyhow::{bail, Context};
use anyhow::{Context, bail};
use aya::{
maps::{HashMap, LpmTrie, MapData, PerCpuArray, RingBuf},
programs::{lsm::LsmLink, Program},
Btf, Ebpf,
maps::{HashMap, LpmTrie, MapData, PerCpuArray, RingBuf},
programs::{Program, lsm::LsmLink},
};
use checks::Checks;
use globset::{Glob, GlobSet, GlobSetBuilder};
Expand All @@ -18,7 +18,7 @@ use tokio::{

use crate::{event::Event, host_info, metrics::EventCounter};

use fact_ebpf::{event_t, inode_key_t, inode_value_t, metrics_t, path_prefix_t, LPM_SIZE_MAX};
use fact_ebpf::{LPM_SIZE_MAX, event_t, inode_key_t, inode_value_t, metrics_t, path_prefix_t};

mod checks;

Expand Down Expand Up @@ -273,8 +273,8 @@ mod bpf_tests {
use tokio::{sync::watch, time::timeout};

use crate::{
config::{reloader::Reloader, FactConfig},
event::{process::Process, EventTestData},
config::{FactConfig, reloader::Reloader},
event::{EventTestData, process::Process},
host_info,
metrics::exporter::Exporter,
};
Expand Down
10 changes: 3 additions & 7 deletions fact/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use std::{
time::Duration,
};

use anyhow::{bail, Context};
use anyhow::{Context, bail};
use clap::Parser;
use log::info;
use yaml_rust2::{yaml, Yaml, YamlLoader};
use yaml_rust2::{Yaml, YamlLoader, yaml};

pub mod reloader;
#[cfg(test)]
Expand Down Expand Up @@ -47,11 +47,7 @@ impl FactConfig {
.iter()
.filter_map(|p| {
let p = Path::new(p);
if p.exists() {
Some(p)
} else {
None
}
if p.exists() { Some(p) } else { None }
})
.map(|p| {
let content =
Expand Down
4 changes: 2 additions & 2 deletions fact/src/config/reloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::{

use log::{debug, info, warn};
use tokio::{
sync::{watch, Notify},
sync::{Notify, watch},
task::JoinHandle,
time::interval,
};

use super::{EndpointConfig, FactConfig, GrpcConfig, CONFIG_FILES};
use super::{CONFIG_FILES, EndpointConfig, FactConfig, GrpcConfig};

pub struct Reloader {
config: FactConfig,
Expand Down
2 changes: 1 addition & 1 deletion fact/src/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::{future::Future, pin::Pin};

use http_body_util::Full;
use hyper::{
Method, Request, Response, StatusCode,
body::{Bytes, Incoming},
server::conn::http1,
service::Service,
Method, Request, Response, StatusCode,
};
use hyper_util::rt::TokioIo;
use log::{info, warn};
Expand Down
12 changes: 6 additions & 6 deletions fact/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
use globset::GlobSet;
use serde::Serialize;

use fact_ebpf::{event_t, file_activity_type_t, inode_key_t, PATH_MAX};
use fact_ebpf::{PATH_MAX, event_t, file_activity_type_t, inode_key_t};

use crate::host_info;
use process::Process;
Expand Down Expand Up @@ -43,11 +43,11 @@ fn sanitize_d_path(s: &[c_char]) -> PathBuf {

// Take the file name of the path and remove the " (deleted)" suffix
// if present.
if let Some(file_name) = p.file_name() {
if let Some(file_name) = file_name.to_string_lossy().strip_suffix(" (deleted)") {
// The file name needed to be sanitized
return p.parent().map(|p| p.join(file_name)).unwrap_or_default();
}
if let Some(file_name) = p.file_name()
&& let Some(file_name) = file_name.to_string_lossy().strip_suffix(" (deleted)")
{
// The file name needed to be sanitized
return p.parent().map(|p| p.join(file_name)).unwrap_or_default();
}

p.to_path_buf()
Expand Down
8 changes: 4 additions & 4 deletions fact/src/event/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,16 @@ mod tests {
Some("2bc55a8cae17".to_string()),
),
(
"/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podce705797_e47e_11e9_bd71_42010a000002.slice/docker-6525e65814a99d431b6978e8f8c895013176c6c58173b56639d4b020c14e6022.scope",
Some("6525e65814a9".to_string()),
"/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podce705797_e47e_11e9_bd71_42010a000002.slice/docker-6525e65814a99d431b6978e8f8c895013176c6c58173b56639d4b020c14e6022.scope",
Some("6525e65814a9".to_string()),
),
(
"/machine.slice/libpod-b6e375cfe46efa5cd90d095603dec2de888c28b203285819233040b5cf1212ac.scope/container",
Some("b6e375cfe46e".to_string()),
),
(
"/machine.slice/libpod-cbdfa0f1f08763b1963c30d98e11e1f052cb67f1e9b7c0ab8a6ca6c70cbcad69.scope/container/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-besteffort.slice/kubelet-kubepods-besteffort-pod6eab3b7b_f0a6_4bb8_bff2_d5bc9017c04b.slice/cri-containerd-5ebf11e02dbde102cda4b76bc0e3849a65f9edac7a12bdabfd34db01b9556101.scope",
Some("5ebf11e02dbd".to_string()),
"/machine.slice/libpod-cbdfa0f1f08763b1963c30d98e11e1f052cb67f1e9b7c0ab8a6ca6c70cbcad69.scope/container/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-besteffort.slice/kubelet-kubepods-besteffort-pod6eab3b7b_f0a6_4bb8_bff2_d5bc9017c04b.slice/cri-containerd-5ebf11e02dbde102cda4b76bc0e3849a65f9edac7a12bdabfd34db01b9556101.scope",
Some("5ebf11e02dbd".to_string()),
),
];

Expand Down
8 changes: 4 additions & 4 deletions fact/src/host_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ use log::{debug, warn};
use std::{
collections::HashMap,
env,
ffi::{c_char, CStr, CString},
fs::{read_to_string, File},
ffi::{CStr, CString, c_char},
fs::{File, read_to_string},
io::{BufRead, BufReader},
mem,
path::{Path, PathBuf},
sync::LazyLock,
};

use libc::{
clockid_t, statx, timespec, uname, AT_FDCWD, AT_NO_AUTOMOUNT, AT_STATX_SYNC_AS_STAT,
CLOCK_BOOTTIME, CLOCK_REALTIME, STATX_INO,
AT_FDCWD, AT_NO_AUTOMOUNT, AT_STATX_SYNC_AS_STAT, CLOCK_BOOTTIME, CLOCK_REALTIME, STATX_INO,
clockid_t, statx, timespec, uname,
};

pub fn get_host_mount() -> &'static PathBuf {
Expand Down
4 changes: 2 additions & 2 deletions fact/src/host_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ use std::{
time::Duration,
};

use anyhow::{bail, Context};
use anyhow::{Context, bail};
use aya::maps::MapData;
use fact_ebpf::{inode_key_t, inode_value_t};
use log::{debug, info, warn};
use tokio::{
sync::{broadcast, mpsc, watch, Notify},
sync::{Notify, broadcast, mpsc, watch},
task::JoinHandle,
};

Expand Down
6 changes: 3 additions & 3 deletions fact/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use std::{borrow::BorrowMut, io::Write, str::FromStr};

use anyhow::Context;
use bpf::Bpf;
use host_info::{get_distro, get_hostname, SystemInfo};
use host_info::{SystemInfo, get_distro, get_hostname};
use host_scanner::HostScanner;
use log::{debug, info, warn, LevelFilter};
use log::{LevelFilter, debug, info, warn};
use metrics::exporter::Exporter;
use tokio::{
signal::unix::{signal, SignalKind},
signal::unix::{SignalKind, signal},
sync::{mpsc, watch},
};

Expand Down
2 changes: 1 addition & 1 deletion fact/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use prometheus_client::{encoding::text::encode, registry::Registry};

use fact_ebpf::metrics_t;

use super::{kernel_metrics::KernelMetrics, Metrics};
use super::{Metrics, kernel_metrics::KernelMetrics};

#[derive(Clone)]
pub struct Exporter {
Expand Down
4 changes: 2 additions & 2 deletions fact/src/output/grpc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{sync::Arc, time::Duration};

use anyhow::{bail, Context};
use anyhow::{Context, bail};
use fact_api::file_activity_service_client::FileActivityServiceClient;
use hyper_tls::HttpsConnector;
use hyper_util::client::legacy::connect::HttpConnector;
Expand All @@ -13,8 +13,8 @@ use tokio::{
time::sleep,
};
use tokio_stream::{
wrappers::{errors::BroadcastStreamRecvError, BroadcastStream},
StreamExt,
wrappers::{BroadcastStream, errors::BroadcastStreamRecvError},
};
use tonic::transport::Channel;

Expand Down
2 changes: 1 addition & 1 deletion fact/src/pre_flight.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fs::read_to_string;

use anyhow::{bail, Context};
use anyhow::{Context, bail};

use crate::host_info::get_host_mount;

Expand Down
Loading