Fix SnakeYAML CVE. Make doc and sharing receiver codes consistent. (#5799)

* Fix SnakeYAML CVE. Make doc and sharing receiver codes consistent.

* Update changelog.

* Fix word.

* Fix style issue.
This commit is contained in:
吴晟 Wu Sheng 2020-11-05 23:13:03 +08:00 committed by GitHub
parent f69b23e7c0
commit 3bc6c4cd6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 48 deletions

View File

@ -28,11 +28,14 @@ Release Notes.
* Fix deadlock problem when using elasticsearch-client-7.0.0.
* Fix storage-jdbc isExists not set dbname.
* Fix `searchService` bug in the InfluxDB storage implementation.
* Fix CVE in the alarm module, when activating the dynamic configuration feature.
* Make the codes and doc consistent in sharding server and core server.
#### UI
#### Documentation
* Add VNode FAQ doc.
* Adjust configuration names and system environment names of the sharing server module
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/62?closed=1)

View File

@ -148,9 +148,14 @@ core|default|role|Option values, `Mixed/Receiver/Aggregator`. **Receiver** mode
| - | - |slowTraceSegmentThreshold|Setting this threshold about the latency would make the slow trace segments sampled if they cost more time, even the sampling mechanism activated. The default value is `-1`, which means would not sample slow traces. Unit, millisecond. |SW_SLOW_TRACE_SEGMENT_THRESHOLD|-1|
| - | - |meterAnalyzerActiveFiles|Which files could be meter analyzed, files split by ","|SW_METER_ANALYZER_ACTIVE_FILES||
| receiver-sharing-server|default| Sharing server provides new gRPC and restful servers for data collection. Ana make the servers in the core module working for internal communication only.| - | - |
| - | - | restHost| Binding IP of restful service. Services include GraphQL query and HTTP data report| - | - |
| - | - | restPort | Binding port of restful service | - | - |
| - | - | restContextPath| Web context path of restful service| - | - |
| - | - | restHost| Binding IP of restful service. Services include GraphQL query and HTTP data report| SW_RECEIVER_SHARING_REST_HOST | - |
| - | - | restPort | Binding port of restful service | SW_RECEIVER_SHARING_REST_PORT | - |
| - | - | restContextPath| Web context path of restful service| SW_RECEIVER_SHARING_REST_CONTEXT_PATH | - |
| - | - | restMinThreads| Min threads number of restful service| SW_RECEIVER_SHARING_JETTY_MIN_THREADS|1|
| - | - | restMaxThreads| Max threads number of restful service| SW_RECEIVER_SHARING_JETTY_MAX_THREADS|200|
| - | - | restIdleTimeOut| Connector idle timeout in milliseconds of restful service| SW_RECEIVER_SHARING_JETTY_IDLE_TIMEOUT|30000|
| - | - | restAcceptorPriorityDelta| Thread priority delta to give to acceptor threads of restful service| SW_RECEIVER_SHARING_JETTY_DELTA|0|
| - | - | restAcceptQueueSize| ServerSocketChannel backlog of restful service| SW_RECEIVER_SHARING_JETTY_QUEUE_SIZE|0|
| - | - | gRPCHost|Binding IP of gRPC service. Services include gRPC data report and internal communication among OAP nodes| SW_RECEIVER_GRPC_HOST | 0.0.0.0. Not Activated |
| - | - | gRPCPort| Binding port of gRPC service | SW_RECEIVER_GRPC_PORT | Not Activated |
| - | - | gRPCThreadPoolSize|Pool size of gRPC server| SW_RECEIVER_GRPC_THREAD_POOL_SIZE | CPU core * 4|

View File

