Skip to content

Commit

Permalink
Cherry-pick:a0403b9c1d6d4eecf83d18c8384a0dcdbea278d5
Browse files Browse the repository at this point in the history
  • Loading branch information
cnguoyj-leminis committed Jun 12, 2024
1 parent b871870 commit 37b4b20
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
7 changes: 5 additions & 2 deletions rasp/librasp/src/jvm.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Result, Result as AnyhowResult};

use log::*;
use regex::Regex;
use std::process::Command;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::time::Duration;
use crate::async_command::run_async_process;
use crate::process::ProcessInfo;
use crate::runtime::{ProbeCopy, ProbeState, ProbeStateInspect};
use crate::settings::{self, RASP_VERSION};
use lazy_static::lazy_static;
use fs_extra::file::{copy as file_copy, remove as file_remove, CopyOptions as FileCopyOptions};

lazy_static! {
static ref RASP_JAVA_CHECKSUMSTR: String = {
Expand Down Expand Up @@ -125,7 +128,7 @@ fn get_last_filename(path: &str) -> Option<String> {
}

pub fn copy_probe_nativelib(pid:i32,dst_root:String) -> AnyhowResult<()> {
let java_library_path = jcmd(pid, " VM.system_properties").and_then(|output| {
let _ = jcmd(pid, " VM.system_properties").and_then(|output| {
let output_str = String::from_utf8_lossy(&output);
let lines: Vec<&str> = output_str.split("\n").collect();
let java_library_path_line = lines.iter().find(|line| line.starts_with("java.library.path="));
Expand Down
2 changes: 1 addition & 1 deletion rasp/librasp/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use log::*;

use crate::cpython::{python_attach, CPythonProbe, CPythonProbeState};
use crate::golang::{golang_attach, GolangProbe, GolangProbeState};
use crate::jvm::{java_attach, java_detach, JVMProbe, JVMProbeState};
use crate::jvm::{copy_probe_nativelib,java_attach, java_detach, JVMProbe, JVMProbeState};
use crate::nodejs::{nodejs_attach, NodeJSProbe};
use crate::php::{php_attach, PHPProbeState};
use crate::{
Expand Down
31 changes: 31 additions & 0 deletions rasp/librasp/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,37 @@ pub fn RASP_JAVA_PROBE_BIN() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/SmithProbe.jar")
}


#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
pub fn RASP_JAVA_NETTY_EPOLL_SO() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/nativelib/librasp_netty_transport_native_epoll_x86_64.so")
}

#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
pub fn RASP_JAVA_NETTY_EPOLL_SO() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/nativelib/librasp_netty_transport_native_epoll_aarch_64.so")
}

#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
pub fn RASP_JAVA_NETTY_KQUEUQ_SO_MAC() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/nativelib/librasp_netty_transport_native_kqueue_x86_64.jnilib")
}

#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
pub fn RASP_JAVA_NETTY_DNS_SO_MAC() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/nativelib/librasp_netty_resolver_dns_native_macos_x86_64.jnilib")
}

#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
pub fn RASP_JAVA_NETTY_KQUEUQ_SO_MAC() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/nativelib/librasp_netty_transport_native_kqueue_aarch_64.jnilib")
}

#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
pub fn RASP_JAVA_NETTY_DNS_SO_MAC() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/nativelib/librasp_netty_resolver_dns_native_macos_aarch_64.jnilib")
}

pub fn RASP_JAVA_CHECKSUM_PATH() -> String {
format!("{}{}", RASP_LIB_DIR(), "/java/checksum.data")
}
Expand Down

0 comments on commit 37b4b20

Please sign in to comment.