Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add java attacher config #5483

Merged
merged 12 commits into from
Jun 24, 2021
2 changes: 2 additions & 0 deletions beater/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Config struct {
Sampling SamplingConfig `config:"sampling"`
DataStreams DataStreamsConfig `config:"data_streams"`
DefaultServiceEnvironment string `config:"default_service_environment"`
JavaAttacherConfig JavaAttacherConfig `config:"java_attacher"`

Pipeline string

Expand Down Expand Up @@ -199,5 +200,6 @@ func DefaultConfig() *Config {
Sampling: defaultSamplingConfig(),
DataStreams: defaultDataStreamsConfig(),
AgentAuth: defaultAgentAuth(),
JavaAttacherConfig: defaultJavaAttacherConfig(),
}
}
41 changes: 41 additions & 0 deletions beater/config/java_attacher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package config

// JavaAttacherConfig holds configuration information for running a java
// attacher jarfile.
type JavaAttacherConfig struct {
stuartnelson3 marked this conversation as resolved.
Show resolved Hide resolved
Enabled bool `config:"enabled"`

IncludeAll bool `config:"include_all"`
IncludePID []string `config:"include_pid"`
stuartnelson3 marked this conversation as resolved.
Show resolved Hide resolved

IncludeMain []string `config:"include_main"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note for the implementation: All the values will have to be escaped when passing them to the attacher to avoid injection attack vectors.

Example:

 - include_main: "foo; rm -rf /"

should not lead to the hard drive being purged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

IncludeVMArg []string `config:"include_vmarg"`
IncludeUser []string `config:"include_user"`

ExcludeMain []string `config:"exclude_main"`
ExcludeVMArg []string `config:"exclude_vmarg"`
ExcludeUser []string `config:"exclude_user"`
stuartnelson3 marked this conversation as resolved.
Show resolved Hide resolved

Config []string `config:"config"`
}

func defaultJavaAttacherConfig() JavaAttacherConfig {
return JavaAttacherConfig{Enabled: false}
}