@ -18,18 +18,18 @@
package org.apache.skywalking.oap.server.core.alarm.provider;
import org.apache.skywalking.oap.server.core.alarm.provider.dingtalk.DingtalkSettings;
import org.apache.skywalking.oap.server.core.alarm.provider.grpc.GRPCAlarmSetting;
import org.apache.skywalking.oap.server.core.alarm.provider.slack.SlackSettings;
import org.apache.skywalking.oap.server.core.alarm.provider.wechat.WechatSettings;
import org.yaml.snakeyaml.Yaml;
import java.io.InputStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.skywalking.oap.server.core.alarm.provider.dingtalk.DingtalkSettings;
import org.apache.skywalking.oap.server.core.alarm.provider.grpc.GRPCAlarmSetting;
import org.apache.skywalking.oap.server.core.alarm.provider.slack.SlackSettings;
import org.apache.skywalking.oap.server.core.alarm.provider.wechat.WechatSettings;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
/**
* Rule Reader parses the given `alarm-settings.yml` config file, to the target {@link Rules}.
@ -38,13 +38,13 @@ public class RulesReader {
private Map yamlData;
public RulesReader(InputStream inputStream) {
Yaml yaml = new Yaml();
yamlData = yaml.loadAs(inputStream, Map.class);
Yaml yaml = new Yaml(new SafeConstructor());
yamlData = (Map) yaml.load(inputStream);
}
public RulesReader(Reader io) {
Yaml yaml = new Yaml();
yamlData = yaml.loadAs(io, Map.class);
Yaml yaml = new Yaml(new SafeConstructor());
yamlData = (Map) yaml.load(io);
}
/**
@ -65,7 +65,6 @@ public class RulesReader {
return rules;
}
/**
* Read rule config into {@link AlarmRule}
*/
@ -91,9 +90,9 @@ public class RulesReader {
alarmRule.setIncludeNamesRegex((String) settings.getOrDefault("include-names-regex", ""));
alarmRule.setExcludeNamesRegex((String) settings.getOrDefault("exclude-names-regex", ""));
alarmRule.setIncludeLabels(
(ArrayList) settings.getOrDefault("include-labels", new ArrayList(0)));
(ArrayList) settings.getOrDefault("include-labels", new ArrayList(0)));
alarmRule.setExcludeLabels(
(ArrayList) settings.getOrDefault("exclude-labels", new ArrayList(0)));
(ArrayList) settings.getOrDefault("exclude-labels", new ArrayList(0)));
alarmRule.setIncludeLabelsRegex((String) settings.getOrDefault("include-labels-regex", ""));
alarmRule.setExcludeLabelsRegex((String) settings.getOrDefault("exclude-labels-regex", ""));
alarmRule.setThreshold(settings.get("threshold").toString());
@ -104,8 +103,8 @@ public class RulesReader {
alarmRule.setSilencePeriod((Integer) settings.getOrDefault("silence-period", alarmRule.getPeriod()));
alarmRule.setOnlyAsCondition((Boolean) settings.getOrDefault("only-as-condition", false));
alarmRule.setMessage(
(String) settings.getOrDefault("message", "Alarm caused by Rule " + alarmRule
.getAlarmRuleName()));
(String) settings.getOrDefault("message", "Alarm caused by Rule " + alarmRule
.getAlarmRuleName()));
rules.getRules().add(alarmRule);
}
@ -201,7 +200,7 @@ public class RulesReader {
}
compositeAlarmRule.setExpression(expression);
compositeAlarmRule.setMessage(
(String) settings.getOrDefault("message", "Alarm caused by Rule " + ruleName));
(String) settings.getOrDefault("message", "Alarm caused by Rule " + ruleName));
rules.getCompositeRules().add(compositeAlarmRule);
}
});

View File

