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

Finding Java source files #94

Merged
merged 6 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ Run casr-java:

$ casr-java -o java.casrep -- java casr/tests/casr_tests/java/Test1.java

You can specify paths to directories with source files via environment variable
CASR\_SOURCE\_DIRECTORIES (list separated by ':').

## casr-core

Analyze coredump for security goals and provide detailed report with severity estimation
Expand Down
25 changes: 24 additions & 1 deletion libcasr/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,30 @@ impl CrashReport {
return None;
}

if let Ok(file) = std::fs::File::open(&debug.file) {
// Search for file
anfedotoff marked this conversation as resolved.
Show resolved Hide resolved
let mut sources: Vec<PathBuf> =
if let Ok(sources) = std::env::var("CASR_SOURCE_DIRECTORIES") {
let debug_file_name = PathBuf::from(&debug.file)
.file_name()
.unwrap()
.to_str()
.unwrap()
.to_string();
sources
.split(':')
.map(PathBuf::from)
.filter(|x| x.is_dir())
.map(|x| x.join(&debug_file_name))
.collect()
} else {
Vec::new()
};
sources.push(PathBuf::from(&debug.file));
let Some(source_file) = sources.iter().find(|x| x.exists()) else {
return None;
};

if let Ok(file) = std::fs::File::open(source_file) {
let file = BufReader::new(file);
let start: usize = if debug.line > 5 {
debug.line as usize - 5
Expand Down