Skip to content

Commit 25cf0b4

Browse files
authored
CI refactor (#18)
* Redo CI * fmt * clippy * Change name * Remove --all-features for now
1 parent 34fd253 commit 25cf0b4

File tree

15 files changed

+114
-46
lines changed

15 files changed

+114
-46
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
pre_ci:
10+
uses: dtolnay/.github/.github/workflows/pre_ci.yml@master
11+
12+
build:
13+
name: ${{matrix.name || format('Rust {0}', matrix.rust)}}
14+
needs: pre_ci
15+
if: needs.pre_ci.outputs.continue
16+
runs-on: ${{matrix.os}}-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
rust: [nightly, beta, stable]
21+
os: [ubuntu]
22+
env:
23+
RUSTFLAGS: --cfg deny_warnings -Dwarnings
24+
timeout-minutes: 45
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
submodules: true
29+
- uses: dtolnay/rust-toolchain@master
30+
with:
31+
toolchain: ${{matrix.rust}}
32+
- run: cargo build --all-features

.github/workflows/check.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/style.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Style
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
pre_ci:
10+
uses: dtolnay/.github/.github/workflows/pre_ci.yml@master
11+
12+
build:
13+
name: ${{matrix.name || format('Rust {0}', matrix.rust)}}
14+
needs: pre_ci
15+
if: needs.pre_ci.outputs.continue
16+
runs-on: ${{matrix.os}}-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
rust: [ stable ]
21+
os: [ ubuntu ]
22+
env:
23+
RUSTFLAGS: --cfg deny_warnings -Dwarnings
24+
timeout-minutes: 45
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
submodules: true
29+
- uses: dtolnay/rust-toolchain@master
30+
with:
31+
toolchain: ${{matrix.rust}}
32+
components: clippy, rustfmt
33+
- name: cargo fmt
34+
run: cargo fmt --all -- --check
35+
- name: cargo clippy
36+
run: cargo clippy --all-targets -- -D warnings

src/bin/crackers/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ fn synthesize(config: PathBuf) -> anyhow::Result<()> {
122122
.with(tracing_subscriber::fmt::layer().with_writer(writer))
123123
.init();
124124
let params = p.resolve()?;
125-
let result = match params.combine_instructions{
126-
true => params.build_combined(&z3).and_then(|mut c|c.decide()),
127-
false => params.build_single(&z3).and_then(|mut c| c.decide())
125+
let result = match params.combine_instructions {
126+
true => params.build_combined(&z3).and_then(|mut c| c.decide()),
127+
false => params.build_single(&z3).and_then(|mut c| c.decide()),
128128
};
129129
match result {
130130
Ok(res) => match res {

src/config/constraint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub struct PointerRange {
121121
/// Generates a state constraint that a given varnode must be equal to a given value
122122
pub fn gen_memory_constraint(
123123
m: MemoryEqualityConstraint,
124-
) -> impl for<'a,> Fn(&JingleContext<'a>, &State<'a>, u64) -> Result<Bool<'a>, CrackersError>
124+
) -> impl for<'a> Fn(&JingleContext<'a>, &State<'a>, u64) -> Result<Bool<'a>, CrackersError>
125125
+ Send
126126
+ Sync
127127
+ Clone
@@ -162,14 +162,14 @@ pub fn gen_register_pointer_constraint<'ctx>(
162162
let m = m.clone();
163163
let mut bools = vec![];
164164
let pointer = state.read_varnode(&vn)?;
165-
for (i,byte) in value.as_bytes().iter().enumerate() {
165+
for (i, byte) in value.as_bytes().iter().enumerate() {
166166
let expected = BV::from_u64(jingle.z3, *byte as u64, 8);
167-
let char_ptr = ResolvedVarnode::Indirect(ResolvedIndirectVarNode{
167+
let char_ptr = ResolvedVarnode::Indirect(ResolvedIndirectVarNode {
168168
// dumb but whatever
169169
pointer_location: vn.clone(),
170170
pointer: pointer.clone().add(i as u64),
171171
access_size_bytes: 1,
172-
pointer_space_idx: state.get_code_space_idx()
172+
pointer_space_idx: state.get_code_space_idx(),
173173
});
174174
let actual = state.read_resolved(&char_ptr)?;
175175
bools.push(actual._eq(&expected))

src/config/object.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ fn load_image<T: AsRef<Path>>(path: T) -> Result<(SegmentFile, &'static str), Cr
2424
}
2525

2626
/// gross hack
27-
fn load_image_spec<T: AsRef<Path>>(path: T) -> Result<(OwnedFile, &'static str), CrackersConfigError> {
27+
fn load_image_spec<T: AsRef<Path>>(
28+
path: T,
29+
) -> Result<(OwnedFile, &'static str), CrackersConfigError> {
2830
let data = fs::read(path.as_ref())?;
2931
let file = File::parse(&*data)?;
3032
let arch = map_gimli_architecture(&file).ok_or(UnrecognizedArchitecture(format!(

src/config/synthesis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct SynthesisConfig {
77
pub strategy: SynthesisSelectionStrategy,
88
pub max_candidates_per_slot: usize,
99
pub parallel: usize,
10-
pub combine_instructions: bool
10+
pub combine_instructions: bool,
1111
}
1212

1313
impl Default for SynthesisConfig {
@@ -16,7 +16,7 @@ impl Default for SynthesisConfig {
1616
strategy: SynthesisSelectionStrategy::OptimizeStrategy,
1717
max_candidates_per_slot: 50,
1818
parallel: 4,
19-
combine_instructions: true
19+
combine_instructions: true,
2020
}
2121
}
2222
}

src/gadget/another_iterator.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ impl<'ctx, 'a, T> TraceCandidateIterator<'ctx, 'a, T>
2222
where
2323
T: Iterator<Item = &'a Gadget>,
2424
{
25-
pub(crate) fn new(jingle: &JingleContext<'ctx>, gadgets: T, trace: Vec<ModeledInstruction<'ctx>>) -> Self {
25+
pub(crate) fn new(
26+
jingle: &JingleContext<'ctx>,
27+
gadgets: T,
28+
trace: Vec<ModeledInstruction<'ctx>>,
29+
) -> Self {
2630
let _solver = Solver::new(jingle.z3);
2731
Self {
2832
jingle: jingle.clone(),
@@ -48,7 +52,11 @@ where
4852
.trace
4953
.iter()
5054
.map(|i| {
51-
trace!("Checking {} signature vs gadget {}", i.instr.disassembly, gadget);
55+
trace!(
56+
"Checking {} signature vs gadget {}",
57+
i.instr.disassembly,
58+
gadget
59+
);
5260

5361
gadget_signature.covers(&GadgetSignature::from_instr(&i.instr, i))
5462
&& has_compatible_control_flow(&i.instr, gadget)
@@ -68,7 +76,7 @@ where
6876
}
6977
}
7078
})
71-
}else{
79+
} else {
7280
trace!("Could not model gadget: \n{}", gadget)
7381
}
7482
return Some(next_entry);

src/gadget/library/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct GadgetLibraryParams {
1717
pub operation_blacklist: HashSet<OpCode>,
1818
pub path: String,
1919
pub sample_size: Option<usize>,
20-
pub base_address: Option<u64>
20+
pub base_address: Option<u64>,
2121
}
2222

2323
impl GadgetLibraryParams {

src/gadget/library/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,3 @@ mod tests {
138138
GadgetLibrary::build_from_image(bin_sleigh, &GadgetLibraryParams::default()).unwrap();
139139
}
140140
}
141-

0 commit comments

Comments
 (0)