kind: ConfigMap
apiVersion: v1
metadata:
  name: {{ .Values.jenkins.scriptApprovalConfigMapName }}
  labels:
  {{- include "jenkins-operator.metaLabels" . | nindent 4 }}
data:
  context: |
    /* Copyright 2019 EPAM Systems.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

    See the License for the specific language governing permissions and
    limitations under the License. */

    def scriptList = [
        'method java.util.Collection remove java.lang.Object',
        'field java.lang.String value',
        'method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper getRawBuild',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods getProperties java.lang.Object',
        'method hudson.model.Run getCause java.lang.Class',
        'field java.util.ArrayList size',
        'method com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey getPrivateKey',
        'method com.cloudbees.plugins.credentials.common.IdCredentials getId',
        'method com.cloudbees.plugins.credentials.common.PasswordCredentials getPassword',
        'method com.cloudbees.plugins.credentials.common.UsernameCredentials getUsername',
        'method groovy.json.JsonBuilder toPrettyString',
        'method groovy.json.JsonSlurperClassic parseText java.lang.String',
        'method groovy.json.JsonSlurper parseText java.lang.String',
        'method groovy.lang.GString getBytes',
        'method groovy.lang.GroovyObject getProperty java.lang.String',
        'method hudson.model.Run getEnvironment',
        'method hudson.FilePath readToString',
        'method java.io.File exists',
        'method java.io.File getAbsolutePath',
        'method java.io.File getName',
        'method java.io.File getParent',
        'method java.io.File mkdirs',
        'method java.io.Writer write java.lang.String',
        'method java.lang.AutoCloseable close',
        'method java.lang.Class isInstance java.lang.Object',
        'method java.lang.Iterable iterator',
        'method java.net.HttpURLConnection getResponseCode',
        'method java.net.HttpURLConnection setRequestMethod java.lang.String',
        'method java.net.URI getHost',
        'method java.net.URI getPort',
        'method java.net.URL openConnection',
        'method java.net.URLConnection getHeaderField java.lang.String',
        'method java.net.URLConnection getInputStream',
        'method java.net.URLConnection getOutputStream',
        'method java.net.URLConnection setDoOutput boolean',
        'method java.net.URLConnection setRequestProperty java.lang.String java.lang.String',
        'method java.util.LinkedHashMap$LinkedHashIterator hasNext',
        'method java.util.Map size',
        'method hudson.FilePath readToString',
        'method jenkins.model.Jenkins getComputer java.lang.String',
        'method hudson.model.Computer getChannel',
        'new hudson.FilePath hudson.remoting.VirtualChannel java.lang.String',
        'method hudson.FilePath exists',
        'method org.jenkinsci.plugins.workflow.job.WorkflowRun doStop',
        'method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper build',
        'new groovy.json.JsonBuilder java.lang.Object',
        'new groovy.json.JsonSlurperClassic',
        'new java.io.File java.lang.String',
        'new java.io.OutputStreamWriter java.io.OutputStream',
        'new java.lang.Exception java.lang.String',
        'new java.lang.InterruptedException',
        'new java.net.URI java.lang.String',
        'new java.util.Date',
        'new hudson.FilePath java.io.File',
        'new java.lang.String byte[]',
        'staticField groovy.io.FileType FILES',
        'staticMethod com.cloudbees.plugins.credentials.CredentialsProvider lookupCredentials java.lang.Class hudson.model.ItemGroup',
        'staticMethod java.lang.System getenv java.lang.String',
        'staticMethod jenkins.model.Jenkins getInstance',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods collect java.util.Map groovy.lang.Closure',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods eachFile java.io.File groovy.io.FileType groovy.lang.Closure',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods get java.util.Map java.lang.Object java.lang.Object',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods getAt java.lang.Iterable int',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods getAt java.lang.String int',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods getBytes java.io.File',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods getText java.io.InputStream',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods hasProperty java.lang.Object java.lang.String',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods iterator java.lang.Object',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods iterator java.lang.Object[]',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods plus java.util.List java.lang.Iterable',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods plus java.util.List java.lang.Object',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods plus java.util.List java.util.Collection',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods putAt java.lang.Object java.lang.String java.lang.Object',
        'staticMethod org.codehaus.groovy.runtime.EncodingGroovyMethods encodeBase64 byte[]',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods getAt java.lang.Object java.lang.String',
        'staticMethod org.apache.commons.lang.RandomStringUtils random int boolean boolean',
        'staticMethod org.codehaus.groovy.runtime.EncodingGroovyMethods decodeBase64 java.lang.String',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods toInteger',
        'staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods toInteger java.lang.Number',
        'staticMethod org.codehaus.groovy.runtime.ScriptBytecodeAdapter unaryMinus java.lang.Object',
      ]

    scriptList.each() { item ->
        org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.get().approveSignature(item)
    }