@ -198,13 +198,14 @@ receiver-sharing-server:
selector: ${SW_RECEIVER_SHARING_SERVER:default}
default:
# For Jetty server
host: ${SW_RECEIVER_JETTY_HOST:0.0.0.0}
contextPath: ${SW_RECEIVER_JETTY_CONTEXT_PATH:/}
jettyMinThreads: ${SW_RECEIVER_SHARING_JETTY_MIN_THREADS:1}
jettyMaxThreads: ${SW_RECEIVER_SHARING_JETTY_MAX_THREADS:200}
jettyIdleTimeOut: ${SW_RECEIVER_SHARING_JETTY_IDLE_TIMEOUT:30000}
jettyAcceptorPriorityDelta: ${SW_RECEIVER_SHARING_JETTY_DELTA:0}
jettyAcceptQueueSize: ${SW_RECEIVER_SHARING_JETTY_QUEUE_SIZE:0}
restHost: ${SW_RECEIVER_SHARING_REST_HOST:0.0.0.0}
restPort: ${SW_RECEIVER_SHARING_REST_PORT:0}
contextPath: ${SW_RECEIVER_SHARING_REST_CONTEXT_PATH:/}
restMinThreads: ${SW_RECEIVER_SHARING_JETTY_MIN_THREADS:1}
restMaxThreads: ${SW_RECEIVER_SHARING_JETTY_MAX_THREADS:200}
restIdleTimeOut: ${SW_RECEIVER_SHARING_JETTY_IDLE_TIMEOUT:30000}
restAcceptorPriorityDelta: ${SW_RECEIVER_SHARING_JETTY_DELTA:0}
restAcceptQueueSize: ${SW_RECEIVER_SHARING_JETTY_QUEUE_SIZE:0}
# For gRPC server
gRPCHost: ${SW_RECEIVER_GRPC_HOST:0.0.0.0}
gRPCPort: ${SW_RECEIVER_GRPC_PORT:0}

View File

@ -25,17 +25,17 @@ import org.apache.skywalking.oap.server.library.module.ModuleConfig;
@Getter
@Setter
public class SharingServerConfig extends ModuleConfig {
private String host;
private String restHost;
/**
* Only setting the real port(not 0) makes the jetty server online.
*/
private int port;
private String contextPath;
private int jettyMinThreads = 1;
private int jettyMaxThreads = 200;
private long jettyIdleTimeOut = 30000;
private int jettyAcceptorPriorityDelta = 0;
private int jettyAcceptQueueSize = 0;
private int restPort;
private String restContextPath;
private int restMinThreads = 1;
private int restMaxThreads = 200;
private long restIdleTimeOut = 30000;
private int restAcceptorPriorityDelta = 0;
private int restAcceptQueueSize = 0;
private String gRPCHost;
/**

View File

@ -68,20 +68,20 @@ public class SharingServerModuleProvider extends ModuleProvider {
@Override
public void prepare() {
JettyServerConfig jettyServerConfig = JettyServerConfig.builder()
.host(config.getHost()).port(config.getPort())
.contextPath(config.getContextPath())
.jettyMinThreads(config.getJettyMinThreads())
.jettyMaxThreads(config.getJettyMaxThreads())
.jettyAcceptQueueSize(config.getJettyAcceptQueueSize())
.jettyAcceptorPriorityDelta(
config.getJettyAcceptorPriorityDelta())
.jettyIdleTimeOut(config.getJettyIdleTimeOut()).build();
if (config.getPort() != 0) {
jettyServerConfig.setHost(Strings.isBlank(config.getHost()) ? "0.0.0.0" : config.getHost());
jettyServerConfig.setPort(config.getPort());
jettyServerConfig.setContextPath(config.getContextPath());
if (config.getRestPort() > 0) {
JettyServerConfig jettyServerConfig =
JettyServerConfig.builder()
.host(config.getRestHost()).port(config.getRestPort())
.contextPath(config.getRestContextPath())
.jettyMinThreads(config.getRestMinThreads())
.jettyMaxThreads(config.getRestMaxThreads())
.jettyAcceptQueueSize(config.getRestAcceptQueueSize())
.jettyAcceptorPriorityDelta(
config.getRestAcceptorPriorityDelta())
.jettyIdleTimeOut(config.getRestIdleTimeOut()).build();
jettyServerConfig.setHost(Strings.isBlank(config.getRestHost()) ? "0.0.0.0" : config.getRestHost());
jettyServerConfig.setPort(config.getRestPort());
jettyServerConfig.setContextPath(config.getRestContextPath());
jettyServer = new JettyServer(jettyServerConfig);
jettyServer.initialize();