Skip to content
Open
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 @@ -121,7 +121,6 @@ public static void resetEventSampler() {
}

IastMonitoring.getInstance().incrementSamplerCycle();
IastMonitoring.getInstance().setRemainingHarvestRequests(0);
IastMonitoring.getInstance().getHarvestedTraceId().clear();
logger.log( LogLevel.FINEST, String.format("IAST Monitoring: Sampling of Data started for sampling cycle %s", IastMonitoring.getInstance().getSamplerCycle()), IastMonitoring.class.getName());
}
Expand All @@ -133,11 +132,11 @@ public static void collectSampleIfHarvested() {
AgentConfig.getInstance().getAgentMode().getIastScan().getMonitoringMode().getHarvesting().set(false);
NewRelicSecurity.getAgent().getSecurityMetaData().removeCustomAttribute("HARVEST");
IastMonitoring.getInstance().incrementRequestHarvested();
int remaining = IastMonitoring.getInstance().decrementRemainingHarvestRequests();
if(remaining <= 0){
IastMonitoring.getInstance().setHarvestActive(false);
logger.log(LogLevel.FINEST, "IAST Monitoring: Harvesting Completed", IastMonitoring.class.getName());
}
// int remaining = IastMonitoring.getInstance().decrementRemainingHarvestRequests();
// if(remaining <= 0){
// IastMonitoring.getInstance().setHarvestActive(false);
// logger.log(LogLevel.FINEST, "IAST Monitoring: Harvesting Completed", IastMonitoring.class.getName());
// }
logger.log( LogLevel.FINEST, String.format("IAST Monitoring: %s:%s Sample collected", IastMonitoring.getInstance().getHarvestCycleCount(), IastMonitoring.getInstance().getRequestHarvested()), IastMonitoring.class.getName());
}
}
Expand All @@ -153,7 +152,7 @@ public static boolean eventQuotaReached(String traceId) {

public static boolean shouldProcessInterception() {
if(AgentConfig.getInstance().getAgentMode().getIastScan().getMonitoring()) {
return IastMonitoring.getInstance().getHarvestActive() && NewRelicSecurity.getAgent().getSecurityMetaData().customAttributeContainsKey("HARVEST") && NewRelicSecurity.getAgent().getSecurityMetaData().getCustomAttribute("HARVEST", Boolean.class);
return NewRelicSecurity.getAgent().getSecurityMetaData().customAttributeContainsKey("HARVEST") && NewRelicSecurity.getAgent().getSecurityMetaData().getCustomAttribute("HARVEST", Boolean.class);
} else {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.newrelic.agent.security.AgentConfig;
import com.newrelic.agent.security.intcodeagent.filelogging.LogFileHelper;
import com.newrelic.agent.security.intcodeagent.iast.monitoring.IastMonitoring;
import com.newrelic.agent.security.intcodeagent.logging.IAgentConstants;
import com.newrelic.agent.security.util.IUtilConstants;
import com.newrelic.api.agent.NewRelic;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void scheduleSampling(Runnable runnable, long initialDelay, long delay, T
}

public void shutdownSampling() {
IastMonitoring.getInstance().setHarvestActive(false);
if(scheduledFutureMap.containsKey("sampling")){
ScheduledFuture<?> future = scheduledFutureMap.get("sampling");
future.cancel(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.newrelic.agent.security.AgentInfo;
import com.newrelic.agent.security.instrumentator.dispatcher.DispatcherPool;
import com.newrelic.agent.security.instrumentator.httpclient.RestRequestThreadPool;
import com.newrelic.agent.security.instrumentator.utils.AgentUtils;
import com.newrelic.agent.security.instrumentator.utils.INRSettingsKey;
import com.newrelic.agent.security.intcodeagent.controlcommand.ControlCommandProcessor;
import com.newrelic.agent.security.intcodeagent.controlcommand.ControlCommandProcessorThreadPool;
Expand All @@ -16,7 +15,6 @@
import com.newrelic.api.agent.security.utils.SecurityConnection;
import com.newrelic.api.agent.security.utils.logging.LogLevel;
import com.newrelic.agent.security.intcodeagent.logging.IAgentConstants;
import com.newrelic.agent.security.intcodeagent.utils.CommonUtils;
import com.newrelic.agent.security.util.IUtilConstants;
import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.security.instrumentation.helpers.GrpcClientRequestReplayHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private void startSecurityServices() {
SchedulerHelper.getInstance().scheduleApplicationRuntimeErrorPosting(RuntimeErrorReporter.getInstance()::reportApplicationRuntimeError,
30 , 30, TimeUnit.SECONDS);
SchedulerHelper.getInstance().scheduleDailyLogRollover(LogFileHelper::performDailyRollover);
SchedulerHelper.getInstance().scheduleSampling(IastMonitoring::sampleData, 0, 5, TimeUnit.SECONDS);
// SchedulerHelper.getInstance().scheduleSampling(IastMonitoring::sampleData, 0, 5, TimeUnit.SECONDS);
SchedulerHelper.getInstance().scheduleResetEventSampler(IastMonitoring::resetEventSampler, 0,
AgentConfig.getInstance().getAgentMode().getIastScan().getMonitoringMode().getEventQuotaTimeDuration(), TimeUnit.MINUTES);
logger.logInit(
Expand Down
Loading