14 Commits

Author SHA1 Message Date
f0d7ec56b3 test
Some checks failed
Gentoo Utils / build-oci-image (push) Successful in 8s
Gentoo Utils / grep (push) Failing after 3s
Gentoo Utils / check-format (push) Successful in 7s
Gentoo Utils / docs (push) Successful in 13s
Gentoo Utils / build (push) Successful in 21s
Gentoo Utils / test (push) Successful in 26s
Gentoo Utils / fuzz (push) Successful in 5m58s
2025-12-14 19:58:58 -06:00
e34b7546a4 test 2025-12-14 19:58:58 -06:00
e12212cd2c ci: fix jobs not exiting on failure 2025-12-14 19:58:58 -06:00
104cb98d9e ci: build: remove debugging echos
ci: build: remove redundant source
2025-12-14 19:58:58 -06:00
7f59bb7c02 ci: add fuzz job
ci: fuzz: add timeout

ci: fuzz: add fuzzer timeout
2025-12-14 19:58:58 -06:00
6c0b368f6b scripts: add fuzzer helper script 2025-12-14 19:58:58 -06:00
52ce39d579 Merge pull request 'feature/remove-statics-from-parser-fuzzer' (#13) from feature/remove-statics-from-parser-fuzzer into master
All checks were successful
Gentoo Utils / check-format (push) Successful in 8s
Gentoo Utils / build (push) Successful in 20s
Gentoo Utils / test (push) Successful in 26s
Gentoo Utils / grep (push) Successful in 3s
Gentoo Utils / docs (push) Successful in 12s
Gentoo Utils / build-oci-image (push) Successful in 7s
Reviewed-on: #13
Reviewed-by: penguin <penguin@epenguin.net>
2025-12-14 19:42:50 -06:00
7348681b65 gate atom parser fuzzer debug printing
All checks were successful
Gentoo Utils / build-oci-image (push) Successful in 25s
Gentoo Utils / grep (push) Successful in 4s
Gentoo Utils / check-format (push) Successful in 22s
Gentoo Utils / docs (push) Successful in 26s
Gentoo Utils / build (push) Successful in 36s
Gentoo Utils / test (push) Successful in 40s
2025-12-15 01:09:16 +00:00
5178a7b8ea check for duplicate flags in usedeps, instead of duplicate usedeps 2025-12-15 00:37:47 +00:00
a3ff953e50 except InvalidAtom in atom.py 2025-12-15 00:36:12 +00:00
b0f68fa7e0 remove static variables from atom parser fuzzer
Stdin and Stdout are already synchronized and available to multiple
threads as needed, we don't need to hold onto instances in a static variable.
2025-12-15 00:33:35 +00:00
c25294333b use -E flag in git grep
All checks were successful
Gentoo Utils / build-oci-image (push) Successful in 17s
Gentoo Utils / grep (push) Successful in 4s
Gentoo Utils / check-format (push) Successful in 25s
Gentoo Utils / docs (push) Successful in 30s
Gentoo Utils / build (push) Successful in 40s
Gentoo Utils / test (push) Successful in 33s
2025-12-14 23:14:41 +00:00
08fac67f73 fill in todo! in match arm
All checks were successful
Gentoo Utils / build-oci-image (push) Successful in 7s
Gentoo Utils / grep (push) Successful in 3s
Gentoo Utils / test (push) Successful in 27s
Gentoo Utils / check-format (push) Successful in 8s
Gentoo Utils / docs (push) Successful in 12s
Gentoo Utils / build (push) Successful in 20s
2025-12-14 04:38:33 +00:00
06deeb3ae7 grep for todo! and dbg! in check_commands and in CI 2025-12-14 04:38:33 +00:00
5 changed files with 41 additions and 30 deletions

View File

@@ -180,3 +180,16 @@ jobs:
run: |
meson setup -Ddocs=enabled docs
ninja rustdoc -C docs
grep:
runs-on: brutalisk
needs: [build-oci-image]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps:
- name: Checkout repo
uses: actions/checkout@v5
- name: grep for patterns
run: |
git grep -E 'todo!|dbg!' -- '*.rs' && exit 1 || exit 0

View File

@@ -3,3 +3,4 @@ ninja rustfmt -C build
ninja rustdoc -C build
ninja clippy -C build
ninja test -C build
git grep -E 'todo!|dbg!' -- '*.rs' && exit 1 || exit 0

View File

@@ -4,25 +4,12 @@
use core::slice;
use gentoo_utils::{Parseable, atom::Atom};
use std::{
env::{self},
io::{self, Write},
sync::{LazyLock, Mutex},
};
#[derive(Debug)]
struct State {
input: io::Stdin,
output: io::Stdout,
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn LLVMFuzzerTestOneInput(input: *const u8, len: usize) -> i32 {
static PIPES: LazyLock<Mutex<State>> = LazyLock::new(|| {
Mutex::new(State {
input: io::stdin(),
output: io::stdout(),
})
});
let slice = unsafe { slice::from_raw_parts(input, len) };
let str = str::from_utf8(slice).expect("expected ascii input");
@@ -30,13 +17,13 @@ pub unsafe extern "C" fn LLVMFuzzerTestOneInput(input: *const u8, len: usize) ->
return -1;
}
let mut state = PIPES.lock().unwrap();
writeln!(&mut state.output, "{str}").unwrap();
let stdin = io::stdin();
let mut stdout = io::stdout();
let mut buffer = String::new();
state.input.read_line(&mut buffer).unwrap();
writeln!(&mut stdout, "{str}").unwrap();
stdin.read_line(&mut buffer).unwrap();
let control = match buffer.as_str().trim() {
"0" => Ok(()),
@@ -48,24 +35,33 @@ pub unsafe extern "C" fn LLVMFuzzerTestOneInput(input: *const u8, len: usize) ->
match (control, gentoo_utils) {
(Ok(_), Ok(_)) => {
if env::var("FUZZER_LOG").is_ok() {
eprintln!("agreement that {str} is valid");
}
}
(Err(_), Err(_)) => {
if env::var("FUZZER_LOG").is_ok() {
eprintln!("agreement that {str} is invalid");
}
}
(Ok(_), Err(rest)) => {
panic!("disagreement on {str}\ncontrol:Ok\ngentoo-utils:Err({rest})");
}
(Err(_), Ok(atom))
if atom
.usedeps()
if atom.usedeps().iter().any(|usedep| {
atom.usedeps()
.iter()
.any(|usedep| atom.usedeps().iter().filter(|u| usedep == *u).count() > 1) =>
.filter(|u| *usedep.flag() == *u.flag())
.count()
> 1
}) =>
{
if env::var("FUZZER_LOG").is_ok() {
eprintln!(
"disagreement, but we will allow it since its probably because of duplicated usdeps"
);
}
}
(Err(_), Ok(_)) => {
panic!("disagreement on {str}\ncontrol:Err\ngentoo-utils:Ok")
}

View File

@@ -2,12 +2,13 @@
import sys
from portage.dep import Atom
from portage.exception import InvalidAtom
for line in sys.stdin.buffer:
try:
Atom(line.decode().strip())
sys.stdout.buffer.write(b"0\n")
except:
except InvalidAtom:
sys.stdout.buffer.write(b"1\n")
finally:
sys.stdout.buffer.flush()

View File

@@ -102,7 +102,7 @@ impl Iterator for Ebuilds {
Ok(ebuild) => break Some(Ok(ebuild)),
Err(e) => break Some(Err(e)),
},
_ => todo!(),
Err(e) => break Some(Err(Error::ReadDir(self.0.clone(), e))),
}
}
}