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

Pr 1470 #1515

Merged
merged 2 commits into from
Sep 29, 2023
Merged

Pr 1470 #1515

Show file tree
Hide file tree
Changes from all 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 @@ -14,6 +14,8 @@
*
* security:
* enabled: false
* low-priority-instrumentation:
* enabled: false
* mode: IAST
* validator_service_url: wss://csec.nr-data.net
* agent:
Expand All @@ -31,6 +33,8 @@ public class SecurityAgentConfig {
public static final boolean SECURITY_AGENT_ENABLED_DEFAULT = false;
public static final String SECURITY_ENABLED = "security.enabled";
public static final boolean SECURITY_ENABLED_DEFAULT = false;
public static final String SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED = "security.low-priority-instrumentation.enabled";
public static final boolean SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED_DEFAULT = false;
public static final String SECURITY_MODE = "security.mode";
public static final String SECURITY_MODE_DEFAULT = "IAST";
public static final String SECURITY_VALIDATOR_SERVICE_URL = "security.validator_service_url";
Expand Down Expand Up @@ -130,4 +134,14 @@ public static String getSecurityAgentValidatorServiceUrl() {
public static String getSecurityAgentMode() {
return config.getValue(SECURITY_MODE, SECURITY_MODE_DEFAULT);
}

/**
* Determines whether the security agent low priority attack/vulnerability modules will instrument or not.
*
* @return True if security agent should instrument low priority attack/vulnerability modules, false if it should not
*/
public static boolean isSecurityLowPriorityInstrumentationEnabled() {
return config.getValue(SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED, SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED_DEFAULT);
}

}
5 changes: 5 additions & 0 deletions newrelic-agent/src/main/resources/newrelic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ common: &default_settings
# true, the security module will run but data will not be sent. Default is false.
enabled: false

# Determines whether the low priority attack/vulnerability modules will instrument or not.
# When this is disabled instrumentation of such modules will be skipped and vice versa, default is false.
low-priority-instrumentation:
enabled: false

# New Relic Security provides two modes: IAST and RASP
# Default is IAST. Due to the invasive nature of IAST scanning, DO NOT enable this mode in either a
# production environment or an environment where production data is processed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.newrelic.api.agent.Agent;
import com.newrelic.api.agent.NewRelic;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.MockedStatic;
Expand All @@ -18,6 +17,8 @@
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_DETECTION_RXSS_ENABLED_DEFAULT;
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_ENABLED;
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_ENABLED_DEFAULT;
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED;
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED_DEFAULT;
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_MODE;
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_MODE_DEFAULT;
import static com.newrelic.agent.config.SecurityAgentConfig.SECURITY_VALIDATOR_SERVICE_URL;
Expand Down Expand Up @@ -152,4 +153,14 @@ public void getSecurityAgentMode_returnsCorrectMode() {
when(mockConfig.getValue(SECURITY_MODE, SECURITY_MODE_DEFAULT)).thenReturn("mode");
assertEquals("mode", SecurityAgentConfig.getSecurityAgentMode());
}

@Test
public void isSecurityLowPriorityInstrumentationEnabled_returnsCorrectEnabledFlag() {
when(mockConfig.getValue(SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED, SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED_DEFAULT)).thenReturn(true);
assertTrue(SecurityAgentConfig.isSecurityLowPriorityInstrumentationEnabled());

when(mockConfig.getValue(SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED, SECURITY_LOW_PRIORITY_INSTRUMENTATION_ENABLED_DEFAULT)).thenReturn(false);
assertFalse(SecurityAgentConfig.isSecurityLowPriorityInstrumentationEnabled());
}

}
Loading