@Test public void testExecute() { CloudfrontAuthorizedContentDistributionRule cloudfrontAuthorizedContentDistributionRule = new CloudfrontAuthorizedContentDistributionRule(); Map<String, String> ruleParam = new HashMap<>(); Map<String, String> resourceAttributes = new HashMap<>(); resourceAttributes.put(PacmanSdkConstants.RESOURCE_ID, "test-resource-id"); ruleParam.put("executionId", "test-execution-Id"); ruleParam.put(PacmanSdkConstants.RULE_ID, "test-rule-Id"); RuleResult ruleResult = cloudfrontAuthorizedContentDistributionRule.execute(ruleParam, resourceAttributes); assertTrue(ruleResult.getStatus().equals(PacmanSdkConstants.STATUS_FAILURE)); }
@Override public RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes) { logger.debug("========CloudfrontAuthorizedContentDistributionRule started========="); String cloudFrontResourceID = resourceAttributes.get(PacmanSdkConstants.RESOURCE_ID); String description = "CloudFront instance: " + cloudFrontResourceID + " is unauthorized for content distribution"; MDC.put("executionId", ruleParam.get("executionId")); MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); if (!StringUtils.isEmpty(cloudFrontResourceID)) { logger.info("Found Cloudfront instance with Resource Id: [{}] distributing content without authorization.", resourceAttributes.get(PacmanRuleConstants.RESOURCE_ID)); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE, PacmanRuleConstants.FAILURE_MESSAGE, PacmanUtils.createAnnotation("cloudfront", ruleParam, description, PacmanSdkConstants.SEV_MEDIUM, PacmanSdkConstants.SECURITY)); } return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS, PacmanRuleConstants.SUCCESS_MESSAGE); }
CloudfrontAuthorizedContentDistributionRule extends BaseRule { @Override public RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes) { logger.debug("========CloudfrontAuthorizedContentDistributionRule started========="); String cloudFrontResourceID = resourceAttributes.get(PacmanSdkConstants.RESOURCE_ID); String description = "CloudFront instance: " + cloudFrontResourceID + " is unauthorized for content distribution"; MDC.put("executionId", ruleParam.get("executionId")); MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); if (!StringUtils.isEmpty(cloudFrontResourceID)) { logger.info("Found Cloudfront instance with Resource Id: [{}] distributing content without authorization.", resourceAttributes.get(PacmanRuleConstants.RESOURCE_ID)); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE, PacmanRuleConstants.FAILURE_MESSAGE, PacmanUtils.createAnnotation("cloudfront", ruleParam, description, PacmanSdkConstants.SEV_MEDIUM, PacmanSdkConstants.SECURITY)); } return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS, PacmanRuleConstants.SUCCESS_MESSAGE); } }
CloudfrontAuthorizedContentDistributionRule extends BaseRule { @Override public RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes) { logger.debug("========CloudfrontAuthorizedContentDistributionRule started========="); String cloudFrontResourceID = resourceAttributes.get(PacmanSdkConstants.RESOURCE_ID); String description = "CloudFront instance: " + cloudFrontResourceID + " is unauthorized for content distribution"; MDC.put("executionId", ruleParam.get("executionId")); MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); if (!StringUtils.isEmpty(cloudFrontResourceID)) { logger.info("Found Cloudfront instance with Resource Id: [{}] distributing content without authorization.", resourceAttributes.get(PacmanRuleConstants.RESOURCE_ID)); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE, PacmanRuleConstants.FAILURE_MESSAGE, PacmanUtils.createAnnotation("cloudfront", ruleParam, description, PacmanSdkConstants.SEV_MEDIUM, PacmanSdkConstants.SECURITY)); } return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS, PacmanRuleConstants.SUCCESS_MESSAGE); }  }
CloudfrontAuthorizedContentDistributionRule extends BaseRule { @Override public RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes) { logger.debug("========CloudfrontAuthorizedContentDistributionRule started========="); String cloudFrontResourceID = resourceAttributes.get(PacmanSdkConstants.RESOURCE_ID); String description = "CloudFront instance: " + cloudFrontResourceID + " is unauthorized for content distribution"; MDC.put("executionId", ruleParam.get("executionId")); MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); if (!StringUtils.isEmpty(cloudFrontResourceID)) { logger.info("Found Cloudfront instance with Resource Id: [{}] distributing content without authorization.", resourceAttributes.get(PacmanRuleConstants.RESOURCE_ID)); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE, PacmanRuleConstants.FAILURE_MESSAGE, PacmanUtils.createAnnotation("cloudfront", ruleParam, description, PacmanSdkConstants.SEV_MEDIUM, PacmanSdkConstants.SECURITY)); } return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS, PacmanRuleConstants.SUCCESS_MESSAGE); }  @Override RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes); @Override String getHelpText(); }
CloudfrontAuthorizedContentDistributionRule extends BaseRule { @Override public RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes) { logger.debug("========CloudfrontAuthorizedContentDistributionRule started========="); String cloudFrontResourceID = resourceAttributes.get(PacmanSdkConstants.RESOURCE_ID); String description = "CloudFront instance: " + cloudFrontResourceID + " is unauthorized for content distribution"; MDC.put("executionId", ruleParam.get("executionId")); MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); if (!StringUtils.isEmpty(cloudFrontResourceID)) { logger.info("Found Cloudfront instance with Resource Id: [{}] distributing content without authorization.", resourceAttributes.get(PacmanRuleConstants.RESOURCE_ID)); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE, PacmanRuleConstants.FAILURE_MESSAGE, PacmanUtils.createAnnotation("cloudfront", ruleParam, description, PacmanSdkConstants.SEV_MEDIUM, PacmanSdkConstants.SECURITY)); } return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS, PacmanRuleConstants.SUCCESS_MESSAGE); }  @Override RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes); @Override String getHelpText();  }