MCPcopy Create free account
hub / github.com/baidu/openrasp / argsParser

Method argsParser

rasp-install/java/src/main/java/com/baidu/rasp/App.java:84–146  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

82 }
83
84 private static void argsParser(String[] args) throws ParseException, RaspError {
85 Options options = new Options();
86 options.addOption("install", true, "Specify application server path");
87 options.addOption("uninstall", true, "Specify application server path");
88 options.addOption("appid", true, "Value of cloud.appid");
89 options.addOption("appsecret", true, "Value of cloud.appsecret");
90 options.addOption("heartbeat", true, "Value of cloud.heartbeat_interval");
91 options.addOption("raspid", true, "Value of rasp.id");
92 options.addOption("backendurl", true, "Value of cloud.backendurl");
93 options.addOption("keepconf", false, "Do not override openrasp.yml");
94 options.addOption("h", "help", false, "You're reading this!");
95 options.addOption("pid", true, "Specify the pid of Java server to attach");
96 options.addOption("nodetect", false, "Install without updating startup scripts, " +
97 "useful for standalone Java servers like SpringBoot");
98 options.addOption("nodep", false, "Disable parsing of Jar dependency");
99 options.addOption("prepend", false, "Prepend the origin java options");
100 options.addOption("debuglevel", true, "Set debug level to enable verbose output in RASP agent");
101
102 CommandLineParser parser = new PosixParser();
103 CommandLine cmd = parser.parse(options, args);
104 if (cmd.hasOption("help") || cmd.hasOption("h")) {
105 showHelp(options);
106 } else {
107 if (cmd.hasOption("install") && cmd.hasOption("uninstall")) {
108 throw new RaspError(E10005 + "Can't use -install and -uninstall simultaneously");
109 } else {
110 if (cmd.hasOption("install")) {
111 baseDir = cmd.getOptionValue("install");
112 install = "install";
113 } else if (cmd.hasOption("uninstall")) {
114 baseDir = cmd.getOptionValue("uninstall");
115 install = "uninstall";
116 } else {
117 throw new RaspError(E10005 + "One of -install and -uninstall must be specified");
118 }
119
120 noDetect = cmd.hasOption("nodetect");
121 noDependencyCheck = cmd.hasOption("nodep");
122 isPrepend = cmd.hasOption("prepend");
123
124 if (cmd.hasOption("pid")) {
125 isAttach = true;
126 pid = getIntegerParam(cmd, "pid");
127 }
128 }
129
130 if (cmd.hasOption("debuglevel")) {
131 debuglevel = getIntegerParam(cmd, "debuglevel");
132 }
133
134 keepConfig = cmd.hasOption("keepconf");
135 appId = cmd.getOptionValue("appid");
136 appSecret = cmd.getOptionValue("appsecret");
137 if (cmd.hasOption("heartbeat")) {
138 heartbeatInterval = getIntegerParam(cmd, "heartbeat");
139 }
140 raspId = cmd.getOptionValue("raspid");
141 url = cmd.getOptionValue("backendurl");

Callers 1

operateServerMethod · 0.95

Calls 3

showHelpMethod · 0.95
getIntegerParamMethod · 0.95
parseMethod · 0.45

Tested by

no test coverage detected