From ecd14d7c3202fa63a718f0d9a1fc4643d96e5e54 Mon Sep 17 00:00:00 2001 From: lovesh-ap Date: Wed, 6 Nov 2024 16:32:58 +0530 Subject: [PATCH] fix default value for IAST_SCAN_INSTANCE_COUNT --- .../java/com/newrelic/agent/security/AgentConfig.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/newrelic-security-agent/src/main/java/com/newrelic/agent/security/AgentConfig.java b/newrelic-security-agent/src/main/java/com/newrelic/agent/security/AgentConfig.java index 528ba1fd7..b847535f1 100644 --- a/newrelic-security-agent/src/main/java/com/newrelic/agent/security/AgentConfig.java +++ b/newrelic-security-agent/src/main/java/com/newrelic/agent/security/AgentConfig.java @@ -102,11 +102,13 @@ public long instantiate() throws RestrictionModeException { // Set required LogLevel logLevel = applyRequiredLogLevel(); - if(NewRelic.getAgent().getConfig().getValue(IUtilConstants.IAST_SCAN_INSTANCE_COUNT) instanceof Integer) { - scanControllers.setScanInstanceCount(NewRelic.getAgent().getConfig().getValue(IUtilConstants.IAST_SCAN_INSTANCE_COUNT)); - } else { + try { + scanControllers.setScanInstanceCount(NewRelic.getAgent().getConfig().getValue(IUtilConstants.IAST_SCAN_INSTANCE_COUNT, 0)); + } catch (NumberFormatException | ClassCastException e){ + logger.log(LogLevel.FINEST, String.format("Error while reading IAST_SCAN_INSTANCE_COUNT %s , setting to default", NewRelic.getAgent().getConfig().getValue(IUtilConstants.IAST_SCAN_INSTANCE_COUNT)), AgentConfig.class.getName()); scanControllers.setScanInstanceCount(0); } + //Always set IAST Test Identifier after IAST_SCAN_INSTANCE_COUNT if(NewRelic.getAgent().getConfig().getValue(IUtilConstants.IAST_TEST_IDENTIFIER) instanceof String) { scanControllers.setIastTestIdentifier(NewRelic.getAgent().getConfig().getValue(IUtilConstants.IAST_TEST_IDENTIFIER));