Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error[E0432]: unresolved imports nix::sys, nix::unistd #477

Open
shiwanghua opened this issue Nov 26, 2024 · 9 comments
Open

error[E0432]: unresolved imports nix::sys, nix::unistd #477

shiwanghua opened this issue Nov 26, 2024 · 9 comments

Comments

@shiwanghua
Copy link

shiwanghua commented Nov 26, 2024

https://users.rust-lang.org/t/how-to-create-a-fifo-in-windows/121702

I try to install locally, run in windows:

make all GHIDRA_PATH=G:\ghidra_11.2.1_PUBLIC_20241105

error:

Updating crates.io index
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Compiling libc v0.2.165
Compiling cfg_aliases v0.2.1
Compiling bitflags v2.4.2
Compiling nix v0.29.0
Compiling cwe_checker_lib v0.9.0

error[E0432]: unresolved imports nix::sys, nix::unistd
--> src\cwe_checker_lib\src\utils\ghidra.rs:13:11
|
13 | use nix::{sys::stat, unistd};
| ^^^ ^^^^^^ no unistd in the root
| |
| could not find sys in nix

For more information about this error, try rustc --explain E0432.
error: could not compile cwe_checker_lib (lib) due to 1 previous error
error: failed to compile `cwe_checker v0.9.0

@shiwanghua
Copy link
Author

rustc 1.82.0 (f6e511eec 2024-10-15)

@shiwanghua
Copy link
Author

shiwanghua commented Nov 26, 2024

Besides, ".\src\cwe_checker_lib\Cargo.toml", nix version should change to 0.29.0

nix = "0.29.0"

@shiwanghua
Copy link
Author

rustc --explain E0432
An import was unresolved.

Erroneous code example:

use something::Foo; // error: unresolved import `something::Foo`.

In Rust 2015, paths in use statements are relative to the crate root. To
import items relative to the current and parent modules, use the self:: and
super:: prefixes, respectively.

In Rust 2018 or later, paths in use statements are relative to the current
module unless they begin with the name of a crate or a literal crate::, in
which case they start from the crate root. As in Rust 2015 code, the self::
and super:: prefixes refer to the current and parent modules respectively.

Also verify that you didn't misspell the import name and that the import exists
in the module from where you tried to import it. Example:

use self::something::Foo; // Ok.

mod something {
    pub struct Foo;
}

If you tried to use a module from an external crate and are using Rust 2015,
you may have missed the extern crate declaration (which is usually placed in
the crate root):

extern crate core; // Required to use the `core` crate in Rust 2015.

use core::any;

Since Rust 2018 the extern crate declaration is not required and
you can instead just use it:

use core::any; // No extern crate required in Rust 2018.

@shiwanghua
Copy link
Author

Can cwe-checker be compiled in windows ?

@shiwanghua
Copy link
Author

Since it does not support compile in windows:
https://www.reddit.com/r/rust/comments/1bou5wz/windows_build_issue_could_not_find_sys_in_nix/

@shiwanghua
Copy link
Author

I annotated these lines of code, and got the executable file:

// use nix::{sys::stat, unistd};
// unistd::mkfifo(fifo_path, stat::Mode::from_bits(0o600).unwrap())
// .context("Error creating FIFO pipe")?;

@shiwanghua
Copy link
Author

But report a new error when running:

PS G:\cwe_checker-master> .\target\release\cwe_checker.exe G:\openssl
Error: Unable to create temporary folder

Caused by:
系统找不到指定的路径。 (os error 3)

@vobst
Copy link
Collaborator

vobst commented Dec 10, 2024

Hi, the cwe_checker does not support Windows. You can use the WSL to use the cwe_checker on Windows. Let me know if there are any problems with building and running it in the WSL (According to NationalSecurityAgency/ghidra#697 it should be possible to run Ghidra headless in the WSL).

@shiwanghua
Copy link
Author

shiwanghua commented Dec 11, 2024

Hi, the cwe_checker does not support Windows. You can use the WSL to use the cwe_checker on Windows. Let me know if there are any problems with building and running it in the WSL (According to NationalSecurityAgency/ghidra#697 it should be possible to run Ghidra headless in the WSL).

I finally run cwe_checker successfully in windows...


I create a FIFO use this code:

let _ = OpenOptions::new()
            .read(true)
            .write(true)
            .create(true)
            .open(fifo_path.clone())
            .map(|_| ());

It seems to have no asynchronous functionality.

So I exchange the order: firstly call the command and then read the result file:

ghidra_subprocess
            .join()
            .expect("The Ghidra thread to be joined has panicked!");

// Open the FIFO
let mut file = std::fs::File::open(fifo_path.clone()).expect("Could not open FIFO.");
let mut buf = String::new();
file.read_to_string(&mut buf)
    .expect("Error while reading from FIFO.");
debug_settings.print(&buf, debug::Stage::Pcode(debug::PcodeForm::Raw));
let pcode_parsing_result = serde_json::from_str(&buf);

here are the output:

INFO: Could not determine binary base address. Using base address of Ghidra output as fallback.
ERROR: instr_004011e7_12: Jump target at const:00000003 does not exist
ERROR: instr_004011e7_15: Jump target at const:00000003 does not exist
ERROR: blk_004024a4: Indirect jump target at EXTERNAL:0000000b does not exist
INFO: sub_00402450 is non-returning.
INFO: Call @ instr_00402604_2 to sub_00402450 does not return to blk_00402609.
INFO: Call @ instr_004026b0_2 to sub_00402450 does not return to blk_004026b5.
INFO: CWE215: File type not supported. Currently this check only supports ELF files.
[CWE467] (0.2) (Use of sizeof on a Pointer Type) sizeof on pointer at 004027ba (strncmp).
[CWE476] (0.2) (NULL Pointer Dereference) Memory access at 00401bcc may result in a NULL dereference
[CWE476] (0.3) (NULL Pointer Dereference) There is no check if the return value is NULL at 00401329 (malloc).
[CWE476] (0.3) (NULL Pointer Dereference) There is no check if the return value is NULL at 00401360 (malloc).
[CWE676] (0.1) (Use of Potentially Dangerous Function) __tmainCRTStartup (00401354) -> strlen
[CWE676] (0.1) (Use of Potentially Dangerous Function) __tmainCRTStartup (00401378) -> memcpy
[CWE676] (0.1) (Use of Potentially Dangerous Function) _FindPESectionByName (0040275a) -> strlen
[CWE787] (0.3) (Out-of-bounds Write) Memory write at 00401558 may be out of bounds.
[CWE787] (0.3) (Out-of-bounds Write) Memory write at 004015bc may be out of bounds.
[CWE787] (0.3) (Out-of-bounds Write) Memory write at 00402cd3 may be out of bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants