summaryrefslogtreecommitdiffstats
path: root/common-be
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-09-16 17:11:45 +0300
committerMichael Lando <ml636r@att.com>2018-09-16 14:48:35 +0000
commit01813434e92d27f302b3be8893e175cdb1217306 (patch)
tree3a2b6d19cc470e2f3d155ca08da54ee11b74eb83 /common-be
parent0e9742f33076348a98dcff8190091b2a89cd327f (diff)
fix security vilation CVE-2017-7536
Change-Id: Ia772f190bcbff0d4e3a49ea42807e9224b420763 Issue-ID: SDC-1720 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'common-be')
0 files changed, 0 insertions, 0 deletions
n97' href='#n97'>97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright © 2020 Bell Canada
  ~
  ~ 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.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.onap.ccsdk.cds.components.cba</groupId>
        <artifactId>blueprint-model</artifactId>
        <version>1.1.0-SNAPSHOT</version>
    </parent>

    <artifactId>test-blueprint-kotlin-parent</artifactId>
    <packaging>pom</packaging>

    <name>Components Model Catalog - Blueprints Model - Test Kotlin Parent</name>

    <dependencies>
        <dependency>
            <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
            <artifactId>execution-service</artifactId>
        </dependency>
        <dependency>
            <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
            <artifactId>resource-resolution</artifactId>
        </dependency>
        <dependency>
            <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
            <artifactId>netconf-executor</artifactId>
        </dependency>
        <dependency>
            <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
            <artifactId>restconf-executor</artifactId>
        </dependency>
        <dependency>
            <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
            <artifactId>cli-executor</artifactId>
        </dependency>
        <dependency>
            <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
            <artifactId>message-prioritizaion</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.mockk</groupId>
            <artifactId>mockk</artifactId>
            <version>1.10.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.14.0</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
        <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
        <resources>
            <resource>
                <directory>${project.basedir}/Environments</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>default-prepare-agent</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>pre-integration-test</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>post-integration-test</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-descriptor</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check-license</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>check-style</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.onap.ccsdk.cds.components.cba</groupId>
                        <artifactId>cba-assembly-descriptor</artifactId>
                        <version>${ccsdk.cds.version}</version>
                        <exclusions>
                            <exclusion>
                                <groupId>*</groupId>
                                <artifactId>*</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptorRefs>
                                <descriptorRef>cba_zip</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>deploy-cba</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.gmaven</groupId>
                        <artifactId>groovy-maven-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>com.squareup.okhttp3</groupId>
                                <artifactId>okhttp</artifactId>
                                <version>3.14.0</version>
                            </dependency>
                            <dependency>
                                <groupId>commons-io</groupId>
                                <artifactId>commons-io</artifactId>
                                <version>${commons-io-version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>deploy-cba</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <source>
                                        import okhttp3.Credentials
                                        import okhttp3.MediaType
                                        import okhttp3.MultipartBody
                                        import okhttp3.OkHttpClient
                                        import okhttp3.Request
                                        import okhttp3.RequestBody
                                        import org.apache.commons.io.IOUtils

                                        import java.io.File

                                        target = "${basedir.absolutePath}/target"
                                        userName = throwIfPropMissing('cds.username')
                                        password = throwIfPropMissing('cds.password')
                                        protocol = properties['cds.protocol'] ?: 'http'
                                        host = properties['cds.host'] ?: 'localhost'
                                        port = properties['cds.port'] ?: '8081'

                                        def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
                                        def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
                                        def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
                                        def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'

                                        def throwIfPropMissing(prop) {
                                        value = properties[prop]
                                        if (!value || "".equals(value)) {
                                        throw new RuntimeException("Property missing: $prop")
                                        }
                                        return value
                                        }

                                        def buildRequest(endpoint, fileName) {
                                        body = new MultipartBody.Builder()
                                        .setType(MultipartBody.FORM)
                                        .addFormDataPart("file",
                                        fileName,
                                        RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
                                        .build()

                                        return new Request.Builder()
                                        .url("$protocol://$host:$port/$endpoint")
                                        .addHeader('Authorization', Credentials.basic(userName, password))
                                        .post(body)
                                        .build()
                                        }

                                        def logAndThrow(msg) {
                                        if(response) {
                                        log.error(response.body().string())
                                        }
                                        throw new RuntimeException(msg)
                                        }

                                        response = null
                                        try {
                                        def client = new OkHttpClient()

                                        response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
                                        if (!response || !response.isSuccessful()) {
                                        logAndThrow("Failed to enrich CBA")
                                        }

                                        IOUtils.copy(
                                        response.body().byteStream(),
                                        new FileOutputStream(new File(target, enrichedCba))
                                        )
                                        log.info("Created enriched cba: $enrichedCba")

                                        response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
                                        if (!response || !response.isSuccessful()) {
                                        logAndThrow("Failed to publish CBA")
                                        }

                                        log.info("CBA Deployed")
                                        log.info(response.body().string())
                                        } finally {
                                        if (response) {
                                        response.close()
                                        }
                                        }
                                    </source>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>