-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2114 from newrelic/sanitize-environment
Sanitize environment
- Loading branch information
Showing
7 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
newrelic-agent/src/main/java/com/newrelic/agent/config/ObfuscateJvmPropsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.newrelic.agent.config; | ||
|
||
import java.util.Set; | ||
|
||
public interface ObfuscateJvmPropsConfig { | ||
|
||
boolean isEnabled(); | ||
|
||
Set<String> getAllow(); | ||
|
||
Set<String> getBlock(); | ||
} |
44 changes: 44 additions & 0 deletions
44
newrelic-agent/src/main/java/com/newrelic/agent/config/ObfuscateJvmPropsConfigImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.newrelic.agent.config; | ||
|
||
import java.util.*; | ||
|
||
public class ObfuscateJvmPropsConfigImpl extends BaseConfig implements ObfuscateJvmPropsConfig { | ||
|
||
private static final String SYSTEM_PROPERTY_ROOT="newrelic.config.obfuscate_jvm_props."; | ||
private static final String ALLOW = "allow"; | ||
private static final String BLOCK = "block"; | ||
private static final String ENABLED = "enabled"; | ||
private static final boolean DEFAULT_ENABLED = true; | ||
private static final Set<String> DEFAULT_ALLOW = Collections.singleton("-X*"); | ||
private final boolean isEnabled; | ||
private final Set<String> blockList; | ||
private final Set<String> allowList; | ||
|
||
public ObfuscateJvmPropsConfigImpl(Map<String, Object> props) { | ||
super(props, SYSTEM_PROPERTY_ROOT); | ||
isEnabled = getProperty(ENABLED, DEFAULT_ENABLED); | ||
blockList = initializeBlock(); | ||
allowList = initializeAllow(); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return isEnabled; | ||
} | ||
|
||
@Override | ||
public Set<String> getAllow() { return allowList; } | ||
|
||
@Override | ||
public Set<String> getBlock() { return blockList; } | ||
|
||
private Set<String> initializeBlock() { | ||
return new HashSet<>(getUniqueStrings(BLOCK)); | ||
} | ||
|
||
private Set<String> initializeAllow() { | ||
Set<String> tempAllow = new HashSet<>(getUniqueStrings(ALLOW)); | ||
tempAllow.addAll(DEFAULT_ALLOW); | ||
return tempAllow; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters