Skip to content

Commit

Permalink
[casr-java] Add source-dirs options (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkctkuy authored Nov 3, 2023
1 parent ba88e70 commit e1849e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion casr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ["/tests"]
[dependencies]
shell-words = "1.1"
anyhow = "1.0"
clap = { version = "4.2", features = ["wrap_help", "cargo"] }
clap = { version = "4.2", features = ["wrap_help", "cargo", "env"] }
chrono = "0.4"
goblin = "0.6"
log = "0.4"
Expand Down
19 changes: 13 additions & 6 deletions casr/src/bin/casr-java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ fn main() -> Result<()> {
.value_name("FILE")
.help("Stdin file for program"),
)
.arg(
Arg::new("source-dirs")
.long("source-dirs")
.env("CASR_SOURCE_DIRS")
.action(ArgAction::Set)
.num_args(1..)
.value_delimiter(':')
.value_parser(clap::value_parser!(PathBuf))
.value_name("DIR")
.help("Paths to directories with Java source files (list separated by ':' for env)"),
)
.arg(
Arg::new("timeout")
.short('t')
Expand Down Expand Up @@ -151,12 +162,8 @@ fn main() -> Result<()> {
report.crashline = crash_line.to_string();
if let CrashLine::Source(mut debug) = crash_line {
// Modify DebugInfo to find sources
let source_dirs: Vec<PathBuf> = if let Ok(sources) = std::env::var("CASR_SOURCE_DIRS") {
sources
.split(':')
.map(PathBuf::from)
.filter(|x| x.is_dir())
.collect()
let source_dirs = if let Some(sources) = matches.get_many::<PathBuf>("source-dirs") {
sources.collect()
} else {
Vec::new()
};
Expand Down
25 changes: 12 additions & 13 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,23 @@ Create CASR reports (.casrep) from java reports
[ARGS]... Add "-- <path> <arguments>" to run

Options:
-o, --output <REPORT> Path to save report. Path can be a directory, then report name
is generated
--stdout Print CASR report to stdout
--stdin <FILE> Stdin file for program
-t, --timeout <SECONDS> Timeout (in seconds) for target execution, 0 value means that
timeout is disabled [default: 0]
--ignore <FILE> File with regular expressions for functions and file paths that
should be ignored
-h, --help Print help
-V, --version Print version
-o, --output <REPORT> Path to save report. Path can be a directory, then report
name is generated
--stdout Print CASR report to stdout
--stdin <FILE> Stdin file for program
--source-dirs <DIR>... Paths to directories with Java source files (list separated
by ':' for env) [env: CASR_SOURCE_DIRS=]
-t, --timeout <SECONDS> Timeout (in seconds) for target execution, 0 value means
that timeout is disabled [default: 0]
--ignore <FILE> File with regular expressions for functions and file paths
that should be ignored
-h, --help Print help
-V, --version Print version

Run casr-java:

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

You can specify paths to directories with Java source files via environment variable
`CASR_SOURCE_DIRS` (list separated by ':').

## casr-core

Analyze coredump for security goals and provide detailed report with severity estimation
Expand Down

0 comments on commit e1849e5

Please sign in to comment.