forked from baidu/openrasp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-java.sh
executable file
·81 lines (61 loc) · 1.83 KB
/
build-java.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
#
# 手动编译说明
# https://rasp.baidu.com/doc/hacking/compile/java.html
##################################
# #
# 自动编译,并生成OpenRASP安装包 #
# #
##################################
cd "$(dirname "$0")"
BASE_DIR=$(pwd)
echo "base dir: $BASE_DIR"
PLUGIN_ROOT=$BASE_DIR/plugins/official
OUTPUT_ROOT=$BASE_DIR/rasp-$(date +%Y-%m-%d)
BASENAME="$(basename $OUTPUT_ROOT)"
rm -rf "$OUTPUT_ROOT" rasp-java.{zip,tar.gz}
mkdir -p "$OUTPUT_ROOT"/rasp/{plugins,conf} || exit 1
function log {
echo "================= $1 ==================="
}
function buildRaspInstall {
cd $BASE_DIR/rasp-install/java
log "mvn clean package..."
mvn clean package || exit 1
cp $BASE_DIR/rasp-install/java/target/RaspInstall.jar $OUTPUT_ROOT || exit 1
rm -rf $BASE_DIR/rasp-install/java/target
}
# 编译Rasp
function buildRasp {
cd $BASE_DIR/agent/java || exit 1
log "mvn clean package"
mvn clean package || exit 1
cp $BASE_DIR/agent/java/boot/target/rasp.jar $OUTPUT_ROOT/rasp || exit 1
cp $BASE_DIR/agent/java/engine/target/rasp-engine.jar $OUTPUT_ROOT/rasp || exit 1
}
function buildPlugin {
cd $PLUGIN_ROOT || exit 1
cp $PLUGIN_ROOT/plugin.js $OUTPUT_ROOT/rasp/plugins/official.js || exit 1
}
function copyConf {
cp $BASE_DIR/rasp-install/java/src/main/resources/rasp.properties $OUTPUT_ROOT/rasp/conf/rasp.properties || exit 1
}
log "[1] build RaspInstall.jar"
buildRaspInstall
log "[2] copy OpenRasp Plugin"
buildPlugin
log "[3] copy rasp.properties"
copyConf
log "[4] build OpenRasp"
buildRasp
cd $OUTPUT_ROOT/..
target=rasp-java.tar.gz
tar -czvf $target $BASENAME || exit
#mv $target $BASE_DIR || exit
log "Created $target"
target=rasp-java.zip
zip -r $target $BASENAME || exit
#mv $target $BASE_DIR || exit
log "Created $target"
log "SUCCESS!"
rm -rf $BASENAME