Skip to content

Commit

Permalink
fix(mpt-v1): prevent leak of information through template resolution …
Browse files Browse the repository at this point in the history
…endpoint (#3706) (#3710)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
danielpeach and mergify[bot] authored Jun 25, 2020
1 parent b57e006 commit f40ede7
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ package com.netflix.spinnaker.orca.controllers

import com.netflix.spinnaker.kork.web.exceptions.InvalidRequestException
import com.netflix.spinnaker.orca.pipelinetemplate.PipelineTemplateService
import com.netflix.spinnaker.orca.pipelinetemplate.exceptions.TemplateLoaderException
import com.netflix.spinnaker.orca.pipelinetemplate.v1schema.converter.PipelineTemplateConverter
import com.netflix.spinnaker.orca.pipelinetemplate.v1schema.model.PipelineTemplate
import com.netflix.spinnaker.orca.pipelinetemplate.v1schema.model.TemplateConfiguration.TemplateSource
import groovy.util.logging.Slf4j
import javax.servlet.http.HttpServletResponse
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
Expand Down Expand Up @@ -51,4 +55,10 @@ class PipelineTemplateController {
String convertPipelineToPipelineTemplate(@RequestBody Map<String, Object> pipeline) {
new PipelineTemplateConverter().convertToPipelineTemplate(pipeline)
}

@ExceptionHandler(TemplateLoaderException)
static void handleTemplateLoaderException(TemplateLoaderException tle, HttpServletResponse response) {
log.error("Could not load pipeline template from source: {}", tle.message)
response.sendError(HttpStatus.BAD_REQUEST.value(), "Could not load pipeline template from source")
}
}

0 comments on commit f40ede7

Please sign in to comment.