content: package dev.aikido.agent_api.vulnerabilities;
  
  import dev.aikido.agent_api.background.Endpoint;
  import dev.aikido.agent_api.context.ContextObject;
  import dev.aikido.agent_api.storage.ServiceConfiguration;
  
  import java.util.List;
  
  import static dev.aikido.agent_api.helpers.patterns.MatchEndpoints.matchEndpoints;
  import static dev.aikido.agent_api.storage.ServiceConfigStore.getConfig;
  
  public final class SkipVulnerabilityScanDecider {
      private SkipVulnerabilityScanDecider() {}
      public static boolean shouldSkipVulnerabilityScan(ContextObject context) {
          if (context == null) {
              return true;
          }
          if (context.getForcedProtectionOff().isEmpty()) {
              ServiceConfiguration config = getConfig();
              List<Endpoint> matchedEndpoints = matchEndpoints(context.getRouteMetadata(), config.getEndpoints());
  
              if (matchedEndpoints != null && matchedEndpoints.stream().anyMatch(Endpoint::protectionForcedOff)) {
                  // Protection is forced off on one of more of the matched endpoints :
                  context.setForcedProtectionOff(true);
              } else {
                  context.setForcedProtectionOff(false);
              }
          }
  
          // Get stored forcedProtectionOff value from cache.
          return context.getForcedProtectionOff().get();
      }
  }
  