Skip to content

Commit

Permalink
Update manifest-producer.yml
Browse files Browse the repository at this point in the history
Update gimli requirement from 0.28.1 to 0.29.0

Updates the requirements on [gimli](https://github.com/gimli-rs/gimli) to permit the latest version.
- [Changelog](https://github.com/gimli-rs/gimli/blob/master/CHANGELOG.md)
- [Commits](gimli-rs/gimli@0.28.1...0.29.0)

---
updated-dependencies:
- dependency-name: gimli
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Update object requirement from 0.34.0 to 0.35.0

Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](gimli-rs/object@0.34.0...0.35.0)

---
updated-dependencies:
- dependency-name: object
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
giusbianco committed Sep 25, 2024
1 parent 02e89b6 commit ca6a41a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 63 deletions.
57 changes: 3 additions & 54 deletions .github/workflows/manifest-producer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,63 +119,12 @@ jobs:
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}

weighted-code-coverage:

needs: [build, docs]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Install grcov
env:
GRCOV_LINK: https://github.com/mozilla/grcov/releases/download
GRCOV_BINARY: grcov-x86_64-unknown-linux-musl.tar.bz2
run: |
curl -L "$GRCOV_LINK/v$GRCOV_VERSION/$GRCOV_BINARY" |
tar xj -C $HOME/.cargo/bin
- name: Install weighted-code-coverage
env:
WCC_LINK: https://github.com/SoftengPoliTo/weighted-code-coverage/releases/download
run: |
curl -L "$WCC_LINK/v$WCC_VERSION/weighted-code-coverage-$WCC_VERSION-x86_64-unknown-linux-gnu.tar.gz" |
tar xz -C $HOME/.cargo/bin
- name: Run tests
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "manifest-producer-%p-%m.profraw"
run: |
cargo test --verbose
- name: Run grcov
run: |
grcov . --binary-path ./target/debug/ -t coveralls -s . --token YOUR_COVERALLS_TOKEN -o coveralls.json
- name: Run weighted-code-coverage
run: |
mkdir $HOME/wcc-output
weighted-code-coverage -p src/ -j coveralls.json -c cyclomatic --json $HOME/wcc-output/out.json
- name: Upload weighted-code-coverage data
uses: actions/upload-artifact@v4
with:
name: weighted-code-coverage-ubuntu
path: ~/wcc-output/out.json

############################### DEPENDENCY LAYER ###############################

audit:

needs: [code-coverage, weighted-code-coverage]
needs: code-coverage

runs-on: ubuntu-latest

Expand All @@ -199,7 +148,7 @@ jobs:

deny:

needs: [code-coverage, weighted-code-coverage]
needs: code-coverage

runs-on: ubuntu-latest

Expand Down Expand Up @@ -237,7 +186,7 @@ jobs:
udeps:

needs: [code-coverage, weighted-code-coverage]
needs: code-coverage

runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
Cargo.lock
/elf_file
*.json
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ goblin = "0.8.0"
thiserror = "1.0.50"
cpp_demangle = "0.4.3"
serde_json = "1.0"
object = "0.34.0"
gimli = "0.28.1"
object = "0.35.0"
gimli = "0.29.0"
memmap2 = "0.9.4"
rustc-demangle = "0.1.23"

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ The manifest-producer binary uses the library to perform analysis of ELF files.
To use the manifest-producer tool, you can run the following command from the command line:

```bash
cargo run manifest-producer <elf_file_path>
cargo run <ELF_file_path> <JSON_file_path>
```

Where `<elf_file_path>` is the path to the ELF file to be analyzed.
`<ELF_file_path>` represents the path to the ELF file intended for analysis, while `<JSON_file_path>` denotes the path to the JSON file containing the list of APIs.

## Dependencies

Expand Down
27 changes: 22 additions & 5 deletions src/bin/manifest-producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use manifest_producer::error::{Error, Result};
use manifest_producer::manifest_creation::{
basic_info_manifest, feature_manifest, flow_call_manifest,
};
use std::env;
use serde_json::Value;
use std::{env, fs};

/// Perform ELF analysis including API detection, system call flow encapsulation, and manifest generation.
///
Expand Down Expand Up @@ -54,18 +55,34 @@ pub fn elf_analysis(file_path: &str, api_list: Vec<&str>, path: &str) -> Result<
Ok(())
}

fn read_api_list(json_file_path: &str) -> Result<Vec<String>> {
let contents = fs::read_to_string(json_file_path)?;
let json: Value = serde_json::from_str(&contents)?;
let api_list: Vec<String> = serde_json::from_value(json)?;
Ok(api_list)
}

fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Usage: {} <elf_file_path>", args[0]);
if args.len() < 3 {
println!("Usage: {} <ELF_file_path> <JSON_file_path>", args[0]);
return;
}
let elf_file_path = &args[1];
let json_file_path = &args[2];

let api_list = match read_api_list(json_file_path) {
Ok(list) => list,
Err(error) => {
eprintln!("Error reading API list from JSON file: {}", error);
return;
}
};
let api_list_refs: Vec<&str> = api_list.iter().map(|s| s.as_str()).collect();

let api_list = vec!["get_flags"];
let manifest_path = "./manifest-produced";

match elf_analysis(elf_file_path, api_list, manifest_path) {
match elf_analysis(elf_file_path, api_list_refs, manifest_path) {
Ok(_) => println!("Analysis performed successfully!"),
Err(error) => eprintln!("Elf analysis failed: {}", error),
};
Expand Down

0 comments on commit ca6a41a

Please sign in to comment.