Skip to content

Commit

Permalink
fir code by cargo clippy
Browse files Browse the repository at this point in the history
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
  • Loading branch information
sat0ken committed Oct 4, 2024
1 parent efcaef1 commit a2c7dc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions experiment/seccomp/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use seccomp::{
instruction::{self, *},
instruction::{*},
seccomp::{NotifyFd, Seccomp},
};

Expand Down Expand Up @@ -98,7 +98,7 @@ async fn main() -> Result<()> {
Rule::new("mkdir".parse()?,0, syscall_args!(), true)
]
};
let mut seccomp = Seccomp {filters: Vec::from(inst_data)};
let seccomp = Seccomp {filters: Vec::from(inst_data)};

tokio::spawn(async move {
tokio::signal::ctrl_c()
Expand Down
11 changes: 5 additions & 6 deletions experiment/seccomp/src/seccomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use nix::{
unistd,
};
use syscalls::{SyscallArgs};
use syscalls::Sysno::bpf;
use crate::instruction::{*};
use crate::instruction::{Arch, Instruction, SECCOMP_IOC_MAGIC};

Expand Down Expand Up @@ -204,13 +203,13 @@ struct Filters {

fn get_syscall_number(arc: &Arch, name: &str) -> Option<u64> {
match arc {
&Arch::X86 => {
Arch::X86 => {
match syscalls::x86_64::Sysno::from_str(name) {
Ok(syscall) => Some(syscall as u64),
Err(_) => None,
}
},
&Arch::AArch64 => {
Arch::AArch64 => {
match syscalls::aarch64::Sysno::from_str(name) {
Ok(syscall) => Some(syscall as u64),
Err(_) => None,
Expand All @@ -235,7 +234,7 @@ impl From<InstructionData> for Vec<Instruction> {
}

bpf_prog.append(&mut vec![Instruction::stmt(BPF_RET | BPF_K, SECCOMP_RET_ALLOW)]);
return bpf_prog;
bpf_prog
}
}

Expand All @@ -258,7 +257,7 @@ impl Rule {
}

pub fn to_instruction(arch: &Arch, action: u32, rule: &Rule) -> Vec<Instruction> {
let mut bpf_prog = gen_validate(&arch);
let mut bpf_prog = gen_validate(arch);
bpf_prog.append(&mut vec![Instruction::stmt(BPF_LD | BPF_W | BPF_ABS, 0)]);
bpf_prog.append(&mut vec![Instruction::jump(BPF_JMP | BPF_JEQ | BPF_K, 0, 1,
get_syscall_number(arch, &rule.syscall).unwrap() as c_uint)]);
Expand All @@ -272,6 +271,6 @@ impl Rule {
} else {
bpf_prog.append(&mut vec![Instruction::stmt(BPF_RET | BPF_K, action)]);
}
return bpf_prog
bpf_prog
}
}

0 comments on commit a2c7dc8

Please sign in to comment.