Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ public class ServerOptions extends OptionHolder {
"arthas.ip",
"arthas bound ip",
disallowEmpty(),
"0.0.0.0"
"127.0.0.1"
);

public static final ConfigOption<String> ARTHAS_DISABLED_COMMANDS =
new ConfigOption<>(
"arthas.disabledCommands",
"arthas disabled commands",
disallowEmpty(),
"jad"
"jad,ognl,vmtool"
Comment thread
imbajin marked this conversation as resolved.
Comment thread
imbajin marked this conversation as resolved.
);

public static final ConfigOption<Boolean> ALLOW_TRACE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ batch.max_write_ratio=80
batch.max_write_threads=0

# configuration of arthas
arthas.telnet_port=8562
arthas.http_port=8561
arthas.telnetPort=8562
Comment thread
JisoLya marked this conversation as resolved.
arthas.httpPort=8561
arthas.ip=127.0.0.1
arthas.disabled_commands=jad
arthas.disabledCommands=jad,ognl,vmtool
Comment thread
JisoLya marked this conversation as resolved.

# authentication configs
#auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ public class ArthasConfig {
@Value("${arthas.httpPort:8565}")
private String httpPort;

@Value("${arthas.ip:0.0.0.0}")
@Value("${arthas.ip:127.0.0.1}")
private String arthasip;

@Value("${arthas.disabledCommands:jad}")
@Value("${arthas.disabledCommands:jad,ognl,vmtool}")
private String disCmd;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.apache.hugegraph.pd.common.PDException;
import org.apache.hugegraph.pd.grpc.Metapb;
Expand All @@ -44,6 +45,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.alipay.sofa.jraft.entity.PeerId;
import com.alipay.sofa.jraft.util.Endpoint;
Expand Down Expand Up @@ -189,6 +192,16 @@ public Map<String, Object> cleanPartition(@PathVariable(value = "id") int id) th
@GetMapping(value = "/arthasstart", produces = "application/json")
Comment thread
JisoLya marked this conversation as resolved.
public Map<String, Object> arthasstart(
@RequestParam(required = false, defaultValue = "") String flags) {
String remoteAddr = ((ServletRequestAttributes) Objects.requireNonNull(
Comment thread
JisoLya marked this conversation as resolved.
Outdated
RequestContextHolder.getRequestAttributes())).getRequest().getRemoteAddr();

boolean isLocalRequest = "127.0.0.1".equals(remoteAddr) ||
Comment thread
JisoLya marked this conversation as resolved.
Outdated
"[0:0:0:0:0:0:0:1]".equals(remoteAddr);
Comment thread
JisoLya marked this conversation as resolved.
Outdated
if (!isLocalRequest){
Comment thread
JisoLya marked this conversation as resolved.
Outdated
Comment thread
JisoLya marked this conversation as resolved.
Outdated
List<String> ret = new ArrayList<>();
ret.add("Arthas start is ONLY allowed from localhost.");
return forbiddenMap("arthasstart", ret);
Comment thread
JisoLya marked this conversation as resolved.
Outdated
}
Comment thread
JisoLya marked this conversation as resolved.
Outdated
HashMap<String, String> configMap = new HashMap<>();
configMap.put("arthas.telnetPort", appConfig.getArthasConfig().getTelnetPort());
configMap.put("arthas.httpPort", appConfig.getArthasConfig().getHttpPort());
Expand Down Expand Up @@ -225,6 +238,13 @@ public Map<String, Object> okMap(String k, Object v) {
return map;
Comment thread
JisoLya marked this conversation as resolved.
Outdated
}

public Map<String, Object> forbiddenMap(String k, Object v){
Comment thread
JisoLya marked this conversation as resolved.
Outdated
HashMap<String, Object> map = new HashMap<>();
map.put("status", 403);
map.put(k,v);
Comment thread
JisoLya marked this conversation as resolved.
Outdated
return map;
}

@Data
public class Raft {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ logging:
config: classpath:log4j2-dev.xml
level:
root: info

arthas:
telnetPort: 8566
httpPort: 8565
# Only allow starting arthas locally
ip: 127.0.0.1
disabledCommands: jad,ognl,vmtool
Loading