Skip to content

Commit d1c1f28

Browse files
committed
add: dedicated podman rules
1 parent dcfd1c5 commit d1c1f28

15 files changed

Lines changed: 238 additions & 42 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
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
@@ -1,6 +1,6 @@
11
[package]
22
name = "raudit"
3-
version = "0.22.0"
3+
version = "0.23.0"
44
edition = "2024"
55
authors = ["deoktr"]
66
license = "GPLv3"

Containerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
FROM docker.io/library/rust:1.89
22

3-
RUN rustup target add x86_64-unknown-linux-gnu && \
4-
rustup toolchain install stable-x86_64-unknown-linux-gnu
3+
RUN rustup target add x86_64-unknown-linux-gnu \
4+
&& rustup toolchain install stable-x86_64-unknown-linux-gnu
55

66
WORKDIR /src
77

8-
COPY Cargo.toml .
9-
COPY Cargo.lock .
8+
COPY Cargo.toml Cargo.lock ./
109
COPY src src
1110
RUN cargo fetch
1211

13-
CMD [ "cargo", "build", "--release", "--target=x86_64-unknown-linux-gnu", "--offline" ]
12+
CMD ["cargo", "build", "--release", "--target=x86_64-unknown-linux-gnu", "--offline"]

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634634
rAudit, a Linux security audit tool
635-
Copyright (C) 2024 - 2025 deoktr
635+
Copyright (C) 2024 - 2026 deoktr
636636

637637
This program is free software: you can redistribute it and/or modify
638638
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652652
If the program does terminal interaction, make it output a short
653653
notice like this when it starts in an interactive mode:
654654

655-
rAudit Copyright (C) 2024 - 2025 deoktr
655+
rAudit Copyright (C) 2024 - 2026 deoktr
656656
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657
This is free software, and you are welcome to redistribute it
658658
under certain conditions; type `show c' for details.

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ rAudit is a security audit tool to help you create your own security audit check
44

55
Goals:
66

7-
- Fast and reliable audits
8-
- Easy to extend and create your own checks
9-
- JSON output
10-
11-
What it is NOT:
12-
13-
- A configuration tool, no change is ever applied, just checks
14-
- A vulnerability checker, no attempts to find vulnerable versions of applications are made
7+
- Fast and reliable audits.
8+
- Easy to extend and create your own checks.
9+
- JSON output.
1510

1611
## Usage
1712

@@ -108,7 +103,7 @@ What is supported:
108103
- Kenel params.
109104
- Kernel compilation params.
110105
- Sysctl params.
111-
- Docker/Podman containers.
106+
- Docker and Podman.
112107
- Login.defs configuration.
113108
- Modprobe including blacklisted and disabled modules.
114109
- PAM rules.
@@ -220,6 +215,7 @@ Benchmark 1: ./target/release/raudit
220215
- Add documentation, both user and dev
221216
- Add option to only have `id`, `message` and `state` in JSON output of checks
222217
- Add check timeout, if they take too long just stop them, maybe even with ctrl+c?
218+
- Build in CI on release
223219

224220
## License
225221

src/check.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ static REPORT: Lazy<Mutex<Report>> = Lazy::new(|| Mutex::new(Report::default()))
3636
pub struct Report {
3737
/// List of checks
3838
checks: Vec<Check>,
39-
4039
/// Check stats
4140
stats: ReportStats,
42-
4341
/// Raudit version
4442
version: String,
4543
}
@@ -48,13 +46,10 @@ pub struct Report {
4846
pub enum CheckState {
4947
/// Check passed
5048
Passed,
51-
5249
/// Check failed
5350
Failed,
54-
5551
/// Check function execution error
5652
Error,
57-
5853
/// Check is yet to execute
5954
Waiting,
6055
}

src/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ fn add_all_checks() {
152152
rules::modprobe::add_checks();
153153
rules::mount::add_checks();
154154
rules::pam::add_checks();
155+
rules::podman::add_checks();
155156
rules::shell::add_checks();
156157
rules::sshd::add_checks();
157158
rules::sudo::add_checks();

src/docker.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
*/
1818

1919
// TODO: cache containers JSON config instead of query for all checks
20-
// TODO: check if Docker or Podman is used, to know which command we should use
2120
// TODO: check: <https://github.com/docker/docker-bench-security>
22-
// TODO: ensure all docker/podman apps inside containers are running as user
23-
// podman container inspect -l --format '{{.Id}}={{.Config.User}}'
21+
// docker container inspect -l --format '{{.Id}}={{.Config.User}}'
2422
// each line are id=user
2523
// the user should also define the group, ex: `999:999`
2624
// with uid and gid > 0 and < 1000
@@ -37,15 +35,14 @@
3735
use std::process;
3836
use std::process::Stdio;
3937

40-
use crate::{check, log_debug};
38+
use crate::{check, log_debug, log_trace};
4139

4240
/// Ensure containers are not started with `--privileged` flag.
4341
///
4442
/// Don't start containers with `--privileged`.
4543
/// Check manually with:
4644
/// docker container inspect -l --format '{{.Id}}={{.Config.CreateCommand}}'
4745
pub fn docker_not_privileged() -> check::CheckReturn {
48-
// can be docker or podman
4946
let mut cmd = process::Command::new("docker");
5047
cmd.stdin(Stdio::null());
5148
cmd.args(vec![
@@ -69,8 +66,7 @@ pub fn docker_not_privileged() -> check::CheckReturn {
6966
// remove []
7067
let cmd: Vec<&str> = create_cmd[1..create_cmd.len() - 1].split(" ").collect();
7168

72-
// debug
73-
log_debug!("{} {:?}", id, cmd);
69+
log_trace!("docker privileged {} {:?}", id, cmd);
7470

7571
if cmd.contains(&"--privileged") {
7672
Some(id.to_string())
@@ -98,7 +94,6 @@ pub fn docker_not_privileged() -> check::CheckReturn {
9894
/// check manually with:
9995
/// docker container inspect -l --format '{{.Id}}={{.Config.CreateCommand}}'
10096
pub fn docker_cap_drop() -> check::CheckReturn {
101-
// can be docker or podman
10297
let mut cmd = process::Command::new("docker");
10398
cmd.stdin(Stdio::null());
10499
cmd.args(vec![
@@ -122,8 +117,7 @@ pub fn docker_cap_drop() -> check::CheckReturn {
122117
// remove []
123118
let cap_list: Vec<&str> = cap_drop[1..cap_drop.len() - 1].split(" ").collect();
124119

125-
// debug
126-
log_debug!("{} {:?}", id, cap_list);
120+
log_trace!("docker cap {} {:?}", id, cap_list);
127121

128122
if cap_list.len() < 11 {
129123
Some(id.to_string())

src/group.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use crate::base::empty_or_missing_file;
2323
use crate::{check, log_debug, log_error};
2424

2525
const GROUP_PATH: &str = "/etc/group";
26-
2726
const SHADOW_PATH: &str = "/etc/gshadow";
2827

2928
static GROUPS: OnceLock<Groups> = OnceLock::new();

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ mod malloc;
3838
mod modprobe;
3939
mod mount;
4040
mod pam;
41+
mod podman;
4142
mod ps;
4243
mod shell;
4344
mod sshd;
@@ -65,6 +66,7 @@ mod rules {
6566
pub mod modprobe;
6667
pub mod mount;
6768
pub mod pam;
69+
pub mod podman;
6870
pub mod shell;
6971
pub mod sshd;
7072
pub mod sudo;

0 commit comments

Comments
 (0)